Class InvokeServiceCmd<T>
java.lang.Object
com.flowable.serviceregistry.engine.impl.cmd.InvokeServiceCmd<T>
- All Implemented Interfaces:
Command<T>
- Direct Known Subclasses:
InvokeListServiceCmd,InvokeSingleServiceCmd
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classprotected static enumprotected static class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ServiceInvocationResultconvertToServiceInvocationResult(ServiceInvocationResponse invocationResponse, ServiceInvocationResultResponse result) protected ServiceInvocationResultResponsecreateServiceInvocationResultResponseForJsonNode(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration, ServiceInvocationResponse invocationResponse, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Object responseObject) createValidateAndCompleteServiceInvocationInputDataMap(ServiceDefinition serviceDefinition, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, com.fasterxml.jackson.databind.ObjectMapper objectMapper, ExpressionManager expressionManager) Creates, validates and completes the service invocation data according the input parameter definition of the service.execute(CommandContext commandContext) protected InvokeServiceCmd.ValueWrapperextractValue(com.fasterxml.jackson.databind.node.ObjectNode objectNode, ServiceOutputParameter outputParameter) protected InvokeServiceCmd.ValueWrapperextractValue(Object responseDataObject, ServiceOutputParameter outputParameter, ServiceInvocationResponse response, com.fasterxml.jackson.databind.ObjectMapper objectMapper) protected InvokeServiceCmd.ValueWrapperextractValue(Map<String, Object> responseMap, ServiceOutputParameter outputParameter) protected InvokeServiceCmd.ValueWrapperextractValue(VariableContainer container, ServiceOutputParameter outputParameter) protected ObjectgetDefaultValue(ServiceOutputParameter outputParameter, String defaultValue, ServiceInvocationContext context, ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper) protected Stringprotected ObjectgetLookupId(ServiceDefinitionModel serviceDefinitionModel, ServiceInvocationResponse invocationResponse, Map<String, Object> resultMap, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Search for the lookup id value in the response according the mapping in the service definition and do proper handling of the response type (e.g.protected Collection<ServiceOutputParameter>getNestedMappingOutputParameters(NestedOutputMapping nestedOutputMapping, ServiceRegistryEngineConfiguration engineConfiguration, ServiceInvocationContextImpl context) protected ServiceDefinitionEntitygetServiceDefinition(String tenantId, CommandContext commandContext) protected ServiceDefinitionModelgetServiceDefinitionModel(ServiceDefinitionEntity serviceDefinition, CommandContext commandContext) protected ServiceInvokergetServiceInvoker(ServiceDefinitionModel serviceDefinitionModel, CommandContext commandContext) protected ServiceOperationgetServiceOperation(ServiceDefinitionModel serviceDefinitionModel) handleObjectOutputTypeForArrayResponse(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration, ServiceInvocationResponse invocationResponse, Iterable<?> responseObject) Handles service object output for array responses.handleOutputParametersValues(Object responseData, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration, Collection<ServiceOutputParameter> outputParameters, ServiceInvocationResponse invocationResponse) handleOutputParameterValues(Object responseData, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration, ServiceInvocationResponse invocationResponse) Verifies and handles output values according the output paramter definition of the service (specially missing and null-value output).protected ServiceInvocationResultResponsehandleServiceInvocationResponse(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvoker serviceInvoker, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration, ServiceInvocationResponse invocationResponse) protected booleanhasNestedOutputMapping(ServiceOutputParameter outputParameter) protected abstract Tinvoke(ServiceInvoker serviceInvoker, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, CommandContext commandContext) protected TinvokeService(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvoker serviceInvoker, ServiceInvocationContextImpl context, CommandContext commandContext) protected booleanisErrorResponse(ServiceInvocationResponse invocationResponse) protected voidprocessAndValidateInputParameter(ServiceDefinition serviceDefinition, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInputParameter inputParameter, Map<String, Object> serviceInvocationInputData, com.fasterxml.jackson.databind.ObjectMapper objectMapper, ExpressionManager expressionManager) Internal method to process a single input parameter by looking at its definition and checking its value.protected ServiceDefinitionEntityresolveServiceDefinitionByKey(String tenantId, ServiceRegistryEngineConfiguration serviceEngineConfiguration) protected ServiceDefinitionEntityresolveServiceDefinitionByReferenceKey(String tenantId, ServiceDefinitionEntityManager serviceDefinitionEntityManager, CommandContext commandContext) protected booleanshouldMapParameter(boolean isErrorResponse, ServiceOutputParameter outputParameter, ServiceDefinitionModel model, ServiceOperation operation) protected voidvalidateOperationTypeMatchesRequestedType(ServiceOperation operation, String requestedOperationType) protected void
-
Field Details
-
serviceInvocationBuilder
-
-
Constructor Details
-
InvokeServiceCmd
-
-
Method Details
-
execute
-
validateParameters
protected void validateParameters() -
createValidateAndCompleteServiceInvocationInputDataMap
protected Map<String,Object> createValidateAndCompleteServiceInvocationInputDataMap(ServiceDefinition serviceDefinition, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, com.fasterxml.jackson.databind.ObjectMapper objectMapper, ExpressionManager expressionManager) Creates, validates and completes the service invocation data according the input parameter definition of the service.- Parameters:
serviceDefinition-serviceDefinitionModel- the service definition model the invocation is based onserviceOperation- the service operation representing the service to be invokedobjectMapper- the object mapper used for creating and initializing variable values in JSONexpressionManager- the expression manager used for evaluating default values for input parameters- Returns:
- the initialized and validated variable data map
- Throws:
FlowableIllegalArgumentException- if the input parameter validation failed (e.g. a required parameter value was missing)
-
processAndValidateInputParameter
protected void processAndValidateInputParameter(ServiceDefinition serviceDefinition, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInputParameter inputParameter, Map<String, Object> serviceInvocationInputData, com.fasterxml.jackson.databind.ObjectMapper objectMapper, ExpressionManager expressionManager) Internal method to process a single input parameter by looking at its definition and checking its value. If a required input parameters value is missing and no default one is provided, it will throw an exception.- Parameters:
serviceDefinition- the service definitionserviceDefinitionModel- the service definition model the invocation is based onserviceOperation- the service operation the invocation is based oninputParameter- the input parameter to be processedserviceInvocationInputData- the service invocation input data map to be validated and completed for the given parameterobjectMapper- the object mapper used for creating and initializing variable values in JSONexpressionManager- the expression manager used for evaluating default values for input parameters- Throws:
FlowableIllegalArgumentException- if the input parameter validation failed (e.g. a required parameter value was missing)
-
getServiceDefinition
protected ServiceDefinitionEntity getServiceDefinition(String tenantId, CommandContext commandContext) -
resolveServiceDefinitionByKey
protected ServiceDefinitionEntity resolveServiceDefinitionByKey(String tenantId, ServiceRegistryEngineConfiguration serviceEngineConfiguration) -
resolveServiceDefinitionByReferenceKey
protected ServiceDefinitionEntity resolveServiceDefinitionByReferenceKey(String tenantId, ServiceDefinitionEntityManager serviceDefinitionEntityManager, CommandContext commandContext) -
getServiceDefinitionModel
protected ServiceDefinitionModel getServiceDefinitionModel(ServiceDefinitionEntity serviceDefinition, CommandContext commandContext) -
getServiceInvoker
protected ServiceInvoker getServiceInvoker(ServiceDefinitionModel serviceDefinitionModel, CommandContext commandContext) -
getServiceOperation
-
validateOperationTypeMatchesRequestedType
protected void validateOperationTypeMatchesRequestedType(ServiceOperation operation, String requestedOperationType) -
invokeService
protected T invokeService(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvoker serviceInvoker, ServiceInvocationContextImpl context, CommandContext commandContext) -
invoke
protected abstract T invoke(ServiceInvoker serviceInvoker, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, CommandContext commandContext) -
handleServiceInvocationResponse
protected ServiceInvocationResultResponse handleServiceInvocationResponse(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvoker serviceInvoker, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration, ServiceInvocationResponse invocationResponse) -
createServiceInvocationResultResponseForJsonNode
protected ServiceInvocationResultResponse createServiceInvocationResultResponseForJsonNode(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration, ServiceInvocationResponse invocationResponse, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Object responseObject) -
handleObjectOutputTypeForArrayResponse
protected Map<String,Object> handleObjectOutputTypeForArrayResponse(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration, ServiceInvocationResponse invocationResponse, Iterable<?> responseObject) Handles service object output for array responses. Mappings extract the values into an array:GIVEN
- output parameter mappings:
[ {name: 'rawResponse', source: 'responseBody', type: 'json'}, {name: 'muppetName', mappingName: 'muppetCharacterNames', type: 'string'} ] - payload:
[{id: 1, muppetName: 'Kermit'}, {id: 2, muppetName: 'Gonzo'}]
The resulting service output object looks like:
{ rawResponse: [{id: 1, muppetName: 'Kermit'}, {id: 2, muppetName: 'Gonzo'}], muppetCharacterNames: ['Kermit', 'Gonzo'] } - output parameter mappings:
-
convertToServiceInvocationResult
protected ServiceInvocationResult convertToServiceInvocationResult(ServiceInvocationResponse invocationResponse, ServiceInvocationResultResponse result) -
handleOutputParameterValues
protected Map<String,Object> handleOutputParameterValues(Object responseData, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration, ServiceInvocationResponse invocationResponse) Verifies and handles output values according the output paramter definition of the service (specially missing and null-value output).- Parameters:
responseData- the response returned by the invokerserviceDefinitionModel- the service modelserviceOperation- the operation which was invokedcontext- the context within which the service was invokedinvocationResponse- , theServiceInvocationResponsefor which the output params are handeled
-
handleOutputParametersValues
protected Map<String,Object> handleOutputParametersValues(Object responseData, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration, Collection<ServiceOutputParameter> outputParameters, ServiceInvocationResponse invocationResponse) -
shouldMapParameter
protected boolean shouldMapParameter(boolean isErrorResponse, ServiceOutputParameter outputParameter, ServiceDefinitionModel model, ServiceOperation operation) -
isErrorResponse
-
getNestedMappingOutputParameters
protected Collection<ServiceOutputParameter> getNestedMappingOutputParameters(NestedOutputMapping nestedOutputMapping, ServiceRegistryEngineConfiguration engineConfiguration, ServiceInvocationContextImpl context) -
getDefaultValue
protected Object getDefaultValue(ServiceOutputParameter outputParameter, String defaultValue, ServiceInvocationContext context, ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
extractValue
protected InvokeServiceCmd.ValueWrapper extractValue(com.fasterxml.jackson.databind.node.ObjectNode objectNode, ServiceOutputParameter outputParameter) -
extractValue
protected InvokeServiceCmd.ValueWrapper extractValue(Map<String, Object> responseMap, ServiceOutputParameter outputParameter) -
extractValue
protected InvokeServiceCmd.ValueWrapper extractValue(VariableContainer container, ServiceOutputParameter outputParameter) -
extractValue
protected InvokeServiceCmd.ValueWrapper extractValue(Object responseDataObject, ServiceOutputParameter outputParameter, ServiceInvocationResponse response, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
hasNestedOutputMapping
-
getLookupId
protected Object getLookupId(ServiceDefinitionModel serviceDefinitionModel, ServiceInvocationResponse invocationResponse, Map<String, Object> resultMap, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Search for the lookup id value in the response according the mapping in the service definition and do proper handling of the response type (e.g. JSON vs map).- Parameters:
serviceDefinitionModel- the service definition model where the lookup id mapping is taken frominvocationResponse- the invocation response containing the lookup id field and its valueresultMap- the result map containing the lookup idobjectMapper- the object mapper needed for converting the value- Returns:
- the lookup id value, if available, null otherwise
-
getHeaderValue
-