Class InvokeServiceCmd
java.lang.Object
com.flowable.serviceregistry.engine.impl.cmd.InvokeServiceCmd
- All Implemented Interfaces:
org.flowable.common.engine.impl.interceptor.Command<ServiceInvocationResponse>
public class InvokeServiceCmd extends java.lang.Object implements org.flowable.common.engine.impl.interceptor.Command<ServiceInvocationResponse>
-
Field Summary
Fields Modifier and Type Field Description protected ServiceInvocationBuilderserviceInvocationBuilder -
Constructor Summary
Constructors Constructor Description InvokeServiceCmd(ServiceInvocationBuilder serviceInvocationBuilder) -
Method Summary
Modifier and Type Method Description protected java.util.Map<java.lang.String,java.lang.Object>createValidateAndCompleteServiceInvocationInputDataMap(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, com.fasterxml.jackson.databind.ObjectMapper objectMapper, org.flowable.common.engine.impl.el.ExpressionManager expressionManager)Creates, validates and completes the service invocation data according the input parameter definition of the service.ServiceInvocationResponseexecute(org.flowable.common.engine.impl.interceptor.CommandContext commandContext)protected java.lang.ObjectgetLookupId(ServiceDefinitionModel serviceDefinitionModel, ServiceInvocationResponse invocationResponse)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 ServiceDefinitionEntitygetServiceDefinition(java.lang.String tenantId, org.flowable.common.engine.impl.interceptor.CommandContext commandContext)protected ServiceDefinitionModelgetServiceDefinitionModel(ServiceDefinitionEntity serviceDefinition, org.flowable.common.engine.impl.interceptor.CommandContext commandContext)protected ServiceInvokergetServiceInvoker(ServiceDefinitionModel serviceDefinitionModel, org.flowable.common.engine.impl.interceptor.CommandContext commandContext)protected ServiceOperationgetServiceOperation(ServiceDefinitionModel serviceDefinitionModel)protected voidhandleOutputParameterValues(ServiceInvocationResponse invocationResponse, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContext context, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper)Verifies and handles output values according the output paramter definition of the service (specially missing and null-value output).protected booleanhasMissingValue(ServiceInvocationResponse invocationResponse, ServiceOutputParameter outputParameter)protected booleanhasNullValue(ServiceInvocationResponse invocationResponse, ServiceOutputParameter outputParameter)protected ServiceInvocationResponseinvokeService(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvoker serviceInvoker, ServiceInvocationContextImpl context, org.flowable.common.engine.impl.interceptor.CommandContext commandContext, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper)protected voidprocessAndValidateInputParameter(ServiceDefinitionModel serviceDefinitionModel, ServiceInputParameter inputParameter, java.util.Map<java.lang.String,java.lang.Object> serviceInvocationInputData, com.fasterxml.jackson.databind.ObjectMapper objectMapper, org.flowable.common.engine.impl.el.ExpressionManager expressionManager)Internal method to process a single input parameter by looking at its definition and checking its value.protected voidremoveNullValue(ServiceInvocationResponse invocationResponse, ServiceOutputParameter outputParameter)protected ServiceDefinitionEntityresolveServiceDefinitionByKey(java.lang.String tenantId, ServiceRegistryEngineConfiguration serviceEngineConfiguration)protected ServiceDefinitionEntityresolveServiceDefinitionByReferenceKey(java.lang.String tenantId, ServiceDefinitionEntityManager serviceDefinitionEntityManager, org.flowable.common.engine.impl.interceptor.CommandContext commandContext)protected voidsetDefaultValue(ServiceInvocationResponse invocationResponse, ServiceOutputParameter outputParameter, java.lang.String defaultValue, ServiceInvocationContext context, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper)protected voidsetNullValue(ServiceInvocationResponse invocationResponse, ServiceOutputParameter outputParameter)protected voidvalidateParameters()
-
Field Details
-
Constructor Details
-
Method Details
-
execute
public ServiceInvocationResponse execute(org.flowable.common.engine.impl.interceptor.CommandContext commandContext)- Specified by:
executein interfaceorg.flowable.common.engine.impl.interceptor.Command<ServiceInvocationResponse>
-
validateParameters
protected void validateParameters() -
createValidateAndCompleteServiceInvocationInputDataMap
protected java.util.Map<java.lang.String,java.lang.Object> createValidateAndCompleteServiceInvocationInputDataMap(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, com.fasterxml.jackson.databind.ObjectMapper objectMapper, org.flowable.common.engine.impl.el.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:
org.flowable.common.engine.api.FlowableIllegalArgumentException- if the input parameter validation failed (e.g. a required parameter value was missing)
-
processAndValidateInputParameter
protected void processAndValidateInputParameter(ServiceDefinitionModel serviceDefinitionModel, ServiceInputParameter inputParameter, java.util.Map<java.lang.String,java.lang.Object> serviceInvocationInputData, com.fasterxml.jackson.databind.ObjectMapper objectMapper, org.flowable.common.engine.impl.el.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:
org.flowable.common.engine.api.FlowableIllegalArgumentException- if the input parameter validation failed (e.g. a required parameter value was missing)
-
getServiceDefinition
protected ServiceDefinitionEntity getServiceDefinition(java.lang.String tenantId, org.flowable.common.engine.impl.interceptor.CommandContext commandContext) -
resolveServiceDefinitionByKey
protected ServiceDefinitionEntity resolveServiceDefinitionByKey(java.lang.String tenantId, ServiceRegistryEngineConfiguration serviceEngineConfiguration) -
resolveServiceDefinitionByReferenceKey
protected ServiceDefinitionEntity resolveServiceDefinitionByReferenceKey(java.lang.String tenantId, ServiceDefinitionEntityManager serviceDefinitionEntityManager, org.flowable.common.engine.impl.interceptor.CommandContext commandContext) -
getServiceDefinitionModel
protected ServiceDefinitionModel getServiceDefinitionModel(ServiceDefinitionEntity serviceDefinition, org.flowable.common.engine.impl.interceptor.CommandContext commandContext) -
getServiceInvoker
protected ServiceInvoker getServiceInvoker(ServiceDefinitionModel serviceDefinitionModel, org.flowable.common.engine.impl.interceptor.CommandContext commandContext) -
getServiceOperation
-
invokeService
protected ServiceInvocationResponse invokeService(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvoker serviceInvoker, ServiceInvocationContextImpl context, org.flowable.common.engine.impl.interceptor.CommandContext commandContext, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
handleOutputParameterValues
protected void handleOutputParameterValues(ServiceInvocationResponse invocationResponse, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContext context, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper)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 invokedexpressionManager- the expression manager used to resolve default value expressionsobjectMapper- the object mapper used to manipulate the output JSON object (if JSON based and not map based)
-
hasMissingValue
protected boolean hasMissingValue(ServiceInvocationResponse invocationResponse, ServiceOutputParameter outputParameter) -
hasNullValue
protected boolean hasNullValue(ServiceInvocationResponse invocationResponse, ServiceOutputParameter outputParameter) -
setNullValue
protected void setNullValue(ServiceInvocationResponse invocationResponse, ServiceOutputParameter outputParameter) -
removeNullValue
protected void removeNullValue(ServiceInvocationResponse invocationResponse, ServiceOutputParameter outputParameter) -
setDefaultValue
protected void setDefaultValue(ServiceInvocationResponse invocationResponse, ServiceOutputParameter outputParameter, java.lang.String defaultValue, ServiceInvocationContext context, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
getLookupId
protected java.lang.Object getLookupId(ServiceDefinitionModel serviceDefinitionModel, ServiceInvocationResponse invocationResponse)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 value- Returns:
- the lookup id value, if available, null otherwise
-