Class DefaultCartNotificationService
java.lang.Object
com.broadleafcommerce.cart.service.messaging.DefaultCartNotificationService
- All Implemented Interfaces:
CartNotificationService
Default implementation for
CartNotificationService.- Author:
- Dima Myroniuk (dmyroniuk)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final StringThe key to theJpaCart.getInternalAttributes()containing checkout workflow errors -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCartNotificationService(CartRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.common.messaging.notification.NotificationStateService notificationStateService, com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager, CartNotificationRepository cartNotificationRepository, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringconvertCartRejectionEventToJson(@NonNull CartRejectionEvent event) protected StringA hook point to determine the message producer type based on the givenQuoteStatusChangedEvent.protected StringdetermineQuoteStatusChangeEventProducerType(@NonNull QuoteStatusChangedEvent event) Determines the message producer type based on the cart status and action type inQuoteStatusChangedEvent.protected CartNotificationRepositoryprotected com.broadleafcommerce.common.messaging.notification.DetachedDurableMessageSenderprotected com.broadleafcommerce.common.messaging.notification.MessageSerializationHelperprotected com.broadleafcommerce.common.messaging.notification.NotificationManagerprotected com.broadleafcommerce.common.messaging.notification.NotificationStateServiceprotected com.fasterxml.jackson.databind.ObjectMapperprotected com.broadleafcommerce.cart.client.properties.QuotePropertiesprotected CartRepository<com.broadleafcommerce.data.tracking.core.Trackable>protected com.broadleafcommerce.common.extension.TypeFactoryvoidsendCartApprovalRequestEvent(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.CartActionAudit audit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends cart approval requested event.voidsendCartApprovalRequestEvent(@NonNull CartApprovalRequestEvent event, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends cart approval request event.voidsendCartAwaitingPaymentResultsEvent(@NonNull CartAwaitingPaymentResultsEvent event, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends cart awaiting payment results event.voidsendCartPendingPaymentFailedEventUri(@NonNull CartPendingPaymentFailedEvent event, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends cart pending payment failed event.voidsendCartRejectionEvent(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.CartActionAudit audit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends cart rejection event.voidsendCartRejectionEvent(@NonNull CartRejectionEvent event, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends cart rejection event.voidsendCheckoutCompletionEvent(@NonNull CheckoutCompletionEvent event, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends checkout completion event.protected voidsendEvent(com.broadleafcommerce.data.tracking.core.Trackable cart, String messageJson, String messageName, String messageType) voidsendExternalPaymentTransactionCartFinalizationEvent(@NonNull ExternalPaymentTransactionCartFinalizationEvent event, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidsendQuoteStatusChangedEvent(@NonNull QuoteStatusChangedEvent event, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends the givenQuoteStatusChangedEvent.voidsendQuoteStatusUpdatedEvent(@NonNull com.broadleafcommerce.cart.client.domain.Cart quote, @NonNull com.broadleafcommerce.cart.client.domain.CartActionAudit audit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends quote status updated event.voidsendRollbackEvent(@NonNull CheckoutRollbackEvent event, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends rollback event to process the error during checkout.voidsetDurableMessageSender(com.broadleafcommerce.common.messaging.notification.DetachedDurableMessageSender durableMessageSender) voidsetHelper(com.broadleafcommerce.common.messaging.notification.MessageSerializationHelper helper) voidsetQuoteProperties(com.broadleafcommerce.cart.client.properties.QuoteProperties quoteProperties) voidsetTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory) protected voidvalidateCartApprovalRequestEvent(@NonNull CartApprovalRequestEvent event) protected voidvalidateCartAwaitingPaymentResults(@NonNull JpaCart cart) protected voidprotected voidvalidateCartFields(@NonNull com.broadleafcommerce.data.tracking.core.Trackable cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hook point to validate the given cart's fields.protected voidvalidateCartHasPendingPaymentFailedStatus(@NonNull JpaCart cart) protected voidvalidateCartHasWorkflowErrorForRequestId(@NonNull com.broadleafcommerce.data.tracking.core.Trackable cart, @NonNull String requestId) Validates if the checkout rollback event can be resent for the given cart.protected voidvalidateCartIsAwaitingPaymentResultWithRequestId(@NonNull com.broadleafcommerce.data.tracking.core.Trackable cart, @NonNull String requestId) Validates if the cart has a request id related to a checkout attempt that resulted in the awaiting payment result cart status.protected voidvalidateCartIsRejected(@NonNull com.broadleafcommerce.data.tracking.core.Trackable cart) protected voidvalidateCartIsSubmitted(@NonNull com.broadleafcommerce.data.tracking.core.Trackable cart) protected voidvalidateCartPendingPaymentFailedEvent(@NonNull CartPendingPaymentFailedEvent event) protected voidvalidateCartRejectionEvent(@NonNull CartRejectionEvent event) protected voidvalidateCartRequiresApproval(@NonNull com.broadleafcommerce.data.tracking.core.Trackable cart) protected voidvalidateCheckoutCompletionEvent(@NonNull CheckoutCompletionEvent event) protected voidvalidateCheckoutRollbackEvent(@NonNull CheckoutRollbackEvent event) protected voidvalidateExternalPaymentTransactionCartFinalizationEvent(@NonNull ExternalPaymentTransactionCartFinalizationEvent event, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidvalidateQuoteStatusChangedEvent(@NonNull QuoteStatusChangedEvent event) protected voidvalidateQuoteStatusMatchesEventAudit(@NonNull com.broadleafcommerce.data.tracking.core.Trackable quote, @NonNull QuoteStatusChangedEvent event)
-
Field Details
-
CHECKOUT_WORKFLOW_ERRORS
The key to theJpaCart.getInternalAttributes()containing checkout workflow errors- See Also:
-
AWAITING_PAYMENT_RESULT_REQUEST_ID
- See Also:
-
CART_ID_REQUIRED
- See Also:
-
-
Constructor Details
-
DefaultCartNotificationService
public DefaultCartNotificationService(CartRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.common.messaging.notification.NotificationStateService notificationStateService, com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager, CartNotificationRepository cartNotificationRepository, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
sendRollbackEvent
public void sendRollbackEvent(@NonNull @NonNull CheckoutRollbackEvent event, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartNotificationServiceSends rollback event to process the error during checkout. It uses durable sending to guarantee delivery.- Specified by:
sendRollbackEventin interfaceCartNotificationService- Parameters:
event- the message payloadcontextInfo- context information around sandbox and multitenant state- See Also:
-
sendCheckoutCompletionEvent
public void sendCheckoutCompletionEvent(@NonNull @NonNull CheckoutCompletionEvent event, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartNotificationServiceSends checkout completion event. It uses durable sending to guarantee delivery.- Specified by:
sendCheckoutCompletionEventin interfaceCartNotificationService- Parameters:
event- the message payloadcontextInfo- context information around sandbox and multitenant state- See Also:
-
CheckoutCompletionProducer
-
sendExternalPaymentTransactionCartFinalizationEvent
public void sendExternalPaymentTransactionCartFinalizationEvent(@NonNull @NonNull ExternalPaymentTransactionCartFinalizationEvent event, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartNotificationService- Specified by:
sendExternalPaymentTransactionCartFinalizationEventin interfaceCartNotificationService- Parameters:
event- the message payloadcontextInfo- context information around sandbox and multitenant state
-
sendCartRejectionEvent
public void sendCartRejectionEvent(@NonNull @NonNull CartRejectionEvent event, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartNotificationServiceSends cart rejection event. It uses durable sending to guarantee delivery.- Specified by:
sendCartRejectionEventin interfaceCartNotificationService- Parameters:
event- the message payloadcontextInfo- context information around sandbox and multitenant state- See Also:
-
sendCartRejectionEvent
public void sendCartRejectionEvent(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.cart.client.domain.CartActionAudit audit, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartNotificationServiceSends cart rejection event. It uses durable sending to guarantee delivery.- Specified by:
sendCartRejectionEventin interfaceCartNotificationService- Parameters:
cart- The updatedCartaudit- TheCartActionAuditfor the updatecontextInfo- context information around sandbox and multitenant state- See Also:
-
sendCartApprovalRequestEvent
public void sendCartApprovalRequestEvent(@NonNull @NonNull CartApprovalRequestEvent event, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartNotificationServiceSends cart approval request event. It uses durable sending to guarantee delivery.- Specified by:
sendCartApprovalRequestEventin interfaceCartNotificationService- Parameters:
event- the message payloadcontextInfo- context information around sandbox and multitenant state- See Also:
-
sendCartApprovalRequestEvent
public void sendCartApprovalRequestEvent(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.cart.client.domain.CartActionAudit audit, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartNotificationServiceSends cart approval requested event. It uses durable sending to guarantee delivery.- Specified by:
sendCartApprovalRequestEventin interfaceCartNotificationService- Parameters:
cart- The updatedCartaudit- TheCartActionAuditfor the updatecontextInfo- context information around sandbox and multitenant state- See Also:
-
convertCartRejectionEventToJson
-
sendCartPendingPaymentFailedEventUri
public void sendCartPendingPaymentFailedEventUri(@NonNull @NonNull CartPendingPaymentFailedEvent event, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartNotificationServiceSends cart pending payment failed event. It uses durable sending to guarantee delivery.- Specified by:
sendCartPendingPaymentFailedEventUriin interfaceCartNotificationService- Parameters:
event- the message payloadcontextInfo- context information around sandbox and multitenant state- See Also:
-
sendCartAwaitingPaymentResultsEvent
public void sendCartAwaitingPaymentResultsEvent(@NonNull @NonNull CartAwaitingPaymentResultsEvent event, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartNotificationServiceSends cart awaiting payment results event. It uses durable sending to guarantee delivery.- Specified by:
sendCartAwaitingPaymentResultsEventin interfaceCartNotificationService- Parameters:
event- the message payloadcontextInfo- context information around sandbox and multitenant state- See Also:
-
sendQuoteStatusUpdatedEvent
public void sendQuoteStatusUpdatedEvent(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart quote, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartActionAudit audit, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartNotificationServiceSends quote status updated event.- Specified by:
sendQuoteStatusUpdatedEventin interfaceCartNotificationService- Parameters:
quote- the quote to send the notification foraudit- The relatedCartActionAuditcontextInfo- Additional sandbox and multitenant info
-
sendQuoteStatusChangedEvent
protected void sendQuoteStatusChangedEvent(@NonNull @NonNull QuoteStatusChangedEvent event, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends the givenQuoteStatusChangedEvent.- Parameters:
event- theQuoteStatusChangedEventto send outcontextInfo- context information around sandbox and multitenant state
-
determineQuoteStatusChangeEventProducerType
protected String determineQuoteStatusChangeEventProducerType(@NonNull @NonNull QuoteStatusChangedEvent event) Determines the message producer type based on the cart status and action type inQuoteStatusChangedEvent.- Parameters:
event- theQuoteStatusChangedEventcontaining the cart status and action type- Returns:
- the message producer type based on the cart status and action type
-
determineCustomQuoteStatusChangeEventProducerType
protected String determineCustomQuoteStatusChangeEventProducerType(@NonNull @NonNull QuoteStatusChangedEvent event) A hook point to determine the message producer type based on the givenQuoteStatusChangedEvent.- Parameters:
event- theQuoteStatusChangedEventcontaining the cart status and action type- Throws:
UnsupportedOperationException- by default
-
validateCheckoutRollbackEvent
-
validateCartIsAwaitingPaymentResultWithRequestId
protected void validateCartIsAwaitingPaymentResultWithRequestId(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.Trackable cart, @NonNull @NonNull String requestId) Validates if the cart has a request id related to a checkout attempt that resulted in the awaiting payment result cart status.- Parameters:
cart- the cart used to validate if the event can be resentrequestId- the checkout request id
-
validateCartHasWorkflowErrorForRequestId
protected void validateCartHasWorkflowErrorForRequestId(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.Trackable cart, @NonNull @NonNull String requestId) Validates if the checkout rollback event can be resent for the given cart.- Parameters:
cart- the cart used to validate if the event can be resentrequestId- the checkout request id
-
validateCheckoutCompletionEvent
-
validateCartFields
protected void validateCartFields(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.Trackable cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hook point to validate the given cart's fields.Validates that the cart's order number exist by default.
- Parameters:
cart- the cart to validate againstcontextInfo- context information related to multitenancy
-
validateExternalPaymentTransactionCartFinalizationEvent
protected void validateExternalPaymentTransactionCartFinalizationEvent(@NonNull @NonNull ExternalPaymentTransactionCartFinalizationEvent event, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
validateCartRejectionEvent
-
validateCartApprovalRequestEvent
-
validateCartPendingPaymentFailedEvent
protected void validateCartPendingPaymentFailedEvent(@NonNull @NonNull CartPendingPaymentFailedEvent event) -
validateCartAwaitingPaymentResultsEvent
protected void validateCartAwaitingPaymentResultsEvent(@NonNull @NonNull CartAwaitingPaymentResultsEvent event) -
validateQuoteStatusChangedEvent
-
sendEvent
-
validateCartIsSubmitted
protected void validateCartIsSubmitted(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.Trackable cart) -
validateCartIsRejected
protected void validateCartIsRejected(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.Trackable cart) -
validateCartRequiresApproval
protected void validateCartRequiresApproval(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.Trackable cart) -
validateCartHasPendingPaymentFailedStatus
-
validateCartAwaitingPaymentResults
-
validateQuoteStatusMatchesEventAudit
protected void validateQuoteStatusMatchesEventAudit(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.Trackable quote, @NonNull @NonNull QuoteStatusChangedEvent event) -
getRepository
-
getNotificationStateService
protected com.broadleafcommerce.common.messaging.notification.NotificationStateService getNotificationStateService() -
getNotificationManager
protected com.broadleafcommerce.common.messaging.notification.NotificationManager getNotificationManager() -
getCartNotificationRepository
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
setTypeFactory
@Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
getQuoteProperties
protected com.broadleafcommerce.cart.client.properties.QuoteProperties getQuoteProperties() -
setQuoteProperties
@Autowired public void setQuoteProperties(com.broadleafcommerce.cart.client.properties.QuoteProperties quoteProperties) -
getDurableMessageSender
protected com.broadleafcommerce.common.messaging.notification.DetachedDurableMessageSender getDurableMessageSender() -
setDurableMessageSender
@Autowired public void setDurableMessageSender(com.broadleafcommerce.common.messaging.notification.DetachedDurableMessageSender durableMessageSender) -
getHelper
protected com.broadleafcommerce.common.messaging.notification.MessageSerializationHelper getHelper() -
setHelper
@Autowired public void setHelper(com.broadleafcommerce.common.messaging.notification.MessageSerializationHelper helper)
-