What is the definition of a document's parent?
More specifically, how do I differentiate between the immediate parent and the parent of the parent(grandparent) when using the JAVA code below?
DocumentModel x = session.getParentDocument( input.getParentRef());
where session is the injected session and input is a reference to the current document's DocumentModel.
If I look at x.getType() the type is the parent of the parent (grandparent) not the parent document.
The documents on all three levels are folders (from bottom to top a folder, in a folder, in a folder)
0 votes
1 answers
3502 views
The code below produces interesting results:
parentTitle contains the Title of the grandparent document.
The DocumentModelList children contains a list of documents in the immediate parent document.
parentDoc = session.getParentDocument(input.getParentRef());
String parentTitle =parentDoc.getTitle();
DocumentModelList children = session.getChildren(input.getParentRef());
log.info("Parent title = "+ parentTitle);
for (DocumentModel z:children){
}