Class DefaultVendorVisibilityManager

java.lang.Object
com.broadleafcommerce.data.tracking.core.marketplace.vendor.visibility.DefaultVendorVisibilityManager
All Implemented Interfaces:
VendorVisibilityManager

public class DefaultVendorVisibilityManager extends Object implements VendorVisibilityManager
The default implementation of VendorVisibilityManager.
  • Constructor Details

    • DefaultVendorVisibilityManager

      public DefaultVendorVisibilityManager(List<VendorVisibilityHandler> handlers, @Nullable com.broadleafcommerce.common.extension.data.DataRouteReference dataRouteReference)
  • Method Details

    • supportsVendorDiscrimination

      public boolean supportsVendorDiscrimination(@NonNull @NonNull Class<?> persistedDomainEntityType)
      Description copied from interface: VendorVisibilityManager
      Ultimately reports whether this manager has a VendorVisibilityHandler which can support the provided persistedDomainEntityType.

      This can be useful to determine whether an entity should participate in vendor-discrimination behavior.

      Specified by:
      supportsVendorDiscrimination in interface VendorVisibilityManager
      Parameters:
      persistedDomainEntityType - the persisted-domain entity type for which to check vendor-handling support
      Returns:
      true if there is a VendorVisibilityHandler 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 a persistedDomainEntity, 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 given persistedDomainEntity, true will be returned with the assumption that there is no visibility check that needs to be performed.

      Specified by:
      isEntityMutableByVendorRestrictions in interface VendorVisibilityManager
      Parameters:
      persistedDomainEntity - the persisted-domain entity to validate visibility for
      restrictedVendorRefs - 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 a persistedDomainEntityTypeBeingRead that is being read in a query, return a Node filter string for it that restricts results to only include data from the restrictedVendorRefs.

      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 given persistedDomainEntityTypeBeingRead, null will be returned with the assumption that there is no filtration that needs to be performed for that entity.

      Specified by:
      createVendorNarrowingFilter in interface VendorVisibilityManager
      Parameters:
      persistedDomainEntityTypeBeingRead - the persisted-domain entity type for which to produce a vendor-narrowing filter
      restrictedVendorRefs - 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 the restrictedVendorRefs. Alternatively, return null 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 a persistedDomainEntity, determine what vendor it is associated to (if any).

      If no VendorVisibilityHandler supports this operation for the given persistedDomainEntity, null will be returned with the assumption that there is no associated vendor.

      Specified by:
      getAssociatedVendorRef in interface VendorVisibilityManager
      Parameters:
      persistedDomainEntity - the persisted-domain entity to determine the vendor association for
      contextInfo - 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

      protected List<VendorVisibilityHandler> getHandlers()
    • getDataRouteReference

      @Nullable protected com.broadleafcommerce.common.extension.data.DataRouteReference getDataRouteReference()