Class DefaultVendorVisibilityManager

    • Constructor Detail

      • DefaultVendorVisibilityManager

        public DefaultVendorVisibilityManager​(List<VendorVisibilityHandler> handlers,
                                              @Nullable
                                              com.broadleafcommerce.common.extension.data.DataRouteReference dataRouteReference)
    • Method Detail

      • supportsVendorDiscrimination

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

        public boolean isEntityMutableByVendorRestrictions​(@NonNull
                                                           @NonNull Object persistedDomainEntity,
                                                           @NonNull
                                                           @NonNull Set<String> restrictedVendorRefs,
                                                           @Nullable
                                                           ContextInfo contextInfo)
        Description copied from interface: VendorVisibilityManager
        Given a persistedDomainEntity, report whether that entity is mutable by the given vendor restrictions.

        This is particularly useful to validate whether an entity can be inserted or updated by a vendor-restricted authentication.

        If no VendorVisibilityHandler supports this operation for the given persistedDomainEntity, true will be returned with the assumption that there is no visibility check that needs to be performed.

        Specified by:
        isEntityMutableByVendorRestrictions in interface VendorVisibilityManager
        Parameters:
        persistedDomainEntity - the persisted-domain entity to validate visibility for
        restrictedVendorRefs - the "vendorRef" (typically a vendor ID or code) of all vendors that visibility should be restricted to. Cannot be empty.
        contextInfo - context information surrounding sandboxing/multitenant state
        Returns:
        true if the entity is visible by the given vendor restrictions, false otherwise
        See Also:
        VendorAwareTrackablePolicyUtils, VendorVisibilityHandler.isEntityMutableByVendorRestrictions(Object, Set, ContextInfo)
      • createVendorNarrowingFilter

        @Nullable
        public String createVendorNarrowingFilter​(@NonNull
                                                  @NonNull Class<?> persistedDomainEntityTypeBeingRead,
                                                  @NonNull
                                                  @NonNull Set<String> restrictedVendorRefs,
                                                  @Nullable
                                                  ContextInfo contextInfo)
        Description copied from interface: VendorVisibilityManager
        Given a persistedDomainEntityTypeBeingRead that is being read in a query, return a Node filter string for it that restricts results to only include data from the restrictedVendorRefs.

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

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

        Specified by:
        createVendorNarrowingFilter in interface VendorVisibilityManager
        Parameters:
        persistedDomainEntityTypeBeingRead - the persisted-domain entity type for which to produce a vendor-narrowing filter
        restrictedVendorRefs - the "vendorRef" (typically a vendor ID or code) of all vendors that the results need to be restricted to. Cannot 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 to only include data from the restrictedVendorRefs. Alternatively, return null if the handlers shouldn't/can't produce a filter for the given inputs.
        See Also:
        VendorNarrowingContextInfoCustomizer, VendorVisibilityHandler.createVendorNarrowingFilter(Set, ContextInfo)
      • getDataRouteReference

        @Nullable
        protected com.broadleafcommerce.common.extension.data.DataRouteReference getDataRouteReference()