Package org.cdlib.mrt.utility
Class HTTPUtil
java.lang.Object
org.cdlib.mrt.utility.HTTPUtil
This class will contain utilities for HTTP transactions
- Author:
- dloy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.http.client.HttpClientstatic org.apache.http.HttpResponsedeleteHttpResponse(String requestURL, int timeout) Perform a DELETE operationstatic InputStreamdeleteObject(String requestURL, int timeout) Deletestatic InputStreamdeleteObject(String requestURL, int timeout, int retry) getObject with timeout and retrystatic voiddumpHttpResponse(org.apache.http.HttpResponse response, int goodStatus) Used to trace IT callsstatic final StringgetBasicAuthenticationHeader(String username, String password) static InputStreamgetFTPInputStream(String ftpURLS, int timeout) static org.apache.http.client.HttpClientgetHttpClient(int timeout) static org.apache.http.client.HttpClientgetHttpClient(String requestURL, int timeout) static org.apache.http.HttpResponsegetHttpResponse(String requestURL, int timeout) Perform a GET operationstatic org.apache.http.HttpResponsegetHttpResponse(String requestURL, int timeout, long startByte, long endByte) Perform a GET operationstatic org.apache.http.HttpResponsegetHttpResponse(URL hrefURL, int timeout, int retry) static InputStreamSend this manifestFile to mrt storestatic InputStreamgetObject with timeout and retrystatic InputStreamgetObject404(String requestURL, int timeout, int retry) getObject with timeout and retrystatic org.apache.http.HttpEntitygetObjectEntity(String requestURL, int timeout) Send this manifestFile to mrt storestatic org.apache.http.HttpEntitygetObjectEntity(String requestURL, int timeout, long startByte, long endByte) Send this manifestFile to mrt storestatic PropertiesgetObjectProperties(String requestURL, int timeout, int retry) Get structured properties from a Get requeststatic org.apache.http.HttpResponsegetObjectResponse(String requestURL, int timeout, int retry) Get structured properties from a Get requeststatic LinkedHashList<String, String> static InputStreamgetTimeoutInputStream(URL sourceURL, int timeout) Make a connection using URL and perform timeout test using threadsstatic booleanstatic org.apache.http.HttpResponsepostHttpResponse(String requestURL, Properties prop, int timeout) Send this manifestFile to mrt storestatic org.apache.http.HttpResponsepostMultipartHeader(String requestURL, Properties mainHeaders, Properties stringParts, Map<String, File> fileParts, int timeout) Do multipart poststatic org.apache.http.HttpResponsepostMultipartHttpResponse(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) Do multipart poststatic org.apache.http.HttpResponsepostMultipartHttpResponse2(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) Do multipart poststatic InputStreampostMultipartObject(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) Return InputStream from multipart requeststatic InputStreampostMultipartObject2(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) Return InputStream from multipart requeststatic InputStreampostObject(String requestURL, Properties prop, int timeout) Send this manifestFile to mrt storestatic org.apache.http.HttpResponseputMultipartHttpResponse(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) Do multipart poststatic InputStreamputMultipartObject(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) Return InputStream from multipart requeststatic Propertiesresponse2Property(org.apache.http.HttpResponse response)
-
Constructor Details
-
HTTPUtil
public HTTPUtil()
-
-
Method Details
-
getObject
Send this manifestFile to mrt store- Parameters:
manifestFile-- Returns:
-
getObjectEntity
public static org.apache.http.HttpEntity getObjectEntity(String requestURL, int timeout, long startByte, long endByte) throws TException Send this manifestFile to mrt store- Parameters:
manifestFile-- Returns:
-
getObjectEntity
public static org.apache.http.HttpEntity getObjectEntity(String requestURL, int timeout) throws TException Send this manifestFile to mrt store- Parameters:
manifestFile-- Returns:
-
getObject
getObject with timeout and retry- Parameters:
requestURL- build inputStream to this URLtimeout- milliseconds for timeoutretry- number of retry attemps- Returns:
- InputStream to URL service
- Throws:
TException
-
getObject404
getObject with timeout and retry- Parameters:
requestURL- build inputStream to this URLtimeout- milliseconds for timeoutretry- number of retry attemps- Returns:
- InputStream to URL service
- Throws:
TException
-
deleteObject
Delete- Parameters:
requestURL- delete URLtimeout- timeout in .001 seconds- Returns:
- delete response
- Throws:
TException
-
deleteObject
getObject with timeout and retry- Parameters:
requestURL- build inputStream to this URLtimeout- milliseconds for timeoutretry- number of retry attemps- Returns:
- InputStream to URL service
- Throws:
TException
-
getHttpResponse
public static org.apache.http.HttpResponse getHttpResponse(String requestURL, int timeout) throws TException Perform a GET operation- Parameters:
requestURL- get requesttimeout- connection timeout- Returns:
- http response
- Throws:
TException- process exception
-
getHttpResponse
public static org.apache.http.HttpResponse getHttpResponse(String requestURL, int timeout, long startByte, long endByte) throws TException Perform a GET operation- Parameters:
requestURL- get requesttimeout- connection timeout- Returns:
- http response
- Throws:
TException- process exception
-
dumpHttpResponse
public static void dumpHttpResponse(org.apache.http.HttpResponse response, int goodStatus) Used to trace IT calls- Parameters:
response- http responsegoodStatus- expected status to skip dump
-
getObjectProperties
public static Properties getObjectProperties(String requestURL, int timeout, int retry) throws TException Get structured properties from a Get request- Parameters:
requestURL- build inputStream to this URLtimeout- milliseconds for timeoutretry- number of retry attemps- Returns:
- Properties generated from HTTPResponse
- Throws:
TException- process Exception
-
getObjectResponse
public static org.apache.http.HttpResponse getObjectResponse(String requestURL, int timeout, int retry) throws TException Get structured properties from a Get request- Parameters:
requestURL- build inputStream to this URLtimeout- milliseconds for timeoutretry- number of retry attemps- Returns:
- Properties generated from HTTPResponse
- Throws:
TException- process Exception
-
response2Property
- Throws:
TException
-
deleteHttpResponse
public static org.apache.http.HttpResponse deleteHttpResponse(String requestURL, int timeout) throws TException Perform a DELETE operation- Parameters:
requestURL- get requesttimeout- connection timeout- Returns:
- http response
- Throws:
TException- process exception
-
postObject
public static InputStream postObject(String requestURL, Properties prop, int timeout) throws TException Send this manifestFile to mrt store- Parameters:
manifestFile-- Returns:
-
postHttpResponse
public static org.apache.http.HttpResponse postHttpResponse(String requestURL, Properties prop, int timeout) throws TException Send this manifestFile to mrt store- Parameters:
manifestFile-- Returns:
-
postMultipartHeader
public static org.apache.http.HttpResponse postMultipartHeader(String requestURL, Properties mainHeaders, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionDo multipart post- Parameters:
requestURL- request URLstringParts- multipart String bodiesfileParts- multipart File bodiestimeout- client timeout- Returns:
- HttpReponse from POST request
- Throws:
TException
-
postMultipartObject2
public static InputStream postMultipartObject2(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionReturn InputStream from multipart request- Parameters:
requestURL- request URLstringParts- multipart String bodiesfileParts- multipart File bodiestimeout- client timeout- Returns:
- response stream from multipart request
- Throws:
TException
-
postMultipartHttpResponse2
public static org.apache.http.HttpResponse postMultipartHttpResponse2(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionDo multipart post- Parameters:
requestURL- request URLstringParts- multipart String bodiesfileParts- multipart File bodiestimeout- client timeout- Returns:
- HttpReponse from POST request
- Throws:
TException
-
putMultipartObject
public static InputStream putMultipartObject(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionReturn InputStream from multipart request- Parameters:
requestURL- request URLstringParts- multipart String bodiesfileParts- multipart File bodiestimeout- client timeout- Returns:
- response stream from multipart request
- Throws:
TException
-
putMultipartHttpResponse
public static org.apache.http.HttpResponse putMultipartHttpResponse(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionDo multipart post- Parameters:
requestURL- request URLstringParts- multipart String bodiesfileParts- multipart File bodiestimeout- client timeout- Returns:
- HttpReponse from POST request
- Throws:
TException
-
postMultipartObject
public static InputStream postMultipartObject(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionReturn InputStream from multipart request- Parameters:
requestURL- request URLstringParts- multipart String bodiesfileParts- multipart File bodiestimeout- client timeout- Returns:
- response stream from multipart request
- Throws:
TException
-
postMultipartHttpResponse
public static org.apache.http.HttpResponse postMultipartHttpResponse(String requestURL, Properties stringParts, Map<String, File> fileParts, int timeout) throws TExceptionDo multipart post- Parameters:
requestURL- request URLstringParts- multipart String bodiesfileParts- multipart File bodiestimeout- client timeout- Returns:
- HttpReponse from POST request
- Throws:
TException
-
getHttpResponse
public static org.apache.http.HttpResponse getHttpResponse(URL hrefURL, int timeout, int retry) throws TException - Throws:
TException
-
isFTP
-
getFTPInputStream
- Throws:
TException
-
getTimeoutInputStream
Make a connection using URL and perform timeout test using threads- Parameters:
sourceURL- connect to this URLtimeout- connection timeout in secondsfw- framework instance- Throws:
TException
-
getQuery
-
createHttpClient_AcceptsUntrustedCerts
public static org.apache.http.client.HttpClient createHttpClient_AcceptsUntrustedCerts() throws Exception- Throws:
Exception
-
getHttpClient
- Throws:
Exception
-
getHttpClient
public static org.apache.http.client.HttpClient getHttpClient(String requestURL, int timeout) throws Exception - Throws:
Exception
-
getBasicAuthenticationHeader
-