Package org.qdl_lang.extensions.http
Class HTTPClient
- java.lang.Object
-
- org.qdl_lang.extensions.http.HTTPClient
-
- All Implemented Interfaces:
Serializable,QDLMetaModule
public class HTTPClient extends Object implements QDLMetaModule
Class that is the workhorse forQDLHTTPModule. See the blurb
/home/ncsa/dev/ncsa-git/qdl/language/src/main/docs/http-extension.odtCreated by Jeff Gaynor
on 10/5/21 at 7:02 AM- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classHTTPClient.CloseclassHTTPClient.ConfigurationclassHTTPClient.CreateCredentialsclassHTTPClient.DeleteclassHTTPClient.DownloadclassHTTPClient.EchoHTTPRequestclassHTTPClient.EchoHTTPResponseclassHTTPClient.GetclassHTTPClient.HeadersclassHTTPClient.HostclassHTTPClient.IsJSONclassHTTPClient.IsOpenclassHTTPClient.IsTextclassHTTPClient.OpenclassHTTPClient.PostclassHTTPClient.Put
-
Field Summary
Fields Modifier and Type Field Description StringCLOSE_METHODstatic StringCONFIGURATIONstatic StringCONTENT_FORMstatic intCONTENT_FORM_VALUEstatic StringCONTENT_HTMLstatic intCONTENT_HTML_VALUEstatic StringCONTENT_JSONstatic intCONTENT_JSON_VALUEstatic StringCONTENT_KEYstatic StringCONTENT_TEXTstatic intCONTENT_TEXT_VALUEstatic intCONTENT_TYPE_MISSING_VALUEstatic StringCREATE_CREDENTIALS_METHODStringDELETE_METHODStringDOWNLOAD_METHODstatic StringECHO_HTTP_REQUESTstatic StringECHO_HTTP_RESPONSEStringGET_METHODstatic StringHEADERS_KEYStringHEADERS_METHODStringHOST_METHODstatic StringIS_JSONStringIS_OPEN_METHODstatic StringIS_TEXTprotected StringLIST_ENCODE_AS_ARRAYprotected StringLIST_ENCODE_AS_PARAMETERprotected StringLIST_ENCODE_AS_VALUEprotected StringLIST_ENCODE_TYPEprotected StringLIST_VALUE_SEPARATORStringOPEN_METHODStringPOST_METHODStringPUT_METHODstatic StringSTATUS_KEY
-
Constructor Summary
Constructors Constructor Description HTTPClient()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckInit()voiddeserializeFromJSON(net.sf.json.JSONObject json)QDLValuedoPostOrPut(QDLValue[] qdlValues, State state, boolean isPost)protected StringgetActualHost(String uriPath)Given a uriPath, return the actual path to the service.protected intgetContentType(Set<String> contentType)QDLStemgetResponseStem(org.apache.http.HttpResponse response)Utility to turn the response, whatever it is, into a stem.protected List<String>getURIPathBlurb()protected QDLStemjsonToStemJSON(String rawJSON)protected StringparamsToRequest(QDLValue[] qdlValues)Takes the array of objects for an evaluate method and creates the right url This is used in get and delete.net.sf.json.JSONObjectserializeToJSON()Send back a serialization of internal state for this object.StringtoParamList(String key, Collection<? extends QDLValue> values)
-
-
-
Field Detail
-
HOST_METHOD
public String HOST_METHOD
-
GET_METHOD
public String GET_METHOD
-
HEADERS_METHOD
public String HEADERS_METHOD
-
PUT_METHOD
public String PUT_METHOD
-
POST_METHOD
public String POST_METHOD
-
DELETE_METHOD
public String DELETE_METHOD
-
CLOSE_METHOD
public String CLOSE_METHOD
-
OPEN_METHOD
public String OPEN_METHOD
-
IS_OPEN_METHOD
public String IS_OPEN_METHOD
-
DOWNLOAD_METHOD
public String DOWNLOAD_METHOD
-
CONTENT_FORM
public static final String CONTENT_FORM
- See Also:
- Constant Field Values
-
CONTENT_FORM_VALUE
public static final int CONTENT_FORM_VALUE
- See Also:
- Constant Field Values
-
CONTENT_JSON
public static final String CONTENT_JSON
- See Also:
- Constant Field Values
-
CONTENT_JSON_VALUE
public static final int CONTENT_JSON_VALUE
- See Also:
- Constant Field Values
-
CONTENT_HTML
public static final String CONTENT_HTML
- See Also:
- Constant Field Values
-
CONTENT_HTML_VALUE
public static final int CONTENT_HTML_VALUE
- See Also:
- Constant Field Values
-
CONTENT_TEXT
public static final String CONTENT_TEXT
- See Also:
- Constant Field Values
-
CONTENT_TEXT_VALUE
public static final int CONTENT_TEXT_VALUE
- See Also:
- Constant Field Values
-
CONTENT_TYPE_MISSING_VALUE
public static final int CONTENT_TYPE_MISSING_VALUE
- See Also:
- Constant Field Values
-
CONTENT_KEY
public static final String CONTENT_KEY
- See Also:
- Constant Field Values
-
HEADERS_KEY
public static final String HEADERS_KEY
- See Also:
- Constant Field Values
-
STATUS_KEY
public static final String STATUS_KEY
- See Also:
- Constant Field Values
-
LIST_ENCODE_AS_ARRAY
protected final String LIST_ENCODE_AS_ARRAY
- See Also:
- Constant Field Values
-
LIST_ENCODE_AS_PARAMETER
protected final String LIST_ENCODE_AS_PARAMETER
- See Also:
- Constant Field Values
-
LIST_ENCODE_AS_VALUE
protected final String LIST_ENCODE_AS_VALUE
- See Also:
- Constant Field Values
-
LIST_ENCODE_TYPE
protected String LIST_ENCODE_TYPE
-
LIST_VALUE_SEPARATOR
protected String LIST_VALUE_SEPARATOR
-
CREATE_CREDENTIALS_METHOD
public static String CREATE_CREDENTIALS_METHOD
-
IS_JSON
public static String IS_JSON
-
IS_TEXT
public static String IS_TEXT
-
ECHO_HTTP_REQUEST
public static final String ECHO_HTTP_REQUEST
- See Also:
- Constant Field Values
-
ECHO_HTTP_RESPONSE
public static final String ECHO_HTTP_RESPONSE
- See Also:
- Constant Field Values
-
CONFIGURATION
public static final String CONFIGURATION
- See Also:
- Constant Field Values
-
-
Method Detail
-
checkInit
protected void checkInit()
-
paramsToRequest
protected String paramsToRequest(QDLValue[] qdlValues) throws UnsupportedEncodingException
Takes the array of objects for an evaluate method and creates the right url This is used in get and delete. Options are 0 args - return current host 1 arg - stem, parameters 2 args - uri path + stem of parameters- Parameters:
qdlValues-- Returns:
- a valid get/delete string of host+uri_path+?key0=value0&key1=value1...
- Throws:
UnsupportedEncodingException
-
toParamList
public String toParamList(String key, Collection<? extends QDLValue> values) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
getResponseStem
public QDLStem getResponseStem(org.apache.http.HttpResponse response) throws IOException
Utility to turn the response, whatever it is, into a stem.- Parameters:
response-- Returns:
- Throws:
IOException
-
getActualHost
protected String getActualHost(String uriPath)
Given a uriPath, return the actual path to the service. This does the nitpicky things to create the path.- Parameters:
uriPath-- Returns:
-
serializeToJSON
public net.sf.json.JSONObject serializeToJSON()
Description copied from interface:QDLMetaModuleSend back a serialization of internal state for this object. This allows for the state you choose to be serialized and then reloaded.NOTE
There is no canonical form for this. Set it how you will and deserialize it accordingly.- Specified by:
serializeToJSONin interfaceQDLMetaModule- Returns:
-
deserializeFromJSON
public void deserializeFromJSON(net.sf.json.JSONObject json)
- Specified by:
deserializeFromJSONin interfaceQDLMetaModule
-
-