Skip to main content

Various Operations on JCR Nodes

Loop over all Parents of given Child Node

@Self
private Resource currentResource;

/**
Loops over all parents to find 'customNode' e.g meta tags set via dialog multi
*/
private Resource getCustomNodeResource(Page page) {
String childPath = "/jcr:content/customNode";
Resource resource = null;
int currentPageDepth = page.getDepth();
for (int i=1; i < currentPageDepth; i++) {
resource = currentResource.getChild(page.getPath() + childPath);
if (resource != null) {
break;
} else {
page = page.getParent();
}
}
return resource;
}