Class ExternalCatalogProvider
java.lang.Object
com.broadleafcommerce.catalogbrowse.service.provider.external.AbstractExternalProvider
com.broadleafcommerce.catalogbrowse.service.provider.external.catalog.ExternalCatalogProvider
- All Implemented Interfaces:
BrowseEntityProvider,CatalogProvider
Connects to an external catalog service.
- Author:
- Nathan Moore (nathandmoore)
-
Constructor Summary
ConstructorsConstructorDescriptionExternalCatalogProvider(org.springframework.web.reactive.function.client.WebClient catalogBrowseWebClient, com.fasterxml.jackson.databind.ObjectMapper mapper, PricingProvider browsePricingProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptiondataDrivenEnumDetailsRequestToParams(@NonNull DataDrivenEnumDetailsRequest detailsRequest) Converts aDataDrivenEnumDetailsRequestto request params.Retrieves the categories with details for the requests.fetchBrowseEntityDetails(@NonNull BrowseDetailsRequest request) Retrieves a browse entity such as aProductthat matches the givenrequest.fetchCartFieldMappings(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a list of mappings between product and cart item.fetchCategoryWithDetails(@NonNull CategoryDetailsRequest request) Retrieves the category with details for the request.fetchDataDrivenEnumsWithDetails(@NonNull DataDrivenEnumDetailsRequest request) Retrieves the data driven enum list with details for the request.fetchProductsWithDetails(@NonNull ProductDetailsRequest request) Retrieves the product list with details for the request.protected Stringprotected InventoryProviderprotected PricingProviderprotected Stringprotected org.springframework.web.reactive.function.client.WebClientprotected StringgetCustomerContextParams(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) getCustomerContextParams(com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Stringprotected Stringprotected com.broadleafcommerce.common.extension.intercommunication.ExternalClientprotected reactor.core.publisher.Mono<ProductList>getProductList(org.springframework.web.reactive.function.client.WebClientResponseException ex) protected Stringprotected Stringprotected ExternalCatalogProviderPropertiesprotected Stringprotected com.broadleafcommerce.common.extension.TypeFactoryprotected StringgetUrl()<T extends Product>
voidhydrateProductAssets(@NonNull Collection<T> products, org.springframework.util.MultiValueMap<String, String> parameters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves theAssetsfor the providedproductsand populates them ontoProduct.setAssets(java.util.List<com.broadleafcommerce.catalogbrowse.domain.Asset>).hydrateProductsAvailability(@NonNull List<T> toHydrate, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hydrates inventory availability onto the retrieved products.hydrateProductsPricing(@NonNull List<T> toHydrate, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hydrates pricing onto the retrieved products.<T extends Product>
voidhydrateProductTags(@NonNull Collection<T> products, org.springframework.util.MultiValueMap<String, String> parameters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves theProductTagsfor the providedproductsand populates them ontoProduct.getAdvancedTags().minimizeAssets(List<A> assets) Removes extraneous information from theAssetsto reduce response size, e.g., removeContextStatesince that is not usually useful for commerce users.protected voidpricePromotionalCategoryProducts(@NotNull Category category, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Makes a call to pricing service for any promotional products on the category.voidsetBrowseInventoryProvider(InventoryProvider browseInventoryProvider) voidsetProductDetailExternalClient(com.broadleafcommerce.common.extension.intercommunication.ExternalClient productDetailExternalClient) voidsetProperties(ExternalCatalogProviderProperties properties) Methods inherited from class com.broadleafcommerce.catalogbrowse.service.provider.external.AbstractExternalProvider
getAuthenticationUtils, getExternalProviderProperties, getHeaders, getHeaders, getMapper, isCallerWhitelistedService, setAuthenticationUtils, setExternalProviderProperties
-
Constructor Details
-
ExternalCatalogProvider
public ExternalCatalogProvider(@Qualifier("catalogBrowseWebClient") org.springframework.web.reactive.function.client.WebClient catalogBrowseWebClient, com.fasterxml.jackson.databind.ObjectMapper mapper, PricingProvider browsePricingProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
fetchProductsWithDetails
Description copied from interface:CatalogProviderRetrieves the product list with details for the request.- Specified by:
fetchProductsWithDetailsin interfaceCatalogProvider- Parameters:
request- All of the relevant information to be used to retrieve a product's details- Returns:
- The product list for the parameters provided.
-
fetchCategoryWithDetails
Description copied from interface:CatalogProviderRetrieves the category with details for the request.- Specified by:
fetchCategoryWithDetailsin interfaceCatalogProvider- Parameters:
request- All of the relevant information to be used to retrieve a category's details- Returns:
- The category for the parameters provided.
-
fetchAllCategoriesWithDetails
Description copied from interface:CatalogProviderRetrieves the categories with details for the requests.- Specified by:
fetchAllCategoriesWithDetailsin interfaceCatalogProvider- Parameters:
request- All of the relevant information to be used to retrieve a categories' details- Returns:
- The categories for the parameters provided.
-
fetchDataDrivenEnumsWithDetails
public DataDrivenEnumList fetchDataDrivenEnumsWithDetails(@NonNull @NonNull DataDrivenEnumDetailsRequest request) Description copied from interface:CatalogProviderRetrieves the data driven enum list with details for the request.- Specified by:
fetchDataDrivenEnumsWithDetailsin interfaceCatalogProvider- Parameters:
request- All of the relevant information to be used to retrieve a list of data driven enum with their details- Returns:
- The data driven enum list for the parameters provided.
-
fetchCartFieldMappings
public List<CartFieldMapping> fetchCartFieldMappings(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CatalogProviderRetrieves a list of mappings between product and cart item.- Specified by:
fetchCartFieldMappingsin interfaceCatalogProvider- Parameters:
contextInfo- Additional sandbox and multitenant info.- Returns:
- a list of mappings between product and cart item
-
dataDrivenEnumDetailsRequestToParams
protected org.springframework.util.MultiValueMap<String,String> dataDrivenEnumDetailsRequestToParams(@NonNull @NonNull DataDrivenEnumDetailsRequest detailsRequest) Converts aDataDrivenEnumDetailsRequestto request params.- Parameters:
detailsRequest- theDataDrivenEnumDetailsRequestto convert- Returns:
- a map of query parameters
-
hydrateProductAssets
public <T extends Product> void hydrateProductAssets(@NonNull @NonNull Collection<T> products, @Nullable org.springframework.util.MultiValueMap<String, String> parameters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CatalogProviderRetrieves theAssetsfor the providedproductsand populates them ontoProduct.setAssets(java.util.List<com.broadleafcommerce.catalogbrowse.domain.Asset>).Note that this is only necessary if assets are requested separately from product details such as for hydrating search results. Otherwise, they are already hydrated on the results of
CatalogProvider.fetchProductsWithDetails(com.broadleafcommerce.catalogbrowse.domain.ProductDetailsRequest)andCatalogProvider.fetchCategoryWithDetails(com.broadleafcommerce.catalogbrowse.domain.CategoryDetailsRequest).- Specified by:
hydrateProductAssetsin interfaceCatalogProvider- Parameters:
products-Productsto hydrate.parameters- Request parameters to include when fetching assetscontextInfo- Additional sandbox and multitenant info.
-
hydrateProductTags
public <T extends Product> void hydrateProductTags(@NonNull @NonNull Collection<T> products, @Nullable org.springframework.util.MultiValueMap<String, String> parameters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CatalogProviderRetrieves theProductTagsfor the providedproductsand populates them ontoProduct.getAdvancedTags().- Specified by:
hydrateProductTagsin interfaceCatalogProvider- Parameters:
products-Productsto hydrate.parameters- Request parameters to include when fetching assetscontextInfo- Additional sandbox and multitenant info.
-
fetchBrowseEntityDetails
Description copied from interface:BrowseEntityProviderRetrieves a browse entity such as aProductthat matches the givenrequest.- Specified by:
fetchBrowseEntityDetailsin interfaceBrowseEntityProvider- Parameters:
request- All of the relevant information to be used to retrieve a browse entity's details such as a list of URIs.- Returns:
- The details of the browse entities matching the
request
-
minimizeAssets
Removes extraneous information from theAssetsto reduce response size, e.g., removeContextStatesince that is not usually useful for commerce users. Setbroadleaf.catalogbrowse.catalogprovider.asset-minification-enabledto false to disable. -
getProductList
protected reactor.core.publisher.Mono<ProductList> getProductList(org.springframework.web.reactive.function.client.WebClientResponseException ex) -
pricePromotionalCategoryProducts
protected void pricePromotionalCategoryProducts(@NotNull @NotNull Category category, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Makes a call to pricing service for any promotional products on the category.- Parameters:
category- theCategoryto check promotional products onpriceContext-PriceContextfrom the originating requestpriceInfoContext-PriceInfoContextfrom the originating requestcontextInfo- Multitenant and sandbox info
-
hydrateProductsPricing
protected <T extends Product> List<T> hydrateProductsPricing(@NonNull @NonNull List<T> toHydrate, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hydrates pricing onto the retrieved products.- Type Parameters:
T- The type of theProducts- Parameters:
toHydrate- Products to hydratepriceContext-PriceContextfrom the originating requestpriceInfoContext-PriceInfoContextfrom the originating requestcontextInfo- Multitenant and sandbox info- Returns:
- A pricing-hydrated list of the provided products.
-
hydrateProductsAvailability
protected <T extends Product> List<T> hydrateProductsAvailability(@NonNull @NonNull List<T> toHydrate, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hydrates inventory availability onto the retrieved products.- Type Parameters:
T- The type of theProducts- Parameters:
toHydrate- Products to hydratecontextInfo- Multitenant and sandbox info- Returns:
- An availability-hydrated list of the provided products.
-
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>
-
getCustomerContextParams
protected org.springframework.util.MultiValueMap<String,String> getCustomerContextParams(@Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @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:
priceContext- PriceContext header.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> -
getUrl
-
getProductsUri
-
getProductAssetsUri
-
getCategoriesUri
-
getBrowseEntitiesUri
-
getDataDrivenEnumsUri
-
getCartFieldMappingsUri
-
getProductTagsUri
-
getServiceClient
-
getCatalogBrowseWebClient
protected org.springframework.web.reactive.function.client.WebClient getCatalogBrowseWebClient() -
getBrowsePricingProvider
-
getBrowseInventoryProvider
-
setBrowseInventoryProvider
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getProperties
-
setProperties
-
getProductDetailExternalClient
protected com.broadleafcommerce.common.extension.intercommunication.ExternalClient getProductDetailExternalClient() -
setProductDetailExternalClient
@Autowired @Qualifier("browseProductDetailExternalClient") public void setProductDetailExternalClient(com.broadleafcommerce.common.extension.intercommunication.ExternalClient productDetailExternalClient)
-