public class ExternalCartProvider extends AbstractExternalProvider implements CartProvider
Modifier and Type | Class and Description |
---|---|
protected static class |
ExternalCartProvider.CartConflictResponse |
Constructor and Description |
---|
ExternalCartProvider(org.springframework.web.reactive.function.client.WebClient webClient,
com.fasterxml.jackson.databind.ObjectMapper objectMapper,
com.broadleafcommerce.common.extension.TypeFactory typeFactory,
ExternalCartProperties properties,
CartHolder<com.broadleafcommerce.cart.client.domain.Cart> requestCartHolder) |
Modifier and Type | Method and Description |
---|---|
protected StaleCartException |
cartConflict(Integer requestCartVersion,
String cartId,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo,
org.springframework.web.reactive.function.client.WebClientResponseException.Conflict conflictException)
Builds an exception when a CONFLICT exception is thrown from the Cart Service, indicating
that an optimistic lock failure occurred.
|
com.broadleafcommerce.cart.client.domain.Cart |
createCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Create a new cart.
|
com.broadleafcommerce.cart.client.domain.Cart |
createNonRequestCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Create a new cart, without updating the original request cart.
|
void |
deleteCartItem(String cartId,
com.broadleafcommerce.cart.client.domain.CartItem cartItem,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Delete the cart item.
|
protected int |
findCartItemIndex(com.broadleafcommerce.cart.client.domain.Cart cart,
String itemId)
Finds the index at which the cart item with the given ID is at.
|
com.broadleafcommerce.cart.client.domain.Cart |
patchCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Patch the cart.
|
protected com.broadleafcommerce.cart.client.domain.Cart |
populateCurrency(com.broadleafcommerce.cart.client.domain.Cart cart,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
protected com.broadleafcommerce.cart.client.domain.Cart |
resolveCartFromConflict(org.springframework.web.reactive.function.client.WebClientResponseException.Conflict conflict)
Attempts to extract a fresh version of the cart from the CONFLICT error's response body.
|
protected Optional<com.broadleafcommerce.cart.client.domain.Cart> |
retrieveCart(String retrieveCartUrl,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Method for retrieving a single, optional cart.
|
protected com.broadleafcommerce.cart.client.domain.Cart |
retrieveCartAfterConflict(String cartId,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieves the latest version of the cart following a conflict error if possible.
|
Optional<com.broadleafcommerce.cart.client.domain.Cart> |
retrieveCartById(String cartId,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the cart.
|
Optional<com.broadleafcommerce.cart.client.domain.Cart> |
retrieveCartByOrderNumber(String customerId,
String orderNumber,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Find the cart (if it exists) for the provided customer id and order number.
|
Optional<com.broadleafcommerce.cart.client.domain.Cart> |
retrieveCsrOwnedCart(String customerId,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the
DefaultCartStatuses.CSR_OWNED cart for the provided customer. |
Optional<com.broadleafcommerce.cart.client.domain.Cart> |
retrieveCustomerCartByStatus(String customerId,
String status,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Finds a cart with the given status belonging to the provided customer.
|
Optional<com.broadleafcommerce.cart.client.domain.Cart> |
retrieveHistoricalCartForAnonymousCustomer(String emailAddress,
String orderNumber,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Finds a single, historical cart for an anonymous customer.
|
SimplePage<com.broadleafcommerce.cart.client.domain.Cart> |
retrieveHistoricalCartsForCustomer(String customerId,
Date startDate,
Date endDate,
org.springframework.data.domain.Pageable page,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Find all carts not
DefaultCartStatuses.IN_PROCESS ,
DefaultCartStatuses.CSR_OWNED , or DefaultCartStatuses.NAMED for the provided
customer and dates. |
Optional<com.broadleafcommerce.cart.client.domain.Cart> |
retrieveInProcessCart(String customerId,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the
DefaultCartStatuses.IN_PROCESS cart for the provided customer. |
protected void |
syncItemToCart(com.broadleafcommerce.cart.client.domain.Cart cart,
com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Takes changes made from an update to a single item and applies them to the cart and items in
it.
|
com.broadleafcommerce.cart.client.domain.Cart |
updateCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Update the cart.
|
com.broadleafcommerce.cart.client.domain.CartItem |
updateCartItem(com.broadleafcommerce.cart.client.domain.Cart cart,
com.broadleafcommerce.cart.client.domain.CartItem cartItem,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Update the cart item.
|
protected com.broadleafcommerce.cart.client.domain.Cart |
updateRequestCart(com.broadleafcommerce.cart.client.domain.Cart cart)
This updates the cart for the current request with a recently received version from the cart
service.
|
executeRequest, getHeaders, getObjectMapper, getTypeFactory, getWebClient, pageableToParams, uriVars
public ExternalCartProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalCartProperties properties, CartHolder<com.broadleafcommerce.cart.client.domain.Cart> requestCartHolder)
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveInProcessCart(String customerId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartProvider
DefaultCartStatuses.IN_PROCESS
cart for the provided customer.retrieveInProcessCart
in interface CartProvider
customerId
- The id of the customer for which we are attempting to find an
DefaultCartStatuses.IN_PROCESS
cart.contextInfo
- Context information around sandbox and multitenant state.DefaultCartStatuses.IN_PROCESS
cart for the provided customer.public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCsrOwnedCart(String customerId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartProvider
DefaultCartStatuses.CSR_OWNED
cart for the provided customer.retrieveCsrOwnedCart
in interface CartProvider
customerId
- The id of the customer for which we are attempting to find an
DefaultCartStatuses.CSR_OWNED
cart.contextInfo
- Context information around sandbox and multitenant state.DefaultCartStatuses.CSR_OWNED
cart for the provided customer.public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCustomerCartByStatus(String customerId, String status, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartProvider
retrieveCustomerCartByStatus
in interface CartProvider
customerId
- the customer IDstatus
- the statuscontextInfo
- the context infopublic Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCartByOrderNumber(String customerId, String orderNumber, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartProvider
retrieveCartByOrderNumber
in interface CartProvider
customerId
- the id of the customer who owns the cartorderNumber
- the order number for the cartcontextInfo
- Context information around sandbox and multitenant state.public SimplePage<com.broadleafcommerce.cart.client.domain.Cart> retrieveHistoricalCartsForCustomer(String customerId, @Nullable Date startDate, @Nullable Date endDate, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartProvider
DefaultCartStatuses.IN_PROCESS
,
DefaultCartStatuses.CSR_OWNED
, or DefaultCartStatuses.NAMED
for the provided
customer and dates.retrieveHistoricalCartsForCustomer
in interface CartProvider
customerId
- the id of the customer who owns the cartsstartDate
- the starting date to filter carts byendDate
- the ending date to filter carts bypage
- the requested page of results from the databasecontextInfo
- Context information around sandbox and multitenant state.DefaultCartStatuses.IN_PROCESS
or
DefaultCartStatuses.NAMED
for the provided customer and dates.public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveHistoricalCartForAnonymousCustomer(String emailAddress, String orderNumber, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartProvider
retrieveHistoricalCartForAnonymousCustomer
in interface CartProvider
emailAddress
- The email address associated with the cart
orderNumber
- The historical cart's order number
contextInfo
- Context information around sandbox and multitenant state.public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCartById(String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartProvider
retrieveCartById
in interface CartProvider
cartId
- The id of the cart on which to perform the operation.contextInfo
- Context information around sandbox and multitenant state.public com.broadleafcommerce.cart.client.domain.Cart createNonRequestCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartProvider
createNonRequestCart
in interface CartProvider
cart
- The cart to createcontextInfo
- Context information around sandbox and multitenant state.public com.broadleafcommerce.cart.client.domain.Cart createCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartProvider
createCart
in interface CartProvider
cart
- The cart to createcontextInfo
- Context information around sandbox and multitenant state.public com.broadleafcommerce.cart.client.domain.Cart updateCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartProvider
updateCart
in interface CartProvider
cart
- The cart on which to perform the operation.contextInfo
- Context information around sandbox and multitenant state.public com.broadleafcommerce.cart.client.domain.Cart patchCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartProvider
patchCart
in interface CartProvider
cart
- The cart on which to perform the operation.contextInfo
- Context information around sandbox and multitenant state.public com.broadleafcommerce.cart.client.domain.CartItem updateCartItem(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartProvider
updateCartItem
in interface CartProvider
cart
- the cart the item belongs tocartItem
- The cart item on which to perform the operation.contextInfo
- Context information around sandbox and multitenant state.public void deleteCartItem(String cartId, com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartProvider
deleteCartItem
in interface CartProvider
cartId
- the ID of the card the item belongs tocartItem
- The cart item on which to perform the operation.contextInfo
- Context information around sandbox and multitenant state.protected Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCart(String retrieveCartUrl, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Optional.empty()
.retrieveCartUrl
- Fully built URL specifying the endpoint to hit and including query
paramscontextInfo
- Context information around sandbox and multitenant state.ProviderApiException
- if an error occurs during or from the request such as a 500
responseprotected com.broadleafcommerce.cart.client.domain.Cart populateCurrency(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected int findCartItemIndex(com.broadleafcommerce.cart.client.domain.Cart cart, String itemId)
cart
- the cart to search throughitemId
- the ID of the item to find the index ofcom.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- when no item with the given ID existsprotected void syncItemToCart(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.CartItem cartItem)
cart
- the cart to apply updates tocartItem
- the updated version of the item that was just updateprotected com.broadleafcommerce.cart.client.domain.Cart updateRequestCart(com.broadleafcommerce.cart.client.domain.Cart cart)
cart
- the cart to update the request context withprotected StaleCartException cartConflict(Integer requestCartVersion, @Nullable String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, org.springframework.web.reactive.function.client.WebClientResponseException.Conflict conflictException)
requestCartVersion
- the requested version of the cartcartId
- the ID of the requested cart, or null if not known (in which case, fresh cart
retrieval will be skipped)contextInfo
- Context information around sandbox and multitenant state.conflictException
- an exception representing the HTTP 409 (CONFLICT) error@Nullable protected com.broadleafcommerce.cart.client.domain.Cart resolveCartFromConflict(org.springframework.web.reactive.function.client.WebClientResponseException.Conflict conflict)
conflict
- the conflict exception that occurred while saving a cart@Nullable protected com.broadleafcommerce.cart.client.domain.Cart retrieveCartAfterConflict(@Nullable String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
cartConflict(Integer, String, ContextInfo, WebClientResponseException.Conflict)
.cartId
- the ID of the relevant cartcontextInfo
- Context information around sandbox and multitenant state.Copyright © 2021. All rights reserved.