Question

How do I resolve a URL to a JCR Node object?

Answer

To accomplish this you need to
1) Resolve the URL to a sling resource by calling the resolve method of resourceResolver object.
2) Adopt the resource object to a jcr node by calling its' adoptTo method.

The following code would accomplish this.

Resource res = resourceResolver.resolve(uri);
Node myNode = res.adaptTo(Node.class); 

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy