Class Submitter
Abstraction of a background thread that is used to submit support requests
to the McIDAS-V Help Desk Team.
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SupportForm
Used to gather user input and system information.private static final org.slf4j.Logger
Logging object.private org.apache.commons.httpclient.methods.PostMethod
Handy reference to the status code (and more) of ourPOST
.private static final int
We'll follow up to this many redirects forrequestUrl
.static final String
Error message to display if the server had problems.private final String
URL that we'll attempt toPOST
our requests at.private int
Number of redirects we've tried since starting.private String
Keeps track of the most recent redirect forrequestUrl
. -
Constructor Summary
ConstructorsConstructorDescriptionSubmitter
(SupportForm form) Prepare a support request to be sent (off of the event dispatch thread). -
Method Summary
Modifier and TypeMethodDescriptionprivate static org.apache.commons.httpclient.methods.multipart.FilePart
buildFakeFilePart
(String id, String file, byte[] data) Creates a file attachment that isn't based upon an actual file.private static org.apache.commons.httpclient.methods.PostMethod
buildPostMethod
(String url, SupportForm form) Attempts toPOST
tourl
using the information fromform
.private static org.apache.commons.httpclient.methods.multipart.FilePart
buildRealFilePart
(String id, String file) Creates a file attachment that's based upon a real file.protected String
compute()
Attempt to POST contents of support request form torequestUrl
.protected void
onCompletion
(String result, Throwable exception, boolean cancelled) Handles completion of a support request.Methods inherited from class edu.wisc.ssec.mcidasv.util.BackgroundTask
cancel, get, get, isCancelled, isDone, onProgress, run, setProgress
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Field Details
-
POST_ERROR
Error message to display if the server had problems.- See Also:
-
logger
Logging object. -
POST_ATTEMPTS
We'll follow up to this many redirects forrequestUrl
.- See Also:
-
form
Used to gather user input and system information. -
requestUrl
URL that we'll attempt toPOST
our requests at.- See Also:
-
validFormUrl
Keeps track of the most recent redirect forrequestUrl
. -
tryCount
Number of redirects we've tried since starting. -
method
Handy reference to the status code (and more) of ourPOST
.
-
-
Constructor Details
-
Submitter
Prepare a support request to be sent (off of the event dispatch thread).- Parameters:
form
- Support request form to send. Cannot benull
.
-
-
Method Details
-
buildRealFilePart
private static org.apache.commons.httpclient.methods.multipart.FilePart buildRealFilePart(String id, String file) Creates a file attachment that's based upon a real file.- Parameters:
id
- The parameter ID. Usually something like "form_data[att_two]".file
- Path to the file that's going to be attached.- Returns:
POST
-able file attachment using the name and contents offile
.
-
buildFakeFilePart
private static org.apache.commons.httpclient.methods.multipart.FilePart buildFakeFilePart(String id, String file, byte[] data) Creates a file attachment that isn't based upon an actual file. Useful for something like the "extra" attachment where you collect a bunch of data but don't want to deal with creating a temporary file.- Parameters:
id
- Parameter ID. Typically something like "form_data[att_extra]".file
- Fake name of the file. Can be whatever you like.data
- The actual data to place inside the attachment.- Returns:
POST
-able file attachment using a spoofed filename!
-
buildPostMethod
private static org.apache.commons.httpclient.methods.PostMethod buildPostMethod(String url, SupportForm form) Attempts toPOST
tourl
using the information fromform
.- Parameters:
url
- URL that'll accept thePOST
. TypicallyrequestUrl
.form
- TheSupportForm
that contains the data to use in the support request.- Returns:
- Big honkin' object that contains the support request.
-
compute
Attempt to POST contents of support request form torequestUrl
.- Specified by:
compute
in classBackgroundTask<String>
- Throws:
WrapperException
- if there was a problem on the server.
-
onCompletion
Handles completion of a support request.- Overrides:
onCompletion
in classBackgroundTask<String>
- Parameters:
result
- Result ofcompute()
.exception
- Exception thrown fromcompute()
, if any.cancelled
- Whether or not the user opted to cancel.
-