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.Predicate
buildVendorNarrowingCriteria
(@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 apersistedDomainTypeToRead
that is being read in a query, build and return aPredicate
for it that restricts results to only include data accessible from therestrictedVendorRefs
.protected List<JpaVendorNarrowingCriteriaHandler>
protected Optional<JpaVendorNarrowingCriteriaHandler>
getHandlerSupportingEntity
(Class<?> persistedDomainTypeToRead) boolean
supportsVendorDiscrimination
(Class<?> persistedDomainEntityType) Ultimately reports whether this manager has aJpaVendorNarrowingCriteriaHandler
which can support the providedpersistedDomainEntityType
.
-
Constructor Details
-
DefaultJpaVendorNarrowingCriteriaManager
public DefaultJpaVendorNarrowingCriteriaManager(List<JpaVendorNarrowingCriteriaHandler> criteriaHandlers)
-
-
Method Details
-
supportsVendorDiscrimination
Description copied from interface:JpaVendorNarrowingCriteriaManager
Ultimately reports whether this manager has aJpaVendorNarrowingCriteriaHandler
which can support the providedpersistedDomainEntityType
.This can be useful to determine whether an entity should participate in vendor-discrimination behavior.
- Specified by:
supportsVendorDiscrimination
in interfaceJpaVendorNarrowingCriteriaManager
- Parameters:
persistedDomainEntityType
- the persisted-domain entity type for which to check vendor-handling support- Returns:
true
if there is aJpaVendorNarrowingCriteriaHandler
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 apersistedDomainTypeToRead
that is being read in a query, build and return aPredicate
for 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
JpaVendorNarrowingCriteriaHandler
supports this operation for the givenpersistedDomainTypeToRead
,null
will be returned with the assumption that there is no filtration that needs to be performed for that entity.- Specified by:
buildVendorNarrowingCriteria
in 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
Predicate
that can appropriately filter query results to only include the records accessible fromrestrictedVendorRefs
. Alternatively, returnsnull
if no vendor narrowing should be applied. - See Also:
-
getHandlerSupportingEntity
protected Optional<JpaVendorNarrowingCriteriaHandler> getHandlerSupportingEntity(Class<?> persistedDomainTypeToRead) -
getCriteriaHandlers
-