Package com.day.cq.wcm.api.policies
Interface ContentPolicyManager
-
@ProviderType public interface ContentPolicyManager
Content Policy Manager API.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ContentPolicy
copyPolicy(ContentPolicy originalPolicy, java.lang.String newTitle, java.lang.String newDescription)
java.util.List<ContentPolicy>
getPolicies(java.lang.String path)
Get the list of policies for the given pathjava.util.List<ContentPolicy>
getPolicies(java.lang.String path, java.lang.String policyResourceType)
Get the list of policies for the given path.ContentPolicy
getPolicy(ComponentContext componentContext)
Get theContentPolicy
for the givenComponentContext
.ContentPolicy
getPolicy(Resource contentResource)
Get theContentPolicy
for the givenResource
.ContentPolicy
getPolicy(Resource contentResource, SlingHttpServletRequest request)
Get theContentPolicy
for the givenResource
.java.lang.String
getPolicyLocation(Resource resource)
Returns the policy location for the given resource Policies are located following their respective component path location under the settings/wcm/policies directory The returned string is an absolute path to the directory that should contain policies for the given resource This function only returns a path if the given resource is contained in a page making use of the editable template If this requirement is not meet the returned string is nullContentPolicyMapping
getPolicyMapping(Resource resource)
java.util.List<ContentPolicyMapping>
getPolicyMappings(ContentPolicy contentPolicy)
java.util.List<Template>
getTemplates(java.lang.String policyAbsolutePath)
Get the templates a policy is used injava.util.List<Template>
getTemplates(java.lang.String policyAbsolutePath, Predicate filter)
Get a filtered list of templates a policy is used inboolean
isPolicyUsed(java.lang.String policyAbsolutePath, Predicate filter)
Verifies if there is any Template matching the given predicate and using the policy with given path
-
-
-
Method Detail
-
getPolicy
@Nullable ContentPolicy getPolicy(@Nonnull ComponentContext componentContext)
Get theContentPolicy
for the givenComponentContext
.- Parameters:
componentContext
- The mandatory component context to get the content policy for.- Returns:
- The content policy for the given component context or
null
if none is configured. - Throws:
java.lang.IllegalArgumentException
- This exception is thrown, if the given component context isnull
.
-
getPolicy
@Nullable ContentPolicy getPolicy(@Nonnull Resource contentResource)
Get theContentPolicy
for the givenResource
.- Parameters:
contentResource
- The mandatory resource to get the content policy for.- Returns:
- The content policy for the given resource or
null
if none is configured. - Throws:
java.lang.IllegalArgumentException
- This exception is thrown, if the given resource isnull
.
-
getPolicy
@Nullable ContentPolicy getPolicy(@Nonnull Resource contentResource, @Nullable SlingHttpServletRequest request)
Get theContentPolicy
for the givenResource
.- Parameters:
contentResource
- The mandatory resource to get the content policy for.request
- Request from which to read specific attributes and parameters. Allows to resolve delegated policy resources- Returns:
- The content policy for the given resource or
null
if none is configured. - Throws:
java.lang.IllegalArgumentException
- This exception is thrown, if the given resource isnull
.
-
getPolicies
java.util.List<ContentPolicy> getPolicies(java.lang.String path)
Get the list of policies for the given path- Parameters:
path
- Path from where to start searching for policies- Returns:
- the list of policies for the given path.
-
getPolicies
java.util.List<ContentPolicy> getPolicies(java.lang.String path, java.lang.String policyResourceType)
Get the list of policies for the given path. Here you can limit search to the given policy resource type Policy Resource Types are relative- Parameters:
path
- Path from where to start searching for policiespolicyResourceType
- Sling resource type associated with the policies- Returns:
- the list of policies for the given path.
-
copyPolicy
ContentPolicy copyPolicy(ContentPolicy originalPolicy, java.lang.String newTitle, java.lang.String newDescription)
- Parameters:
originalPolicy
- policy to be copiednewTitle
- The title of the target policynewDescription
- The Description o the target policy- Returns:
- The policy with new Description.
-
getPolicyMapping
ContentPolicyMapping getPolicyMapping(Resource resource)
- Parameters:
resource
- The resource for which policy mapping to be fetched- Returns:
ContentPolicyMapping
-
getPolicyMappings
java.util.List<ContentPolicyMapping> getPolicyMappings(ContentPolicy contentPolicy)
- Parameters:
contentPolicy
- Policy for which policy mapping to be fetched.- Returns:
- The List of
ContentPolicyMapping
-
getPolicyLocation
java.lang.String getPolicyLocation(Resource resource)
Returns the policy location for the given resource Policies are located following their respective component path location under the settings/wcm/policies directory The returned string is an absolute path to the directory that should contain policies for the given resource This function only returns a path if the given resource is contained in a page making use of the editable template If this requirement is not meet the returned string is null- Parameters:
resource
- Resource contained in a page making use of an editable template- Returns:
- The path to the directory that contains the policies for the given resource
-
getTemplates
java.util.List<Template> getTemplates(java.lang.String policyAbsolutePath)
Get the templates a policy is used in- Parameters:
policyAbsolutePath
- absolute path to policy- Returns:
- list of templates where the policy is used in
-
getTemplates
java.util.List<Template> getTemplates(java.lang.String policyAbsolutePath, @Nullable Predicate filter)
Get a filtered list of templates a policy is used in- Parameters:
policyAbsolutePath
- absolute path to policyfilter
- for the templates- Returns:
- list of templates where the policy is used in
-
isPolicyUsed
boolean isPolicyUsed(java.lang.String policyAbsolutePath, @Nullable Predicate filter)
Verifies if there is any Template matching the given predicate and using the policy with given path- Parameters:
policyAbsolutePath
- aString
absolute path to policyfilter
- aPredicate
used to filter the templates on which lookup is performed; if thefilter
isnull
, no filtering will be performed- Returns:
true
if there is any Template using the Policy withpolicyAbsolutePath
path and is matching thefilter
, if provided.- Since:
- 1.7
-
-