Interface TransitionHandler

All Known Implementing Classes:
DefaultTransitionHandler

public interface TransitionHandler
TransitionHandlers are responsible for listening for TransitionConsumers channel events (such as PromotionConsumer) associated with a specific business domain type. Generally, a WorkflowTransitionHelper is employed by concrete implementations to engage the promotion in response to the event consumption here.

Generally, concrete implementations take a form similar to this.

 @EnableBinding(PromotionConsumer.class)
 public class TestTransitionHandler implements TransitionHandler<BusinessItem> {

   private final WorkflowTransitionHelper helper;

   public TestTransitionHandler(TestRepository repository, TrackingBusinessDomainMapper mapper,
          CommonCatalogService catalogService) {
       helper = new WorkflowTransitionHelper(repository, mapper, catalogService);
   }

   @Override
   public void processPromotionRequest(PromotionRequest request) {
       helper.promote(request);
   }

 }
 
DefaultTransitionHandler should be used as a base starting point if no custom requirements are needed. @EnableBinding is a meta annotation containing @Configuration. The implementation may be component scanned or imported by other configurations.
Author:
Jeff Fischer
  • Method Details

    • logger

      default org.apache.commons.logging.Log logger()
    • handle

      default boolean handle(WorkflowPromoteRequest request)
    • handle

      default boolean handle(WorkflowDeployRequest request)
    • handle

      default boolean handle(WorkflowRejectRequest request)
    • handle

      default boolean handle(WorkflowRevertRequest request)
    • handle

      default boolean handle(WorkflowRebaseRequest request)
    • getNarrowedEntity

      default Class<?> getNarrowedEntity()
    • getEntityDomain

      default Optional<Class<?>> getEntityDomain()
      The entity domain to use if the inheriting class's generic P is the interface ContextStateAware.
      Returns:
      The business domain to use if the inheriting class's generic P is the interface ContextStateAware.
    • canHandle

      default boolean canHandle(TransitionRequest request)
    • isRequestedEntityWhitelistedForTransition

      default boolean isRequestedEntityWhitelistedForTransition(TransitionRequest request)
      Examines whether the provided TransitionRequest.getEntity() is whitelisted for transition operations by this handler.

      This is most important for security purposes since the entity class will be dynamically loaded. Only allowing instantiation of whitelisted types protects against injection of malicious code.

      Parameters:
      request - the TransitionRequest whose TransitionRequest.getEntity() should be checked
      Returns:
      true if the entity is whitelisted, false otherwise
    • canHandleDynamically

      default boolean canHandleDynamically(Class<?> entityType, Class<?> requestType)
      If the inheriting class's generic P is ContextStateAware, then check can handle against a dynamically defined getEntityDomain().
      Parameters:
      entityType - The entity type of the incoming TransitionRequest
      requestType - The type of the incoming TransitionRequest
      Returns:
      Whether the incoming TransitionRequest can be handled dynamically
    • processPromotionRequest

      void processPromotionRequest(WorkflowPromoteRequest request)
      Handle the WorkflowPromoteRequest that has been deemed appropriate for this handler based on comparing the WorkflowTransitionRequest.getEntity() against the generic type of the handler implementation.
      Parameters:
      request - The request for a Trackable entity promotion
    • processDeploymentRequest

      void processDeploymentRequest(WorkflowDeployRequest request)
      Handle the WorkflowDeployRequest that has been deemed appropriate for this handler based on comparing the WorkflowTransitionRequest.getEntity() against the generic type of the handler implementation.
      Parameters:
      request - The request for a Trackable entity deployment
    • processRejectionRequest

      void processRejectionRequest(WorkflowRejectRequest request)
      Handle the WorkflowRejectRequest that has been deemed appropriate for this handler based on comparing the WorkflowTransitionRequest.getEntity() against the generic type of the handler implementation.
      Parameters:
      request - The request for a Trackable entity rejection
    • processReversionRequest

      void processReversionRequest(WorkflowRevertRequest request)
      Handle the WorkflowRevertRequest that has been deemed appropriate for this handler based on comparing the WorkflowTransitionRequest.getEntity() against the generic type of the handler implementation.
      Parameters:
      request - The request for a Trackable entity reversion
    • processRebasingRequest

      void processRebasingRequest(WorkflowRebaseRequest request)
      Handle the WorkflowRebaseRequest that has been deemed appropriate for this handler based on comparing the WorkflowTransitionRequest.getEntity() against the generic type of the handler implementation.
      Parameters:
      request - The request for a Trackable entity rebase
    • validate

      default void validate(com.broadleafcommerce.common.messaging.Securable request)
      Verify the signed JWT token and validate the user claims (especially authorities) against the consumption functionality. Generally, throw an IllegalArgumentException if the claims made in the JWT are deemed incorrect or inappropriate for the desired task.
      Parameters:
      request - Message instance capable of supplying a signed JWT token