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 StringCHECKOUT_WORKFLOW_ERRORSstatic StringCHECKOUT_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.Cartexecute(@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.CartexecuteActivity(@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 CartProvidergetCartProvider()protected CheckoutRollbackEventProducergetCheckoutRollbackEventProducer()protected org.springframework.context.MessageSourcegetMessageSource()protected com.broadleafcommerce.common.extension.TypeFactorygetTypeFactory()protected List<CheckoutWorkflowActivity>getWorkflowActivities()protected voidlogErrorInitiatingWorkflowRollback(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull CheckoutWorkflowActivityException e)protected voidlogErrorInitiatingWorkflowRollback(@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.CartrecordRollbackError(@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.CartrecordWorkflowError(@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.Cartrollback(@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 theCheckoutWorkflowActivitiesup to that point.-
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:CheckoutWorkflowMethod 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:
executein interfaceCheckoutWorkflow- Parameters:
cart- TheCartthat 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.
-
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:CheckoutWorkflowMethod used to coordinate the rollback of work that has been done by theCheckoutWorkflowActivitiesup to that point.- Specified by:
rollbackin interfaceCheckoutWorkflow- Parameters:
cart- TheCartthat 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)
-
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 theCheckoutWorkflowActivitycontextInfo- 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()
-
-