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 Details

    • 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 Details

    • 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 interface ItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
      Parameters:
      customerRef - the reference to the customer for which to find rules for
      pageable - the requested page of access rules
      context - 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 interface ItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
      Parameters:
      customerRef - the customer to check access for
      itemListIds - the list of item list ids to check
      roles - the access roles we want to verify
      context - 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 interface ItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
      Parameters:
      customerRef - the reference to the customer for which to find the rule for
      itemListId - the ID of the item list to find the rule for
      context - 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 interface ItemListAccessRuleProvider<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 interface ItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
      Parameters:
      itemListId - the item list ID
      rules - 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 interface ItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
      Parameters:
      itemListId - the item list ID
      rule - 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 interface ItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
      Parameters:
      itemListId - the item list ID
      rule - 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 interface ItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
      Parameters:
      itemListId - the ID of the item list to delete from
      ruleId - the ID of the access rule
      context - 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 interface ItemListAccessRuleProvider<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
      Parameters:
      itemListId - the ID of the item list to delete from
      ruleIds - the IDs of the rules to delete
      context - 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()