Class ExternalItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
-
- com.broadleafcommerce.cartoperation.service.provider.external.ExternalItemListAccessRuleProvider<P>
-
- All Implemented Interfaces:
ItemListAccessRuleProvider<P>
public class ExternalItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule> extends AbstractExternalProvider implements ItemListAccessRuleProvider<P>
External (HTTP) implementation of an item list access rule provider.- Author:
- Jacob Mitash
-
-
Constructor Summary
Constructors Constructor Description ExternalItemListAccessRuleProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalCartProperties properties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description P
createItemListAccessRule(P rule, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Create an item list access rule.List<P>
createItemListAccessRules(@NonNull String itemListId, @NonNull List<P> rules, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Creates item list access rules.protected org.springframework.util.MultiValueMap<String,String>
customerRefToParams(@NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef)
Converts a customer reference to request params.void
deleteItemListAccessRule(@NonNull String itemListId, @NonNull String ruleId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Deletes an item list access rule by ID.void
deleteItemListAccessRules(@NonNull String itemListId, @NonNull Set<String> ruleIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Deletes item list access rules by IDs.protected org.springframework.web.util.UriComponentsBuilder
getBaseUri()
Gets the base URI common to all requests this provider will make.Optional<P>
getItemListAccessRuleForCustomerAndItemList(@NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull String itemListId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Get an item list access rule for a customer for specific list.org.springframework.data.domain.Page<P>
getItemListAccessRulesForCustomer(@NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Get item list access rules by customer.protected org.springframework.core.ParameterizedTypeReference<List<P>>
getListType()
Gets the type reference for a list of access rules.protected org.springframework.core.ParameterizedTypeReference<ResponsePageGenerator<P>>
getPageType()
Gets the type reference for a page generator of access rules.protected ExternalCartProperties
getProperties()
protected String
getServiceClient()
protected org.springframework.core.ParameterizedTypeReference<P>
getType()
Gets the type reference for a list of access rules.P
replaceItemListAccessRule(@NonNull String itemListId, P rule, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Replaces an item list access rule.P
updateItemListAccessRule(@NonNull String itemListId, P rule, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Updates an item list access rule.com.broadleafcommerce.cart.client.domain.ItemListAccessResponse
validateCustomerAccess(@NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull Set<String> itemListIds, @NonNull Set<String> roles, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Checks item list access rules for a list of item list ids based on the given customer ref and role-
Methods inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
executeRequest, getHeaders, getObjectMapper, getTypeFactory, getWebClient, pageableToParams, uriVars
-
-
-
-
Constructor Detail
-
ExternalItemListAccessRuleProvider
public ExternalItemListAccessRuleProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalCartProperties properties)
-
-
Method Detail
-
getItemListAccessRulesForCustomer
public org.springframework.data.domain.Page<P> getItemListAccessRulesForCustomer(@NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @Nullable org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:ItemListAccessRuleProvider
Get item list access rules by customer.- Specified by:
getItemListAccessRulesForCustomer
in interfaceItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
- Parameters:
customerRef
- the reference to the customer for which to find rules forpageable
- the requested page of access rulescontext
- the context of the request- Returns:
- a page of item list access rules
-
validateCustomerAccess
public com.broadleafcommerce.cart.client.domain.ItemListAccessResponse validateCustomerAccess(@NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull @NonNull Set<String> itemListIds, @NonNull @NonNull Set<String> roles, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:ItemListAccessRuleProvider
Checks item list access rules for a list of item list ids based on the given customer ref and role- Specified by:
validateCustomerAccess
in interfaceItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
- Parameters:
customerRef
- the customer to check access foritemListIds
- the list of item list ids to checkroles
- the access roles we want to verifycontext
- the context of the request- Returns:
- two lists, accessible and inaccessible item list ids
-
getItemListAccessRuleForCustomerAndItemList
public Optional<P> getItemListAccessRuleForCustomerAndItemList(@NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull @NonNull String itemListId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:ItemListAccessRuleProvider
Get an item list access rule for a customer for specific list.- Specified by:
getItemListAccessRuleForCustomerAndItemList
in interfaceItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
- Parameters:
customerRef
- the reference to the customer for which to find the rule foritemListId
- the ID of the item list to find the rule forcontext
- the context of the request- Returns:
- the item list access rule for the customer and list, or null if none was found
-
createItemListAccessRule
public P createItemListAccessRule(@NonNull P rule, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:ItemListAccessRuleProvider
Create an item list access rule.- Specified by:
createItemListAccessRule
in interfaceItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
- Parameters:
rule
- the rule to create (must contain item list ID)context
- the context of the request- Returns:
- the created access rule
-
createItemListAccessRules
public List<P> createItemListAccessRules(@NonNull @NonNull String itemListId, @NonNull @NonNull List<P> rules, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:ItemListAccessRuleProvider
Creates item list access rules.- Specified by:
createItemListAccessRules
in interfaceItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
- Parameters:
itemListId
- the item list IDrules
- the rules to create (must belong to the same item list)context
- the context of the request- Returns:
- the created access rules
-
updateItemListAccessRule
public P updateItemListAccessRule(@NonNull @NonNull String itemListId, @NonNull P rule, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:ItemListAccessRuleProvider
Updates an item list access rule.- Specified by:
updateItemListAccessRule
in interfaceItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
- Parameters:
itemListId
- the item list IDrule
- the rule to update with (must include ID)context
- the context of the request- Returns:
- the updated item list access rule
-
replaceItemListAccessRule
public P replaceItemListAccessRule(@NonNull @NonNull String itemListId, @NonNull P rule, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:ItemListAccessRuleProvider
Replaces an item list access rule.- Specified by:
replaceItemListAccessRule
in interfaceItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
- Parameters:
itemListId
- the item list IDrule
- the rule to replace with (must include ID)context
- the context of the request- Returns:
- the replaced item list access rule
-
deleteItemListAccessRule
public void deleteItemListAccessRule(@NonNull @NonNull String itemListId, @NonNull @NonNull String ruleId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:ItemListAccessRuleProvider
Deletes an item list access rule by ID.- Specified by:
deleteItemListAccessRule
in interfaceItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
- Parameters:
itemListId
- the ID of the item list to delete fromruleId
- the ID of the access rulecontext
- the context of the request
-
deleteItemListAccessRules
public void deleteItemListAccessRules(@NonNull @NonNull String itemListId, @NonNull @NonNull Set<String> ruleIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:ItemListAccessRuleProvider
Deletes item list access rules by IDs.- Specified by:
deleteItemListAccessRules
in interfaceItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
- Parameters:
itemListId
- the ID of the item list to delete fromruleIds
- the IDs of the rules to deletecontext
- the context of the request
-
getBaseUri
protected org.springframework.web.util.UriComponentsBuilder getBaseUri()
Gets the base URI common to all requests this provider will make.- Returns:
- a URI components builder with the base URI set up
-
customerRefToParams
protected org.springframework.util.MultiValueMap<String,String> customerRefToParams(@NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef)
Converts a customer reference to request params.- Parameters:
customerRef
- the customer reference to convert- Returns:
- a map of query parameters
-
getType
protected org.springframework.core.ParameterizedTypeReference<P> getType()
Gets the type reference for a list of access rules.- Returns:
- type reference for a list of access rules
-
getListType
protected org.springframework.core.ParameterizedTypeReference<List<P>> getListType()
Gets the type reference for a list of access rules.- Returns:
- type reference for a list of access rules
-
getPageType
protected org.springframework.core.ParameterizedTypeReference<ResponsePageGenerator<P>> getPageType()
Gets the type reference for a page generator of access rules.- Returns:
- type reference for a page generator of access rules
-
getServiceClient
protected String getServiceClient()
-
getProperties
protected ExternalCartProperties getProperties()
-
-