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 Summary
ConstructorsConstructorDescriptionDefaultJpaVendorNarrowingCriteriaManager(List<JpaVendorNarrowingCriteriaHandler> criteriaHandlers) -
Method Summary
Modifier and TypeMethodDescription<D> jakarta.persistence.criteria.PredicatebuildVendorNarrowingCriteria(@NonNull Set<String> restrictedVendorRefs, @NonNull Class<D> persistedDomainTypeToRead, @NonNull jakarta.persistence.criteria.CriteriaQuery<?> criteriaQuery, @NonNull jakarta.persistence.criteria.Root<D> root, @NonNull Map<String, Object> queryParameters, @NonNull jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given apersistedDomainTypeToReadthat is being read in a query, build and return aPredicatefor it that restricts results to only include data accessible from therestrictedVendorRefs.protected List<JpaVendorNarrowingCriteriaHandler>protected Optional<JpaVendorNarrowingCriteriaHandler>getHandlerSupportingEntity(Class<?> persistedDomainTypeToRead) booleansupportsVendorDiscrimination(Class<?> persistedDomainEntityType) Ultimately reports whether this manager has aJpaVendorNarrowingCriteriaHandlerwhich can support the providedpersistedDomainEntityType.
-
Constructor Details
-
DefaultJpaVendorNarrowingCriteriaManager
public DefaultJpaVendorNarrowingCriteriaManager(List<JpaVendorNarrowingCriteriaHandler> criteriaHandlers)
-
-
Method Details
-
supportsVendorDiscrimination
Description copied from interface:JpaVendorNarrowingCriteriaManagerUltimately reports whether this manager has aJpaVendorNarrowingCriteriaHandlerwhich can support the providedpersistedDomainEntityType.This can be useful to determine whether an entity should participate in vendor-discrimination behavior.
- Specified by:
supportsVendorDiscriminationin interfaceJpaVendorNarrowingCriteriaManager- Parameters:
persistedDomainEntityType- the persisted-domain entity type for which to check vendor-handling support- Returns:
trueif there is aJpaVendorNarrowingCriteriaHandlerwhich can handle the entity,falseotherwise
-
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:JpaVendorNarrowingCriteriaManagerGiven apersistedDomainTypeToReadthat is being read in a query, build and return aPredicatefor it that restricts results to only include data accessible from therestrictedVendorRefs.This is particularly useful to prevent vendor-restricted authentications from accessing data outside of their allowed vendors.
If no
JpaVendorNarrowingCriteriaHandlersupports this operation for the givenpersistedDomainTypeToRead,nullwill be returned with the assumption that there is no filtration that needs to be performed for that entity.- Specified by:
buildVendorNarrowingCriteriain interfaceJpaVendorNarrowingCriteriaManager- 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 queriedcriteriaQuery- the query for which vendor-narrowing criteria should be builtroot- the entity root for the queryqueryParameters- parameters that will be set on the querycriteriaBuilder- a standard criteria buildercontextInfo- 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
Predicatethat can appropriately filter query results to only include the records accessible fromrestrictedVendorRefs. Alternatively, returnsnullif no vendor narrowing should be applied. - See Also:
-
getHandlerSupportingEntity
protected Optional<JpaVendorNarrowingCriteriaHandler> getHandlerSupportingEntity(Class<?> persistedDomainTypeToRead) -
getCriteriaHandlers
-