Class InvokeServiceCmd
- java.lang.Object
-
- com.flowable.serviceregistry.engine.impl.cmd.InvokeServiceCmd
-
- All Implemented Interfaces:
org.flowable.common.engine.impl.interceptor.Command<ServiceInvocationResultResponse>
public class InvokeServiceCmd extends java.lang.Object implements org.flowable.common.engine.impl.interceptor.Command<ServiceInvocationResultResponse>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InvokeServiceCmd.ServiceInvocationResultResponseImpl
-
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 Concrete Methods 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.ServiceInvocationResultResponse
execute(org.flowable.common.engine.impl.interceptor.CommandContext commandContext)
protected java.lang.Object
getDefaultValue(ServiceOutputParameter outputParameter, java.lang.String defaultValue, ServiceInvocationContext context, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
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.protected ServiceDefinitionEntity
getServiceDefinition(java.lang.String tenantId, org.flowable.common.engine.impl.interceptor.CommandContext commandContext)
protected ServiceDefinitionModel
getServiceDefinitionModel(ServiceDefinitionEntity serviceDefinition, org.flowable.common.engine.impl.interceptor.CommandContext commandContext)
protected ServiceInvoker
getServiceInvoker(ServiceDefinitionModel serviceDefinitionModel, org.flowable.common.engine.impl.interceptor.CommandContext commandContext)
protected ServiceOperation
getServiceOperation(ServiceDefinitionModel serviceDefinitionModel)
protected java.lang.Object
getValue(ServiceInvocationResponse invocationResponse, java.lang.String parameterName, java.lang.String parameterType, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
protected java.util.Map<java.lang.String,java.lang.Object>
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).protected boolean
hasMissingValue(ServiceInvocationResponse invocationResponse, java.lang.String parameterName)
protected boolean
hasNullValue(ServiceInvocationResponse invocationResponse, java.lang.String parameterName)
protected ServiceInvocationResultResponse
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)
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.protected ServiceDefinitionEntity
resolveServiceDefinitionByKey(java.lang.String tenantId, ServiceRegistryEngineConfiguration serviceEngineConfiguration)
protected ServiceDefinitionEntity
resolveServiceDefinitionByReferenceKey(java.lang.String tenantId, ServiceDefinitionEntityManager serviceDefinitionEntityManager, org.flowable.common.engine.impl.interceptor.CommandContext commandContext)
protected void
validateParameters()
-
-
-
Field Detail
-
serviceInvocationBuilder
protected ServiceInvocationBuilder serviceInvocationBuilder
-
-
Constructor Detail
-
InvokeServiceCmd
public InvokeServiceCmd(ServiceInvocationBuilder serviceInvocationBuilder)
-
-
Method Detail
-
execute
public ServiceInvocationResultResponse execute(org.flowable.common.engine.impl.interceptor.CommandContext commandContext)
- Specified by:
execute
in interfaceorg.flowable.common.engine.impl.interceptor.Command<ServiceInvocationResultResponse>
-
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
protected ServiceOperation getServiceOperation(ServiceDefinitionModel serviceDefinitionModel)
-
invokeService
protected ServiceInvocationResultResponse 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 java.util.Map<java.lang.String,java.lang.Object> 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, java.lang.String parameterName)
-
hasNullValue
protected boolean hasNullValue(ServiceInvocationResponse invocationResponse, java.lang.String parameterName)
-
getDefaultValue
protected java.lang.Object getDefaultValue(ServiceOutputParameter outputParameter, java.lang.String defaultValue, ServiceInvocationContext context, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
getValue
protected java.lang.Object getValue(ServiceInvocationResponse invocationResponse, java.lang.String parameterName, java.lang.String parameterType, 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
-
-