Class AbstractCartStatusChangeHandler
- All Implemented Interfaces:
CartStatusHandler
- Direct Known Subclasses:
AbstractAccountCartStatusHandler,AbstractQuoteCartStatusHandler
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractCartStatusChangeHandler(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCartActionAuditUserInfo(com.broadleafcommerce.cart.client.domain.CartActionAudit cartActionAudit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hook point to populate fields related to user info in theCartActionAudit.protected com.broadleafcommerce.cart.client.domain.CartActionAuditbuildCartActionAuditToCreate(ChangeCartStatusRequest changeStatusRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aCartActionAuditbased on the given fields.protected booleancanBeReadByUser(@NonNull CartStatusValidationRequest statusValidationRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the cart can be read by the currently authenticated user when the cart's current status isgetStatusToHandle().protected booleancanBeTransitionedToByUser(@NonNull ChangeCartStatusRequest changeStatusRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the cart can be transitioned togetStatusToHandle()by the currently authenticated user.protected booleancanBeUpdatedByUser(@NonNull CartStatusValidationRequest statusValidationRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the cart can be updated by the currently authenticated user when the cart's current status isgetStatusToHandle().booleancanHandle(ChangeCartStatusRequest changeStatusRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if this handler can handle the status change.protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtilsprotected StringgetCartActionType(ChangeCartStatusRequest changeCartStatusRequest) Hook point to determine the cart action type.protected com.broadleafcommerce.data.tracking.core.policy.trackable.TrackablePolicyUtilsprotected abstract StringGets the status to handle by this handlerprotected com.broadleafcommerce.common.extension.TypeFactorygetValidOriginatingStatuses(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets a set of valid originating statuses that can transition to thegetStatusToHandle().protected booleanisCartOwner(@NonNull CartStatusValidationRequest statusValidationRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the givenCustomerRefis the owner of the givenCart.protected booleanisCartOwner(@NonNull ChangeCartStatusRequest changeStatusRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the givenCustomerRefis the owner of the givenCart.protected ChangeCartStatusRequestpostProcessStatusChange(@NonNull ChangeCartStatusRequest changeStatusRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Perform any additional handling after theCarthas changed status.process(@NonNull ChangeCartStatusRequest changeStatusRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Processes the cart status change if it is valid.protected ChangeCartStatusRequestprocessStatusChange(@NonNull ChangeCartStatusRequest changeStatusRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Perform the status change of theCart.voidsetPolicyUtils(com.broadleafcommerce.data.tracking.core.policy.trackable.TrackablePolicyUtils policyUtils) protected voidvalidateOriginatingStatus(@NonNull ChangeCartStatusRequest changeStatusRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates the originating status.voidvalidateStatusIsReadableByUser(@NonNull CartStatusValidationRequest statusValidationRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the status is readable by the currently authenticated user.voidvalidateStatusIsUpdatableByUser(@NonNull CartStatusValidationRequest statusValidationRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the status is updatable by the currently authenticated user.voidvalidateStatusTransition(@NonNull ChangeCartStatusRequest changeStatusRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates that the status that theCartis transitioning to is a valid next status.protected voidvalidateTransitionRules(@NonNull ChangeCartStatusRequest changeStatusRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Evaluates the givenCartand next status again any transition rules in place.
-
Field Details
-
USER_AUTHENTICATION_FAILED
- See Also:
-
INACCESSIBLE_CART_STATUS
- See Also:
-
-
Constructor Details
-
AbstractCartStatusChangeHandler
public AbstractCartStatusChangeHandler(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
getStatusToHandle
Gets the status to handle by this handler- Returns:
- the status to handle by this handler
-
getValidOriginatingStatuses
protected abstract Set<String> getValidOriginatingStatuses(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets a set of valid originating statuses that can transition to thegetStatusToHandle().The valid originating statuses may vary depending on the context and
certain quote configurations.- Parameters:
contextInfo- the contextInfo for the request- Returns:
- a set of valid originating statuses that can transition to the
getStatusToHandle()
-
canHandle
public boolean canHandle(ChangeCartStatusRequest changeStatusRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartStatusHandlerDetermines if this handler can handle the status change.- Specified by:
canHandlein interfaceCartStatusHandler- Parameters:
changeStatusRequest- theChangeCartStatusRequestto facilitate the cart status changecontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- true if this handler can handle the status change, otherwise false
-
process
public ChangeCartStatusRequest process(@NonNull @NonNull ChangeCartStatusRequest changeStatusRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartStatusHandlerProcesses the cart status change if it is valid.- Specified by:
processin interfaceCartStatusHandler- Parameters:
changeStatusRequest- theChangeCartStatusRequestto facilitate the cart status changecontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- the
ChangeCartStatusRequestwith the updatedCartand other fields.
-
validateStatusTransition
public void validateStatusTransition(@NonNull @NonNull ChangeCartStatusRequest changeStatusRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartStatusHandlerValidates that the status that theCartis transitioning to is a valid next status.- Specified by:
validateStatusTransitionin interfaceCartStatusHandler- Parameters:
changeStatusRequest- theChangeCartStatusRequestto facilitate the cart status changecontextInfo- context information surrounding sandboxing and multitenant state
-
validateStatusIsReadableByUser
public void validateStatusIsReadableByUser(@NonNull @NonNull CartStatusValidationRequest statusValidationRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartStatusHandlerDetermines if the status is readable by the currently authenticated user.For example, a sales rep should not be able to read quotes in the
DefaultQuoteStatuses.DRAFTINGstatus.- Specified by:
validateStatusIsReadableByUserin interfaceCartStatusHandler- Parameters:
statusValidationRequest- theCartStatusValidationRequestto facilitate the cart status validationcontextInfo- context information surrounding sandboxing and multitenant state
-
validateStatusIsUpdatableByUser
public void validateStatusIsUpdatableByUser(@NonNull @NonNull CartStatusValidationRequest statusValidationRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartStatusHandlerDetermines if the status is updatable by the currently authenticated user.For example, a customer should not be able to update quotes in the
DefaultQuoteStatuses.ASSIGNEDstatus.- Specified by:
validateStatusIsUpdatableByUserin interfaceCartStatusHandler- Parameters:
statusValidationRequest- theCartStatusValidationRequestto facilitate the cart status validationcontextInfo- context information surrounding sandboxing and multitenant state
-
isCartOwner
protected boolean isCartOwner(@NonNull @NonNull ChangeCartStatusRequest changeStatusRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the givenCustomerRefis the owner of the givenCart.- Parameters:
changeStatusRequest- theChangeCartStatusRequestto facilitate the cart status changecontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- true if the currently authenticated user is the owner of the
Cart, otherwise false
-
isCartOwner
protected boolean isCartOwner(@NonNull @NonNull CartStatusValidationRequest statusValidationRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the givenCustomerRefis the owner of the givenCart.- Parameters:
statusValidationRequest- theCartStatusValidationRequestto facilitate the cart status validationcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- true if the currently authenticated user is the owner of the
Cart, otherwise false
-
canBeReadByUser
protected boolean canBeReadByUser(@NonNull @NonNull CartStatusValidationRequest statusValidationRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the cart can be read by the currently authenticated user when the cart's current status isgetStatusToHandle().This is helpful to restrict certain user types to read a cart in certain statuses.
For example, in a B2B quote context, a sales rep should not be able to read quotes in the
DefaultQuoteStatuses.DRAFTINGstatus, only the cart owner can.- Parameters:
statusValidationRequest- theChangeCartStatusRequestto facilitate the cart status changecontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- true if it is readable by the user, otherwise false
-
canBeUpdatedByUser
protected boolean canBeUpdatedByUser(@NonNull @NonNull CartStatusValidationRequest statusValidationRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the cart can be updated by the currently authenticated user when the cart's current status isgetStatusToHandle().This is helpful to restrict certain user types to update a cart in certain statuses.
For example, in a B2B quote context, only the cart owner should be able to update quotes in the
DefaultQuoteStatuses.DRAFTINGstatus.- Parameters:
statusValidationRequest- theCartStatusValidationRequestto facilitate the cart status validationcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- true if it is updatable by the user, otherwise false
-
canBeTransitionedToByUser
protected boolean canBeTransitionedToByUser(@NonNull @NonNull ChangeCartStatusRequest changeStatusRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the cart can be transitioned togetStatusToHandle()by the currently authenticated user.This is helpful to restrict certain user types to update a cart in certain statuses.
For example, in a B2B quote context, only the sales rep can transition a quote from
DefaultQuoteStatuses.ASSIGNEDtoDefaultQuoteStatuses.PUBLISHED.- Parameters:
changeStatusRequest- theChangeCartStatusRequestto facilitate the cart status changecontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- true if it can be transitioned to the status by the user, otherwise false
-
validateOriginatingStatus
protected void validateOriginatingStatus(@NonNull @NonNull ChangeCartStatusRequest changeStatusRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates the originating status.- Parameters:
changeStatusRequest- theChangeCartStatusRequestto facilitate the cart status changecontextInfo- context information surrounding sandboxing and multitenant state- Throws:
InvalidCartStatusTransitionException- if the originating status is invalid
-
validateTransitionRules
protected void validateTransitionRules(@NonNull @NonNull ChangeCartStatusRequest changeStatusRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Evaluates the givenCartand next status again any transition rules in place.By default, this does nothing. This serves as a hook point to add custom transition rules.
- Parameters:
changeStatusRequest- theChangeCartStatusRequestto facilitate the cart status changecontextInfo- context information surrounding sandboxing and multitenant state
-
processStatusChange
protected ChangeCartStatusRequest processStatusChange(@NonNull @NonNull ChangeCartStatusRequest changeStatusRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Perform the status change of theCart.By default, this updates the status and creates a corresponding
CartActionAudit. This serves as a hook point for additional steps for the status change.- Parameters:
changeStatusRequest- theChangeCartStatusRequestto facilitate the cart status changecontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- the
ChangeCartStatusRequestwith the updated cart
-
buildCartActionAuditToCreate
protected com.broadleafcommerce.cart.client.domain.CartActionAudit buildCartActionAuditToCreate(ChangeCartStatusRequest changeStatusRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aCartActionAuditbased on the given fields.- Parameters:
changeStatusRequest- theChangeCartStatusRequestto facilitate the audit hydrationcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- the resulting cart action audit
-
getCartActionType
Hook point to determine the cart action type.Returns
DefaultQuoteActionTypes.UNKNOWNby default unless overridden.- Parameters:
changeCartStatusRequest- the change cart status request- Returns:
DefaultQuoteActionTypes.UNKNOWNby default unless overridden.
-
addCartActionAuditUserInfo
protected void addCartActionAuditUserInfo(com.broadleafcommerce.cart.client.domain.CartActionAudit cartActionAudit, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hook point to populate fields related to user info in theCartActionAudit.- Parameters:
cartActionAudit- the cart action auditcontextInfo- context information surrounding sandboxing and multitenant state
-
postProcessStatusChange
protected ChangeCartStatusRequest postProcessStatusChange(@NonNull @NonNull ChangeCartStatusRequest changeStatusRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Perform any additional handling after theCarthas changed status.By default, this does nothing. This serves as a hook point for customization.
- Parameters:
changeStatusRequest- theChangeCartStatusRequestto facilitate the cart status changecontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- the change status request after performing any additional handling.
-
getAuthenticationUtils
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getPolicyUtils
@Nullable protected com.broadleafcommerce.data.tracking.core.policy.trackable.TrackablePolicyUtils getPolicyUtils() -
setPolicyUtils
@Autowired(required=false) public void setPolicyUtils(com.broadleafcommerce.data.tracking.core.policy.trackable.TrackablePolicyUtils policyUtils)
-