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 Summary
Modifier and TypeMethodDescriptiondefault boolean
canHandle
(TransitionRequest request) default boolean
canHandleDynamically
(Class<?> entityType, Class<?> requestType) If the inheriting class's generic P isContextStateAware
, then check can handle against a dynamically definedgetEntityDomain()
.The entity domain to use if the inheriting class's generic P is the interfaceContextStateAware
.default Class<?>
default boolean
handle
(WorkflowDeployRequest request) default boolean
handle
(WorkflowPromoteRequest request) default boolean
handle
(WorkflowRebaseRequest request) default boolean
handle
(WorkflowRejectRequest request) default boolean
handle
(WorkflowRevertRequest request) default boolean
Examines whether the providedTransitionRequest.getEntity()
is whitelisted for transition operations by this handler.default org.apache.commons.logging.Log
logger()
void
Handle the WorkflowDeployRequest that has been deemed appropriate for this handler based on comparing theWorkflowTransitionRequest.getEntity()
against the generic type of the handler implementation.void
Handle the WorkflowPromoteRequest that has been deemed appropriate for this handler based on comparing theWorkflowTransitionRequest.getEntity()
against the generic type of the handler implementation.void
Handle the WorkflowRebaseRequest that has been deemed appropriate for this handler based on comparing theWorkflowTransitionRequest.getEntity()
against the generic type of the handler implementation.void
Handle the WorkflowRejectRequest that has been deemed appropriate for this handler based on comparing theWorkflowTransitionRequest.getEntity()
against the generic type of the handler implementation.void
Handle the WorkflowRevertRequest that has been deemed appropriate for this handler based on comparing theWorkflowTransitionRequest.getEntity()
against the generic type of the handler implementation.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.
-
Method Details
-
logger
default org.apache.commons.logging.Log logger() -
handle
-
handle
-
handle
-
handle
-
handle
-
getNarrowedEntity
-
getEntityDomain
The entity domain to use if the inheriting class's generic P is the interfaceContextStateAware
.- Returns:
- The business domain to use if the inheriting class's generic P is the interface
ContextStateAware
.
-
canHandle
-
isRequestedEntityWhitelistedForTransition
Examines whether the providedTransitionRequest.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
- theTransitionRequest
whoseTransitionRequest.getEntity()
should be checked- Returns:
true
if the entity is whitelisted,false
otherwise
-
canHandleDynamically
If the inheriting class's generic P isContextStateAware
, then check can handle against a dynamically definedgetEntityDomain()
.- Parameters:
entityType
- The entity type of the incomingTransitionRequest
requestType
- The type of the incomingTransitionRequest
- Returns:
- Whether the incoming
TransitionRequest
can be handled dynamically
-
processPromotionRequest
Handle the WorkflowPromoteRequest that has been deemed appropriate for this handler based on comparing theWorkflowTransitionRequest.getEntity()
against the generic type of the handler implementation.- Parameters:
request
- The request for aTrackable
entity promotion
-
processDeploymentRequest
Handle the WorkflowDeployRequest that has been deemed appropriate for this handler based on comparing theWorkflowTransitionRequest.getEntity()
against the generic type of the handler implementation.- Parameters:
request
- The request for aTrackable
entity deployment
-
processRejectionRequest
Handle the WorkflowRejectRequest that has been deemed appropriate for this handler based on comparing theWorkflowTransitionRequest.getEntity()
against the generic type of the handler implementation.- Parameters:
request
- The request for aTrackable
entity rejection
-
processReversionRequest
Handle the WorkflowRevertRequest that has been deemed appropriate for this handler based on comparing theWorkflowTransitionRequest.getEntity()
against the generic type of the handler implementation.- Parameters:
request
- The request for aTrackable
entity reversion
-
processRebasingRequest
Handle the WorkflowRebaseRequest that has been deemed appropriate for this handler based on comparing theWorkflowTransitionRequest.getEntity()
against the generic type of the handler implementation.- Parameters:
request
- The request for aTrackable
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 anIllegalArgumentException
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
-