Class ResourceResolution
java.lang.Object
org.apache.sling.scripting.sightly.engine.ResourceResolution
Utility class which is used by the HTL engine & extensions to resolve resources.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable org.apache.sling.api.resource.ResourcegetResourceForJakartaRequest(@Nullable org.apache.sling.api.resource.ResourceResolver resolver, @Nullable org.apache.sling.api.SlingJakartaHttpServletRequest request) Resolves the resource accessed by arequest.static @Nullable org.apache.sling.api.resource.ResourcegetResourceForRequest(@Nullable org.apache.sling.api.resource.ResourceResolver resolver, org.apache.sling.api.SlingHttpServletRequest request) Deprecated.static @Nullable org.apache.sling.api.resource.ResourcegetResourceFromSearchPath(@Nullable org.apache.sling.api.resource.Resource base, @Nullable String path) Resolves a resource from the search path relative to thebaseresource by traversing thesling:resourceSuperTypechain.
-
Constructor Details
-
ResourceResolution
public ResourceResolution()
-
-
Method Details
-
getResourceFromSearchPath
@Nullable public static @Nullable org.apache.sling.api.resource.Resource getResourceFromSearchPath(@Nullable @Nullable org.apache.sling.api.resource.Resource base, @Nullable @Nullable String path) Resolves a resource from the search path relative to the
baseresource by traversing thesling:resourceSuperTypechain.Since this method will traverse the
sling:resourceSuperTypechain, theResourceResolverused for resolving thebaseresource should be able to read the super type resources.- Parameters:
base- the base resource from which to start the lookuppath- the relative path to the resource; if the path is absolute theResourceidentified by this path will be returned- Returns:
- the resource identified by the relative
pathornullif no resource was found - Throws:
UnsupportedOperationException- if the resource is not in the resource resolver's search pathIllegalStateException- 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
@Deprecated(since="1.2.0") @Nullable public static @Nullable org.apache.sling.api.resource.Resource getResourceForRequest(@Nullable @Nullable org.apache.sling.api.resource.ResourceResolver resolver, @Nullable org.apache.sling.api.SlingHttpServletRequest request) Deprecated.Resolves the resource accessed by a
request. Since therequestcan use an anonymousResourceResolver, the passedresolverparameter should have read access rights to resources from the search path.- Parameters:
resolver- aResourceResolverthat has read access rights to resources from the search pathrequest- the request- Returns:
- the resource identified by the
requestornullif no resource was found
-
getResourceForJakartaRequest
@Nullable public static @Nullable org.apache.sling.api.resource.Resource getResourceForJakartaRequest(@Nullable @Nullable org.apache.sling.api.resource.ResourceResolver resolver, @Nullable @Nullable org.apache.sling.api.SlingJakartaHttpServletRequest request) Resolves the resource accessed by a
request. Since therequestcan use an anonymousResourceResolver, the passedresolverparameter should have read access rights to resources from the search path.- Parameters:
resolver- aResourceResolverthat has read access rights to resources from the search pathrequest- the request- Returns:
- the resource identified by the
requestornullif no resource was found
-
getResourceForJakartaRequest(ResourceResolver, SlingJakartaHttpServletRequest)instead