Class DefaultJpaVendorNarrowingCriteriaManager

java.lang.Object
com.broadleafcommerce.sandbox.provider.jpa.marketplace.vendor.DefaultJpaVendorNarrowingCriteriaManager
All Implemented Interfaces:
JpaVendorNarrowingCriteriaManager

public class DefaultJpaVendorNarrowingCriteriaManager extends Object implements JpaVendorNarrowingCriteriaManager
Default implementation of JpaVendorNarrowingCriteriaManager.
  • Constructor Details

  • Method Details

    • supportsVendorDiscrimination

      public boolean supportsVendorDiscrimination(Class<?> persistedDomainEntityType)
      Description copied from interface: JpaVendorNarrowingCriteriaManager
      Ultimately reports whether this manager has a JpaVendorNarrowingCriteriaHandler 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 JpaVendorNarrowingCriteriaManager
      Parameters:
      persistedDomainEntityType - the persisted-domain entity type for which to check vendor-handling support
      Returns:
      true if there is a JpaVendorNarrowingCriteriaHandler which can handle the entity, false otherwise
    • buildVendorNarrowingCriteria

      @Nullable public <D> jakarta.persistence.criteria.Predicate buildVendorNarrowingCriteria(@NonNull @NonNull Set<String> restrictedVendorRefs, @NonNull @NonNull Class<D> persistedDomainTypeToRead, @NonNull @NonNull jakarta.persistence.criteria.CriteriaQuery<?> criteriaQuery, @NonNull @NonNull jakarta.persistence.criteria.Root<D> root, @NonNull @NonNull Map<String,Object> queryParameters, @NonNull @NonNull jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: JpaVendorNarrowingCriteriaManager
      Given a persistedDomainTypeToRead that is being read in a query, build and return a Predicate for it that restricts results to only include data accessible from the restrictedVendorRefs.

      This is particularly useful to prevent vendor-restricted authentications from accessing data outside of their allowed vendors.

      If no JpaVendorNarrowingCriteriaHandler supports this operation for the given persistedDomainTypeToRead, null will be returned with the assumption that there is no filtration that needs to be performed for that entity.

      Specified by:
      buildVendorNarrowingCriteria in interface JpaVendorNarrowingCriteriaManager
      Type Parameters:
      D - the persisted-domain type of the entity being queried
      Parameters:
      restrictedVendorRefs - the "vendorRef" (typically a vendor ID or code) of all vendors that data should be restricted to. Cannot be empty.
      persistedDomainTypeToRead - the persisted-domain type of the entity being queried
      criteriaQuery - the query for which vendor-narrowing criteria should be built
      root - the entity root for the query
      queryParameters - parameters that will be set on the query
      criteriaBuilder - a standard criteria builder
      contextInfo - context information surrounding multitenant state. While typical narrowing will not apply, this parameter may be useful to certain implementations for determining additional information about the request.
      Returns:
      a Predicate that can appropriately filter query results to only include the records accessible from restrictedVendorRefs. Alternatively, returns null if no vendor narrowing should be applied.
      See Also:
    • getHandlerSupportingEntity

      protected Optional<JpaVendorNarrowingCriteriaHandler> getHandlerSupportingEntity(Class<?> persistedDomainTypeToRead)
    • getCriteriaHandlers

      protected List<JpaVendorNarrowingCriteriaHandler> getCriteriaHandlers()