@Tracked(value=TRACE) @Activity(value="REST Service Adapter", category=AdapterActivity.class, icon="com.centurylink.mdw.base/adapter.png", pagelet="com.centurylink.mdw.base/restService.pagelet") public class RestServiceAdapter extends HttpServiceAdapter implements HeaderAwareAdapter
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AUTH_APP_ID |
static java.lang.String |
AUTH_PASSWORD |
static java.lang.String |
AUTH_PROVIDER |
static java.lang.String |
AUTH_USER |
static java.lang.String |
ENDPOINT_URI |
static java.lang.String |
HEADERS_VARIABLE |
static java.lang.String |
HTTP_METHOD |
static java.lang.String |
REQUEST_VARIABLE |
CONNECT_TIMEOUT, DEFAULT_ERROR_HTTP_CODE, DEFAULT_RETRY_HTTP_CODE, ERROR_HTTP_CODES, PROP_PASS, PROP_USER, READ_TIMEOUT, RETRY_HTTP_CODES
DISABLED, GROOVY, JAVA_EL, JAVASCRIPT, logger, OUTPUTDOCS
COMPCODE_AUTO_RETRY, DEFAULT_STUBBER_PORT, DEFAULT_STUBBER_TIMEOUT, DO_LOGGING, MAKE_ACTUAL_CALL, PROP_MAX_TRIES, PROP_RETRY_INTERVAL, PROP_SYNCHRONOUS_RESPONSE, PROP_TIMEOUT, REQUEST_XSD, RESPONSE_VARIABLE, RESPONSE_XSD
Constructor and Description |
---|
RestServiceAdapter() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getAdapterInvocationErrorMessage()
Specific stacktrace error message for RestServiceAdapter to include the endpoint
|
java.lang.Object |
getAuthProvider() |
protected java.lang.String |
getEndpointUri()
Returns the endpoint URL for the RESTful service.
|
HttpHelper |
getHttpHelper(java.lang.Object connection)
Allows the overriding of this method without overriding invoke()
|
protected java.lang.String |
getHttpMethod() |
protected java.lang.String |
getRequestData()
The method overrides the one from the super class and does the following:
For HTTP GET and DELETE requests, it returns an empty string
Otherwise it gets the value of the variable with the name specified in the
attribute REQUEST_VARIABLE.
|
java.util.Map<java.lang.String,java.lang.String> |
getRequestHeaders()
Override to specify HTTP request headers.
|
protected org.json.JSONObject |
getRequestMeta() |
protected java.util.Map<java.lang.String,java.lang.String> |
getRequestParameters()
Override to specify URL request parameters.
|
java.util.Map<java.lang.String,java.lang.String> |
getResponseHeaders()
Protocol adapter must call setResponseHeaders() with appropriate values extracted from the response.
|
protected org.json.JSONObject |
getResponseMeta() |
protected AdapterStubRequest |
getStubRequest(java.lang.String requestContent) |
protected java.lang.String |
getUrlEncoding() |
java.lang.Object |
invoke(java.lang.Object pConnection,
java.lang.Object requestData,
java.util.Map<java.lang.String,java.lang.String> requestHeaders) |
java.lang.String |
invoke(java.lang.Object inConn,
java.lang.String request,
int timeout,
java.util.Map<java.lang.String,java.lang.String> headers)
Invokes the RESTful service by submitting an HTTP request against the configured
endpoint URI.
|
protected java.lang.Long |
logRequest(Request request) |
java.lang.Object |
openConnection()
Open connection
|
java.lang.Object |
openConnection(java.lang.String proxyHost,
int proxyPort) |
java.lang.Object |
openConnection(java.lang.String proxyHost,
int proxyPort,
java.net.Proxy.Type proxyType)
Returns an HttpConnection based on the configured endpoint, which
includes the resource path.
|
protected java.lang.String |
performHttpAction(HttpHelper httpHelper,
java.lang.String request) |
protected void |
setResponseHeaders(java.util.Map<java.lang.String,java.lang.String> headers) |
canBeAsynchronous, canBeSynchronous, closeConnection, getConnectTimeout, getReadTimeout, getResponse, init, setRequestHeaders
directInvoke, doInvoke, doLogging, execute, executePostScript, executePreScript, filterStubResponse, getAttribute, getErrorCode, getMaxTries, getRetryInterval, getStubbedResponse, getStubResponse, getTimeoutForResponse, handleConnectionException, handleException, handleRetry, hasPostScript, hasPreScript, isRetryable, isStubMode, isSynchronous, logRequest, logResponse, logResponse, onFailure, onSuccess, populateResponseVariable
execute
createDocument, createDocument, createDocument, createDocument, evaluateExpression, executeScript, getActivityId, getActivityInstance, getActivityInstanceId, getActivityName, getAttribute, getAttribute, getAttribute, getAttribute, getAttributes, getAttributeValue, getAttributeValueSmart, getDocument, getDocumentContent, getDocumentForUpdate, getDocumentType, getEngine, getExternalEventInstanceDetails, getLogger, getMainProcessDefinition, getMasterRequestId, getOutputDocuments, getPackage, getParameterId, getParameters, getParameterStringValue, getParameterType, getParameterValue, getPerformanceLevel, getProcessDefinition, getProcessId, getProcessInstance, getProcessInstanceId, getProcessInstanceOwner, getProcessInstanceOwnerId, getProperty, getRequiredAttribute, getRequiredVariableValue, getReturnCode, getReturnMessage, getRuntimeContext, getScriptEvaluator, getScriptExecClassName, getScriptExecutor, getValue, getValues, getValueSmart, getVariableInstance, getVariableValue, getVariableValueSmart, getWorkTransitionInstanceId, initialize, isDisabled, isLogDebugEnabled, isLogInfoEnabled, isOutputDocument, lockActivityInstance, lockProcessInstance, logdebug, logDebug, logError, logError, logexception, loginfo, logInfo, logsevere, logwarn, logWarn, prepare, setOutputDocuments, setParameterValue, setParameterValueAsDocument, setParameterValues, setProcessInstanceCompletionCode, setReturnCode, setReturnMessage, setValue, setVariableValue, setVariableValue, startTransaction, stopTransaction, translatePlaceHolder, updateDocumentContent, updateDocumentInfo, updateDocumentInfo, valueIsJavaExpression, valueIsVariable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
execute
public static final java.lang.String HTTP_METHOD
public static final java.lang.String ENDPOINT_URI
public static final java.lang.String HEADERS_VARIABLE
public static final java.lang.String AUTH_PROVIDER
public static final java.lang.String AUTH_APP_ID
public static final java.lang.String AUTH_USER
public static final java.lang.String AUTH_PASSWORD
public static final java.lang.String REQUEST_VARIABLE
public java.lang.Object openConnection() throws ConnectionException
TextAdapter
openConnection
in interface TextAdapter
openConnection
in class HttpServiceAdapter
ConnectionException
- retriable connection failurepublic java.lang.Object openConnection(java.lang.String proxyHost, int proxyPort) throws ConnectionException
ConnectionException
public java.lang.Object openConnection(java.lang.String proxyHost, int proxyPort, java.net.Proxy.Type proxyType) throws ConnectionException
ConnectionException
public HttpHelper getHttpHelper(java.lang.Object connection) throws ActivityException
HttpServiceAdapter
Allows the overriding of this method without overriding invoke()
getHttpHelper
in class HttpServiceAdapter
ActivityException
public java.lang.Object getAuthProvider() throws ActivityException
ActivityException
protected java.util.Map<java.lang.String,java.lang.String> getRequestParameters()
protected java.lang.String getUrlEncoding()
protected java.lang.String getEndpointUri() throws PropertyException
BaseActivity.getAttributeValueSmart(String)
.PropertyException
public java.lang.String invoke(java.lang.Object inConn, java.lang.String request, int timeout, java.util.Map<java.lang.String,java.lang.String> headers) throws ConnectionException, AdapterException
invoke
in interface TextAdapter
invoke
in class HttpServiceAdapter
inConn
- the object returned by openConnection()
and is typically the adapter activity instance itself.request
- request contenttimeout
- time out in seconds. Ignored if no response is expected.headers
- protocol request data, e.g. correlation IDConnectionException
AdapterException
TextAdapter.invoke(java.lang.Object, java.lang.String, int, java.util.Map)
protected java.lang.String performHttpAction(HttpHelper httpHelper, java.lang.String request) throws ActivityException, java.io.IOException, AdapterException
ActivityException
java.io.IOException
AdapterException
protected java.lang.String getRequestData() throws ActivityException
getRequestData
in class TextAdapterActivity
ActivityException
protected java.lang.String getHttpMethod() throws ActivityException
ActivityException
public java.util.Map<java.lang.String,java.lang.String> getRequestHeaders()
getRequestHeaders
in interface HeaderAwareAdapter
getRequestHeaders
in class HttpServiceAdapter
public java.util.Map<java.lang.String,java.lang.String> getResponseHeaders()
TextAdapterActivity
getResponseHeaders
in interface HeaderAwareAdapter
getResponseHeaders
in class TextAdapterActivity
protected void setResponseHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
setResponseHeaders
in class TextAdapterActivity
protected AdapterStubRequest getStubRequest(java.lang.String requestContent) throws AdapterException
getStubRequest
in class TextAdapterActivity
AdapterException
public java.lang.Object invoke(java.lang.Object pConnection, java.lang.Object requestData, java.util.Map<java.lang.String,java.lang.String> requestHeaders) throws AdapterException, ConnectionException
invoke
in interface HeaderAwareAdapter
AdapterException
ConnectionException
public java.lang.String getAdapterInvocationErrorMessage()
getAdapterInvocationErrorMessage
in interface AdapterInvocationError
getAdapterInvocationErrorMessage
in class TextAdapterActivity
protected org.json.JSONObject getRequestMeta() throws java.lang.Exception
getRequestMeta
in class TextAdapterActivity
java.lang.Exception
protected org.json.JSONObject getResponseMeta() throws java.lang.Exception
getResponseMeta
in class TextAdapterActivity
java.lang.Exception
protected java.lang.Long logRequest(Request request)
logRequest
in class TextAdapterActivity
Copyright © 2019 CenturyLink, Inc.