Class InvokeServiceCmd<T>
- java.lang.Object
-
- com.flowable.serviceregistry.engine.impl.cmd.InvokeServiceCmd<T>
-
- All Implemented Interfaces:
Command<T>
- Direct Known Subclasses:
InvokeListServiceCmd
,InvokeSingleServiceCmd
public abstract class InvokeServiceCmd<T> extends Object implements Command<T>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InvokeServiceCmd.ServiceInvocationArrayResultResponse
static class
InvokeServiceCmd.ServiceInvocationResultResponseImpl
protected static class
InvokeServiceCmd.ValuePresence
protected static class
InvokeServiceCmd.ValueWrapper
-
Field Summary
Fields Modifier and Type Field Description protected ServiceInvocationBuilder
serviceInvocationBuilder
-
Constructor Summary
Constructors Constructor Description InvokeServiceCmd(ServiceInvocationBuilder serviceInvocationBuilder)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ServiceInvocationResult
convertToServiceInvocationResult(ServiceInvocationResponse invocationResponse, ServiceInvocationResultResponse result)
protected Map<String,Object>
createValidateAndCompleteServiceInvocationInputDataMap(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.T
execute(CommandContext commandContext)
protected InvokeServiceCmd.ValueWrapper
extractValue(com.fasterxml.jackson.databind.node.ObjectNode objectNode, ServiceOutputParameter outputParameter)
protected InvokeServiceCmd.ValueWrapper
extractValue(Object invocationResponse, ServiceOutputParameter outputParameter)
protected InvokeServiceCmd.ValueWrapper
extractValue(Map<String,Object> responseMap, ServiceOutputParameter outputParameter)
protected Object
getDefaultValue(ServiceOutputParameter outputParameter, String defaultValue, ServiceInvocationContext context, ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
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.protected Collection<ServiceOutputParameter>
getNestedMappingOutputParameters(NestedOutputMapping nestedOutputMapping, ServiceRegistryEngineConfiguration engineConfiguration, ServiceInvocationContextImpl context)
protected ServiceDefinitionEntity
getServiceDefinition(String tenantId, CommandContext commandContext)
protected ServiceDefinitionModel
getServiceDefinitionModel(ServiceDefinitionEntity serviceDefinition, CommandContext commandContext)
protected ServiceInvoker
getServiceInvoker(ServiceDefinitionModel serviceDefinitionModel, CommandContext commandContext)
protected ServiceOperation
getServiceOperation(ServiceDefinitionModel serviceDefinitionModel)
protected Map<String,Object>
handleOutputParametersValues(Object invocationResponse, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration, Collection<ServiceOutputParameter> outputParameters)
protected Map<String,Object>
handleOutputParameterValues(Object invocationResponse, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration)
Verifies and handles output values according the output paramter definition of the service (specially missing and null-value output).protected ServiceInvocationResultResponse
handleServiceInvocationResponse(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvoker serviceInvoker, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration, ServiceInvocationResponse invocationResponse)
protected boolean
hasNestedOutputMapping(ServiceOutputParameter outputParameter)
protected abstract T
invoke(ServiceInvoker serviceInvoker, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, CommandContext commandContext)
protected T
invokeService(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvoker serviceInvoker, ServiceInvocationContextImpl context, CommandContext commandContext)
protected void
processAndValidateInputParameter(ServiceDefinitionModel serviceDefinitionModel, 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 ServiceDefinitionEntity
resolveServiceDefinitionByKey(String tenantId, ServiceRegistryEngineConfiguration serviceEngineConfiguration)
protected ServiceDefinitionEntity
resolveServiceDefinitionByReferenceKey(String tenantId, ServiceDefinitionEntityManager serviceDefinitionEntityManager, CommandContext commandContext)
protected void
validateOperationTypeMatchesRequestedType(ServiceOperation operation, String requestedOperationType)
protected void
validateParameters()
-
-
-
Field Detail
-
serviceInvocationBuilder
protected ServiceInvocationBuilder serviceInvocationBuilder
-
-
Constructor Detail
-
InvokeServiceCmd
public InvokeServiceCmd(ServiceInvocationBuilder serviceInvocationBuilder)
-
-
Method Detail
-
execute
public T execute(CommandContext commandContext)
-
validateParameters
protected void validateParameters()
-
createValidateAndCompleteServiceInvocationInputDataMap
protected Map<String,Object> createValidateAndCompleteServiceInvocationInputDataMap(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:
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(ServiceDefinitionModel serviceDefinitionModel, 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:
serviceDefinitionModel
- the service definition model 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
protected ServiceOperation getServiceOperation(ServiceDefinitionModel serviceDefinitionModel)
-
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)
-
convertToServiceInvocationResult
protected ServiceInvocationResult convertToServiceInvocationResult(ServiceInvocationResponse invocationResponse, ServiceInvocationResultResponse result)
-
handleOutputParameterValues
protected Map<String,Object> handleOutputParameterValues(Object invocationResponse, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration)
Verifies and handles output values according the output paramter definition of the service (specially missing and null-value output).- Parameters:
invocationResponse
- the response returned by the invokerserviceDefinitionModel
- the service modelserviceOperation
- the operation which was invokedcontext
- the context within which the service was invoked
-
handleOutputParametersValues
protected Map<String,Object> handleOutputParametersValues(Object invocationResponse, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, ServiceRegistryEngineConfiguration serviceEngineConfiguration, Collection<ServiceOutputParameter> outputParameters)
-
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(Object invocationResponse, ServiceOutputParameter outputParameter)
-
hasNestedOutputMapping
protected boolean hasNestedOutputMapping(ServiceOutputParameter outputParameter)
-
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
-
-