Interface JpaVendorNarrowingCriteriaManager

All Known Implementing Classes:
DefaultJpaVendorNarrowingCriteriaManager

public interface JpaVendorNarrowingCriteriaManager
This is a higher-level component that understands how to build criteria to perform vendor-narrowing-related operations relating to various entities in the sandbox microservice.

Typically, consumers should rely on JpaVendorNarrowingQueryCustomizer rather than interacting with this component directly.

Ultimately, the purpose of this component is to inject all JpaVendorNarrowingCriteriaHandler beans, and then delegate to the one that supports performing a given operation on a particular entity.

This is somewhat analogous to VendorVisibilityManager.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    <D> jakarta.persistence.criteria.Predicate
    buildVendorNarrowingCriteria(Set<String> restrictedVendorRefs, Class<D> persistedDomainTypeToRead, jakarta.persistence.criteria.CriteriaQuery<?> criteriaQuery, jakarta.persistence.criteria.Root<D> root, Map<String,Object> queryParameters, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    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.
    boolean
    supportsVendorDiscrimination(Class<?> persistedDomainEntityType)
    Ultimately reports whether this manager has a JpaVendorNarrowingCriteriaHandler which can support the provided persistedDomainEntityType.
  • Method Details

    • supportsVendorDiscrimination

      boolean supportsVendorDiscrimination(Class<?> persistedDomainEntityType)
      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.

      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 <D> jakarta.persistence.criteria.Predicate buildVendorNarrowingCriteria(Set<String> restrictedVendorRefs, Class<D> persistedDomainTypeToRead, jakarta.persistence.criteria.CriteriaQuery<?> criteriaQuery, jakarta.persistence.criteria.Root<D> root, Map<String,Object> queryParameters, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      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.

      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: