Class CatalogAccessPolicy

java.lang.Object
com.broadleafcommerce.catalog.domain.accesspolicy.CatalogAccessPolicy
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware, Serializable

public class CatalogAccessPolicy extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware
Represents a set of rules concerning what Catalog entities can be accessed by the specified users or request contexts. This will cause entities within the related catalog or the entire catalog to be filtered for requests besides the normal data tracking filtration.

CatalogAccessPolicies can fit into two types by default: Those targeting entire Catalogs and those targeting specific contents. Contents are targetable by setting filterRules for them. The only specific contents that are targetable by default are Products. For both types, the targeted catalog or contents are only visible to the users or requests contexts matched by the matchRule.

Author:
Nathan Moore (nathandmoore)
See Also:
  • Constructor Details

    • CatalogAccessPolicy

      public CatalogAccessPolicy()
  • Method Details

    • getId

      public String getId()
      Id for the policy.
      Returns:
      Id for the policy.
    • getName

      public String getName()
      Name of the policy.
      Returns:
      Name of the policy.
    • getActiveStartDate

      public Instant getActiveStartDate()
      The date from which the policy should be active.
      Returns:
      The date from which the policy should be active.
    • getActiveEndDate

      public Instant getActiveEndDate()
      The date until which the policy should be active. Must be after activeStartDate. null indicates the policy will not stop being active after activeStartDate.
      Returns:
      The date until which the policy should be active.
    • getFilterRules

      public Map<String,String> getFilterRules()
      Filters used by this policy to restrict access to the Catalog entities that match them. The key specifies the entity type (e.g, PRODUCT or CATEGORY) and the value is an RSQL rule that should be applied for queries against that entity type. By default, only Products are targetable.

      You can target more entities by creating CatalogFilterRulesMappings to map the persistent entity to the key in the appropriate service, e.g., JpaProduct class to the PRODUCT key. This is only used when getTargetType() is DefaultCatalogAccessPolicyTargetType.PRODUCT.

      Returns:
      Rules that should be applied to cause the inclusion of items.
    • getContextState

      public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      getContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Returns:
      a subset of Tracking information to expose the context state for this object
    • getTargetType

      public String getTargetType()
      The target type denoting how to restrict this catalog access policy.
      Returns:
      the target type of the catalog access policy.
      See Also:
    • getTargetCatalogIds

      public List<String> getTargetCatalogIds()
      List of the target Catalog.getId() that this catalog access policy applies to. This is only used when getTargetType() is DefaultCatalogAccessPolicyTargetType.CATALOG.
      Returns:
      the list of catalog ids to target.
    • getMatchRule

      public String getMatchRule()
      Match rule to evaluate against a context object containing user and request data. This rule is a SpEL expression.
      Returns:
      the match rule to evaluate.
    • setId

      public void setId(String id)
      Id for the policy.
      Parameters:
      id - Id for the policy.
    • setName

      public void setName(String name)
      Name of the policy.
      Parameters:
      name - Name of the policy.
    • setActiveStartDate

      public void setActiveStartDate(Instant activeStartDate)
      The date from which the policy should be active.
      Parameters:
      activeStartDate - The date from which the policy should be active.
    • setActiveEndDate

      public void setActiveEndDate(Instant activeEndDate)
      The date until which the policy should be active. Must be after activeStartDate. null indicates the policy will not stop being active after activeStartDate.
      Parameters:
      activeEndDate - The date until which the policy should be active.
    • setFilterRules

      public void setFilterRules(Map<String,String> filterRules)
      Filters used by this policy to restrict access to the Catalog entities that match them. The key specifies the entity type (e.g, PRODUCT or CATEGORY) and the value is an RSQL rule that should be applied for queries against that entity type. By default, only Products are targetable.

      You can target more entities by creating CatalogFilterRulesMappings to map the persistent entity to the key in the appropriate service, e.g., JpaProduct class to the PRODUCT key. This is only used when getTargetType() is DefaultCatalogAccessPolicyTargetType.PRODUCT.

      Parameters:
      inclusionFilters - Rules that should be applied to cause the inclusion of items.
    • setContextState

      public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      setContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Parameters:
      contextState - a subset of Tracking information to expose the context state for this object
    • setTargetType

      public void setTargetType(String targetType)
      The target type denoting how to restrict this catalog access policy.
      Parameters:
      targetType - the target type of the catalog access policy.
      See Also:
    • setTargetCatalogIds

      public void setTargetCatalogIds(List<String> targetCatalogIds)
      List of the target Catalog.getId() that this catalog access policy applies to. This is only used when getTargetType() is DefaultCatalogAccessPolicyTargetType.CATALOG.
      Parameters:
      targetCatalogIds - the list of catalog ids to target.
    • setMatchRule

      public void setMatchRule(String matchRule)
      Match rule to evaluate against a context object containing user and request data. This rule is a SpEL expression.
      Parameters:
      matchRule - the match rule to evaluate.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object