*/
private Resource resolveInternal(String absPath) {
Resource resource = null;
String curPath = absPath;
try {
final ResourcePathIterator it = new ResourcePathIterator(absPath);
while (it.hasNext() && resource == null) {
curPath = it.next();
resource = getResourceInternal(curPath);
}
} catch (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) {
String rpi = absPath.substring(curPath.length());
resource.getResourceMetadata().setResolutionPathInfo(rpi);
log.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 = getResourceInternal("/");
StringTokenizer tokener = new StringTokenizer(absPath, "/");
while (resource != null && tokener.hasMoreTokens()) {
String childNameRaw = tokener.nextToken();
Resource nextResource = getChildInternal(resource, childNameRaw);
if (nextResource != null) {
resource = nextResource;
} else {
String childName = null;
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)