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 Details

  • 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

      protected Notification buildRequesterNotification(com.jayway.jsonpath.DocumentContext jsonContext)
      Builds the Notification 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

      protected void processMessage(org.springframework.messaging.Message<String> message)
      Description copied from class: AbstractEmailNotificationMessageListener
      Processes the received message by extracting fields relevant to sending an email notification.
      Overrides:
      processMessage in class AbstractEmailNotificationMessageListener
      Parameters:
      message - the message payload
    • getClassName

      protected String getClassName()
      Description copied from class: AbstractEmailNotificationMessageListener
      Get the class name to identify this listener for handling message idempotency.
      Specified by:
      getClassName in class AbstractEmailNotificationMessageListener
      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 class AbstractEmailNotificationMessageListener
      Parameters:
      jsonContext - the message payload
      Returns:
      whether the email should be sent
    • getMessageType

      protected String getMessageType(com.jayway.jsonpath.DocumentContext jsonContext)
      Description copied from class: AbstractEmailNotificationMessageListener
      Determine which message type should be sent.
      Specified by:
      getMessageType in class AbstractEmailNotificationMessageListener
      Parameters:
      jsonContext - the message payload
      Returns:
      the message type to send
    • getApproveMessageType

      protected String getApproveMessageType(com.jayway.jsonpath.DocumentContext jsonContext)
    • getNotificationSubject

      protected String getNotificationSubject(com.jayway.jsonpath.DocumentContext jsonContext)
      Description copied from class: AbstractEmailNotificationMessageListener
      Determine the subject to use for the email notification.
      Specified by:
      getNotificationSubject in class AbstractEmailNotificationMessageListener
      Parameters:
      jsonContext - the message payload
      Returns:
      the subject to use for the email notification
    • getApproveNotificationSubject

      protected String getApproveNotificationSubject(com.jayway.jsonpath.DocumentContext jsonContext)
      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

      protected List<Recipient> getRecipients(com.jayway.jsonpath.DocumentContext jsonContext)
      Determine the recipients to use for the order confirmation email notification. The email notification will be sent to the Cart.getApproverEmail() if the cart was checked out by an approver.
      Specified by:
      getRecipients in class AbstractEmailNotificationMessageListener
      Parameters:
      jsonContext - the message payload
      Returns:
      the subject to use for the cart approval email notification
    • getApproverRecipientCommunicationPreferences

      protected String getApproverRecipientCommunicationPreferences(String accountId, String approverEmail, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getCustomerRecipientCommunicationPreferences

      protected String getCustomerRecipientCommunicationPreferences(@Nullable String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getApproverEmail

      @Nullable protected String getApproverEmail(com.jayway.jsonpath.DocumentContext jsonContext)
    • getRequesterRecipient

      protected List<Recipient> getRequesterRecipient(com.jayway.jsonpath.DocumentContext jsonContext)
      Determine the recipients to use for the cart approval email notification. The user requesting cart approval is referenced by Cart.getCustomerRef() and Cart.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

      @Nullable protected String getCustomerName(com.jayway.jsonpath.DocumentContext jsonContext)

      Read the customer name from the given context.

      If the customer is registered, the full name from getRequesterNamePath() 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

      protected String getRequesterRecipientCommunicationPreferences(String accountId, String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getRequesterName

      protected String getRequesterName(com.jayway.jsonpath.DocumentContext jsonContext)

      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 the ContextInfo for the current message
      Specified by:
      buildNotificationContext in class AbstractEmailNotificationMessageListener
      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 class AbstractEmailNotificationMessageListener
      Parameters:
      notification - the Notification for the current message
      context - 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

      protected String getCustomerNamePath()
      Get the Json path to the customer name from OrderConfirmationPathProperties.
      Returns:
      The Json path to the customer name property.
    • getBillingAddressFullNamePath

      protected String getBillingAddressFullNamePath()
      Get the Json path to the full name from billing address from OrderConfirmationPathProperties.
      Returns:
      The Json path to the full name from billing address property
    • getRequesterNamePath

      protected String getRequesterNamePath()
      Get the Json path to the requester name from OrderConfirmationPathProperties.
      Returns:
      The Json path to the requester name property.
    • getOrderStatusPath

      protected String getOrderStatusPath()
      Get the Json path to the order status from OrderConfirmationPathProperties.
      Returns:
      The Json path to the order status property.
    • getCartOrderNumberPath

      protected String getCartOrderNumberPath()
      Get the Json path to the cart order number from OrderConfirmationPathProperties.
      Returns:
      The Json path to the cart order number property.
    • getCustomerEmailPath

      protected String getCustomerEmailPath()
      Get the Json path to the customer email from OrderConfirmationPathProperties.
      Returns:
      The Json path to the customer email property.
    • getApproverEmailPath

      protected String getApproverEmailPath()
    • getCustomerIdPath

      protected String getCustomerIdPath()
    • getAccountIdPath

      protected String getAccountIdPath()
    • getAccountId

      @Nullable protected String getAccountId(com.jayway.jsonpath.DocumentContext jsonContext)
    • getCustomerId

      @Nullable protected String getCustomerId(com.jayway.jsonpath.DocumentContext jsonContext)
    • getCartProvider

      protected CartProvider getCartProvider()
    • getOrderConfirmationPathProperties

      protected OrderConfirmationPathProperties getOrderConfirmationPathProperties()