Class PageRewriteRule

    • Constructor Detail

      • PageRewriteRule

        public PageRewriteRule()
    • Method Detail

      • getId

        public String getId()
        Description copied from interface: RewriteRule
        Returns the unique identifier for this Rule.
        Specified by:
        getId in interface RewriteRule
        Returns:
        the id
      • 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 of root. 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 interface RewriteRule
        Parameters:
        pageContent - The root of the subtree to be rewritten
        finalPaths - 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 saved
        RewriteException - 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 interface RewriteRule
        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 interface ServiceBasedRewriteRule
        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 specified sling:resourceType in any of its matching logic.
        Specified by:
        hasPattern in interface ServiceBasedRewriteRule
        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