Class ExternalCartProvider
java.lang.Object
com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
com.broadleafcommerce.cartoperation.service.provider.external.ExternalCartProvider
- All Implemented Interfaces:
CartProvider
- Author:
- Chad Harchar (charchar), Nathan Moore (nathandmoore)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class -
Field Summary
Fields inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
ENTITY_NOT_FOUND -
Constructor Summary
ConstructorsConstructorDescriptionExternalCartProvider(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) -
Method Summary
Modifier and TypeMethodDescriptionprotected StaleCartExceptioncartConflict(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.CartcreateCart(@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.CartcreateNonRequestCart(@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.voiddeleteCart(String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Archives a cart for the provided cart id.voiddeleteCartItem(String cartId, com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Delete the cart item.protected intfindCartItemIndex(com.broadleafcommerce.cart.client.domain.Cart cart, String itemId) Finds the index at which the cart item with the given ID is at.getCartIdVariables(String cartId) protected Stringprotected Stringprotected Stringcom.broadleafcommerce.cart.client.domain.CartpatchCart(@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.CartpopulateCurrency(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.cart.client.domain.CartresolveCartFromConflict(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.Optional<com.broadleafcommerce.cart.client.domain.Cart>retrieveAnonymousCustomerCartById(String cartId, String emailAddress, Set<String> allowedStatuses, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find the cart (if it exists) for the provided cart id and email address excluding the customer owned carts.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.CartretrieveCartAfterConflict(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>retrieveCartByStatus(String customerId, String accountId, String status, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds a customer or account cart with the given status, customer cart will automatically be retrieved if the givenaccountIdis null.Optional<com.broadleafcommerce.cart.client.domain.Cart>retrieveCartByStatusAndName(String customerId, String status, String name, String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds a customer or account cart with the given status, customer cart will automatically be retrieved if the givenaccountIdis null.org.springframework.data.domain.Page<com.broadleafcommerce.cart.client.domain.Cart>retrieveCarts(cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves aPageofCartsbased on the given filters.org.springframework.data.domain.Page<com.broadleafcommerce.cart.client.domain.Cart>retrieveCartsByStatuses(String customerId, String accountId, Set<String> statuses, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves aPageof customer or accountCartsbased on the given statuses, customer id, and account id.org.springframework.data.domain.Page<com.broadleafcommerce.cart.client.domain.Cart>retrieveCartsMatchingTenantByStatus(String status, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves aPageofCartsbased on the given status and matching the tenant from the givenContextInfo.Optional<com.broadleafcommerce.cart.client.domain.Cart>retrieveCustomerCartById(String customerId, String cartId, Set<String> allowedStatuses, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find the cart (if it exists) for the provided cart id and customer id.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 that areDefaultCartStatuses.SUBMITTEDorDefaultCartStatuses.CANCELLEDfor the provided customer and dates.org.springframework.data.domain.Page<com.broadleafcommerce.cart.client.domain.Cart>retrieveMyCarts(@NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves aPageofCartsbased on the given filters.voidsendCartAwaitingPaymentResultsEvent(@NonNull CartAwaitingPaymentResultsEvent cartAwaitingPaymentResultsEvent, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends the cart awaiting payment results event to the cart service.voidsendCartPendingPaymentFailedEvent(@NonNull CartPendingPaymentFailedEvent cartPendingPaymentFailedEvent, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends the cart pending payment failed event to the cart service.voidsendCartRejectionEvent(@NonNull CartRejectionEvent cartRejectionEvent, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends the cart rejection event to the cart service.voidsendCheckoutCompletionEvent(CheckoutCompletionEvent checkoutCompletionEvent, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends the checkout completion event to the cart service.voidsendExternalPaymentTransactionCartFinalizationEvent(ExternalPaymentTransactionCartFinalizationEvent cartFinalizationEvent, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends theExternalPaymentTransactionCartFinalizationEventvia the cart service which uses durable message sending to guarantee message delivery.voidsendRollbackEvent(CheckoutRollbackEvent rollbackEvent, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends the rollback event to the cart service.protected voidsyncItemToCart(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.CartupdateCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Update the cart.com.broadleafcommerce.cart.client.domain.CartupdateCart(@NonNull UpdateCartRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Update the cart.com.broadleafcommerce.cart.client.domain.CartItemupdateCartItem(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.List<com.broadleafcommerce.cart.client.domain.Cart>updateCartsMatchingTenantStatus(List<String> cartIds, String status, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates theCart.getStatus()for the given cart ids and status and matching the tenant from the givenContextInfo.protected com.broadleafcommerce.cart.client.domain.CartupdateRequestCart(com.broadleafcommerce.cart.client.domain.Cart cart) This updates the cart for the current request with a recently received version from the cart service.Methods inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
buildNotFoundException, executeRequest, getHeaders, getObjectMapper, getTypeFactory, getWebClient, isEntityNotFound, pageableToParams, uriVarsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.cartoperation.service.provider.CartProvider
retrieveCartsInStatus, retrieveCsrOwnedCart, retrieveCsrOwnedCart, retrieveCustomerCartByStatus, retrieveInProcessCart, retrieveInProcessCart
-
Constructor Details
-
ExternalCartProvider
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)
-
-
Method Details
-
retrieveCarts
public org.springframework.data.domain.Page<com.broadleafcommerce.cart.client.domain.Cart> retrieveCarts(cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderRetrieves aPageofCartsbased on the given filters.- Specified by:
retrieveCartsin interfaceCartProvider- Parameters:
filters- the filters to applypageable- the requested page of resultscontextInfo- context information related to multitenancy- Returns:
- a
PageofCartsbased on the given filters
-
retrieveMyCarts
public org.springframework.data.domain.Page<com.broadleafcommerce.cart.client.domain.Cart> retrieveMyCarts(@NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderRetrieves aPageofCartsbased on the given filters.- Specified by:
retrieveMyCartsin interfaceCartProviderfilters- the filters to applypageable- the requested page of resultscontextInfo- context information related to multitenancy- Returns:
- a
PageofCartsbased on the given filters
-
retrieveCartsByStatuses
public org.springframework.data.domain.Page<com.broadleafcommerce.cart.client.domain.Cart> retrieveCartsByStatuses(String customerId, @Nullable String accountId, Set<String> statuses, @Nullable org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderRetrieves aPageof customer or accountCartsbased on the given statuses, customer id, and account id. Customer cart will automatically be retrieved if the givenaccountIdis null.- Specified by:
retrieveCartsByStatusesin interfaceCartProvider- Parameters:
customerId- the id of the customer that owns theCartsaccountId- the id of the account that theCartsbelong to, null can be passed in to retrieve customerCartsstatuses- cart statuses to find theCartsbypageable- the requested page of resultscontextInfo- context information related to multitenancy- Returns:
- a
Pageof customer or accountCartsbased on the given statuses, customer id, and account id
-
retrieveCartByStatus
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCartByStatus(String customerId, @Nullable String accountId, String status, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderFinds a customer or account cart with the given status, customer cart will automatically be retrieved if the givenaccountIdis null.The cart with the latest
Cart.getCreateDate()is retrieved if there're multipleCarts.- Specified by:
retrieveCartByStatusin interfaceCartProvider- Parameters:
customerId- the customer IDaccountId- the account ID, null can be passed in to retrieve customer cartstatus- the statuscontextInfo- the context info- Returns:
- a cart if it exists
-
retrieveCartByStatusAndName
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCartByStatusAndName(String customerId, String status, @Nullable String name, @Nullable String accountId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderFinds a customer or account cart with the given status, customer cart will automatically be retrieved if the givenaccountIdis null.The cart with the latest
Cart.getCreateDate()is retrieved if there're multipleCarts.- Specified by:
retrieveCartByStatusAndNamein interfaceCartProvider- Parameters:
customerId- the customer IDstatus- the statusname- the name of the cart to match or, if null, then a cart with no nameaccountId- the account ID, null can be passed in to retrieve customer cartcontextInfo- the context info- Returns:
- a cart if it exists
-
retrieveCartByOrderNumber
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCartByOrderNumber(String customerId, String orderNumber, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderFind the cart (if it exists) for the provided customer id and order number.- Specified by:
retrieveCartByOrderNumberin interfaceCartProvider- Parameters:
customerId- the id of the customer who owns the cartorderNumber- the order number for the cartcontextInfo- Context information around sandbox and multitenant state.- Returns:
- a cart (if it exists) with the given order number that belongs to the provided customer
-
retrieveCustomerCartById
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCustomerCartById(String customerId, String cartId, Set<String> allowedStatuses, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderFind the cart (if it exists) for the provided cart id and customer id.- Specified by:
retrieveCustomerCartByIdin interfaceCartProvider- Parameters:
customerId- the customer idcartId- the id of the cartallowedStatuses- the set of cart statuses that are allowedcontextInfo- Context information around sandbox and multitenant state.- Returns:
- the cart (if it exists) for the provided cart id and customer id
-
retrieveHistoricalCartsForCustomer
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) Description copied from interface:CartProviderFind all carts that areDefaultCartStatuses.SUBMITTEDorDefaultCartStatuses.CANCELLEDfor the provided customer and dates.- Specified by:
retrieveHistoricalCartsForCustomerin interfaceCartProvider- Parameters:
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.- Returns:
- all carts that are
DefaultCartStatuses.SUBMITTEDorfor the provided customer and dates.
-
retrieveHistoricalCartForAnonymousCustomer
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveHistoricalCartForAnonymousCustomer(String emailAddress, String orderNumber, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderFinds a single, historical cart for an anonymous customer.- Specified by:
retrieveHistoricalCartForAnonymousCustomerin interfaceCartProvider- Parameters:
emailAddress- Theemail address associated with the cartorderNumber- Thehistorical cart's order numbercontextInfo- Context information around sandbox and multitenant state.- Returns:
- The single, historical cart for an anonymous customer
-
retrieveAnonymousCustomerCartById
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveAnonymousCustomerCartById(String cartId, String emailAddress, Set<String> allowedStatuses, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderFind the cart (if it exists) for the provided cart id and email address excluding the customer owned carts.- Specified by:
retrieveAnonymousCustomerCartByIdin interfaceCartProvider- Parameters:
cartId- the id of the cartemailAddress- the email address of the customerallowedStatuses- the set of cart statuses that are allowedcontextInfo- Context information around sandbox and multitenant state.- Returns:
- the cart (if it exists) for the provided cart id and email address
-
retrieveCartById
public Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCartById(String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderRetrieve the cart.- Specified by:
retrieveCartByIdin interfaceCartProvider- Parameters:
cartId- The id of the cart on which to perform the operation.contextInfo- Context information around sandbox and multitenant state.- Returns:
- The cart for the provided id.
-
createNonRequestCart
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) Description copied from interface:CartProviderCreate a new cart, without updating the original request cart.- Specified by:
createNonRequestCartin interfaceCartProvider- Parameters:
cart- The cart to createcontextInfo- Context information around sandbox and multitenant state.- Returns:
- The created cart.
-
createCart
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) Description copied from interface:CartProviderCreate a new cart.- Specified by:
createCartin interfaceCartProvider- Parameters:
cart- The cart to createcontextInfo- Context information around sandbox and multitenant state.- Returns:
- The created cart.
-
updateCart
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) Description copied from interface:CartProviderUpdate the cart.- Specified by:
updateCartin interfaceCartProvider- Parameters:
cart- The cart on which to perform the operation.contextInfo- Context information around sandbox and multitenant state.- Returns:
- The updated cart.
-
updateCart
public com.broadleafcommerce.cart.client.domain.Cart updateCart(@NonNull @NonNull UpdateCartRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderUpdate the cart.- Specified by:
updateCartin interfaceCartProvider- Parameters:
request- The request used to perform the operation.contextInfo- Context information around sandbox and multitenant state.- Returns:
- The updated cart.
-
retrieveCartsMatchingTenantByStatus
public org.springframework.data.domain.Page<com.broadleafcommerce.cart.client.domain.Cart> retrieveCartsMatchingTenantByStatus(String status, @Nullable org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderRetrieves aPageofCartsbased on the given status and matching the tenant from the givenContextInfo.Note that this ignores application context and should only be used in scheduled jobs where application context is not available.
- Specified by:
retrieveCartsMatchingTenantByStatusin interfaceCartProvider- Parameters:
status- the status to find the cartspageable- the requested page of resultscontextInfo- context information related to multitenancy- Returns:
- a
PageofCartsbased on the given status and matching the tenant from the givenContextInfo
-
updateCartsMatchingTenantStatus
public List<com.broadleafcommerce.cart.client.domain.Cart> updateCartsMatchingTenantStatus(List<String> cartIds, String status, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderUpdates theCart.getStatus()for the given cart ids and status and matching the tenant from the givenContextInfo.Note that this ignores application context and should only be used in scheduled jobs where application context is not available.
- Specified by:
updateCartsMatchingTenantStatusin interfaceCartProvider- Parameters:
cartIds- the ids of the carts to update the status forstatus- the status to update the carts tocontextInfo- Context information around sandbox and multitenant state.- Returns:
- The updated carts.
-
deleteCart
public void deleteCart(String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderArchives a cart for the provided cart id.- Specified by:
deleteCartin interfaceCartProvider- Parameters:
cartId- the id of the carts to archive.contextInfo- Context information around sandbox and multitenant state.
-
patchCart
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) Description copied from interface:CartProviderPatch the cart. A patch does not replace the cart, but partially updates it using any non-null fields.- Specified by:
patchCartin interfaceCartProvider- Parameters:
cart- The cart on which to perform the operation.contextInfo- Context information around sandbox and multitenant state.- Returns:
- The patched cart.
-
updateCartItem
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) Description copied from interface:CartProviderUpdate the cart item.- Specified by:
updateCartItemin interfaceCartProvider- Parameters:
cart- the cart the item belongs tocartItem- The cart item on which to perform the operation.contextInfo- Context information around sandbox and multitenant state.- Returns:
- The updated cart item.
-
deleteCartItem
public void deleteCartItem(String cartId, com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderDelete the cart item.- Specified by:
deleteCartItemin interfaceCartProvider- Parameters:
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.
-
sendRollbackEvent
public void sendRollbackEvent(CheckoutRollbackEvent rollbackEvent, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderSends the rollback event to the cart service. The cart service handles this event and uses durable message sending to guarantee message delivery.- Specified by:
sendRollbackEventin interfaceCartProvider- Parameters:
rollbackEvent- the event that should be sentcontextInfo- context information around sandbox and multitenant state
-
sendCheckoutCompletionEvent
public void sendCheckoutCompletionEvent(CheckoutCompletionEvent checkoutCompletionEvent, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderSends the checkout completion event to the cart service. The cart service handles this event and uses durable message sending to guarantee message delivery.- Specified by:
sendCheckoutCompletionEventin interfaceCartProvider- Parameters:
checkoutCompletionEvent- the event that should be sentcontextInfo- context information around sandbox and multitenant state
-
sendExternalPaymentTransactionCartFinalizationEvent
public void sendExternalPaymentTransactionCartFinalizationEvent(ExternalPaymentTransactionCartFinalizationEvent cartFinalizationEvent, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderSends theExternalPaymentTransactionCartFinalizationEventvia the cart service which uses durable message sending to guarantee message delivery.- Specified by:
sendExternalPaymentTransactionCartFinalizationEventin interfaceCartProvider- Parameters:
cartFinalizationEvent- the event to be sentcontextInfo- context information related to multitenancy.
-
sendCartRejectionEvent
public void sendCartRejectionEvent(@NonNull @NonNull CartRejectionEvent cartRejectionEvent, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderSends the cart rejection event to the cart service. The cart service handles this event and uses durable message sending to guarantee message delivery.- Specified by:
sendCartRejectionEventin interfaceCartProvider- Parameters:
cartRejectionEvent- the event that should be sentcontextInfo- context information around sandbox and multitenant state
-
getMyCartsStatusFilter
-
getStandardCartFilter
-
sendCartPendingPaymentFailedEvent
public void sendCartPendingPaymentFailedEvent(@NonNull @NonNull CartPendingPaymentFailedEvent cartPendingPaymentFailedEvent, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderSends the cart pending payment failed event to the cart service. The cart service handles this event and uses durable message sending to guarantee message delivery.- Specified by:
sendCartPendingPaymentFailedEventin interfaceCartProvider- Parameters:
cartPendingPaymentFailedEvent- the event that should be sentcontextInfo- context information around sandbox and multitenant state
-
sendCartAwaitingPaymentResultsEvent
public void sendCartAwaitingPaymentResultsEvent(@NonNull @NonNull CartAwaitingPaymentResultsEvent cartAwaitingPaymentResultsEvent, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartProviderSends the cart awaiting payment results event to the cart service. The cart service handles this event and uses durable message sending to guarantee message delivery.- Specified by:
sendCartAwaitingPaymentResultsEventin interfaceCartProvider- Parameters:
cartAwaitingPaymentResultsEvent- the event that should be sentcontextInfo- context information around sandbox and multitenant state
-
retrieveCart
protected Optional<com.broadleafcommerce.cart.client.domain.Cart> retrieveCart(String retrieveCartUrl, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Method for retrieving a single, optional cart. This will handle adding headers and attributes and handle errors in a common way. 404 results in returningOptional.empty().- Parameters:
retrieveCartUrl- Fully built URL specifying the endpoint to hit and including query paramscontextInfo- Context information around sandbox and multitenant state.- Returns:
- a single, optional cart.
- Throws:
ProviderApiException- if an error occurs during or from the request such as a 500 response
-
populateCurrency
protected com.broadleafcommerce.cart.client.domain.Cart populateCurrency(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
findCartItemIndex
Finds the index at which the cart item with the given ID is at.- Parameters:
cart- the cart to search throughitemId- the ID of the item to find the index of- Returns:
- the index of the cart item
- Throws:
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException- when no item with the given ID exists
-
syncItemToCart
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.- Parameters:
cart- the cart to apply updates tocartItem- the updated version of the item that was just update
-
updateRequestCart
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. This should be called after calling any endpoint which leaves the cart in an out of date state. For example, an update on the cart will result in a completely new cart instance being returned from the cart service. That new instance should be run through this method. This will ignore carts that have a different ID than the one associated to the request.- Parameters:
cart- the cart to update the request context with- Returns:
- the same cart provided for chaining purposes
-
cartConflict
protected 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) Builds an exception when a CONFLICT exception is thrown from the Cart Service, indicating that an optimistic lock failure occurred. This exception contains a freshly retrieved instance of the cart, allowing the client to update it's version of the cart to match.- Parameters:
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- Returns:
- a stale cart exception with the freshly retrieved cart if able
-
resolveCartFromConflict
@Nullable 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.- Parameters:
conflict- the conflict exception that occurred while saving a cart- Returns:
- the cart from the response body, or null if unavailable
-
retrieveCartAfterConflict
@Nullable protected com.broadleafcommerce.cart.client.domain.Cart retrieveCartAfterConflict(@Nullable String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves the latest version of the cart following a conflict error if possible. SeecartConflict(Integer, String, ContextInfo, WebClientResponseException.Conflict).- Parameters:
cartId- the ID of the relevant cartcontextInfo- Context information around sandbox and multitenant state.- Returns:
- the retrieved cart, or null if unable to retrieve
-
getCartIdVariables
-
getServiceClient
-