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 String
Deprecated, for removal: This API element is subject to removal in a future version.protected static final String
Deprecated, for removal: This API element is subject to removal in a future version.protected static final String
Deprecated, for removal: This API element is subject to removal in a future version.protected static final String
Deprecated, for removal: This API element is subject to removal in a future version.protected static final String
protected static final String
protected static final String
protected static final String
Deprecated, for removal: This API element is subject to removal in a future version.protected static final String
protected static final String
protected static final String
Deprecated, 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.ContextInfo
buildNotificationContext
(com.jayway.jsonpath.DocumentContext jsonContext) Build theContextInfo
for the current messageprotected Notification
buildRequesterNotification
(com.jayway.jsonpath.DocumentContext jsonContext) Builds theNotification
to be sent to the user who requested cart approval once the cart has gone through checkout.protected String
getAccountId
(com.jayway.jsonpath.DocumentContext jsonContext) protected String
protected String
getApproveMessageType
(com.jayway.jsonpath.DocumentContext jsonContext) protected String
getApproveNotificationSubject
(com.jayway.jsonpath.DocumentContext jsonContext) Determine the subject to use for the cart approval email notification.protected String
getApproverEmail
(com.jayway.jsonpath.DocumentContext jsonContext) protected String
protected String
getApproverRecipientCommunicationPreferences
(String accountId, String approverEmail, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected String
Get the Json path to the full name from billing address fromOrderConfirmationPathProperties
.protected String
Get the Json path to the cart order number fromOrderConfirmationPathProperties
.protected CartProvider
protected String
Get the class name to identify this listener for handling message idempotency.protected String
Get the Json path to the customer email fromOrderConfirmationPathProperties
.protected String
getCustomerId
(com.jayway.jsonpath.DocumentContext jsonContext) protected String
protected String
getCustomerName
(com.jayway.jsonpath.DocumentContext jsonContext) Read the customer name from the given context.protected String
Get the Json path to the customer name fromOrderConfirmationPathProperties
.protected String
getCustomerRecipientCommunicationPreferences
(String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected String
getMessageType
(com.jayway.jsonpath.DocumentContext jsonContext) Determine which message type should be sent.protected String
getNotificationSubject
(com.jayway.jsonpath.DocumentContext jsonContext) Determine the subject to use for the email notification.protected OrderConfirmationPathProperties
protected String
Get 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 String
getRequesterName
(com.jayway.jsonpath.DocumentContext jsonContext) Read the requester name from the given context.protected String
Get 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 String
getRequesterRecipientCommunicationPreferences
(String accountId, String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) void
handleMessage
(org.springframework.messaging.Message<String> message) protected void
modifyNotification
(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 void
populateCartItems
(com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
populateCartItemsAndGroups
(com.jayway.jsonpath.DocumentContext jsonContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
populateFulfillmentGroups
(com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
processMessage
(org.springframework.messaging.Message<String> message) Processes the received message by extracting fields relevant to sending an email notification.protected boolean
validateShouldSendNotification
(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 theNotification
to 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:AbstractEmailNotificationMessageListener
Processes the received message by extracting fields relevant to sending an email notification.- Overrides:
processMessage
in classAbstractEmailNotificationMessageListener
- Parameters:
message
- the message payload
-
getClassName
Description copied from class:AbstractEmailNotificationMessageListener
Get the class name to identify this listener for handling message idempotency.- Specified by:
getClassName
in 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:
validateShouldSendNotification
in classAbstractEmailNotificationMessageListener
- Parameters:
jsonContext
- the message payload- Returns:
- whether the email should be sent
-
getMessageType
Description copied from class:AbstractEmailNotificationMessageListener
Determine which message type should be sent.- Specified by:
getMessageType
in classAbstractEmailNotificationMessageListener
- Parameters:
jsonContext
- the message payload- Returns:
- the message type to send
-
getApproveMessageType
-
getNotificationSubject
Description copied from class:AbstractEmailNotificationMessageListener
Determine the subject to use for the email notification.- Specified by:
getNotificationSubject
in 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:
getRecipients
in 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:AbstractEmailNotificationMessageListener
Build theContextInfo
for the current message- Specified by:
buildNotificationContext
in 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:AbstractEmailNotificationMessageListener
Extension point to allow modifying the notification or context before sending to the notification service- Overrides:
modifyNotification
in 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
-