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 Details

  • Constructor Details

  • Method Details

    • execute

      public ServiceInvocationResponse execute​(org.flowable.common.engine.impl.interceptor.CommandContext commandContext)
      Specified by:
      execute in interface org.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 on
      serviceOperation - the service operation representing the service to be invoked
      objectMapper - the object mapper used for creating and initializing variable values in JSON
      expressionManager - 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 on
      inputParameter - the input parameter to be processed
      serviceInvocationInputData - the service invocation input data map to be validated and completed for the given parameter
      objectMapper - the object mapper used for creating and initializing variable values in JSON
      expressionManager - 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 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 invoker
      serviceDefinitionModel - the service model
      serviceOperation - the operation which was invoked
      context - the context within which the service was invoked
      expressionManager - the expression manager used to resolve default value expressions
      objectMapper - 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 from
      invocationResponse - the invocation response containing the lookup id field and its value
      Returns:
      the lookup id value, if available, null otherwise