Class CatalogDiscriminatedEntityVendorVisibilityHandler

  • All Implemented Interfaces:
    com.broadleafcommerce.common.extension.data.DataRoutePartitionAware, VendorVisibilityHandler, org.springframework.core.Ordered

    public class CatalogDiscriminatedEntityVendorVisibilityHandler
    extends Object
    implements VendorVisibilityHandler
    Responsible for performing vendor-visibility operations on catalog-discriminated entities.

    Catalog-discriminated entities are implicitly associated to vendors through their catalog's Catalog.getVendorRef(). This handler is capable of taking a set of vendors and determining the catalog IDs associated to those vendors. Whether or not an entity is within a vendor can then be determined by comparing its catalog ID.

    Since many services may not want to participate in this behavior, this component is not registered as a bean by default. Consumers must manually define this bean in their configurations.

    • Method Detail

      • canHandle

        public boolean canHandle​(@NonNull
                                 @NonNull Class<?> persistedDomainEntityType)
        If the persistedDomainEntityType is catalog discriminated, this handler supports it.
        Specified by:
        canHandle in interface VendorVisibilityHandler
        Parameters:
        persistedDomainEntityType - the type to check support for
        Returns:
        true if the trackable behavior is catalog-discriminated, false otherwise
      • getOrder

        public int getOrder()
        Specified by:
        getOrder in interface org.springframework.core.Ordered
        Specified by:
        getOrder in interface VendorVisibilityHandler
      • getDataRoutePartition

        public String getDataRoutePartition()
        Specified by:
        getDataRoutePartition in interface com.broadleafcommerce.common.extension.data.DataRoutePartitionAware
      • createVendorNarrowingFilter

        public String createVendorNarrowingFilter​(@NonNull
                                                  @NonNull Set<String> restrictedVendorRefs,
                                                  @Nullable
                                                  ContextInfo contextInfo)
        Builds a filter on tracking.catalog.contextId that serves as an "upper bound" to possible catalogs the results can come from.

        The narrowing filter cannot just only allow the directly assigned vendor catalog IDs. A vendor catalog may inherit from a non-vendor catalog, and thus for the purpose of reading data, it should be possible for results to contain records from the non-vendor parent catalogs. Thus we fetch those ancestor catalog IDs and include them as possible valid values for our narrowing filter.

        Specified by:
        createVendorNarrowingFilter in interface VendorVisibilityHandler
        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 the restrictedVendorRefs. Cannot return null.
        See Also:
        VendorVisibilityManager.createVendorNarrowingFilter(Class, Set, ContextInfo)
      • buildCatalogIdFilter

        protected String buildCatalogIdFilter​(@NonNull
                                              @NonNull Set<String> catalogIds)