*/
private Resource resolveInternal(final String absPath) {
Resource resource = null;
String curPath = absPath;
try {
final ResourcePathIterator it = new ResourcePathIterator(absPath);
while (it.hasNext() && resource == null) {
curPath = it.next();
resource = getAbsoluteResourceInternal(curPath, true);
}
} catch (final Exception ex) {
throw new SlingException("Problem trying " + curPath + " for request path " + absPath, ex);
}
// SLING-627: set the part cut off from the uriPath as
// sling.resolutionPathInfo property such that
// uriPath = curPath + sling.resolutionPathInfo
if (resource != null) {
final String rpi = absPath.substring(curPath.length());
resource.getResourceMetadata().setResolutionPath(absPath.substring(0, curPath.length()));
resource.getResourceMetadata().setResolutionPathInfo(rpi);
logger.debug("resolveInternal: Found resource {} with path info {} for {}", new Object[] { resource, rpi, absPath });
} else {
// no direct resource found, so we have to drill down into the
// resource tree to find a match
resource = getAbsoluteResourceInternal("/", true);
final StringBuilder resolutionPath = new StringBuilder();
final StringTokenizer tokener = new StringTokenizer(absPath, "/");
while (resource != null && tokener.hasMoreTokens()) {
final String childNameRaw = tokener.nextToken();
Resource nextResource = getChildInternal(resource, childNameRaw);
if (nextResource != null) {
resource = nextResource;
resolutionPath.append("/").append(childNameRaw);
} else {
String childName = null;
final ResourcePathIterator rpi = new ResourcePathIterator(childNameRaw);
while (rpi.hasNext() && nextResource == null) {
childName = rpi.next();
nextResource = getChildInternal(resource, childName);
}
// switch the currentResource to the nextResource (may be
// null)