Class DefaultCatalogService
java.lang.Object
com.broadleafcommerce.search.index.catalog.service.DefaultCatalogService
- All Implemented Interfaces:
CatalogService
Default implementation to read
products
from the Catalog Service.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCatalogService
(org.springframework.web.reactive.function.client.WebClient webClient, String catalogEndpoint, String readProductIdsPath, String readProductsPath) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addBatchProductIdFilter
(org.springframework.web.util.UriBuilder uriBuilder, List<String> ids) protected void
addProductConsolidationConfigurationParams
(org.springframework.web.util.UriBuilder uriBuilder) Adds the request parameters to configure the product consolidation request.protected String
buildReadBatchOfProductIdsUri
(String startId, int batchSize) protected String
Builds a catalog fetch URI with a filter containing a range of IDs of products to retrieve from catalog.protected String
protected com.broadleafcommerce.common.extension.intercommunication.ExternalClient
protected String
protected String
The service client to use when calling catalog.protected org.springframework.web.reactive.function.client.WebClient
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>
Reads a batch ofProducts
by an id.List<com.broadleafcommerce.search.catalog.core.domain.Product>
readBatchOfProducts
(List<String> ids) Reads a batch ofProducts
by their IDs.void
setExternalClient
(com.broadleafcommerce.common.extension.intercommunication.ExternalClient externalClient) void
setServiceClient
(String serviceClient) The service client to use when calling catalog.
-
Field Details
-
CLIENT_REGISTRATION_ID
- See Also:
-
RSQL_FILTER_PARAM
- See Also:
-
ID_START_QUERY_PARAM
- See Also:
-
SIZE_QUERY_PARAM
- See Also:
-
SORT_QUERY_PARAM
- See Also:
-
ID_IN_QUERY_PARAM
- See Also:
-
CONTEXT_ID
- See Also:
-
CONFIGURABLE_PARAM
- See Also:
-
INCLUDE_ALL_PRODUCT_ASSETS_PARAM
- See Also:
-
-
Constructor Details
-
DefaultCatalogService
-
-
Method Details
-
readBatchOfProductIds
public List<String> readBatchOfProductIds(@Nullable String startId, int batchSize) throws com.broadleafcommerce.search.api.SearchIndexException Description copied from interface:CatalogService
Reads a batch of IDs to be placed in a queue for processing.- Specified by:
readBatchOfProductIds
in 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
-
readBatchOfProducts
public List<com.broadleafcommerce.search.catalog.core.domain.Product> readBatchOfProducts(List<String> ids) throws com.broadleafcommerce.search.api.SearchIndexException Description copied from interface:CatalogService
Reads a batch ofProducts
by their IDs.- Specified by:
readBatchOfProducts
in 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:CatalogService
Reads a batch ofProducts
by an id.- Specified by:
readBatchOfProducts
in 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.
-
buildReadBatchOfProductIdsUri
-
buildReadBatchOfProductsUri
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.
-
addProductConsolidationConfigurationParams
protected void addProductConsolidationConfigurationParams(org.springframework.web.util.UriBuilder uriBuilder) Adds the request parameters to configure the product consolidation request.- Parameters:
uriBuilder
- theUriBuilder
to add the request parameters for
-
addBatchProductIdFilter
-
getWebClient
protected org.springframework.web.reactive.function.client.WebClient getWebClient() -
getCatalogEndpoint
-
getReadProductIdsPath
-
getReadProductsPath
-
getExternalClient
protected com.broadleafcommerce.common.extension.intercommunication.ExternalClient getExternalClient() -
setExternalClient
@Autowired @Qualifier("catalogExternalClient") public void setExternalClient(com.broadleafcommerce.common.extension.intercommunication.ExternalClient externalClient) -
getServiceClient
The service client to use when calling catalog. Default is "indexerclient". -
setServiceClient
The service client to use when calling catalog. Default is "indexerclient".
-