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:templatereference to the mapped value Removes thecq:designPathproperty, 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 StringNN_ROOT_CONTAINER
-
Constructor Summary
Constructors Constructor Description PageRewriteRule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidactivate(org.osgi.service.component.ComponentContext context, com.adobe.aem.modernize.structure.rule.PageRewriteRule.Config config)@Nullable NodeapplyTo(@NotNull Node pageContent, @NotNull Set<String> finalPaths)Applies this rule to the subtree rooted at the specifiedrootnode.@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.StringgetId()Returns the unique identifier for this Rule.intgetRanking()Ranking of this Rule relative to others that may also match a given node.StringgetTitle()The title for this rule.booleanhasPattern(@NotNull String... slingResourceTypes)Indicates if this service uses any of the specifiedsling:resourceTypein any of its matching logic.booleanmatches(@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:RewriteRuleThe title for this rule.- Specified by:
getTitlein interfaceRewriteRule- Returns:
- the title
-
getId
public String getId()
Description copied from interface:RewriteRuleReturns the unique identifier for this Rule.- Specified by:
getIdin interfaceRewriteRule- Returns:
- the id
-
matches
public boolean matches(@NotNull @NotNull Node root) throws RepositoryException
Description copied from interface:RewriteRuleReturns true if this rule matches the given subtree.- Specified by:
matchesin 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:RewriteRuleApplies this rule to the subtree rooted at the specified
rootnode. 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:
applyToin 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:RewriteRuleRanking of this Rule relative to others that may also match a given node.- Specified by:
getRankingin 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:ServiceBasedRewriteRuleLists 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:
findMatchesin 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:ServiceBasedRewriteRuleIndicates if this service uses any of the specifiedsling:resourceTypein any of its matching logic.- Specified by:
hasPatternin 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
-
-