Class ManageCartEndpoint
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.web.endpoint.ManageCartEndpoint
-
@FrameworkRestController @FrameworkMapping("/cart") public class ManageCartEndpoint extends Object
- Author:
- Nick Crum (ncrum)
-
-
Constructor Summary
Constructors Constructor Description ManageCartEndpoint(CartResolverService cartResolverService, CartOperationService cartOperationService, CartTransferService cartTransferService, CartVersionValidationService cartVersionValidationService, GuestCartProtectionService guestCartProtectionService, GuestCartTokenValidator guestCartTokenValidator, ItemListAddToCartService itemListAddToCartService)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description com.broadleafcommerce.cart.client.domain.Cart
addAttributeToCart(String cartId, AddAttributeRequest addAttributeRequest, boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
ItemListAddToCartResponse
addItemListsToCart(String cartId, AddItemListToCartRequest addItemListToCartRequest, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
com.broadleafcommerce.cart.client.domain.Cart
addItemToCart(String cartId, AddItemRequest addItemRequest, boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
BulkAddToCartResponse
addManyItemsToCart(String cartId, List<AddItemRequest> addItemRequests, boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
AddCodeToCartResponse
addOfferCodeToCart(String cartId, AddCodeRequest addCodeRequest, boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected String
cartNotFoundMessage(String cartId)
com.broadleafcommerce.cart.client.domain.Cart
createCart(CartCreationRequest cartCreationRequest, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
com.broadleafcommerce.cart.client.domain.Cart
getCart(String cartId, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Deprecated as of 1.7.0-GA.com.broadleafcommerce.cart.client.domain.Cart
getCart(String cartId, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected CartOperationService
getCartOperationService()
protected CartResolverService
getCartResolverService()
protected CartTransferService
getCartTransferService()
protected CartVersionValidationService
getCartVersionValidationService()
protected GuestCartProtectionService
getGuestCartProtectionService()
protected GuestCartTokenValidator
getGuestCartTokenValidator()
protected ItemListAddToCartService
getItemListAddToCartService()
com.broadleafcommerce.cart.client.domain.Cart
priceCart(String cartId, PriceCartRequest priceCartRequest, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected <T> T
protectCartOperationForGuest(Function<com.broadleafcommerce.cart.client.domain.Cart,T> operation, com.broadleafcommerce.cart.client.domain.Cart initialCart, String guestToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Helper method to validate the guest token, protect the resolved cart, & execute the operation.protected com.broadleafcommerce.cart.client.domain.Cart
protectCartOperationForGuest(Supplier<com.broadleafcommerce.cart.client.domain.Cart> operation, com.broadleafcommerce.cart.client.domain.Cart initialCart, String guestToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Since 1.6.1, in favor ofprotectCartOperationForGuest(Function, Cart, String, ContextInfo)
protected <T> T
protectCartOperationForGuest(Supplier<T> operation, com.broadleafcommerce.cart.client.domain.Cart initialCart, String guestToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Function<T,com.broadleafcommerce.cart.client.domain.Cart> cartExtractor)
Deprecated.Since 1.6.1, in favor ofprotectCartOperationForGuest(Function, Cart, String, ContextInfo)
protected void
protectGuestCartIfNecessary(com.broadleafcommerce.cart.client.domain.Cart cart, String guestToken)
If the provided cart is a guest cart, and there is no guest token, this will clear out any customer information from the cart.protected com.broadleafcommerce.cart.client.domain.Cart
protectGuestCartIfNecessary(com.broadleafcommerce.cart.client.domain.Cart cart, String guestToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
If the provided cart is a guest cart, and there is no guest token, then this will produce a cloned guest cart, excluding any customer data.com.broadleafcommerce.cart.client.domain.Cart
removeAttributeFromCart(String cartId, String attributeKey, boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
com.broadleafcommerce.cart.client.domain.Cart
removeFromCartInBulk(String cartId, boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Set<String> cartItemIds)
com.broadleafcommerce.cart.client.domain.Cart
removeItemFromCart(String cartId, String cartItemId, boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
com.broadleafcommerce.cart.client.domain.Cart
removeManyItemsFromCart(String cartId, Collection<String> cartItemIds, boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
com.broadleafcommerce.cart.client.domain.Cart
removeOfferCodeFromCart(String cartId, String offerCode, boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected com.broadleafcommerce.cart.client.domain.Cart
resolveCart(String cartId, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected com.broadleafcommerce.cart.client.domain.Cart
resolveCartForRead(String cartId, Integer cartVersion, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected 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)
com.broadleafcommerce.cart.client.domain.Cart
transferCart(String cartId, Integer cartVersion, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
com.broadleafcommerce.cart.client.domain.Cart
updateItemInCart(String cartId, String cartItemId, UpdateItemRequest updateItemRequest, boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected void
validateGuestTokenIfNecessary(com.broadleafcommerce.cart.client.domain.Cart cart, String guestToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
If the provided cart is a guest cart, this will attempt to validate the guest token for the cart.
-
-
-
Field Detail
-
BASE_URI
public static final String BASE_URI
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ManageCartEndpoint
public ManageCartEndpoint(CartResolverService cartResolverService, CartOperationService cartOperationService, CartTransferService cartTransferService, CartVersionValidationService cartVersionValidationService, GuestCartProtectionService guestCartProtectionService, GuestCartTokenValidator guestCartTokenValidator, ItemListAddToCartService itemListAddToCartService)
-
-
Method Detail
-
createCart
@FrameworkPostMapping(consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart createCart(@RequestBody CartCreationRequest cartCreationRequest, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
getCart
@Deprecated public com.broadleafcommerce.cart.client.domain.Cart getCart(@PathVariable String cartId, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Deprecated as of 1.7.0-GA. UsegetCart(String, String, CustomerRef, ContextInfo)
. ThecartVersion
should not be included as it is irrelevant for reads. It's only relevant for cart-modification requests.
-
getCart
@FrameworkGetMapping("/{cartId}") public com.broadleafcommerce.cart.client.domain.Cart getCart(@PathVariable String cartId, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
transferCart
@FrameworkPostMapping("/{cartId}/transfer") public com.broadleafcommerce.cart.client.domain.Cart transferCart(@PathVariable String cartId, Integer cartVersion, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
priceCart
@FrameworkPostMapping(value="/{cartId}/pricing", consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart priceCart(@PathVariable String cartId, @RequestBody PriceCartRequest priceCartRequest, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
addItemToCart
@FrameworkPostMapping(value="/{cartId}/items", consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart addItemToCart(@PathVariable String cartId, @RequestBody AddItemRequest addItemRequest, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
updateItemInCart
@FrameworkPatchMapping(value="/{cartId}/items/{cartItemId}", consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart updateItemInCart(@PathVariable String cartId, @PathVariable String cartItemId, @RequestBody UpdateItemRequest updateItemRequest, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
removeItemFromCart
@FrameworkDeleteMapping("/{cartId}/items/{cartItemId}") public com.broadleafcommerce.cart.client.domain.Cart removeItemFromCart(@PathVariable String cartId, @PathVariable String cartItemId, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
addManyItemsToCart
@FrameworkPostMapping(value="/{cartId}/bulk-items", consumes="application/json") public BulkAddToCartResponse addManyItemsToCart(@PathVariable String cartId, @RequestBody List<AddItemRequest> addItemRequests, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
removeManyItemsFromCart
@Deprecated @FrameworkDeleteMapping("/{cartId}/bulk-items") public com.broadleafcommerce.cart.client.domain.Cart removeManyItemsFromCart(@PathVariable String cartId, @RequestParam Collection<String> cartItemIds, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.UseremoveFromCartInBulk(String, boolean, Integer, String, CustomerRef, ContextInfo, Set)
. This will allow much longer lists of IDs without worrying about whether the URL is too long and corrects the HTTP method semantics by using POST since we're not actually deleting a resource at the URL.
-
removeFromCartInBulk
@FrameworkPostMapping(value="/{cartId}/bulk-items/delete", consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart removeFromCartInBulk(@PathVariable String cartId, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @RequestBody Set<String> cartItemIds)
-
addItemListsToCart
@FrameworkPostMapping(value="/{cartId}/item-lists", consumes="application/json") public ItemListAddToCartResponse addItemListsToCart(@PathVariable String cartId, @RequestBody AddItemListToCartRequest addItemListToCartRequest, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
addOfferCodeToCart
@FrameworkPostMapping(value="/{cartId}/offer-codes", consumes="application/json") public AddCodeToCartResponse addOfferCodeToCart(@PathVariable String cartId, @RequestBody AddCodeRequest addCodeRequest, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
removeOfferCodeFromCart
@FrameworkDeleteMapping("/{cartId}/offer-codes/{offerCode}") public com.broadleafcommerce.cart.client.domain.Cart removeOfferCodeFromCart(@PathVariable String cartId, @PathVariable String offerCode, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
addAttributeToCart
@FrameworkPostMapping(value="/{cartId}/attributes", consumes="application/json") public com.broadleafcommerce.cart.client.domain.Cart addAttributeToCart(@PathVariable String cartId, @RequestBody AddAttributeRequest addAttributeRequest, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
removeAttributeFromCart
@FrameworkDeleteMapping("/{cartId}/attributes/{attributeKey}") public com.broadleafcommerce.cart.client.domain.Cart removeAttributeFromCart(@PathVariable String cartId, @PathVariable String attributeKey, @RequestParam(defaultValue="true") boolean price, Integer cartVersion, String guestToken, com.broadleafcommerce.order.common.domain.CustomerRef customer, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
resolveCartForRead
protected com.broadleafcommerce.cart.client.domain.Cart resolveCartForRead(String cartId, @Nullable Integer cartVersion, @Nullable com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
resolveCartForUpdate
protected 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)
-
resolveCart
protected com.broadleafcommerce.cart.client.domain.Cart resolveCart(@NonNull String cartId, @Nullable com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
protectCartOperationForGuest
@Deprecated protected <T> T protectCartOperationForGuest(Supplier<T> operation, com.broadleafcommerce.cart.client.domain.Cart initialCart, String guestToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Function<T,com.broadleafcommerce.cart.client.domain.Cart> cartExtractor)
Deprecated.Since 1.6.1, in favor ofprotectCartOperationForGuest(Function, Cart, String, ContextInfo)
Helper method to validate the guest token, execute the operation, extract the resulting cart, protect the resulting cart, and finally returning the response.- Type Parameters:
T
- the response type- Parameters:
operation
- the operation to execute as a supplierinitialCart
- the initial cartguestToken
- the guest tokencontextInfo
- the context infocartExtractor
- extracts the cart from the result- Returns:
- the response
-
protectCartOperationForGuest
@Deprecated protected com.broadleafcommerce.cart.client.domain.Cart protectCartOperationForGuest(Supplier<com.broadleafcommerce.cart.client.domain.Cart> operation, com.broadleafcommerce.cart.client.domain.Cart initialCart, String guestToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Since 1.6.1, in favor ofprotectCartOperationForGuest(Function, Cart, String, ContextInfo)
Delegates toprotectCartOperationForGuest(Supplier, Cart, String, ContextInfo, Function)
with the expectation that the operation returns aCart
and the extractor is a simple identity function.- Parameters:
operation
- the operation to execute as a supplierinitialCart
- the initial cartguestToken
- the guest tokencontextInfo
- the context info- Returns:
- the response
-
protectCartOperationForGuest
protected <T> T protectCartOperationForGuest(Function<com.broadleafcommerce.cart.client.domain.Cart,T> operation, com.broadleafcommerce.cart.client.domain.Cart initialCart, String guestToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Helper method to validate the guest token, protect the resolved cart, & execute the operation.- Type Parameters:
T
- the response type- Parameters:
operation
- the operation to execute as a functioninitialCart
- the initial cartguestToken
- the guest tokencontextInfo
- the context info- Returns:
- the response
-
validateGuestTokenIfNecessary
protected void validateGuestTokenIfNecessary(com.broadleafcommerce.cart.client.domain.Cart cart, String guestToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
If the provided cart is a guest cart, this will attempt to validate the guest token for the cart.- Parameters:
cart
- the cartguestToken
- the guest tokencontextInfo
- the context info
-
protectGuestCartIfNecessary
protected void protectGuestCartIfNecessary(com.broadleafcommerce.cart.client.domain.Cart cart, String guestToken)
If the provided cart is a guest cart, and there is no guest token, this will clear out any customer information from the cart.Note, this method does not persist the changes to the cart, and is only intended to be used as a last step before returning the cart object.
- Parameters:
cart
- the cartguestToken
- the guest token
-
protectGuestCartIfNecessary
protected com.broadleafcommerce.cart.client.domain.Cart protectGuestCartIfNecessary(com.broadleafcommerce.cart.client.domain.Cart cart, String guestToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
If the provided cart is a guest cart, and there is no guest token, then this will produce a cloned guest cart, excluding any customer data.- Parameters:
cart
- the cartguestToken
- the guest tokencontextInfo
- the context info- Returns:
- the protected cart
-
getCartResolverService
protected CartResolverService getCartResolverService()
-
getCartOperationService
protected CartOperationService getCartOperationService()
-
getCartTransferService
protected CartTransferService getCartTransferService()
-
getCartVersionValidationService
protected CartVersionValidationService getCartVersionValidationService()
-
getGuestCartProtectionService
protected GuestCartProtectionService getGuestCartProtectionService()
-
getGuestCartTokenValidator
protected GuestCartTokenValidator getGuestCartTokenValidator()
-
getItemListAddToCartService
protected ItemListAddToCartService getItemListAddToCartService()
-
-