Class DefaultCartResolverService
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.DefaultCartResolverService
-
- All Implemented Interfaces:
CartResolverService
public class DefaultCartResolverService extends Object implements CartResolverService
- Author:
- Nick Crum (ncrum)
-
-
Constructor Summary
Constructors Constructor Description DefaultCartResolverService(CartOperationService cartOperationService, com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
applicationMatches(com.broadleafcommerce.cart.client.domain.Cart cart, String applicationId)
protected boolean
contextMatches(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected boolean
customerHasAccessToCart(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils
getAuthenticationUtils()
protected CartOperationService
getCartOperationService()
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 aCart
given the cart ID, customer, and context.Optional<com.broadleafcommerce.cart.client.domain.Cart>
resolveCartByStatus(@NonNull Collection<String> status, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Resolves theCart
with the first matching status for the given customer and context.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.broadleafcommerce.cartoperation.service.CartResolverService
resolveCartByStatus, resolveInProcessCart
-
-
-
-
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 aCart
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 interfaceCartResolverService
- Parameters:
cartId
- the cart IDcustomer
- the customercontextInfo
- 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 theCart
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 interfaceCartResolverService
- Parameters:
status
- the statuses to checkcustomer
- the customercontextInfo
- 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)
-
getCartOperationService
protected CartOperationService getCartOperationService()
-
getAuthenticationUtils
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils()
-
-