Class DefaultItemListAccessRuleService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>

java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.cart.service.DefaultItemListAccessRuleService<P>
All Implemented Interfaces:
ItemListAccessRuleService<P>, com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>

public class DefaultItemListAccessRuleService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule> extends com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P> implements ItemListAccessRuleService<P>
Default implementation of an item list access rule service.
Author:
Jacob Mitash
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultItemListAccessRuleService(ItemListAccessRuleRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.CrudEntityHelper helper)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    deleteAllByListIds(Collection<String> listIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Deletes all access rules that belong to multiple item lists
    com.broadleafcommerce.cart.client.domain.ItemListAccessResponse
    filterItemListIdsByRoles(@NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull Set<String> roles, @NonNull Set<String> listIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Filters item list IDs based on whether the customer has a specified role for them or not.
    org.springframework.data.domain.Page<P>
    findAllByCustomer(@NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Find all access rules for a specific customer.
    org.springframework.data.domain.Page<P>
    findAllByItemListId(@NonNull String itemListId, @NonNull org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Finds all access rules for a specific item list.
    findByItemListIdAndCustomer(@NonNull String itemListId, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Finds an access rule for a given list and customer.
    protected ItemListAccessRuleRepository<com.broadleafcommerce.data.tracking.core.Trackable>
     
    protected int
    Gets the precedence of a role.

    Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService

    convertFromPersistentDomain, convertToPersistentDomain, create, createAll, createAllAllowingPartialSuccess, delete, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSort

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService

    create, createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSort
  • Constructor Details

    • DefaultItemListAccessRuleService

      public DefaultItemListAccessRuleService(ItemListAccessRuleRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.CrudEntityHelper helper)
  • Method Details

    • findAllByCustomer

      public org.springframework.data.domain.Page<P> findAllByCustomer(@NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull @NonNull org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: ItemListAccessRuleService
      Find all access rules for a specific customer.
      Specified by:
      findAllByCustomer in interface ItemListAccessRuleService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
      Parameters:
      customerRef - a reference to the customer to find rules for
      pageable - the requested paged of access rules
      context - the context of the request
      Returns:
      a page of access rules
    • findByItemListIdAndCustomer

      public P findByItemListIdAndCustomer(@NonNull @NonNull String itemListId, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: ItemListAccessRuleService
      Finds an access rule for a given list and customer.
      Specified by:
      findByItemListIdAndCustomer in interface ItemListAccessRuleService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
      Parameters:
      itemListId - the ID of the item list to find access rules for
      customerRef - a reference to the customer to find rules for
      context - the context of the request
      Returns:
      the access rule for the given list and customer
    • filterItemListIdsByRoles

      public com.broadleafcommerce.cart.client.domain.ItemListAccessResponse filterItemListIdsByRoles(@NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull @NonNull Set<String> roles, @NonNull @NonNull Set<String> listIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: ItemListAccessRuleService
      Filters item list IDs based on whether the customer has a specified role for them or not.
      Specified by:
      filterItemListIdsByRoles in interface ItemListAccessRuleService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
      Parameters:
      customerRef - a reference to the customer to find rules for
      roles - the roles to check access for
      listIds - list of list item ids to check
      context - the context of the request
      Returns:
      a access response with accessible and inaccessible list item ids for the request
    • findAllByItemListId

      public org.springframework.data.domain.Page<P> findAllByItemListId(@NonNull @NonNull String itemListId, @NonNull @NonNull org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: ItemListAccessRuleService
      Finds all access rules for a specific item list.
      Specified by:
      findAllByItemListId in interface ItemListAccessRuleService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
      Parameters:
      itemListId - the ID of the item list to find access rules for
      pageable - the requested paged of access rules
      context - the context of the request
      Returns:
      a page of access rules for the given item list
    • getRolePrecedence

      protected int getRolePrecedence(String role)
      Gets the precedence of a role. Used to determine the highest level of access if a customer has more than one access rule to a single list. Higher precedence means smaller value.
      Parameters:
      role - the role to get the precedence of
      Returns:
      the precedence of the role
    • deleteAllByListIds

      public void deleteAllByListIds(Collection<String> listIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: ItemListAccessRuleService
      Deletes all access rules that belong to multiple item lists
      Specified by:
      deleteAllByListIds in interface ItemListAccessRuleService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
      Parameters:
      listIds - list of item list ids
      context - the request context information
    • getRepository

      protected ItemListAccessRuleRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
      Overrides:
      getRepository in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>