Class DefaultCartResolverService

    • Constructor Detail

      • DefaultCartResolverService

        public DefaultCartResolverService​(CartOperationService cartOperationService,
                                          com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils)
    • Method Detail

      • resolveCartById

        public 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)
        Description copied from interface: CartResolverService
        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.

        Specified by:
        resolveCartById in interface CartResolverService
        Parameters:
        cartId - the cart ID
        customer - the customer
        contextInfo - the context info
        Returns:
        an optional with a cart, or empty
      • resolveCartByStatus

        public Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveCartByStatus​(@NonNull
                                                                                           @NonNull Collection<String> status,
                                                                                           @NonNull
                                                                                           com.broadleafcommerce.order.common.domain.CustomerRef customer,
                                                                                           @Nullable
                                                                                           com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: CartResolverService
        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.

        Specified by:
        resolveCartByStatus in interface CartResolverService
        Parameters:
        status - the statuses to check
        customer - the customer
        contextInfo - the context info
        Returns:
        an optional with a cart, or empty
      • contextMatches

        protected boolean contextMatches​(com.broadleafcommerce.cart.client.domain.Cart cart,
                                         @Nullable
                                         com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • applicationMatches

        protected boolean applicationMatches​(com.broadleafcommerce.cart.client.domain.Cart cart,
                                             @Nullable
                                             String applicationId)
      • customerHasAccessToCart

        protected boolean customerHasAccessToCart​(com.broadleafcommerce.cart.client.domain.Cart cart,
                                                  @Nullable
                                                  com.broadleafcommerce.order.common.domain.CustomerRef customer,
                                                  @Nullable
                                                  com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • getAuthenticationUtils

        protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils()