edu.wisc.ssec.mcidasv.supportform
Class Submitter

java.lang.Object
  extended by edu.wisc.ssec.mcidasv.util.BackgroundTask<String>
      extended by edu.wisc.ssec.mcidasv.supportform.Submitter
All Implemented Interfaces:
Runnable, Future<String>

public class Submitter
extends BackgroundTask<String>


Field Summary
private  SupportForm form
          Used to gather user input and system information.
private static org.slf4j.Logger logger
           
private  org.apache.commons.httpclient.methods.PostMethod method
          Handy reference to the status code (and more) of our POST.
private static int POST_ATTEMPTS
          We'll follow up to this many redirects for requestUrl.
private  String requestUrl
          URL that we'll attempt to POST our requests at.
private  int tryCount
          Number of redirects we've tried since starting.
private  String validFormUrl
          Keeps track of the most recent redirect for requestUrl.
 
Constructor Summary
Submitter(SupportForm form)
           
 
Method Summary
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.
private static org.apache.commons.httpclient.methods.PostMethod buildPostMethod(String url, SupportForm form)
          Attempts to POST to url using the information from form.
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()
           
protected  void onCompletion(String result, Throwable exception, boolean cancelled)
           
 
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
 

Field Detail

logger

private static final org.slf4j.Logger logger

POST_ATTEMPTS

private static final int POST_ATTEMPTS
We'll follow up to this many redirects for requestUrl.

See Also:
Constant Field Values

form

private final SupportForm form
Used to gather user input and system information.


requestUrl

private final String requestUrl
URL that we'll attempt to POST our requests at.

See Also:
Constant Field Values

validFormUrl

private String validFormUrl
Keeps track of the most recent redirect for requestUrl.


tryCount

private int tryCount
Number of redirects we've tried since starting.


method

private org.apache.commons.httpclient.methods.PostMethod method
Handy reference to the status code (and more) of our POST.

Constructor Detail

Submitter

public Submitter(SupportForm form)
Method Detail

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 of file.

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 to POST to url using the information from form.

Parameters:
url - URL that'll accept the POST. Typically requestUrl.
form - The SupportForm that contains the data to use in the support request.
Returns:
Big honkin' object that contains the support request.

compute

protected String compute()
Specified by:
compute in class BackgroundTask<String>

onCompletion

protected void onCompletion(String result,
                            Throwable exception,
                            boolean cancelled)
Overrides:
onCompletion in class BackgroundTask<String>