Class PageRewriteRule
- java.lang.Object
-
- com.adobe.aem.modernize.structure.rule.PageRewriteRule
-
- All Implemented Interfaces:
RewriteRule
,ServiceBasedRewriteRule
,StructureRewriteRule
,Comparable<RewriteRule>
public class PageRewriteRule extends Object implements StructureRewriteRule
Rewrites the jcr:content node of a Page. Updates thecq:template
reference to the mapped value Removes thecq:designPath
property, as it is unnecessary on Editable Templates Creates a root responsive layout component and moves all children nodes (e.g. components) to this container.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.adobe.aem.modernize.rule.RewriteRule
RewriteRule.Comparator
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
NN_ROOT_CONTAINER
-
Constructor Summary
Constructors Constructor Description PageRewriteRule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
activate(org.osgi.service.component.ComponentContext context, com.adobe.aem.modernize.structure.rule.PageRewriteRule.Config config)
@Nullable Node
applyTo(@NotNull Node pageContent, @NotNull Set<String> finalPaths)
Applies this rule to the subtree rooted at the specifiedroot
node.@NotNull Set<String>
findMatches(@NotNull org.apache.sling.api.resource.Resource resource)
Lists all resource paths in tree rooted at the specified resource, that match any rules of which this service is aware.String
getId()
Returns the unique identifier for this Rule.int
getRanking()
Ranking of this Rule relative to others that may also match a given node.String
getTitle()
The title for this rule.boolean
hasPattern(@NotNull String... slingResourceTypes)
Indicates if this service uses any of the specifiedsling:resourceType
in any of its matching logic.boolean
matches(@NotNull Node root)
Returns true if this rule matches the given subtree.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adobe.aem.modernize.rule.RewriteRule
compareTo
-
-
-
-
Field Detail
-
NN_ROOT_CONTAINER
protected static final String NN_ROOT_CONTAINER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getTitle
public String getTitle()
Description copied from interface:RewriteRule
The title for this rule.- Specified by:
getTitle
in interfaceRewriteRule
- Returns:
- the title
-
getId
public String getId()
Description copied from interface:RewriteRule
Returns the unique identifier for this Rule.- Specified by:
getId
in interfaceRewriteRule
- Returns:
- the id
-
matches
public boolean matches(@NotNull @NotNull Node root) throws RepositoryException
Description copied from interface:RewriteRule
Returns true if this rule matches the given subtree.- Specified by:
matches
in interfaceRewriteRule
- Parameters:
root
- The root of the subtree to be checked for a match- Returns:
- true if this rule applies, false otherwise
- Throws:
RepositoryException
- if reading the repository fails
-
applyTo
@Nullable public @Nullable Node applyTo(@NotNull @NotNull Node pageContent, @NotNull @NotNull Set<String> finalPaths) throws RepositoryException, RewriteException
Description copied from interface:RewriteRule
Applies this rule to the subtree rooted at the specified
root
node. The implementation of this method may either modify the properties and nodes contained in that tree, or replace it by adding a new child to the parent ofroot
. In the latter case, the implementation is responsible for removing the original subtree (without saving).Repository modifications are made but not saved.
Rewrite rules must not rewrite trees in a circular fashion, as this might lead to infinite loops.
Optionally, the implementation can indicate which nodes of the resulting tree are final and therefore safe for the algorithm to skip in subsequent traversals of the tree. Add the paths of final nodes to the specified set.
- Specified by:
applyTo
in interfaceRewriteRule
- Parameters:
pageContent
- The root of the subtree to be rewrittenfinalPaths
- list of nodes paths which should not be updated after this method completes- Returns:
- the root node of the rewritten tree, or null if it was removed
- Throws:
RepositoryException
- if the node updates cannot be savedRewriteException
- if the rewrite operation failed or cannot be completed
-
getRanking
public int getRanking()
Description copied from interface:RewriteRule
Ranking of this Rule relative to others that may also match a given node.- Specified by:
getRanking
in interfaceRewriteRule
- Returns:
- the rule's ranking
-
findMatches
@NotNull public @NotNull Set<String> findMatches(@NotNull @NotNull org.apache.sling.api.resource.Resource resource)
Description copied from interface:ServiceBasedRewriteRule
Lists all resource paths in tree rooted at the specified resource, that match any rules of which this service is aware.This method may result in fuzzy matches to improve performance and prevent resource utilization overhead.
- Specified by:
findMatches
in interfaceServiceBasedRewriteRule
- Parameters:
resource
- Resource for the root of the search- Returns:
- list of paths that match rules or an empty set if none match
-
hasPattern
public boolean hasPattern(@NotNull @NotNull String... slingResourceTypes)
Description copied from interface:ServiceBasedRewriteRule
Indicates if this service uses any of the specifiedsling:resourceType
in any of its matching logic.- Specified by:
hasPattern
in interfaceServiceBasedRewriteRule
- Parameters:
slingResourceTypes
- the sling resource type to check- Returns:
- true type matches
-
activate
protected void activate(org.osgi.service.component.ComponentContext context, com.adobe.aem.modernize.structure.rule.PageRewriteRule.Config config) throws org.osgi.service.cm.ConfigurationException
- Throws:
org.osgi.service.cm.ConfigurationException
-
-