Class ExternalCatalogProvider<I extends CatalogItem>
java.lang.Object
com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
com.broadleafcommerce.cartoperation.service.provider.external.ExternalCatalogProvider<I>
- All Implemented Interfaces:
CatalogProvider<I>
public class ExternalCatalogProvider<I extends CatalogItem>
extends AbstractExternalProvider
implements CatalogProvider<I>
This particular implementation of
CatalogProvider is designed to interact with a provider
that will provide fully hydrated catalog entities, i.e., there is no need for additional calls to
get a product's variants or item choices.- Author:
- Chad Harchar (charchar), Nathan Moore (nathandmoore)
-
Field Summary
Fields inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
ENTITY_NOT_FOUND -
Constructor Summary
ConstructorsConstructorDescriptionExternalCatalogProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalCatalogProperties properties) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.broadleafcommerce.pricing.client.domain.context.PriceContextaddUserTargets(com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Augmentsuser targetsonto thePriceContextbased on the available context information.protected StringbuildPriceContextHeader(@NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) protected com.broadleafcommerce.pricing.client.domain.UserTargetRefcreateUserTargetRef(String targetValue, String targetType) protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtilsprotected CartItemProductMappingProviderprotected org.springframework.core.ParameterizedTypeReferenceGets the type reference for the list of catalog items.getCustomerContextParams(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected ExternalCatalogPropertiesprotected StringgetRetrieveProductsUrl(Collection<String> productIds) Deprecated.protected StringgetRetrieveProductsUrl(Collection<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets the URL to retrieve products.protected Stringprotected UserTargetGenerationServiceretrieveCartItemProductMappings(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve a list of cart item to product mappingsretrieveCatalogItem(@NonNull CatalogItemRequest catalogItemRequest, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve the catalog item for the context information provided.retrieveCatalogItems(@NonNull Collection<CatalogItemRequest> catalogItemRequests, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve the catalog items for the context information provided.voidsetAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils) voidsetCartItemProductMappingProvider(CartItemProductMappingProvider cartItemProductMappingProvider) voidsetUserTargetGenerationService(UserTargetGenerationService userTargetGenerationService) 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.CatalogProvider
retrieveCatalogItem, retrieveCatalogItems, retrieveProduct, retrieveProducts
-
Constructor Details
-
ExternalCatalogProvider
public ExternalCatalogProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalCatalogProperties properties)
-
-
Method Details
-
retrieveCatalogItem
public I retrieveCatalogItem(@NonNull @NonNull CatalogItemRequest catalogItemRequest, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CatalogProviderRetrieve the catalog item for the context information provided. The item should be fully hydrated with all of its relationships including pricing (although not offers).The default implementation uses the product ID to fetch the catalog item.
- Specified by:
retrieveCatalogItemin interfaceCatalogProvider<I extends CatalogItem>- Parameters:
catalogItemRequest- The information required to retrieve the catalog item.priceContext- Pricing context information about the cartcontextInfo- Context information around sandbox and multitenant state.- Returns:
- The catalog item for the request and application provided.
-
retrieveCatalogItems
public CatalogItemList<I> retrieveCatalogItems(@NonNull @NonNull Collection<CatalogItemRequest> catalogItemRequests, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CatalogProviderRetrieve the catalog items for the context information provided. The items should be fully hydrated with all of their relationships including pricing (although not offers).The default implementation uses the product IDs to fetch the list of catalog items.
- Specified by:
retrieveCatalogItemsin interfaceCatalogProvider<I extends CatalogItem>- Parameters:
catalogItemRequests- The information required to retrieve the catalog items.priceContext- ThePriceContextthat is used to retrieve the correct item prices.contextInfo- Context information around sandbox and multitenant state.- Returns:
- The catalog items for the request and application provided.
-
buildPriceContextHeader
protected String buildPriceContextHeader(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) -
retrieveCartItemProductMappings
public List<CartItemMappingProperties.FieldMapping> retrieveCartItemProductMappings(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CatalogProviderRetrieve a list of cart item to product mappings- Specified by:
retrieveCartItemProductMappingsin interfaceCatalogProvider<I extends CatalogItem>- Parameters:
contextInfo- Context information around sandbox and multitenant state.- Returns:
- The list of FieldMapping
-
getRetrieveProductsUrl
Deprecated. -
getRetrieveProductsUrl
protected String getRetrieveProductsUrl(Collection<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets the URL to retrieve products.The
skipPricing=trueparameter is added as the catalog items will be priced separately.- Parameters:
productIds- the ids of the products to retrievecontextInfo- the contextInfo for the request- Returns:
- the URL to retrieve products
-
getServiceClient
-
getCustomerContextParams
protected org.springframework.util.MultiValueMap<String,String> getCustomerContextParams(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aorg.springframework.util.MultiValueMap<String,that includes params related to the currently authenticated user and any dynamic customer segments that should be passed along to the backing service.String> - Parameters:
contextInfo- Additional tenant and sandbox info along with dynamic customer segments.- Returns:
- A
org.springframework.util.MultiValueMap<String,that includes params related to the currently authenticated user and any dynamic customer segments that should be passed along to the backing service.String>
-
getAuthenticationParams
Builds aorg.springframework.util.MultiValueMap<String,that includes params related to the currently authenticated user that should be passed along to the backing service. This is needed because the authentication in that service will belong to the Cart Operations Client rather than the authenticated user.String> -
addUserTargets
protected com.broadleafcommerce.pricing.client.domain.context.PriceContext addUserTargets(@Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Augmentsuser targetsonto thePriceContextbased on the available context information. IfpriceContextis null, it will be initialized.- Parameters:
priceContext- The priceContext to add user targets tocontextInfo- Additional tenant and sandbox info along with dynamic customer segments.- Returns:
- A
PriceContextwith hydrateduser targets.
-
createUserTargetRef
-
getCatalogItemListType
protected org.springframework.core.ParameterizedTypeReference getCatalogItemListType()Gets the type reference for the list of catalog items.By default, this returns a
CatalogItemListof items extending typeProduct.- Returns:
- type reference for the list of catalog items
-
getProperties
-
getAuthenticationUtils
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils() -
setAuthenticationUtils
@Autowired public void setAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils) -
setCartItemProductMappingProvider
@Autowired public void setCartItemProductMappingProvider(CartItemProductMappingProvider cartItemProductMappingProvider) -
getCartItemProductMappingProvider
-
setUserTargetGenerationService
@Autowired public void setUserTargetGenerationService(UserTargetGenerationService userTargetGenerationService) -
getUserTargetGenerationService
-