Class DefaultCatalogService
- java.lang.Object
-
- com.broadleafcommerce.search.index.catalog.service.DefaultCatalogService
-
- All Implemented Interfaces:
CatalogService
public class DefaultCatalogService extends Object implements CatalogService
Default implementation to readproductsfrom the Catalog Service.
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringCLIENT_REGISTRATION_ID
-
Constructor Summary
Constructors Constructor Description DefaultCatalogService(org.springframework.web.reactive.function.client.WebClient webClient, String catalogEndpoint, String readProductIdsPath, String readProductsPath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddBatchProductIdFilter(org.springframework.web.util.UriBuilder uriBuilder, List<String> ids)protected StringbuildReadBatchOfProductIdsUri(String startId, int batchSize)protected StringbuildReadBatchOfProductsUri(List<String> ids)Builds a catalog fetch URI with a filter containing a range of IDs of products to retrieve from catalog.protected StringgetCatalogEndpoint()protected StringgetReadProductIdsPath()protected StringgetReadProductsPath()StringgetServiceClient()The service client to use when calling catalog.protected org.springframework.web.reactive.function.client.WebClientgetWebClient()List<String>readBatchOfProductIds(String startId, int batchSize)Reads a batch of IDs to be placed in a queue for processing.List<com.broadleafcommerce.search.catalog.core.domain.Product>readBatchOfProducts(String id)Reads a batch ofProductsby an id.List<com.broadleafcommerce.search.catalog.core.domain.Product>readBatchOfProducts(List<String> ids)Reads a batch ofProductsby their IDs.voidsetServiceClient(String serviceClient)The service client to use when calling catalog.
-
-
-
Field Detail
-
CLIENT_REGISTRATION_ID
protected static final String CLIENT_REGISTRATION_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
readBatchOfProductIds
public List<String> readBatchOfProductIds(@Nullable String startId, int batchSize) throws com.broadleafcommerce.search.api.SearchIndexException
Description copied from interface:CatalogServiceReads a batch of IDs to be placed in a queue for processing.- Specified by:
readBatchOfProductIdsin interfaceCatalogService- Parameters:
startId- The starting IDbatchSize- The size of the batch to read- Returns:
- A list of product IDs.
- Throws:
com.broadleafcommerce.search.api.SearchIndexException
-
buildReadBatchOfProductIdsUri
protected String buildReadBatchOfProductIdsUri(@Nullable String startId, int batchSize)
-
readBatchOfProducts
public List<com.broadleafcommerce.search.catalog.core.domain.Product> readBatchOfProducts(List<String> ids) throws com.broadleafcommerce.search.api.SearchIndexException
Description copied from interface:CatalogServiceReads a batch ofProductsby their IDs.- Specified by:
readBatchOfProductsin interfaceCatalogService- Parameters:
ids- A list of product IDs.- Returns:
- A list of products or an empty list.
- Throws:
com.broadleafcommerce.search.api.SearchIndexException- if the service call fails for any reason.
-
readBatchOfProducts
public List<com.broadleafcommerce.search.catalog.core.domain.Product> readBatchOfProducts(String id) throws com.broadleafcommerce.search.api.SearchIndexException
Description copied from interface:CatalogServiceReads a batch ofProductsby an id.- Specified by:
readBatchOfProductsin interfaceCatalogService- Parameters:
id- A product ID.- Returns:
- A list of products or an empty list.
- Throws:
com.broadleafcommerce.search.api.SearchIndexException- if the service call fails for any reason.
-
buildReadBatchOfProductsUri
protected String buildReadBatchOfProductsUri(List<String> ids)
Builds a catalog fetch URI with a filter containing a range of IDs of products to retrieve from catalog.e.g. id=ge=1;id=le=10
The List of ids passed into this method should be in ascending order.
- Parameters:
ids- The list of ids- Returns:
- A URI for retrieving a list of products from catalog.
-
addBatchProductIdFilter
protected void addBatchProductIdFilter(org.springframework.web.util.UriBuilder uriBuilder, List<String> ids)
-
getWebClient
protected org.springframework.web.reactive.function.client.WebClient getWebClient()
-
getCatalogEndpoint
protected String getCatalogEndpoint()
-
getReadProductIdsPath
protected String getReadProductIdsPath()
-
getReadProductsPath
protected String getReadProductsPath()
-
getServiceClient
public String getServiceClient()
The service client to use when calling catalog. Default is "indexerclient".
-
setServiceClient
public void setServiceClient(String serviceClient)
The service client to use when calling catalog. Default is "indexerclient".
-
-