java.lang.Object
com.broadleafcommerce.catalogbrowse.service.provider.external.AbstractExternalProvider
com.broadleafcommerce.catalogbrowse.service.provider.external.catalog.ExternalCatalogProvider
All Implemented Interfaces:
BrowseEntityProvider, CatalogProvider

public class ExternalCatalogProvider extends AbstractExternalProvider implements CatalogProvider
Connects to an external catalog service.
Author:
Nathan Moore (nathandmoore)
  • 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

      public ProductList fetchProductsWithDetails(@NonNull @NonNull ProductDetailsRequest request)
      Description copied from interface: CatalogProvider
      Retrieves the product list with details for the request.
      Specified by:
      fetchProductsWithDetails in interface CatalogProvider
      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

      public Category fetchCategoryWithDetails(@NonNull @NonNull CategoryDetailsRequest request)
      Description copied from interface: CatalogProvider
      Retrieves the category with details for the request.
      Specified by:
      fetchCategoryWithDetails in interface CatalogProvider
      Parameters:
      request - All of the relevant information to be used to retrieve a category's details
      Returns:
      The category for the parameters provided.
    • fetchAllCategoriesWithDetails

      public CategoryList fetchAllCategoriesWithDetails(BulkCategoryDetailsRequest request)
      Description copied from interface: CatalogProvider
      Retrieves the categories with details for the requests.
      Specified by:
      fetchAllCategoriesWithDetails in interface CatalogProvider
      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: CatalogProvider
      Retrieves the data driven enum list with details for the request.
      Specified by:
      fetchDataDrivenEnumsWithDetails in interface CatalogProvider
      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: CatalogProvider
      Retrieves a list of mappings between product and cart item.
      Specified by:
      fetchCartFieldMappings in interface CatalogProvider
      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 a DataDrivenEnumDetailsRequest to request params.
      Parameters:
      detailsRequest - the DataDrivenEnumDetailsRequest to 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: CatalogProvider
      Retrieves the Assets for the provided products and populates them onto Product.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) and CatalogProvider.fetchCategoryWithDetails(com.broadleafcommerce.catalogbrowse.domain.CategoryDetailsRequest).
      Specified by:
      hydrateProductAssets in interface CatalogProvider
      Parameters:
      products - Products to hydrate.
      parameters - Request parameters to include when fetching assets
      contextInfo - 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: CatalogProvider
      Retrieves the ProductTags for the provided products and populates them onto Product.getAdvancedTags().
      Specified by:
      hydrateProductTags in interface CatalogProvider
      Parameters:
      products - Products to hydrate.
      parameters - Request parameters to include when fetching assets
      contextInfo - Additional sandbox and multitenant info.
    • fetchBrowseEntityDetails

      public BrowseEntityDetails fetchBrowseEntityDetails(@NonNull @NonNull BrowseDetailsRequest request)
      Description copied from interface: BrowseEntityProvider
      Retrieves a browse entity such as a Product that matches the given request.
      Specified by:
      fetchBrowseEntityDetails in interface BrowseEntityProvider
      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

      protected <A extends Asset> List<A> minimizeAssets(List<A> assets)
      Removes extraneous information from the Assets to reduce response size, e.g., remove ContextState since that is not usually useful for commerce users. Set broadleaf.catalogbrowse.catalogprovider.asset-minification-enabled to false to disable.
      Type Parameters:
      A - The specific type of Asset for extensions.
      Parameters:
      assets - List of Assets
      Returns:
      The minimized assets.
    • 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 - the Category to check promotional products on
      priceContext - PriceContext from the originating request
      priceInfoContext - PriceInfoContext from the originating request
      contextInfo - 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 the Products
      Parameters:
      toHydrate - Products to hydrate
      priceContext - PriceContext from the originating request
      priceInfoContext - PriceInfoContext from the originating request
      contextInfo - 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 the Products
      Parameters:
      toHydrate - Products to hydrate
      contextInfo - 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 a org.springframework.util.MultiValueMap<String,String> that includes params related to the currently authenticated user and any dynamic customer segments that should be passed along to the backing service.
      Parameters:
      contextInfo - Additional tenant and sandbox info along with dynamic customer segments.
      Returns:
      A org.springframework.util.MultiValueMap<String,String> that includes params related to the currently authenticated user and any dynamic customer segments that should be passed along to the backing service.
    • 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 a org.springframework.util.MultiValueMap<String,String> that includes params related to the currently authenticated user and any dynamic customer segments that should be passed along to the backing service.
      Parameters:
      priceContext - PriceContext header.
      contextInfo - Additional tenant and sandbox info along with dynamic customer segments.
      Returns:
      A org.springframework.util.MultiValueMap<String,String> that includes params related to the currently authenticated user and any dynamic customer segments that should be passed along to the backing service.
    • getAuthenticationParams

      protected org.springframework.util.MultiValueMap<String,String> getAuthenticationParams()
      Builds a org.springframework.util.MultiValueMap<String,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.
      Returns:
      A org.springframework.util.MultiValueMap<String,String> that includes params related to the currently authenticated user that should be passed along to the backing service
    • getUrl

      protected String getUrl()
    • getProductsUri

      protected String getProductsUri()
    • getProductAssetsUri

      protected String getProductAssetsUri()
    • getCategoriesUri

      protected String getCategoriesUri()
    • getBrowseEntitiesUri

      protected String getBrowseEntitiesUri()
    • getDataDrivenEnumsUri

      protected String getDataDrivenEnumsUri()
    • getCartFieldMappingsUri

      protected String getCartFieldMappingsUri()
    • getProductTagsUri

      protected String getProductTagsUri()
    • getServiceClient

      protected String getServiceClient()
    • getCatalogBrowseWebClient

      protected org.springframework.web.reactive.function.client.WebClient getCatalogBrowseWebClient()
    • getBrowsePricingProvider

      protected PricingProvider getBrowsePricingProvider()
    • getBrowseInventoryProvider

      protected InventoryProvider getBrowseInventoryProvider()
    • setBrowseInventoryProvider

      @Autowired public void setBrowseInventoryProvider(InventoryProvider browseInventoryProvider)
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getProperties

      protected ExternalCatalogProviderProperties getProperties()
    • setProperties

      @Autowired public void setProperties(ExternalCatalogProviderProperties properties)
    • getProductDetailExternalClient

      protected com.broadleafcommerce.common.extension.intercommunication.ExternalClient getProductDetailExternalClient()
    • setProductDetailExternalClient

      @Autowired @Qualifier("browseProductDetailExternalClient") public void setProductDetailExternalClient(com.broadleafcommerce.common.extension.intercommunication.ExternalClient productDetailExternalClient)