Class NotificationOrderConfirmationMessageListener
java.lang.Object
com.broadleafcommerce.notification.service.messaging.AbstractEmailNotificationMessageListener
com.broadleafcommerce.notification.service.messaging.NotificationOrderConfirmationMessageListener
public class NotificationOrderConfirmationMessageListener
extends AbstractEmailNotificationMessageListener
A message listener that triggers when an order is successfully submitted. Responsible for
creating the order confirmation notification.
- Author:
- Jon Fleschler (jfleschler)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringDeprecated, for removal: This API element is subject to removal in a future version.protected static final StringDeprecated, for removal: This API element is subject to removal in a future version.protected static final StringDeprecated, for removal: This API element is subject to removal in a future version.protected static final StringDeprecated, for removal: This API element is subject to removal in a future version.protected static final Stringprotected static final Stringprotected static final Stringprotected static final StringDeprecated, for removal: This API element is subject to removal in a future version.protected static final Stringprotected static final Stringprotected static final StringDeprecated, for removal: This API element is subject to removal in a future version.Fields inherited from class com.broadleafcommerce.notification.service.messaging.AbstractEmailNotificationMessageListener
EMAIL_DELIVERY, messages, notificationService, tenantProvider, typeFactory, userResolver -
Constructor Summary
ConstructorsConstructorDescriptionNotificationOrderConfirmationMessageListener(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService, NotificationService<Notification> notificationService, org.springframework.context.MessageSource messages, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartProvider cartProvider) NotificationOrderConfirmationMessageListener(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService, NotificationService<Notification> notificationService, org.springframework.context.MessageSource messages, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartProvider cartProvider, OrderConfirmationPathProperties orderConfirmationPathProperties) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.broadleafcommerce.data.tracking.core.context.ContextInfobuildNotificationContext(com.jayway.jsonpath.DocumentContext jsonContext) Build theContextInfofor the current messageprotected NotificationbuildRequesterNotification(com.jayway.jsonpath.DocumentContext jsonContext) Builds theNotificationto be sent to the user who requested cart approval once the cart has gone through checkout.protected StringgetAccountId(com.jayway.jsonpath.DocumentContext jsonContext) protected Stringprotected StringgetApproveMessageType(com.jayway.jsonpath.DocumentContext jsonContext) protected StringgetApproveNotificationSubject(com.jayway.jsonpath.DocumentContext jsonContext) Determine the subject to use for the cart approval email notification.protected StringgetApproverEmail(com.jayway.jsonpath.DocumentContext jsonContext) protected Stringprotected StringgetApproverRecipientCommunicationPreferences(String accountId, String approverEmail, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected StringGet the Json path to the full name from billing address fromOrderConfirmationPathProperties.protected StringGet the Json path to the cart order number fromOrderConfirmationPathProperties.protected CartProviderprotected StringGet the class name to identify this listener for handling message idempotency.protected StringGet the Json path to the customer email fromOrderConfirmationPathProperties.protected StringgetCustomerId(com.jayway.jsonpath.DocumentContext jsonContext) protected Stringprotected StringgetCustomerName(com.jayway.jsonpath.DocumentContext jsonContext) Read the customer name from the given context.protected StringGet the Json path to the customer name fromOrderConfirmationPathProperties.protected StringgetCustomerRecipientCommunicationPreferences(String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected StringgetMessageType(com.jayway.jsonpath.DocumentContext jsonContext) Determine which message type should be sent.protected StringgetNotificationSubject(com.jayway.jsonpath.DocumentContext jsonContext) Determine the subject to use for the email notification.protected OrderConfirmationPathPropertiesprotected StringGet the Json path to the order status fromOrderConfirmationPathProperties.getRecipients(com.jayway.jsonpath.DocumentContext jsonContext) Determine the recipients to use for the order confirmation email notification.protected StringgetRequesterName(com.jayway.jsonpath.DocumentContext jsonContext) Read the requester name from the given context.protected StringGet the Json path to the requester name fromOrderConfirmationPathProperties.getRequesterRecipient(com.jayway.jsonpath.DocumentContext jsonContext) Determine the recipients to use for the cart approval email notification.protected StringgetRequesterRecipientCommunicationPreferences(String accountId, String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidhandleMessage(org.springframework.messaging.Message<String> message) protected voidmodifyNotification(Notification notification, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Extension point to allow modifying the notification or context before sending to the notification serviceprotected voidpopulateCartItems(com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidpopulateCartItemsAndGroups(com.jayway.jsonpath.DocumentContext jsonContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidpopulateFulfillmentGroups(com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidprocessMessage(org.springframework.messaging.Message<String> message) Processes the received message by extracting fields relevant to sending an email notification.protected booleanvalidateShouldSendNotification(com.jayway.jsonpath.DocumentContext jsonContext) Validates the order has been submitted to send the email.Methods inherited from class com.broadleafcommerce.notification.service.messaging.AbstractEmailNotificationMessageListener
buildNotification, buildNotification, getDocumentContext, getIdempotentConsumptionService, getMessages, getNotificationService, getObjectMapper, getPayload, getTenantProvider, getTypeFactory, getUserResolver, handleMessageInternal, modifyNotification, resolveApplicationById, setTenantProvider, setUserResolver
-
Field Details
-
SUBMITTED
- See Also:
-
ORDER_CONFIRMATION
- See Also:
-
ORDER_APPROVAL
- See Also:
-
SUBJECT_MESSAGE
- See Also:
-
APPLICATION_ID_PATH
Deprecated, for removal: This API element is subject to removal in a future version.JSON Paths have been moved toOrderConfirmationPathProperties- See Also:
-
TENANT_ID_PATH
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
-
CART_ORDER_NUMBER_PATH
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
-
ORDER_STATUS_PATH
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
-
CUSTOMER_NAME_PATH
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
-
CUSTOMER_EMAIL_PATH
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
-
LOCALE
- See Also:
-
-
Constructor Details
-
NotificationOrderConfirmationMessageListener
public NotificationOrderConfirmationMessageListener(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService, NotificationService<Notification> notificationService, org.springframework.context.MessageSource messages, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartProvider cartProvider) -
NotificationOrderConfirmationMessageListener
public NotificationOrderConfirmationMessageListener(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService, NotificationService<Notification> notificationService, org.springframework.context.MessageSource messages, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartProvider cartProvider, OrderConfirmationPathProperties orderConfirmationPathProperties)
-
-
Method Details
-
handleMessage
@StreamListener("checkoutCompletionInputNotification") public void handleMessage(org.springframework.messaging.Message<String> message) -
buildRequesterNotification
Builds theNotificationto be sent to the user who requested cart approval once the cart has gone through checkout.Note that this is only relevant for B2B account carts.
- Parameters:
jsonContext- the message payload- Returns:
- the cart approval Notification
-
processMessage
Description copied from class:AbstractEmailNotificationMessageListenerProcesses the received message by extracting fields relevant to sending an email notification.- Overrides:
processMessagein classAbstractEmailNotificationMessageListener- Parameters:
message- the message payload
-
getClassName
Description copied from class:AbstractEmailNotificationMessageListenerGet the class name to identify this listener for handling message idempotency.- Specified by:
getClassNamein classAbstractEmailNotificationMessageListener- Returns:
- the listener's class name
-
validateShouldSendNotification
protected boolean validateShouldSendNotification(com.jayway.jsonpath.DocumentContext jsonContext) Validates the order has been submitted to send the email.- Specified by:
validateShouldSendNotificationin classAbstractEmailNotificationMessageListener- Parameters:
jsonContext- the message payload- Returns:
- whether the email should be sent
-
getMessageType
Description copied from class:AbstractEmailNotificationMessageListenerDetermine which message type should be sent.- Specified by:
getMessageTypein classAbstractEmailNotificationMessageListener- Parameters:
jsonContext- the message payload- Returns:
- the message type to send
-
getApproveMessageType
-
getNotificationSubject
Description copied from class:AbstractEmailNotificationMessageListenerDetermine the subject to use for the email notification.- Specified by:
getNotificationSubjectin classAbstractEmailNotificationMessageListener- Parameters:
jsonContext- the message payload- Returns:
- the subject to use for the email notification
-
getApproveNotificationSubject
Determine the subject to use for the cart approval email notification.- Parameters:
jsonContext- the message payload- Returns:
- the subject to use for the cart approval email notification
-
getRecipients
Determine the recipients to use for the order confirmation email notification. The email notification will be sent to theCart.getApproverEmail()if the cart was checked out by an approver.- Specified by:
getRecipientsin classAbstractEmailNotificationMessageListener- Parameters:
jsonContext- the message payload- Returns:
- the subject to use for the cart approval email notification
-
getApproverRecipientCommunicationPreferences
-
getCustomerRecipientCommunicationPreferences
-
getApproverEmail
-
getRequesterRecipient
Determine the recipients to use for the cart approval email notification. The user requesting cart approval is referenced byCart.getCustomerRef()andCart.getEmailAddress(). This is expected to be the owner of the cart.- Parameters:
jsonContext- the message payload- Returns:
- the recipients to use for the cart approval email notification
-
getCustomerName
Read the customer name from the given context.
If the customer is registered, the full name fromgetRequesterNamePath()will be returned. Otherwise, it returns the customer name from the billing address.This method will check the deprecated name path if the configured path does not exist in the given context.
- Parameters:
jsonContext- the message payload.- Returns:
- The name of the customer from the given payload.
-
getRequesterRecipientCommunicationPreferences
-
getRequesterName
Read the requester name from the given context.
- Parameters:
jsonContext- the message payload.- Returns:
- The name of the requester from the given payload.
-
buildNotificationContext
protected com.broadleafcommerce.data.tracking.core.context.ContextInfo buildNotificationContext(com.jayway.jsonpath.DocumentContext jsonContext) Description copied from class:AbstractEmailNotificationMessageListenerBuild theContextInfofor the current message- Specified by:
buildNotificationContextin classAbstractEmailNotificationMessageListener- Parameters:
jsonContext- the payload of the message- Returns:
- the NotificationContext for the current message
-
modifyNotification
protected void modifyNotification(Notification notification, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from class:AbstractEmailNotificationMessageListenerExtension point to allow modifying the notification or context before sending to the notification service- Overrides:
modifyNotificationin classAbstractEmailNotificationMessageListener- Parameters:
notification- the Notification for the current messagecontext- The context of the request
-
populateCartItemsAndGroups
protected void populateCartItemsAndGroups(com.jayway.jsonpath.DocumentContext jsonContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
populateCartItems
protected void populateCartItems(com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
populateFulfillmentGroups
protected void populateFulfillmentGroups(com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getCustomerNamePath
Get the Json path to the customer name fromOrderConfirmationPathProperties.- Returns:
- The Json path to the customer name property.
-
getBillingAddressFullNamePath
Get the Json path to the full name from billing address fromOrderConfirmationPathProperties.- Returns:
- The Json path to the full name from billing address property
-
getRequesterNamePath
Get the Json path to the requester name fromOrderConfirmationPathProperties.- Returns:
- The Json path to the requester name property.
-
getOrderStatusPath
Get the Json path to the order status fromOrderConfirmationPathProperties.- Returns:
- The Json path to the order status property.
-
getCartOrderNumberPath
Get the Json path to the cart order number fromOrderConfirmationPathProperties.- Returns:
- The Json path to the cart order number property.
-
getCustomerEmailPath
Get the Json path to the customer email fromOrderConfirmationPathProperties.- Returns:
- The Json path to the customer email property.
-
getApproverEmailPath
-
getCustomerIdPath
-
getAccountIdPath
-
getAccountId
-
getCustomerId
-
getCartProvider
-
getOrderConfirmationPathProperties
-