Class DefaultCartApprovalValidationService
java.lang.Object
com.broadleafcommerce.cartoperation.service.approval.DefaultCartApprovalValidationService
- All Implemented Interfaces:
CartApprovalValidationService
public class DefaultCartApprovalValidationService
extends Object
implements CartApprovalValidationService
The default implementation of
CartApprovalValidationService
.-
Constructor Summary
ConstructorDescriptionDefaultCartApprovalValidationService
(org.springframework.context.MessageSource messageSource) -
Method Summary
Modifier and TypeMethodDescriptionprotected String[]
Retrieves the permissions that a user should have to perform cart approver-specific actions, such as submitting cart or rejecting cart.protected String
getMessage
(@NonNull String errorMessage, Object... args) protected org.springframework.context.MessageSource
protected com.broadleafcommerce.data.tracking.core.policy.trackable.TrackablePolicyUtils
Retrieve the list of statuses which are considered valid to request cart approval.Retrieve the list of statuses which are considered valid to reject a cart.void
setPolicyUtils
(com.broadleafcommerce.data.tracking.core.policy.trackable.TrackablePolicyUtils policyUtils) protected void
validateCartStatusForRejection
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Validates that the cart is in a validCart.getStatus()
for rejectionprotected void
validateCartStatusForRequestApproval
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Validates that the cart is in a validCart.getStatus()
for requesting approval.void
validateRequestForRejection
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @NonNull CartApprovalProcessRequest cartApprovalProcessRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Method that calls all validators performing checks on conditions necessary for a cart to be rejected.void
validateSubmitForApproval
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @NonNull CartApprovalProcessRequest cartApprovalProcessRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Method that calls all validators performing checks on conditions necessary for a cart to be submitted for approval.void
validateUserIsCartReviewer
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.order.common.domain.CustomerRef customerRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates that the user has the correct access to reject or submit the givenCart
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.cartoperation.service.approval.CartApprovalValidationService
validateCartSubmission
-
Constructor Details
-
DefaultCartApprovalValidationService
public DefaultCartApprovalValidationService(org.springframework.context.MessageSource messageSource)
-
-
Method Details
-
validateSubmitForApproval
public void validateSubmitForApproval(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @NonNull @NonNull CartApprovalProcessRequest cartApprovalProcessRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartApprovalValidationService
Method that calls all validators performing checks on conditions necessary for a cart to be submitted for approval.- Specified by:
validateSubmitForApproval
in interfaceCartApprovalValidationService
- Parameters:
cart
- TheCart
that is being submitted for approval.customer
- TheCustomerRef
of the user who is submitting the cart for approval.cartApprovalProcessRequest
- theCartApprovalProcessRequest
passed in byCartApprovalService
contextInfo
- context information around sandbox and multitenant state.
-
validateRequestForRejection
public void validateRequestForRejection(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @NonNull @NonNull CartApprovalProcessRequest cartApprovalProcessRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartApprovalValidationService
Method that calls all validators performing checks on conditions necessary for a cart to be rejected.- Specified by:
validateRequestForRejection
in interfaceCartApprovalValidationService
- Parameters:
cart
- TheCart
that is rejected.customer
- TheCustomerRef
of the user who is rejecting the cart.cartApprovalProcessRequest
- theCartApprovalProcessRequest
passed in byCartApprovalService
contextInfo
- context information around sandbox and multitenant state
-
validateUserIsCartReviewer
public void validateUserIsCartReviewer(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartApprovalValidationService
Validates that the user has the correct access to reject or submit the givenCart
.- Specified by:
validateUserIsCartReviewer
in interfaceCartApprovalValidationService
- Parameters:
cart
- theCart
that the user is attempting to accesscustomerRef
- theCustomerRef
representing the user to validate againstcontextInfo
- context information around sandbox and multitenant state
-
validateCartStatusForRequestApproval
protected void validateCartStatusForRequestApproval(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Validates that the cart is in a validCart.getStatus()
for requesting approval.- Parameters:
cart
- TheCart
that's being submitted for approval.- Throws:
CartApprovalValidationException
- if the cart status is not valid to request approval.
-
validateCartStatusForRejection
protected void validateCartStatusForRejection(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Validates that the cart is in a validCart.getStatus()
for rejection- Parameters:
cart
- TheCart
that's being rejected- Throws:
CartApprovalValidationException
- if the cart status is not valid to request approval.
-
getValidRequestApprovalStatuses
Retrieve the list of statuses which are considered valid to request cart approval.Custom valid statuses to request cart for approval should be added here.
- Returns:
- the list of statuses which are considered valid to request cart approval
-
getValidRequestRejectionStatuses
Retrieve the list of statuses which are considered valid to reject a cart.Custom valid statuses to reject a cart should be added here.
- Returns:
- the list of statuses which are considered valid to reject a cart
-
getCartApproverPermissions
Retrieves the permissions that a user should have to perform cart approver-specific actions, such as submitting cart or rejecting cart.Custom cart approver permissions should be added here.
- Returns:
- the permissions that a user should have to perform cart approver-specific actions
-
getMessage
-
getMessageSource
protected org.springframework.context.MessageSource getMessageSource() -
getPolicyUtils
@Nullable protected com.broadleafcommerce.data.tracking.core.policy.trackable.TrackablePolicyUtils getPolicyUtils() -
setPolicyUtils
@Autowired(required=false) public void setPolicyUtils(@Nullable com.broadleafcommerce.data.tracking.core.policy.trackable.TrackablePolicyUtils policyUtils)
-