Class ExternalCatalogProvider

java.lang.Object
com.broadleafcommerce.datafeed.service.collector.provider.ExternalCatalogProvider
All Implemented Interfaces:
CatalogProvider

public class ExternalCatalogProvider extends Object implements CatalogProvider
Default implementation of CatalogProvider.
Author:
Kelly Tisdell (ktisdell)
  • Constructor Details

    • ExternalCatalogProvider

      public ExternalCatalogProvider(org.springframework.web.reactive.function.client.WebClient webClient, CatalogProviderProperties catalogProviderProperties, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ProviderUtil providerUtil)
  • Method Details

    • readIdBatchForPartialFeed

      public List<String> readIdBatchForPartialFeed(@NonNull @NonNull List<IncrementalDataFeedEntityUpdateRecord> updateRecords, @Nullable String filterString, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo)
      Description copied from interface: CatalogProvider
      Given a batch of IncrementalDataFeedEntityUpdateRecords, fetch Product IDs that correspond.
      Specified by:
      readIdBatchForPartialFeed in interface CatalogProvider
      Parameters:
      updateRecords - a list of records with references to products and their IDs
      filterString - a RSQL filter string, or null
      readContextInfo - the ContextInfo for reading the IDs
      Returns:
    • customizeReadIdBatchForPartialFeedMono

      protected <T> reactor.core.publisher.Mono<T> customizeReadIdBatchForPartialFeedMono(reactor.core.publisher.Mono<T> mono)
    • readIdBatchForFullFeed

      public List<String> readIdBatchForFullFeed(@Nullable String cursor, int batchSize, @Nullable String filterString, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CatalogProvider
      Reads a batch of Product IDs, in ascending order, starting at the cursor.
      Specified by:
      readIdBatchForFullFeed in interface CatalogProvider
      Parameters:
      cursor - the last ID fetched, or null
      batchSize - the number of IDs to fetch in a batch
      filterString - a RSQL filter string, or null
      contextInfo - the ContextInfo for reading the IDs
      Returns:
    • customizeReadIdBatchForFullFeedMono

      protected <T> reactor.core.publisher.Mono<T> customizeReadIdBatchForFullFeedMono(reactor.core.publisher.Mono<T> mono)
    • readProducts

      public List<CollectedProduct> readProducts(@NonNull @NonNull List<String> idBatch, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo)
      Description copied from interface: CatalogProvider
      Reads a batch of CollectedProducts from the batch of provided IDs.
      Specified by:
      readProducts in interface CatalogProvider
      Parameters:
      idBatch - batch of IDs for which to fetch products
      readContextInfo - contextInfo the ContextInfo for reading the IDs
      Returns:
    • customizeReadProductsMono

      protected <T> reactor.core.publisher.Mono<T> customizeReadProductsMono(reactor.core.publisher.Mono<T> mono)
    • buildReadBatchOfProductIdsUriForFullFeed

      protected String buildReadBatchOfProductIdsUriForFullFeed(@Nullable String startId, int batchSize, @Nullable String rsql)
    • buildReadBatchOfProductsUri

      protected String buildReadBatchOfProductsUri(@NonNull @NonNull List<String> ids)
      Builds a catalog fetch URI with a filter containing a range of IDs of products to retrieve from catalog.
      Parameters:
      ids - The list of ids
      Returns:
      A URI for retrieving a list of products from catalog.
    • deserializeBatchOfProductsResponse

      protected List<CollectedProduct> deserializeBatchOfProductsResponse(@Nullable List<com.fasterxml.jackson.databind.node.ObjectNode> productJsonObjects)
    • deserializeProduct

      protected CollectedProduct deserializeProduct(com.fasterxml.jackson.databind.node.ObjectNode productJson)
      Deserializes an ObjectNode into CollectedProduct.

      This manual process is necessary, as at the time of writing, concepts like JsonAnySetter and JsonAnyGetter do not fully support ObjectNode. Thus, we first read JSON as ObjectNode directly, then manually parse out specific properties we want to promote as first-class fields.

      Parameters:
      productJson - the ObjectNode representing the product JSON
      Returns:
      a CollectedProduct representation of the input
    • getWebClient

      protected org.springframework.web.reactive.function.client.WebClient getWebClient()
    • getCatalogProviderProperties

      protected CatalogProviderProperties getCatalogProviderProperties()
    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
    • getTypeFactory

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

      protected ProviderUtil getProviderUtil()