Interface VendorVisibilityHandler
-
- All Superinterfaces:
com.broadleafcommerce.common.extension.data.DataRoutePartitionAware
,org.springframework.core.Ordered
- All Known Implementing Classes:
CatalogDiscriminatedEntityVendorVisibilityHandler
public interface VendorVisibilityHandler extends com.broadleafcommerce.common.extension.data.DataRoutePartitionAware, org.springframework.core.Ordered
Certain entities can be "vendor discriminated", and may be associated to vendors in a variety of ways. Sometimes the entity may directly have a field describing its vendor association, and sometimes it may be indirectly associated to a vendor through a relationship with another entity.For example, in the pricing service, price list entities have a field directly stating which "vendorRef" they are associated with. Price data entities, however, have no such direct field. For price data entities, vendor discrimination implicitly applies through the price list the price data is associated to. Thus, for price data, accessibility would be determined by the set of "price list ids" that are associated with the provided "vendorRefs".
A
VendorVisibilityHandler
implementation is responsible for understanding how a particular entity's vendor discrimination is applied and performing key related operations.Implementations declare which entities they support via
canHandle(Class)
, and theVendorVisibilityManager
will delegate to the first that can handle it.Consumers should almost always call on
VendorVisibilityManager
and not call any of the methods in this interface directly.- See Also:
VendorVisibilityManager
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
canHandle(Class<?> persistedDomainEntityType)
Reports whether the handler supports operations on the given type.String
createVendorNarrowingFilter(Set<String> restrictedVendorRefs, ContextInfo contextInfo)
For the persisted domain entity type(s) supported by this handler, build aNode
filter string that can be used in queries for those entities that restricts results to only include data from therestrictedVendorRefs
.String
getAssociatedVendorRef(Object persistedDomainEntity, ContextInfo contextInfo)
Given apersistedDomainEntity
, determine what vendor it is associated to (if any).default int
getOrder()
boolean
isEntityMutableByVendorRestrictions(Object persistedDomainEntity, Set<String> restrictedVendorRefs, ContextInfo contextInfo)
Given apersistedDomainEntity
, report whether that entity is mutable by the given vendor restrictions.
-
-
-
Method Detail
-
canHandle
boolean canHandle(Class<?> persistedDomainEntityType)
Reports whether the handler supports operations on the given type. If supported, theVendorVisibilityManager
will delegate to it for various operations.- Parameters:
persistedDomainEntityType
- the type to check support for- Returns:
- true if the handler supports operations on the given type, false otherwise
-
isEntityMutableByVendorRestrictions
boolean isEntityMutableByVendorRestrictions(Object persistedDomainEntity, Set<String> restrictedVendorRefs, @Nullable ContextInfo contextInfo)
Given apersistedDomainEntity
, report whether that entity is mutable by the given vendor restrictions.This is particularly useful to validate whether an entity can be inserted or updated by a vendor-restricted authentication.
- Parameters:
persistedDomainEntity
- the persisted-domain entity to validate mutability for. This is guaranteed to only be an entity for whichcanHandle(Class)
returns true.restrictedVendorRefs
- the "vendorRef" (typically a vendor ID or code) of all vendors that mutability should be restricted to. Will never be empty.contextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- true if the entity is mutable by the given vendor restrictions, false otherwise
- See Also:
VendorVisibilityManager.isEntityMutableByVendorRestrictions(Object, Set, ContextInfo)
-
createVendorNarrowingFilter
String createVendorNarrowingFilter(Set<String> restrictedVendorRefs, @Nullable ContextInfo contextInfo)
For the persisted domain entity type(s) supported by this handler, build aNode
filter string that can be used in queries for those entities that restricts results to only include data from therestrictedVendorRefs
.This is particularly useful to prevent vendor-restricted authentications from accessing data outside of their allowed vendors.
Note that if there is any caching enabled for queries on the vendor-discriminated entity, the cache key generation must account for the fact that each authentication's restrictions may lead to different query results. See
VendorAwareCacheKeyEnhancer
for more information.- Parameters:
restrictedVendorRefs
- the "vendorRef" (typically a vendor ID or code) of all vendors that the results need to be restricted to. Will never be empty.contextInfo
- context information surrounding sandboxing/multitenant state. Some implementations may inform their filtration decisions with this.- Returns:
- a
Node
filter string that can be used to restrict results on supported entity type(s) to only include data from therestrictedVendorRefs
. Cannot return null. - See Also:
VendorVisibilityManager.createVendorNarrowingFilter(Class, Set, ContextInfo)
-
getAssociatedVendorRef
@Nullable String getAssociatedVendorRef(Object persistedDomainEntity, @Nullable ContextInfo contextInfo)
Given apersistedDomainEntity
, determine what vendor it is associated to (if any).- Parameters:
persistedDomainEntity
- the persisted-domain entity to determine the vendor association forcontextInfo
- context information surrounding multitenant state- Returns:
- the vendorRef that the given entity is associated to, or
null
if not associated to a vendor - See Also:
VendorVisibilityManager.getAssociatedVendorRef(Object, ContextInfo)
-
getOrder
default int getOrder()
- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-
-