Interface CartResolverService

  • All Known Implementing Classes:
    DefaultCartResolverService

    public interface CartResolverService
    The interface used for resolving in-progress Carts.
    Author:
    Nick Crum (ncrum)
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      String getCartNotFoundMessage​(String cartId)  
      Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveCartById​(String cartId, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Resolves a Cart given the cart ID, customer, and context.
      default Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveCartByStatus​(@NonNull String status, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Resolves the Cart with the matching status for the given customer and context.
      Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveCartByStatus​(@NonNull Collection<String> statuses, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Resolves the Cart with the first matching status for the given customer and context.
      com.broadleafcommerce.cart.client.domain.Cart resolveCartForStatusChange​(String cartId, Integer cartVersion, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Similar to resolveCartForUpdate(String, Integer, CustomerRef, ContextInfo) except it will allow carts with status DefaultCartStatuses.REQUIRES_APPROVAL to have their statuses updated.
      com.broadleafcommerce.cart.client.domain.Cart resolveCartForUpdate​(String cartId, Integer cartVersion, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Resolves the cart with additional validation that it can be updated by checking the Cart.getVersion() and Cart.getStatus().
      Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveImplicitCart​(com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Resolves the given CustomerRef's implicit/default cart, which out of the box means an DefaultCartStatuses.IN_PROCESS cart with null name.
      default Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveInProcessCart​(com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • Method Detail

      • resolveCartById

        Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveCartById​(String cartId,
                                                                                @Nullable
                                                                                com.broadleafcommerce.order.common.domain.CustomerRef customer,
                                                                                @Nullable
                                                                                com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Resolves a Cart given the cart ID, customer, and context.

        If the provided CustomerRef is not registered, this will resolve a guest cart for the given ID and context. If the cart is found to be a customer cart, this will return as empty, because an anonymous customer can only access guest carts.

        If the provided CustomerRef is registered, this will resolve a customer cart for the given customer, ID, and context. If the cart is found to be a guest cart, this will return as empty.

        If no cart is found, this will return an empty optional.

        Parameters:
        cartId - the cart ID
        customer - the customer
        contextInfo - the context info
        Returns:
        an optional with a cart, or empty
      • resolveCartByStatus

        Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveCartByStatus​(@NonNull
                                                                                    @NonNull Collection<String> statuses,
                                                                                    @NonNull
                                                                                    com.broadleafcommerce.order.common.domain.CustomerRef customer,
                                                                                    @Nullable
                                                                                    com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Resolves the Cart with the first matching status for the given customer and context.

        This method will iterate through each status, in given order, and attempt to retrieve a cart for that status. The first accessible cart retrieved for a status will be returned.

        If no cart is found, this will return an empty optional.

        Parameters:
        statuses - the statuses to check
        customer - the customer
        contextInfo - the context info
        Returns:
        an optional with a cart, or empty
      • resolveCartForStatusChange

        com.broadleafcommerce.cart.client.domain.Cart resolveCartForStatusChange​(String cartId,
                                                                                 @Nullable
                                                                                 Integer cartVersion,
                                                                                 @Nullable
                                                                                 com.broadleafcommerce.order.common.domain.CustomerRef customer,
                                                                                 @Nullable
                                                                                 com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Similar to resolveCartForUpdate(String, Integer, CustomerRef, ContextInfo) except it will allow carts with status DefaultCartStatuses.REQUIRES_APPROVAL to have their statuses updated. This enables the original requester of the approval to reclaim their cart to make changes.
        Parameters:
        cartId - Id of the cart to resolve
        cartVersion - Cart version expected
        customer - Customer who owns the cart
        contextInfo - Additional sandbox and multitenant info
        Returns:
        The matching cart if it's updatable
        Throws:
        StaleCartException - when the version of the cart resolved is ahead of the cartVersion expected
      • resolveCartForUpdate

        com.broadleafcommerce.cart.client.domain.Cart resolveCartForUpdate​(String cartId,
                                                                           @Nullable
                                                                           Integer cartVersion,
                                                                           @Nullable
                                                                           com.broadleafcommerce.order.common.domain.CustomerRef customer,
                                                                           @Nullable
                                                                           com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Resolves the cart with additional validation that it can be updated by checking the Cart.getVersion() and Cart.getStatus().
        Parameters:
        cartId - Id of the cart to resolve
        cartVersion - Cart version expected
        customer - Customer who owns the cart
        contextInfo - Additional sandbox and multitenant info
        Returns:
        The matching cart if it's updatable
        Throws:
        StaleCartException - when the version of the cart resolved is ahead of the cartVersion expected
        CartApprovalValidationException - when the cart cannot be updated because the customer is not an approver and the cart's status is DefaultCartStatuses.REQUIRES_APPROVAL.
      • resolveCartByStatus

        default Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveCartByStatus​(@NonNull
                                                                                            @NonNull String status,
                                                                                            @NonNull
                                                                                            com.broadleafcommerce.order.common.domain.CustomerRef customer,
                                                                                            @Nullable
                                                                                            com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Resolves the Cart with the matching status for the given customer and context.

        If no cart is found, this will return an empty optional.

        Parameters:
        status - the status to check
        customer - the customer
        contextInfo - the context info
        Returns:
        an optional with a cart, or empty
      • resolveInProcessCart

        @Deprecated(since="1.8.0",
                    forRemoval=true)
        default Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveInProcessCart​(com.broadleafcommerce.order.common.domain.CustomerRef customer,
                                                                                             @Nullable
                                                                                             com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Resolves the current in-progress Cart given the customer and context.

        If no cart is found, this will return an empty optional.

        Prior to 1.8.0, there's an expectation of having only one DefaultCartStatuses.IN_PROCESS cart per user. After 1.8.0, a user can have an unlimited amount of DefaultCartStatuses.IN_PROCESS carts, however a user can only have one implicit/default cart.

        Parameters:
        customer - the customer
        contextInfo - the context info
        Returns:
        an optional with a cart, or empty
      • getCartNotFoundMessage

        String getCartNotFoundMessage​(String cartId)
      • resolveImplicitCart

        Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveImplicitCart​(com.broadleafcommerce.order.common.domain.CustomerRef customer,
                                                                                    @Nullable
                                                                                    com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Resolves the given CustomerRef's implicit/default cart, which out of the box means an DefaultCartStatuses.IN_PROCESS cart with null name.
        Parameters:
        customer - the CustomerRef representing the currently authenticated user
        contextInfo - the context info
        Returns:
        an optional with a cart, or empty