Class ExternalCatalogProvider<I extends CatalogItem>
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
-
- com.broadleafcommerce.cartoperation.service.provider.external.ExternalCatalogProvider<I>
-
- All Implemented Interfaces:
CatalogProvider<I>
public class ExternalCatalogProvider<I extends CatalogItem> extends AbstractExternalProvider implements CatalogProvider<I>
This particular implementation ofCatalogProvider
is designed to interact with a provider that will provide fully hydrated catalog entities, i.e., there is no need for additional calls to get a product's variants or item choices.- Author:
- Chad Harchar (charchar), Nathan Moore (nathandmoore)
-
-
Field Summary
-
Fields inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
ENTITY_NOT_FOUND
-
-
Constructor Summary
Constructors Constructor Description ExternalCatalogProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalCatalogProperties properties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.springframework.util.MultiValueMap<String,String>
getAuthenticationParams()
Builds aMultiValueMap
that includes params related to the currently authenticated user that should be passed along to the backing service.protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils
getAuthenticationUtils()
protected CartItemProductMappingProvider
getCartItemProductMappingProvider()
protected org.springframework.core.ParameterizedTypeReference
getCatalogItemListType()
Gets the type reference for the list of catalog items.protected ExternalCatalogProperties
getProperties()
protected String
getRetrieveProductsUrl(Collection<String> productIds)
protected String
getServiceClient()
List<CartItemMappingProperties.FieldMapping>
retrieveCartItemProductMappings(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve a list of cart item to product mappingsI
retrieveCatalogItem(@NonNull CatalogItemRequest catalogItemRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the catalog item for the context information provided.CatalogItemList<I>
retrieveCatalogItems(@NonNull Collection<CatalogItemRequest> catalogItemRequests, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the catalog items for the context information provided.I
retrieveProduct(@NonNull String productId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the product for the context information provided.CatalogItemList<I>
retrieveProducts(@NonNull Collection<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieve the products for the context information provided.void
setAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils)
void
setCartItemProductMappingProvider(CartItemProductMappingProvider cartItemProductMappingProvider)
-
Methods inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
buildNotFoundException, executeRequest, getHeaders, getObjectMapper, getTypeFactory, getWebClient, isEntityNotFound, pageableToParams, uriVars
-
-
-
-
Constructor Detail
-
ExternalCatalogProvider
public ExternalCatalogProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalCatalogProperties properties)
-
-
Method Detail
-
retrieveProduct
public I retrieveProduct(@NonNull @NonNull String productId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CatalogProvider
Retrieve the product for the context information provided. The product should be fully hydrated with all of its relationships including pricing (although not offers).- Specified by:
retrieveProduct
in interfaceCatalogProvider<I extends CatalogItem>
- Parameters:
productId
- The id of the product to be retrieved.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The product for the id and application provided.
-
retrieveProducts
public CatalogItemList<I> retrieveProducts(@NonNull @NonNull Collection<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CatalogProvider
Retrieve the products for the context information provided. The products should be fully hydrated with all of their relationships including pricing (although not offers).- Specified by:
retrieveProducts
in interfaceCatalogProvider<I extends CatalogItem>
- Parameters:
productIds
- The ids of the products to be retrieved.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The products for the ids and application provided.
-
retrieveCatalogItem
public I retrieveCatalogItem(@NonNull @NonNull CatalogItemRequest catalogItemRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CatalogProvider
Retrieve the catalog item for the context information provided. The item should be fully hydrated with all of its relationships including pricing (although not offers).The default implementation uses the product ID to fetch the catalog item.
- Specified by:
retrieveCatalogItem
in interfaceCatalogProvider<I extends CatalogItem>
- Parameters:
catalogItemRequest
- The information required to retrieve the catalog item.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The catalog item for the request and application provided.
-
retrieveCatalogItems
public CatalogItemList<I> retrieveCatalogItems(@NonNull @NonNull Collection<CatalogItemRequest> catalogItemRequests, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CatalogProvider
Retrieve the catalog items for the context information provided. The items should be fully hydrated with all of their relationships including pricing (although not offers).The default implementation uses the product IDs to fetch the list of catalog items.
- Specified by:
retrieveCatalogItems
in interfaceCatalogProvider<I extends CatalogItem>
- Parameters:
catalogItemRequests
- The information required to retrieve the catalog items.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The catalog items for the request and application provided.
-
retrieveCartItemProductMappings
public List<CartItemMappingProperties.FieldMapping> retrieveCartItemProductMappings(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CatalogProvider
Retrieve a list of cart item to product mappings- Specified by:
retrieveCartItemProductMappings
in interfaceCatalogProvider<I extends CatalogItem>
- Parameters:
contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The list of FieldMapping
-
getRetrieveProductsUrl
protected String getRetrieveProductsUrl(Collection<String> productIds)
-
getServiceClient
protected String getServiceClient()
-
getAuthenticationParams
protected org.springframework.util.MultiValueMap<String,String> getAuthenticationParams()
Builds aMultiValueMap
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
MultiValueMap
that includes params related to the currently authenticated user that should be passed along to the backing service
-
getCatalogItemListType
protected org.springframework.core.ParameterizedTypeReference getCatalogItemListType()
Gets the type reference for the list of catalog items.By default, this returns a
CatalogItemList
of items extending typeProduct
.- Returns:
- type reference for the list of catalog items
-
getProperties
protected ExternalCatalogProperties getProperties()
-
getAuthenticationUtils
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils()
-
setAuthenticationUtils
@Autowired public void setAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils)
-
setCartItemProductMappingProvider
@Autowired public void setCartItemProductMappingProvider(CartItemProductMappingProvider cartItemProductMappingProvider)
-
getCartItemProductMappingProvider
protected CartItemProductMappingProvider getCartItemProductMappingProvider()
-
-