Class DefaultCartNoteOperationService<P extends com.broadleafcommerce.cart.client.domain.CartNote>
java.lang.Object
com.broadleafcommerce.cartoperation.service.note.DefaultCartNoteOperationService<P>
- All Implemented Interfaces:
CartNoteOperationService<P>
public class DefaultCartNoteOperationService<P extends com.broadleafcommerce.cart.client.domain.CartNote>
extends Object
implements CartNoteOperationService<P>
-
Constructor Summary
ConstructorDescriptionDefaultCartNoteOperationService
(QuoteAuthUtils quoteAuthUtils, CartNoteProvider<P> cartNoteProvider) -
Method Summary
Modifier and TypeMethodDescriptionprotected cz.jirutka.rsql.parser.ast.Node
buildCartNoteFilters
(@NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, String cartItemId, @NonNull cz.jirutka.rsql.parser.ast.Node existingFilters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds theNode
filters based on the cart item id and the currently authenticatedCustomerRef
used to retrieveCartNotes
.createCartNote
(P cartNote, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Create a new cart note.void
deleteCartNote
(@NonNull String cartId, @NonNull String cartNoteId, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deletes the cart note.protected CartNoteProvider<P>
protected QuoteAuthUtils
protected P
populateAuthorDetails
(P cartNote, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates theCartNote
's author details.org.springframework.data.domain.Page<P>
readByCartId
(@NonNull String cartId, boolean cartLevelOnly, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves all cart notes based on the given cart id and filter.org.springframework.data.domain.Page<P>
readByCartItemId
(@NonNull String cartId, @NonNull String cartItemId, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves all cart notes based on the given cart item id and filter.replaceCartNote
(@NonNull String cartId, @NonNull String cartNoteId, P cartNote, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Replaces the cart note.protected void
validateCartNoteOwnership
(@NonNull String cartId, @NonNull String cartNoteId, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates the ownership of aCartNote
.
-
Constructor Details
-
DefaultCartNoteOperationService
public DefaultCartNoteOperationService(QuoteAuthUtils quoteAuthUtils, CartNoteProvider<P> cartNoteProvider)
-
-
Method Details
-
createCartNote
public P createCartNote(@NonNull P cartNote, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartNoteOperationService
Create a new cart note.- Specified by:
createCartNote
in interfaceCartNoteOperationService<P extends com.broadleafcommerce.cart.client.domain.CartNote>
- Parameters:
cartNote
- the cart note to createcustomerRef
- the currently authenticatedCustomerRef
contextInfo
- context information around sandbox and multitenant state.- Returns:
- the created cart note.
-
readByCartId
public org.springframework.data.domain.Page<P> readByCartId(@NonNull @NonNull String cartId, boolean cartLevelOnly, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull @NonNull 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:CartNoteOperationService
Retrieves all cart notes based on the given cart id and filter.- Specified by:
readByCartId
in interfaceCartNoteOperationService<P extends com.broadleafcommerce.cart.client.domain.CartNote>
- Parameters:
cartId
- the id of the cart to find the notes forcartLevelOnly
- whether to retrieve cart-level notes onlyfilters
- the filters to applypageable
- the requested page of resultscontextInfo
- context information around sandbox and multitenant state.- Returns:
- the cart notes based on the given cart id and filter
-
readByCartItemId
public org.springframework.data.domain.Page<P> readByCartItemId(@NonNull @NonNull String cartId, @NonNull @NonNull String cartItemId, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull @NonNull 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:CartNoteOperationService
Retrieves all cart notes based on the given cart item id and filter.This is used to retrieve CartItem-level notes.
- Specified by:
readByCartItemId
in interfaceCartNoteOperationService<P extends com.broadleafcommerce.cart.client.domain.CartNote>
- Parameters:
cartId
- the id of the cart to find the notes forcartItemId
- the id of the cart item to find the notes forfilters
- the filters to applypageable
- the requested page of resultscontextInfo
- context information around sandbox and multitenant state.- Returns:
- the cart notes based on the given cart id and filter
-
replaceCartNote
public P replaceCartNote(@NonNull @NonNull String cartId, @NonNull @NonNull String cartNoteId, @NonNull P cartNote, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartNoteOperationService
Replaces the cart note.- Specified by:
replaceCartNote
in interfaceCartNoteOperationService<P extends com.broadleafcommerce.cart.client.domain.CartNote>
- Parameters:
cartId
- the id of the cart that this note belongs tocartNoteId
- the id of the cart note that is being replacedcartNote
- the cart note payloadcontextInfo
- context information around sandbox and multitenant state.- Returns:
- the updated cart note
-
deleteCartNote
public void deleteCartNote(@NonNull @NonNull String cartId, @NonNull @NonNull String cartNoteId, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartNoteOperationService
Deletes the cart note.- Specified by:
deleteCartNote
in interfaceCartNoteOperationService<P extends com.broadleafcommerce.cart.client.domain.CartNote>
- Parameters:
cartId
- the id of the cart that this note belongs tocartNoteId
- the id of the cart note that is being deletedcontextInfo
- context information around sandbox and multitenant state.
-
populateAuthorDetails
protected P populateAuthorDetails(@NonNull P cartNote, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates theCartNote
's author details.- Parameters:
cartNote
- theCartNote
to populate the author details forcustomerRef
- the currently authenticatedCustomerRef
contextInfo
- context information around sandbox and multitenant state.- Returns:
- the
CartNote
populated with author details.
-
buildCartNoteFilters
protected cz.jirutka.rsql.parser.ast.Node buildCartNoteFilters(@NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @Nullable String cartItemId, @NonNull @NonNull cz.jirutka.rsql.parser.ast.Node existingFilters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds theNode
filters based on the cart item id and the currently authenticatedCustomerRef
used to retrieveCartNotes
.If the currently authenticated user is not a sales rep, see
QuoteAuthUtils.isSalesRep(ContextInfo)
, then a filter forCartNote.isInternalOnly()
is added to prevent non-sales-rep users from seeing internal notes.- Parameters:
customerRef
- the currently authenticatedCustomerRef
cartItemId
- the cart item id that the notes belong to, this is only relevant for cart item level notesexistingFilters
- exising filters to build on top of- Returns:
- the
Node
filters based on the cart item id and the currently authenticatedCustomerRef
-
validateCartNoteOwnership
protected void validateCartNoteOwnership(@NonNull @NonNull String cartId, @NonNull @NonNull String cartNoteId, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates the ownership of aCartNote
.- Parameters:
cartId
- the id of the cart that theCartNote
belongs tocartNoteId
- the id of theCartNote
being validatedcustomerRef
- the currently authenticatedCustomerRef
contextInfo
- context information surrounding sandboxing and multitenant state- Throws:
CartNoteAccessException
- if the currently authenticated user doesn't have access
-
getQuoteAuthUtils
-
getCartNoteProvider
-