Class ExternalCartOperationProvider<C extends com.broadleafcommerce.cart.client.domain.Cart>
java.lang.Object
com.broadleafcommerce.subscriptionoperation.service.provider.external.AbstractExternalProvider
com.broadleafcommerce.subscriptionoperation.service.provider.external.ExternalCartOperationProvider<C>
- All Implemented Interfaces:
CartOperationProvider<C>
public class ExternalCartOperationProvider<C extends com.broadleafcommerce.cart.client.domain.Cart>
extends AbstractExternalProvider
implements CartOperationProvider<C>
Default implementation of
CartOperationProvider for interacting with an external service.- Author:
- Nathan Moore (nathandmoore)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringHeader used to build the CustomerRef for the authenticated user while using a service client to call CartOps.Fields inherited from class com.broadleafcommerce.subscriptionoperation.service.provider.external.AbstractExternalProvider
ENTITY_NOT_FOUND, RSQL_FILTER_PARAM, SANDBOX_AWARE_HEADER -
Constructor Summary
ConstructorsConstructorDescriptionExternalCartOperationProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalCartOperationProviderProperties properties, com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAdditionalHeaders(org.springframework.http.HttpHeaders headers) protected com.broadleafcommerce.order.common.domain.CustomerRefprotected com.broadleafcommerce.order.common.domain.CustomerRefBuilds aCustomerRefspecifically for a CSR operating as themselves rather than impersonating a customer or anonymous guest.lcreateCart(@NonNull CreateCartRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Method used to create a newCart.protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtilsprotected org.springframework.web.util.UriComponentsBuilderGets the base URI common to all requests this provider will make.protected org.springframework.core.ParameterizedTypeReference<C>Gets the type reference for a page generator of item list items.protected jakarta.servlet.http.HttpServletRequestprotected ExternalCartOperationProviderPropertiesprotected StringGets the name of the authorized client for this service making the call.protected voidpopulateAccountFields(@NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef) Populates the account-related fields for the givenCustomerReffrom current authentication context.voidsetHttpServletRequest(jakarta.servlet.http.HttpServletRequest httpServletRequest) Methods inherited from class com.broadleafcommerce.subscriptionoperation.service.provider.external.AbstractExternalProvider
addOffsetOrPageNumber, buildNotFoundException, executeRequest, getHeaders, getObjectMapper, getTypeFactory, getWebClient, isEntityNotFound, pageableToParams, uriVars
-
Field Details
-
CUSTOMER_REF_HEADER
Header used to build the CustomerRef for the authenticated user while using a service client to call CartOps.- See Also:
-
-
Constructor Details
-
ExternalCartOperationProvider
public ExternalCartOperationProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalCartOperationProviderProperties properties, com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils)
-
-
Method Details
-
createCart
public C createCart(@NonNull @NonNull CreateCartRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartOperationProviderMethod used to create a newCart.- Specified by:
createCartin interfaceCartOperationProvider<C extends com.broadleafcommerce.cart.client.domain.Cart>- Parameters:
request- The information needed to create a new cart.contextInfo- The sandbox and multitenant context- Returns:
- The created cart.
-
addAdditionalHeaders
protected void addAdditionalHeaders(org.springframework.http.HttpHeaders headers) -
buildCustomerRef
protected com.broadleafcommerce.order.common.domain.CustomerRef buildCustomerRef() -
buildCustomerRefForCSR
protected com.broadleafcommerce.order.common.domain.CustomerRef buildCustomerRefForCSR()Builds aCustomerRefspecifically for a CSR operating as themselves rather than impersonating a customer or anonymous guest.l- Returns:
- The
CustomerRefobject.
-
populateAccountFields
protected void populateAccountFields(@NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef) Populates the account-related fields for the givenCustomerReffrom current authentication context.- Parameters:
customerRef- theCustomerRefto populate the account-related fields for
-
getBaseUri
protected org.springframework.web.util.UriComponentsBuilder getBaseUri()Gets the base URI common to all requests this provider will make.- Returns:
- a URI components builder with the base URI set up
-
getServiceClient
Gets the name of the authorized client for this service making the call.- Returns:
- The name of the authorized client for this service making the call.
-
getCartType
Gets the type reference for a page generator of item list items.- Returns:
- type reference for a page generator of item list items
-
getProperties
-
getAuthenticationUtils
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils() -
getHttpServletRequest
protected jakarta.servlet.http.HttpServletRequest getHttpServletRequest() -
setHttpServletRequest
@Autowired public void setHttpServletRequest(jakarta.servlet.http.HttpServletRequest httpServletRequest)
-