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
ConstructorsConstructorDescriptionDefaultItemListAccessRuleService(ItemListAccessRuleRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.CrudEntityHelper helper) -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteAllByListIds(Collection<String> listIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Deletes all access rules that belong to multiple item listscom.broadleafcommerce.cart.client.domain.ItemListAccessResponsefilterItemListIdsByRoles(@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 intgetRolePrecedence(String role) 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, updateSortMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:ItemListAccessRuleServiceFind all access rules for a specific customer.- Specified by:
findAllByCustomerin interfaceItemListAccessRuleService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>- Parameters:
customerRef- a reference to the customer to find rules forpageable- the requested paged of access rulescontext- 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:ItemListAccessRuleServiceFinds an access rule for a given list and customer.- Specified by:
findByItemListIdAndCustomerin interfaceItemListAccessRuleService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>- Parameters:
itemListId- the ID of the item list to find access rules forcustomerRef- a reference to the customer to find rules forcontext- 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:ItemListAccessRuleServiceFilters item list IDs based on whether the customer has a specified role for them or not.- Specified by:
filterItemListIdsByRolesin interfaceItemListAccessRuleService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>- Parameters:
customerRef- a reference to the customer to find rules forroles- the roles to check access forlistIds- list of list item ids to checkcontext- 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:ItemListAccessRuleServiceFinds all access rules for a specific item list.- Specified by:
findAllByItemListIdin interfaceItemListAccessRuleService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>- Parameters:
itemListId- the ID of the item list to find access rules forpageable- the requested paged of access rulescontext- the context of the request- Returns:
- a page of access rules for the given item list
-
getRolePrecedence
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:ItemListAccessRuleServiceDeletes all access rules that belong to multiple item lists- Specified by:
deleteAllByListIdsin interfaceItemListAccessRuleService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>- Parameters:
listIds- list of item list idscontext- the request context information
-
getRepository
protected ItemListAccessRuleRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()- Overrides:
getRepositoryin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
-