org.hawk.http
Class AbstractHttpExecutor

java.lang.Object
  extended by org.hawk.http.AbstractHttpExecutor
All Implemented Interfaces:
IHttpExecutor
Direct Known Subclasses:
DefaultHttpExecutor

public class AbstractHttpExecutor
extends java.lang.Object
implements IHttpExecutor

An utility to communicate with the targetURL. Apart from sending post requests , this can also also upload file too.

See Also:
HttpModule

Field Summary
protected static HttpSessionLocal<HttpSessionInfo> httpSessionLocal
           
 
Constructor Summary
AbstractHttpExecutor()
           
 
Method Summary
 java.lang.String executeGetRequest(java.lang.String targetURL, boolean invalidateSession)
          requests for a post on the url specified by target url with the parameters specified in the requestparams
 java.lang.String executeMultiPartPOST(java.lang.String urlString, java.util.Map<java.lang.String,java.lang.String> map)
          This executes multipart post request.
 java.lang.String executePost(java.lang.String targetURL, java.lang.String postData, boolean invalidateSession)
          This hits the target URL with the post data using the JSESSIONID.
 boolean loadSessionInfo(org.apache.commons.httpclient.HttpClient client, HttpSessionInfo httpSessionInfo)
           
 boolean setHttpSessionInfo(java.net.URLConnection conn, boolean invalidateSession)
          This stores http session information on the http session local
static boolean setOtherData(java.lang.Object otherData)
          Implementors should use this method to set their custom data.
 java.lang.String uploadFile(java.lang.String urlString, java.lang.String exsistingFileName)
          This uploads a file to the target URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

httpSessionLocal

protected static HttpSessionLocal<HttpSessionInfo> httpSessionLocal
Constructor Detail

AbstractHttpExecutor

public AbstractHttpExecutor()
Method Detail

setOtherData

public static boolean setOtherData(java.lang.Object otherData)
Implementors should use this method to set their custom data.

Parameters:
otherData - input data to be stored on http session
Returns:
returns true on success or false

executePost

public java.lang.String executePost(java.lang.String targetURL,
                                    java.lang.String postData,
                                    boolean invalidateSession)
                             throws java.lang.Exception
This hits the target URL with the post data using the JSESSIONID.

Specified by:
executePost in interface IHttpExecutor
Parameters:
targetURL - target url to hit
data - post data
jsessionid - used for standard j2ee session management.
Returns:
JSESSIONID , essentially during login page of a website.otherwise returns the same.
Throws:
java.lang.Exception

setHttpSessionInfo

public boolean setHttpSessionInfo(java.net.URLConnection conn,
                                  boolean invalidateSession)
This stores http session information on the http session local

Specified by:
setHttpSessionInfo in interface IHttpExecutor
Parameters:
conn -
invalidateSession -
Returns:
See Also:
HttpSessionInfo, HttpSessionLocal

executeMultiPartPOST

public java.lang.String executeMultiPartPOST(java.lang.String urlString,
                                             java.util.Map<java.lang.String,java.lang.String> map)
This executes multipart post request.

Specified by:
executeMultiPartPOST in interface IHttpExecutor
Parameters:
urlString - input url to which data is to be sent.
map - http post data
Returns:
returns the response after hitting urlString with input http post data.

uploadFile

public java.lang.String uploadFile(java.lang.String urlString,
                                   java.lang.String exsistingFileName)
                            throws java.lang.Exception
This uploads a file to the target URL.

Specified by:
uploadFile in interface IHttpExecutor
Parameters:
urlString - target URL to hit
exsistingFileName - name of the file to upload
jsessionid - JSESSIONID to use
Returns:
returns true on success otherwise false
Throws:
java.lang.Exception

executeGetRequest

public java.lang.String executeGetRequest(java.lang.String targetURL,
                                          boolean invalidateSession)
                                   throws java.lang.Exception
Description copied from interface: IHttpExecutor
requests for a post on the url specified by target url with the parameters specified in the requestparams

Specified by:
executeGetRequest in interface IHttpExecutor
invalidateSession - if true discard the jsessionid parameter
Returns:
response body of the the requested url specified by target url
Throws:
java.lang.Exception

loadSessionInfo

public boolean loadSessionInfo(org.apache.commons.httpclient.HttpClient client,
                               HttpSessionInfo httpSessionInfo)