Interface VendorVisibilityHandler
- All Superinterfaces:
com.broadleafcommerce.common.extension.data.DataRoutePartitionAware
,org.springframework.core.Ordered
- All Known Implementing Classes:
CatalogDiscriminatedEntityVendorVisibilityHandler
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 the
VendorVisibilityManager
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:
-
Field Summary
Fields inherited from interface com.broadleafcommerce.common.extension.data.DataRoutePartitionAware
ALL_MATCH
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Reports whether the handler supports operations on the given type.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
.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.Methods inherited from interface com.broadleafcommerce.common.extension.data.DataRoutePartitionAware
getDataRoutePartition
-
Method Details
-
canHandle
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:
-
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:
-
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:
-
getOrder
default int getOrder()- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-