Class ResourceResolution

java.lang.Object
org.apache.sling.scripting.sightly.engine.ResourceResolution

public final class ResourceResolution extends Object
Utility class which is used by the HTL engine & extensions to resolve resources.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.sling.api.resource.Resource
    getResourceForRequest(org.apache.sling.api.resource.ResourceResolver resolver, org.apache.sling.api.SlingHttpServletRequest request)
    Resolves the resource accessed by a request.
    static org.apache.sling.api.resource.Resource
    getResourceFromSearchPath(org.apache.sling.api.resource.Resource base, String path)
    Resolves a resource from the search path relative to the base resource by traversing the sling:resourceSuperType chain.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ResourceResolution

      public ResourceResolution()
  • Method Details

    • getResourceFromSearchPath

      public static org.apache.sling.api.resource.Resource getResourceFromSearchPath(org.apache.sling.api.resource.Resource base, String path)

      Resolves a resource from the search path relative to the base resource by traversing the sling:resourceSuperType chain.

      Since this method will traverse the sling:resourceSuperType chain, the ResourceResolver used for resolving the base resource should be able to read the super type resources.

      Parameters:
      base - the base resource from which to start the lookup
      path - the relative path to the resource; if the path is absolute the Resource identified by this path will be returned
      Returns:
      the resource identified by the relative path or null if no resource was found
      Throws:
      UnsupportedOperationException - if the resource is not in the resource resolver's search path
      IllegalStateException - if the number of steps necessary to search for the resource on the resource superType chain has reached the maximum limit
      See Also:
      • ResourceResolver.getSearchPath()
    • getResourceForRequest

      public static org.apache.sling.api.resource.Resource getResourceForRequest(org.apache.sling.api.resource.ResourceResolver resolver, org.apache.sling.api.SlingHttpServletRequest request)

      Resolves the resource accessed by a request. Since the request can use an anonymous ResourceResolver, the passed resolver parameter should have read access rights to resources from the search path.

      Parameters:
      resolver - a ResourceResolver that has read access rights to resources from the search path
      request - the request
      Returns:
      the resource identified by the request or null if no resource was found