Class DefaultCheckoutWorkflow
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.checkout.workflow.DefaultCheckoutWorkflow
-
- All Implemented Interfaces:
CheckoutWorkflow
public class DefaultCheckoutWorkflow extends Object implements CheckoutWorkflow
- Author:
- Chris Kittrell (ckittrell)
-
-
Field Summary
Fields Modifier and Type Field Description static String
CHECKOUT_WORKFLOW_ERRORS
static String
CHECKOUT_WORKFLOW_ROLLBACK_ERRORS
-
Constructor Summary
Constructors Constructor Description DefaultCheckoutWorkflow(List<CheckoutWorkflowActivity> workflowActivities, CheckoutRollbackEventProducer checkoutRollbackEventProducer, CartProvider cartProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.context.MessageSource messageSource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.broadleafcommerce.cart.client.domain.Cart
execute(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull Map<String,String> paymentLockTokens, @NonNull Map<String,String> securityCodes, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Method used to coordinate the execution ofCheckoutWorkflowActivities
.protected com.broadleafcommerce.cart.client.domain.Cart
executeActivity(@NonNull CheckoutWorkflowActivity activity, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull Map<String,String> paymentLockTokens, @NonNull Map<String,String> securityCodes, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected CartProvider
getCartProvider()
protected CheckoutRollbackEventProducer
getCheckoutRollbackEventProducer()
protected org.springframework.retry.support.RetryTemplate
getMessageRetryTemplate()
protected org.springframework.context.MessageSource
getMessageSource()
protected PaymentProvider<PaymentSummary>
getPaymentProvider()
protected com.broadleafcommerce.common.extension.TypeFactory
getTypeFactory()
protected List<CheckoutWorkflowActivity>
getWorkflowActivities()
protected void
logErrorInitiatingWorkflowRollback(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull CheckoutWorkflowActivityException e)
protected void
logErrorInitiatingWorkflowRollback(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, Exception e)
Log a message to record the initiation of the workflow rollbackprotected com.broadleafcommerce.cart.client.domain.Cart
recordRollbackError(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull Exception e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Method responsible for recording the error that was encountered during the activity's rollback.protected com.broadleafcommerce.cart.client.domain.Cart
recordWorkflowError(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull CheckoutWorkflowActivityException e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Method responsible for recording the error that was encountered during the activity's execution.com.broadleafcommerce.cart.client.domain.Cart
rollback(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Method used to coordinate the rollback of work that has been done by theCheckoutWorkflowActivities
up to that point.protected void
sendCheckoutRollbackEvent(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Send a message to notify external services (and internal listeners) of the checkout workflow rollback, so that they can react accordingly.void
setMessageRetryTemplate(org.springframework.retry.support.RetryTemplate messageRetryTemplate)
void
setPaymentProvider(PaymentProvider<PaymentSummary> paymentProvider)
protected void
unlockPayments(@NonNull Map<String,String> paymentLockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
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.checkout.workflow.CheckoutWorkflow
execute
-
-
-
-
Field Detail
-
CHECKOUT_WORKFLOW_ERRORS
public static final String CHECKOUT_WORKFLOW_ERRORS
- See Also:
- Constant Field Values
-
CHECKOUT_WORKFLOW_ROLLBACK_ERRORS
public static final String CHECKOUT_WORKFLOW_ROLLBACK_ERRORS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultCheckoutWorkflow
public DefaultCheckoutWorkflow(List<CheckoutWorkflowActivity> workflowActivities, CheckoutRollbackEventProducer checkoutRollbackEventProducer, CartProvider cartProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.context.MessageSource messageSource)
-
-
Method Detail
-
execute
public com.broadleafcommerce.cart.client.domain.Cart execute(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @NonNull @NonNull Map<String,String> paymentLockTokens, @NonNull @NonNull Map<String,String> securityCodes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CheckoutWorkflow
Method used to coordinate the execution ofCheckoutWorkflowActivities
. If there is an exception/error during the execution of those activities, thenCheckoutWorkflow.rollback(Cart, String, ContextInfo)
should be called to un-do the work that had been done up to the point of the exception/error.- Specified by:
execute
in interfaceCheckoutWorkflow
- Parameters:
cart
- TheCart
that we're attempting to checkout with.requestId
- The id used to identify changes tied to the specific execution requestpaymentLockTokens
- Tokens that grant this service access to act upon the payment. The presence of these tokens indicates that this execution flow owns the lock.securityCodes
- The map of card security codes keyed by payment id for processing saved paymentscontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The final state of the cart following the execution of the workflow.
-
unlockPayments
protected void unlockPayments(@NonNull @NonNull Map<String,String> paymentLockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
rollback
public com.broadleafcommerce.cart.client.domain.Cart rollback(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CheckoutWorkflow
Method used to coordinate the rollback of work that has been done by theCheckoutWorkflowActivities
up to that point.- Specified by:
rollback
in interfaceCheckoutWorkflow
- Parameters:
cart
- TheCart
that we were attempting to checkout with, but ran into an exception/error.requestId
- The id used to identify changes tied to the specific execution requestcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The final state of the cart following the execution of the workflow rollback.
-
logErrorInitiatingWorkflowRollback
protected void logErrorInitiatingWorkflowRollback(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, Exception e)
Log a message to record the initiation of the workflow rollback- Parameters:
cart
- The cart that is being acted upon in this workflowrequestId
- The id used to identify changes tied to the specific execution requeste
- The exception thrown by theCheckoutWorkflowActivity
-
executeActivity
protected com.broadleafcommerce.cart.client.domain.Cart executeActivity(@NonNull @NonNull CheckoutWorkflowActivity activity, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @NonNull @NonNull Map<String,String> paymentLockTokens, @NonNull @NonNull Map<String,String> securityCodes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
logErrorInitiatingWorkflowRollback
protected void logErrorInitiatingWorkflowRollback(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @NonNull @NonNull CheckoutWorkflowActivityException e)
-
sendCheckoutRollbackEvent
protected void sendCheckoutRollbackEvent(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Send a message to notify external services (and internal listeners) of the checkout workflow rollback, so that they can react accordingly.- Parameters:
cart
- The cart that is being evaluated for checkout.requestId
- The checkout request idcontextInfo
- Context information around sandbox and multitenant state.
-
recordWorkflowError
protected com.broadleafcommerce.cart.client.domain.Cart recordWorkflowError(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @NonNull @NonNull CheckoutWorkflowActivityException e, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Method responsible for recording the error that was encountered during the activity's execution.- Parameters:
cart
- The cart that is being acted upon in this workflowrequestId
- The id used to identify changes tied to the specific execution requeste
- The exception thrown by theCheckoutWorkflowActivity
contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The cart including the recorded activity execution state
-
recordRollbackError
protected com.broadleafcommerce.cart.client.domain.Cart recordRollbackError(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @NonNull @NonNull Exception e, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Method responsible for recording the error that was encountered during the activity's rollback.- Parameters:
cart
- The cart that encountered an error during the execution of this activityrequestId
- The id used to identify changes tied to the specific execution requeste
-contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The cart including the recorded activity rollback state
-
getWorkflowActivities
protected List<CheckoutWorkflowActivity> getWorkflowActivities()
-
getCheckoutRollbackEventProducer
protected CheckoutRollbackEventProducer getCheckoutRollbackEventProducer()
-
getCartProvider
protected CartProvider getCartProvider()
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-
getMessageSource
protected org.springframework.context.MessageSource getMessageSource()
-
setPaymentProvider
@Autowired public void setPaymentProvider(PaymentProvider<PaymentSummary> paymentProvider)
-
getPaymentProvider
protected PaymentProvider<PaymentSummary> getPaymentProvider()
-
setMessageRetryTemplate
@Autowired @Qualifier("checkoutWorkflowRollbackMessageRetryTemplate") public void setMessageRetryTemplate(org.springframework.retry.support.RetryTemplate messageRetryTemplate)
-
getMessageRetryTemplate
protected org.springframework.retry.support.RetryTemplate getMessageRetryTemplate()
-
-