public abstract class InvokeServiceCmd<T> extends Object implements Command<T>
Modifier and Type | Class and Description |
---|---|
static class |
InvokeServiceCmd.ServiceInvocationArrayResultResponse |
static class |
InvokeServiceCmd.ServiceInvocationResultResponseImpl |
protected static class |
InvokeServiceCmd.ValuePresence |
protected static class |
InvokeServiceCmd.ValueWrapper |
Modifier and Type | Field and Description |
---|---|
protected ServiceInvocationBuilder |
serviceInvocationBuilder |
Constructor and Description |
---|
InvokeServiceCmd(ServiceInvocationBuilder serviceInvocationBuilder) |
Modifier and Type | Method and 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(Map<String,Object> responseMap,
ServiceOutputParameter outputParameter) |
protected InvokeServiceCmd.ValueWrapper |
extractValue(com.fasterxml.jackson.databind.node.ObjectNode objectNode,
ServiceOutputParameter outputParameter) |
protected InvokeServiceCmd.ValueWrapper |
extractValue(Object invocationResponse,
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 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> |
handleOutputParameterValues(Object invocationResponse,
ServiceDefinitionModel serviceDefinitionModel,
ServiceOperation serviceOperation,
ServiceInvocationContext context,
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 ServiceInvocationResultResponse |
handleServiceInvocationResponse(ServiceDefinitionModel serviceDefinitionModel,
ServiceOperation serviceOperation,
ServiceInvoker serviceInvoker,
ServiceInvocationContextImpl context,
ExpressionManager expressionManager,
com.fasterxml.jackson.databind.ObjectMapper objectMapper,
ServiceInvocationResponse invocationResponse) |
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() |
protected ServiceInvocationBuilder serviceInvocationBuilder
public InvokeServiceCmd(ServiceInvocationBuilder serviceInvocationBuilder)
public T execute(CommandContext commandContext)
protected void validateParameters()
protected Map<String,Object> createValidateAndCompleteServiceInvocationInputDataMap(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, com.fasterxml.jackson.databind.ObjectMapper objectMapper, ExpressionManager expressionManager)
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 parametersFlowableIllegalArgumentException
- if the input parameter validation failed (e.g. a required parameter value was missing)protected void processAndValidateInputParameter(ServiceDefinitionModel serviceDefinitionModel, ServiceInputParameter inputParameter, Map<String,Object> serviceInvocationInputData, com.fasterxml.jackson.databind.ObjectMapper objectMapper, ExpressionManager expressionManager)
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 parametersFlowableIllegalArgumentException
- if the input parameter validation failed (e.g. a required parameter value was missing)protected ServiceDefinitionEntity getServiceDefinition(String tenantId, CommandContext commandContext)
protected ServiceDefinitionEntity resolveServiceDefinitionByKey(String tenantId, ServiceRegistryEngineConfiguration serviceEngineConfiguration)
protected ServiceDefinitionEntity resolveServiceDefinitionByReferenceKey(String tenantId, ServiceDefinitionEntityManager serviceDefinitionEntityManager, CommandContext commandContext)
protected ServiceDefinitionModel getServiceDefinitionModel(ServiceDefinitionEntity serviceDefinition, CommandContext commandContext)
protected ServiceInvoker getServiceInvoker(ServiceDefinitionModel serviceDefinitionModel, CommandContext commandContext)
protected ServiceOperation getServiceOperation(ServiceDefinitionModel serviceDefinitionModel)
protected void validateOperationTypeMatchesRequestedType(ServiceOperation operation, String requestedOperationType)
protected T invokeService(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvoker serviceInvoker, ServiceInvocationContextImpl context, CommandContext commandContext)
protected abstract T invoke(ServiceInvoker serviceInvoker, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContextImpl context, CommandContext commandContext)
protected ServiceInvocationResultResponse handleServiceInvocationResponse(ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvoker serviceInvoker, ServiceInvocationContextImpl context, ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper, ServiceInvocationResponse invocationResponse)
protected ServiceInvocationResult convertToServiceInvocationResult(ServiceInvocationResponse invocationResponse, ServiceInvocationResultResponse result)
protected Map<String,Object> handleOutputParameterValues(Object invocationResponse, ServiceDefinitionModel serviceDefinitionModel, ServiceOperation serviceOperation, ServiceInvocationContext context, ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
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)protected Object getDefaultValue(ServiceOutputParameter outputParameter, String defaultValue, ServiceInvocationContext context, ExpressionManager expressionManager, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
protected InvokeServiceCmd.ValueWrapper extractValue(com.fasterxml.jackson.databind.node.ObjectNode objectNode, ServiceOutputParameter outputParameter)
protected InvokeServiceCmd.ValueWrapper extractValue(Map<String,Object> responseMap, ServiceOutputParameter outputParameter)
protected InvokeServiceCmd.ValueWrapper extractValue(Object invocationResponse, ServiceOutputParameter outputParameter)
protected Object getLookupId(ServiceDefinitionModel serviceDefinitionModel, ServiceInvocationResponse invocationResponse, Map<String,Object> resultMap, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
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