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 SupportFormUsed to gather user input and system information.private static final org.slf4j.LoggerLogging object.private org.apache.commons.httpclient.methods.PostMethodHandy reference to the status code (and more) of ourPOST.private static final intWe'll follow up to this many redirects forrequestUrl.static final StringError message to display if the server had problems.private final StringURL that we'll attempt toPOSTour requests at.private intNumber of redirects we've tried since starting.private StringKeeps 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.FilePartbuildFakeFilePart(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.PostMethodbuildPostMethod(String url, SupportForm form) Attempts toPOSTtourlusing the information fromform.private static org.apache.commons.httpclient.methods.multipart.FilePartbuildRealFilePart(String id, String file) Creates a file attachment that's based upon a real file.protected Stringcompute()Attempt to POST contents of support request form torequestUrl.protected voidonCompletion(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, setProgressMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 toPOSTour 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 toPOSTtourlusing the information fromform.- Parameters:
url- URL that'll accept thePOST. TypicallyrequestUrl.form- TheSupportFormthat 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:
computein classBackgroundTask<String>- Throws:
WrapperException- if there was a problem on the server.
-
onCompletion
Handles completion of a support request.- Overrides:
onCompletionin classBackgroundTask<String>- Parameters:
result- Result ofcompute().exception- Exception thrown fromcompute(), if any.cancelled- Whether or not the user opted to cancel.
-