Class Path


  • @ProviderType
    public final class Path
    extends java.lang.Object
    Handling of paths and absolute parents in AEM.

    The methods implement special handling for AEM features:

    • Side-by-side version comparison (at /tmp/versionhistory or /content/versionhistory)
    • Launches (at /content/launches)
    Paths starting with one of these special paths are treated in a special way so code relying on the original path structure still works.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int getAbsoluteLevel​(@NotNull java.lang.String path, @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver)
      Gets level from parent use same logic (but reverse) as getAbsoluteParent(Page, int, ResourceResolver).
      static com.day.cq.wcm.api.Page getAbsoluteParent​(@NotNull com.day.cq.wcm.api.Page page, int parentLevel, @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver)
      Get absolute parent of given path.
      static java.lang.String getAbsoluteParent​(@NotNull java.lang.String path, int parentLevel, @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver)
      Get absolute parent of given path.
      static java.lang.String getOriginalPath​(@NotNull java.lang.String path, @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver)
      Resolve original path if the path is a version history or launch path.
      static boolean isEditableTemplatePath​(@NotNull java.lang.String path)  
      static boolean isExperienceFragmentPath​(@NotNull java.lang.String path)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getAbsoluteParent

        public static java.lang.String getAbsoluteParent​(@NotNull
                                                         @NotNull java.lang.String path,
                                                         int parentLevel,
                                                         @NotNull
                                                         @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver)
        Get absolute parent of given path. If the path is a version history or launch path the path level is adjusted accordingly. This is a replacement for Text.getAbsoluteParent(String, int).
        Parameters:
        path - Path
        parentLevel - Parent level
        resourceResolver - Resource resolver
        Returns:
        Absolute parent path or empty string if path is invalid
      • getAbsoluteParent

        public static com.day.cq.wcm.api.Page getAbsoluteParent​(@NotNull
                                                                @NotNull com.day.cq.wcm.api.Page page,
                                                                int parentLevel,
                                                                @NotNull
                                                                @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver)
        Get absolute parent of given path. If the path is a version history or launch path the path level is adjusted accordingly. This is a replacement for Page.getAbsoluteParent(int).
        Parameters:
        page - Page
        parentLevel - Parent level
        resourceResolver - Resource resolver
        Returns:
        Absolute parent page or null if path is invalid
      • getAbsoluteLevel

        public static int getAbsoluteLevel​(@NotNull
                                           @NotNull java.lang.String path,
                                           @NotNull
                                           @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver)
        Gets level from parent use same logic (but reverse) as getAbsoluteParent(Page, int, ResourceResolver). If the path is a version history or launch path the original path is returned.
        Parameters:
        path - Path
        resourceResolver - Resource resolver
        Returns:
        level >= 0 if path is valid, -1 if path is invalid
      • getOriginalPath

        public static java.lang.String getOriginalPath​(@NotNull
                                                       @NotNull java.lang.String path,
                                                       @NotNull
                                                       @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver)
        Resolve original path if the path is a version history or launch path. If the path does not point to any of these locations it is returned unchanged.
        Parameters:
        path - Path
        resourceResolver - Resource resolver
        Returns:
        Path that is not a version history or launch path
      • isExperienceFragmentPath

        public static boolean isExperienceFragmentPath​(@NotNull
                                                       @NotNull java.lang.String path)
        Parameters:
        path - Content path
        Returns:
        true if content path is inside experience fragements path.
      • isEditableTemplatePath

        public static boolean isEditableTemplatePath​(@NotNull
                                                     @NotNull java.lang.String path)
        Parameters:
        path - Content path
        Returns:
        true if content path is inside an editable template definition.