Class RestServiceInvoker
java.lang.Object
com.flowable.serviceregistry.engine.impl.invoker.rest.RestServiceInvoker
- All Implemented Interfaces:
ServiceInvoker
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected tools.jackson.databind.ObjectMapperprotected ServiceRegistryEngineConfiguration -
Constructor Summary
ConstructorsConstructorDescriptionRestServiceInvoker(ServiceRegistryEngineConfiguration serviceRegistryEngineConfiguration, tools.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddHeader(MultiValueMap<String, String> headers, String header) protected tools.jackson.databind.JsonNodeapplyOutputPathIfApplicable(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, tools.jackson.databind.JsonNode resultJsonNode) protected booleanprotected intprotected longprotected voidbuildMultipartRequest(org.flowable.http.common.api.HttpRequest request, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer, org.flowable.common.engine.impl.interceptor.CommandContext commandContext) Builds a multipart request by adding parts for each input parameter.protected voidconfigureRequest(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, org.flowable.http.common.api.HttpRequest request, ServiceInvocationVariablesContainer variablesContainer) protected StringconvertToStringForMultipart(Object value, String inputParameterType) Converts a parameter value to a string for use in multipart form fields.protected org.flowable.http.common.api.client.FlowableHttpClientcreateFlowableHttpClient(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationVariablesContainer variablesContainer, ServiceInvocationContext context, org.flowable.http.common.api.HttpRequest request, ServiceRegistryEngineConfiguration engineConfiguration) protected <T extends org.flowable.http.common.api.delegate.HttpResponseHandler & org.flowable.http.common.api.delegate.HttpRequestHandler>
TcreateHttpRequestOrResponseHandler(tools.jackson.databind.JsonNode handlerNode, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) protected org.flowable.http.common.api.delegate.HttpRequestHandlercreateRequestHandler(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) protected org.flowable.http.common.api.delegate.HttpResponseHandlercreateResponseHandler(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) protected Stringprotected static tools.jackson.databind.JsonNodedictionaryValueTypeToJsonNode(tools.jackson.databind.node.JsonNodeFactory factory, Object value) protected StringencodeBasicAuth(String username, String password, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) protected StringensureUrlIsEncoded(String url, ServiceInvocationVariablesContainer variablesContainer) protected URIorg.flowable.http.common.api.HttpResponseexecute(org.flowable.http.common.api.HttpRequest request, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContext context, ServiceInvocationVariablesContainer serviceDataVariablesContainer) protected RestServiceAuthorizationgetAuthorization(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) protected RestServiceAuthorizationgetAuthorization(tools.jackson.databind.JsonNode config) protected StringgetBody(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer serviceInvocationVariablesContainer) protected org.flowable.content.api.ContentServicegetContentService(org.flowable.common.engine.impl.interceptor.CommandContext commandContext) Gets the ContentService from the command context.protected StringgetFormUrlencodedBody(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer serviceInvocationVariablesContainer) protected MultiValueMap<String, String> getHeaders(tools.jackson.databind.JsonNode config, String serviceDefinitionKey, String serviceOperationKey) protected MultiValueMap<String, String> getHeadersFromGlobalProperties(String globalPropKey) protected longgetTotalCountIfApplicable(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, tools.jackson.databind.JsonNode resultJsonNode) protected StringgetUrl(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) protected StringhandleInputQueryParameters(String url, org.flowable.common.engine.api.variable.VariableContainer variableContainer, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) invoke(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContext context) protected booleanprotected booleanisContentItemJsonRepresentation(org.flowable.common.engine.impl.json.FlowableJsonNode jsonNode) Checks if a JSON node represents a valid content item (has both "id" and "contentStoreId" fields).protected booleanisJsonContentType(String value) protected booleanisJsonContentType(org.flowable.http.common.api.HttpResponse httpResponse) protected booleanisMultipartRequest(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, MultiValueMap<String, String> headers) Checks if the request should be sent as multipart/form-data.protected booleanisUrlEncodedRequest(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) Checks if the request should be sent as application/x-www-form-urlencoded.protected booleanlookupBooleanProperty(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, String field, boolean defaultValue) protected MultiValueMap<String, String> lookupHeaders(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) protected intlookupIntegerProperty(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, String field, int defaultValue) protected longlookupLongProperty(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, String field, int defaultValue) protected StringlookupStringProperty(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, String field, String defaultValue) org.flowable.http.common.api.HttpResponseperform(org.flowable.http.common.api.client.FlowableHttpClient client, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContext context, org.flowable.http.common.api.HttpRequest httpRequest, ServiceInvocationVariablesContainer variablesContainer) protected voidprocessInputParameter(ServiceInvocationVariablesContainer serviceInvocationVariablesContainer, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, tools.jackson.databind.node.ObjectNode bodyJson, ServiceInputParameter inputParameter) protected byte[]readContentItemData(org.flowable.content.api.ContentService contentService, org.flowable.content.api.ContentItem contentItem) Reads the binary content data from a content item.protected org.flowable.content.api.ContentItemresolveContentItemById(String contentItemId, String parameterName, org.flowable.content.api.ContentService contentService) Resolves a ContentItem by its ID.protected List<org.flowable.content.api.ContentItem> resolveContentItems(Object value, String parameterName, org.flowable.content.api.ContentService contentService) Resolves ContentItems from a variable value.protected StringresolveCredentials(RestServiceAuthorization.Credentials credentials, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer, org.flowable.common.engine.impl.interceptor.CommandContext commandContext) protected StringresolveExpressionAsString(String value, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer) protected MultiValueMap<String, String> resolveHeaderExpressions(MultiValueMap<String, String> headers, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer) protected StringresolveOAuth2ClientToken(String oauth2RegistrationKey, org.flowable.common.engine.api.variable.VariableContainer variableContainer, org.flowable.common.engine.impl.interceptor.CommandContext commandContext) protected StringresolveSecret(String secretName, ServiceInvocationVariablesContainer variablesContainer, org.flowable.common.engine.impl.interceptor.CommandContext commandContext) protected booleanshouldIgnoreErrors(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) protected booleanprotected voidvalidate(org.flowable.http.common.api.HttpRequest request, ServiceInvocationVariablesContainer variablesContainer)
-
Field Details
-
KEY
- See Also:
-
serviceRegistryEngineConfiguration
-
objectMapper
protected tools.jackson.databind.ObjectMapper objectMapper
-
-
Constructor Details
-
RestServiceInvoker
public RestServiceInvoker(ServiceRegistryEngineConfiguration serviceRegistryEngineConfiguration, tools.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
invoke
public ServiceInvocationResultResponse invoke(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContext context) - Specified by:
invokein interfaceServiceInvoker
-
createRequestHandler
protected org.flowable.http.common.api.delegate.HttpRequestHandler createRequestHandler(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) -
createResponseHandler
protected org.flowable.http.common.api.delegate.HttpResponseHandler createResponseHandler(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) -
createHttpRequestOrResponseHandler
protected <T extends org.flowable.http.common.api.delegate.HttpResponseHandler & org.flowable.http.common.api.delegate.HttpRequestHandler> T createHttpRequestOrResponseHandler(tools.jackson.databind.JsonNode handlerNode, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) -
configureRequest
protected void configureRequest(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, org.flowable.http.common.api.HttpRequest request, ServiceInvocationVariablesContainer variablesContainer) -
isMultipartRequest
protected boolean isMultipartRequest(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, MultiValueMap<String, String> headers) Checks if the request should be sent as multipart/form-data. This is determined by the 'multipart' config property on the operation. -
isUrlEncodedRequest
protected boolean isUrlEncodedRequest(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) Checks if the request should be sent as application/x-www-form-urlencoded. This is determined by the 'urlEncoded' config property on the operation. -
buildMultipartRequest
protected void buildMultipartRequest(org.flowable.http.common.api.HttpRequest request, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer, org.flowable.common.engine.impl.interceptor.CommandContext commandContext) Builds a multipart request by adding parts for each input parameter. ContentItem parameters are added as file parts, other parameters as text fields. -
getContentService
protected org.flowable.content.api.ContentService getContentService(org.flowable.common.engine.impl.interceptor.CommandContext commandContext) Gets the ContentService from the command context. -
readContentItemData
protected byte[] readContentItemData(org.flowable.content.api.ContentService contentService, org.flowable.content.api.ContentItem contentItem) Reads the binary content data from a content item. -
resolveContentItems
protected List<org.flowable.content.api.ContentItem> resolveContentItems(Object value, String parameterName, org.flowable.content.api.ContentService contentService) Resolves ContentItems from a variable value. Supported value types: - ContentItem object - String representing the content item ID - Collection of ContentItems or String IDs - ArrayNode (JSON array) where each element has "id" and "contentStoreId" fields - ObjectNode (JSON object) with "id" and "contentStoreId" fields -
isContentItemJsonRepresentation
-
isContentItemJsonRepresentation
protected boolean isContentItemJsonRepresentation(org.flowable.common.engine.impl.json.FlowableJsonNode jsonNode) Checks if a JSON node represents a valid content item (has both "id" and "contentStoreId" fields). -
resolveContentItemById
-
convertToStringForMultipart
-
getUrl
protected String getUrl(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) -
handleInputQueryParameters
protected String handleInputQueryParameters(String url, org.flowable.common.engine.api.variable.VariableContainer variableContainer, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) -
getBody
protected String getBody(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer serviceInvocationVariablesContainer) -
getFormUrlencodedBody
protected String getFormUrlencodedBody(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer serviceInvocationVariablesContainer) -
processInputParameter
protected void processInputParameter(ServiceInvocationVariablesContainer serviceInvocationVariablesContainer, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, tools.jackson.databind.node.ObjectNode bodyJson, ServiceInputParameter inputParameter) -
dictionaryValueTypeToJsonNode
protected static tools.jackson.databind.JsonNode dictionaryValueTypeToJsonNode(tools.jackson.databind.node.JsonNodeFactory factory, Object value) -
lookupStringProperty
protected String lookupStringProperty(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, String field, String defaultValue) -
getAuthorization
protected RestServiceAuthorization getAuthorization(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) -
getAuthorization
-
lookupHeaders
protected MultiValueMap<String,String> lookupHeaders(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) -
getHeadersFromGlobalProperties
-
getHeaders
protected MultiValueMap<String,String> getHeaders(tools.jackson.databind.JsonNode config, String serviceDefinitionKey, String serviceOperationKey) -
addHeader
-
resolveHeaderExpressions
protected MultiValueMap<String,String> resolveHeaderExpressions(MultiValueMap<String, String> headers, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer) -
resolveCredentials
protected String resolveCredentials(RestServiceAuthorization.Credentials credentials, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer, org.flowable.common.engine.impl.interceptor.CommandContext commandContext) -
resolveSecret
protected String resolveSecret(String secretName, ServiceInvocationVariablesContainer variablesContainer, org.flowable.common.engine.impl.interceptor.CommandContext commandContext) -
resolveOAuth2ClientToken
-
resolveExpressionAsString
protected String resolveExpressionAsString(String value, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer) -
lookupIntegerProperty
protected int lookupIntegerProperty(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, String field, int defaultValue) -
lookupLongProperty
protected long lookupLongProperty(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, String field, int defaultValue) -
asInt
-
asLong
-
lookupBooleanProperty
protected boolean lookupBooleanProperty(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, String field, boolean defaultValue) -
asBoolean
-
applyOutputPathIfApplicable
protected tools.jackson.databind.JsonNode applyOutputPathIfApplicable(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, tools.jackson.databind.JsonNode resultJsonNode) -
getTotalCountIfApplicable
protected long getTotalCountIfApplicable(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, tools.jackson.databind.JsonNode resultJsonNode) -
execute
public org.flowable.http.common.api.HttpResponse execute(org.flowable.http.common.api.HttpRequest request, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContext context, ServiceInvocationVariablesContainer serviceDataVariablesContainer) -
testMockingEnabled
-
shouldIgnoreErrors
protected boolean shouldIgnoreErrors(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) -
createFlowableHttpClient
protected org.flowable.http.common.api.client.FlowableHttpClient createFlowableHttpClient(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationVariablesContainer variablesContainer, ServiceInvocationContext context, org.flowable.http.common.api.HttpRequest request, ServiceRegistryEngineConfiguration engineConfiguration) -
validate
protected void validate(org.flowable.http.common.api.HttpRequest request, ServiceInvocationVariablesContainer variablesContainer) -
perform
public org.flowable.http.common.api.HttpResponse perform(org.flowable.http.common.api.client.FlowableHttpClient client, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContext context, org.flowable.http.common.api.HttpRequest httpRequest, ServiceInvocationVariablesContainer variablesContainer) -
isJsonContentType
protected boolean isJsonContentType(org.flowable.http.common.api.HttpResponse httpResponse) -
isJsonContentType
-
encodeBasicAuth
protected String encodeBasicAuth(String username, String password, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation) -
ensureUrlIsEncoded
protected String ensureUrlIsEncoded(String url, ServiceInvocationVariablesContainer variablesContainer) -
ensureUrlIsEncodedAndConvertToUri
- Throws:
URISyntaxException
-
decode
-