Class DefaultVendorVisibilityManager
- All Implemented Interfaces:
VendorVisibilityManager
VendorVisibilityManager
.-
Constructor Summary
ConstructorDescriptionDefaultVendorVisibilityManager
(List<VendorVisibilityHandler> handlers, com.broadleafcommerce.common.extension.data.DataRouteReference dataRouteReference) -
Method Summary
Modifier and TypeMethodDescriptioncreateVendorNarrowingFilter
(@NonNull Class<?> persistedDomainEntityTypeBeingRead, @NonNull Set<String> restrictedVendorRefs, ContextInfo contextInfo) Given apersistedDomainEntityTypeBeingRead
that is being read in a query, return aNode
filter string for it 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).protected com.broadleafcommerce.common.extension.data.DataRouteReference
protected List<VendorVisibilityHandler>
protected Optional<VendorVisibilityHandler>
getHandlerSupportingOperationsOnEntity
(Class<?> persistedDomainEntityType) boolean
isEntityMutableByVendorRestrictions
(@NonNull Object persistedDomainEntity, @NonNull Set<String> restrictedVendorRefs, ContextInfo contextInfo) Given apersistedDomainEntity
, report whether that entity is mutable by the given vendor restrictions.boolean
supportsVendorDiscrimination
(@NonNull Class<?> persistedDomainEntityType) Ultimately reports whether this manager has aVendorVisibilityHandler
which can support the providedpersistedDomainEntityType
.
-
Constructor Details
-
DefaultVendorVisibilityManager
public DefaultVendorVisibilityManager(List<VendorVisibilityHandler> handlers, @Nullable com.broadleafcommerce.common.extension.data.DataRouteReference dataRouteReference)
-
-
Method Details
-
supportsVendorDiscrimination
Description copied from interface:VendorVisibilityManager
Ultimately reports whether this manager has aVendorVisibilityHandler
which can support the providedpersistedDomainEntityType
.This can be useful to determine whether an entity should participate in vendor-discrimination behavior.
- Specified by:
supportsVendorDiscrimination
in interfaceVendorVisibilityManager
- Parameters:
persistedDomainEntityType
- the persisted-domain entity type for which to check vendor-handling support- Returns:
true
if there is aVendorVisibilityHandler
which can handle the entity,false
otherwise
-
isEntityMutableByVendorRestrictions
public boolean isEntityMutableByVendorRestrictions(@NonNull @NonNull Object persistedDomainEntity, @NonNull @NonNull Set<String> restrictedVendorRefs, @Nullable ContextInfo contextInfo) Description copied from interface:VendorVisibilityManager
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.
If no
VendorVisibilityHandler
supports this operation for the givenpersistedDomainEntity
,true
will be returned with the assumption that there is no visibility check that needs to be performed.- Specified by:
isEntityMutableByVendorRestrictions
in interfaceVendorVisibilityManager
- Parameters:
persistedDomainEntity
- the persisted-domain entity to validate visibility forrestrictedVendorRefs
- the "vendorRef" (typically a vendor ID or code) of all vendors that visibility should be restricted to. Cannot be empty.contextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- true if the entity is visible by the given vendor restrictions, false otherwise
- See Also:
-
createVendorNarrowingFilter
@Nullable public String createVendorNarrowingFilter(@NonNull @NonNull Class<?> persistedDomainEntityTypeBeingRead, @NonNull @NonNull Set<String> restrictedVendorRefs, @Nullable ContextInfo contextInfo) Description copied from interface:VendorVisibilityManager
Given apersistedDomainEntityTypeBeingRead
that is being read in a query, return aNode
filter string for it 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.
If no
VendorVisibilityHandler
supports this operation for the givenpersistedDomainEntityTypeBeingRead
,null
will be returned with the assumption that there is no filtration that needs to be performed for that entity.- Specified by:
createVendorNarrowingFilter
in interfaceVendorVisibilityManager
- Parameters:
persistedDomainEntityTypeBeingRead
- the persisted-domain entity type for which to produce a vendor-narrowing filterrestrictedVendorRefs
- the "vendorRef" (typically a vendor ID or code) of all vendors that the results need to be restricted to. Cannot 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 to only include data from therestrictedVendorRefs
. Alternatively, returnnull
if the handlers shouldn't/can't produce a filter for the given inputs. - See Also:
-
getAssociatedVendorRef
@Nullable public String getAssociatedVendorRef(Object persistedDomainEntity, @Nullable ContextInfo contextInfo) Description copied from interface:VendorVisibilityManager
Given apersistedDomainEntity
, determine what vendor it is associated to (if any).If no
VendorVisibilityHandler
supports this operation for the givenpersistedDomainEntity
,null
will be returned with the assumption that there is no associated vendor.- Specified by:
getAssociatedVendorRef
in interfaceVendorVisibilityManager
- 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:
-
getHandlerSupportingOperationsOnEntity
protected Optional<VendorVisibilityHandler> getHandlerSupportingOperationsOnEntity(Class<?> persistedDomainEntityType) -
getHandlers
-
getDataRouteReference
@Nullable protected com.broadleafcommerce.common.extension.data.DataRouteReference getDataRouteReference()
-