java.lang.Object
com.broadleafcommerce.cartoperation.service.checkout.workflow.activity.CartItemValidationActivity
All Implemented Interfaces:
CheckoutWorkflowActivity

public class CartItemValidationActivity extends Object implements CheckoutWorkflowActivity
This CheckoutWorkflowActivity is responsible for validating that the cart's CartItems include all necessary selections and data so that we can clearly understand what is being purchased and must later be fulfilled.
Author:
Chad Harchar (charchar), Chris Kittrell (ckittrell)
  • Constructor Details

  • Method Details

    • execute

      public CheckoutProcessDto execute(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CheckoutWorkflowActivity
      Method responsible for executing some work against the cart that is required for checkout. This may include, but is not limited to, cart validation checks, inventory reservations, or payment authorizations.
      Specified by:
      execute in interface CheckoutWorkflowActivity
      Parameters:
      processDto - The CheckoutProcessDto that we're attempting to checkout with.
      contextInfo - Context information around sandbox and multitenant state.
      Returns:
      The final state of the CheckoutProcessDto following the execution of the activity.
    • rollback

      public CheckoutProcessDto rollback(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CheckoutWorkflowActivity
      Method responsible for rolling back any work that was done during the execution of the CheckoutWorkflowActivity.execute(CheckoutProcessDto, ContextInfo) method.
      Specified by:
      rollback in interface CheckoutWorkflowActivity
      Parameters:
      processDto - The CheckoutProcessDto that we were attempting to checkout with, but ran into an exception/error.
      contextInfo - Context information around sandbox and multitenant state.
      Returns:
      The final state of the CheckoutProcessDto following the rollback of the activity.
    • validateCartItems

      protected void validateCartItems(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Validates that each of the cart's CartItems include all necessary selections and data
      Parameters:
      processDto - the CheckoutProcessDto being used for checkout
      contextInfo - Context information around sandbox and multitenant state.
      Throws:
      CheckoutWorkflowActivityException - thrown if an unrecoverable error is encountered during the execution of the activity
    • gatherCartItemConfigErrors

      protected Map<String,String> gatherCartItemConfigErrors(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
      Gathers all of the config error messages for the CartItem into a map.
      Parameters:
      cartItem -
      Returns:
      the map of CartItem config error messages
    • identifyCatalogItemForCartItem

      protected CatalogItem identifyCatalogItemForCartItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull CatalogItemList<? extends CatalogItem> catalogItemList)
    • buildCatalogItemRequests

      protected Collection<CatalogItemRequest> buildCatalogItemRequests(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • isDuplicateCatalogItemRequest

      protected boolean isDuplicateCatalogItemRequest(@NonNull @NonNull Set<CatalogItemRequest> catalogItemRequests, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Hook point to prevent duplicate CatalogItemRequests from being built based on the CartItem.

      By default, we filter on the product ID.

      Parameters:
      catalogItemRequests - the list of requests to pass to the CatalogProvider
      cartItem - the CartItem to build the CatalogItemRequest
      contextInfo - context information around sandbox and multitenant state
      Returns:
      true if building a new CatalogItemRequest would be a duplicate of an existing request in catalogItemRequests
    • buildCatalogItemRequest

      protected CatalogItemRequest buildCatalogItemRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Hook point to create the CatalogItemRequest and populate any additional attributes that should be passed to the CatalogProvider when fetching the catalog representation for the cart item.
      Parameters:
      cartItem - the CartItem to build the CatalogItemRequest
      contextInfo - context information around sandbox and multitenant state
      Returns:
      the populated CatalogItemRequest for the CartItem
    • identifyKeysForCatalogItems

      protected Set<String> identifyKeysForCatalogItems(CatalogItemList<? extends CatalogItem> catalogItemList, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Hook point to collect the keys that will identify the CatalogItems.
      Parameters:
      catalogItemList - the list of CatalogItems
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      the set of identifying keys for the catalog items
    • isCartItemMissingCatalogItems

      protected boolean isCartItemMissingCatalogItems(Set<String> catalogItemKeys, com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Hook point to determine if the CartItem does not have a backing CatalogItem.

      By default, the keys are checked against the cart item's product ID.

      Parameters:
      catalogItemKeys - the set of identifying keys for the catalog items
      cartItem - the cart item to check
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      true if the cartItem does not have a backing CatalogItem
    • getPriceContext

      @Nullable protected com.broadleafcommerce.pricing.client.domain.context.PriceContext getPriceContext(@Nullable Locale locale, @Nullable javax.money.CurrencyUnit currency)
    • getCatalogProvider

      protected CatalogProvider<? extends CatalogItem> getCatalogProvider()
    • getCartItemConfigurationService

      protected CartItemConfigurationService<? extends CatalogItem> getCartItemConfigurationService()
    • getMessageSource

      protected org.springframework.context.MessageSource getMessageSource()
    • setStaleCartItemsService

      @Autowired public void setStaleCartItemsService(StaleCartItemsService staleCartItemsService)
    • getStaleCartItemsService

      protected StaleCartItemsService getStaleCartItemsService()
    • setTypeFactory

      @Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()