public void endElement(String uri, String localName, String qName) throws SAXException {
log.debug("<- element {}", qName);
try {
// currentNode's import is finished, check if any child nodes
// need to be removed
NodeNameList childNames = stack.getChildNames();
Node node = stack.getNode();
int numChildren = 0;
if (node == null) {
DocViewAdapter adapter = stack.getAdapter();
if (adapter != null) {
adapter.endNode();
}
// close transformer if last in stack
if (stack.adapter != null) {
stack.adapter.close();
stack.adapter = null;
log.debug("Sysview transformation complete.");
}
} else {
NodeIterator iter = node.getNodes();
while (iter.hasNext()) {
numChildren++;
Node child = iter.nextNode();
String path = child.getPath();
String label = Text.getName(path);
if (!childNames.contains(label)
&& !hints.contains(path)
&& isIncluded(child, child.getDepth() - rootDepth)) {
// if the child is in the filter, it belongs to
// this aggregate and needs to be removed
if (aclManagement.isACLNode(child)) {
if (aclHandling == AccessControlHandling.OVERWRITE
|| aclHandling == AccessControlHandling.CLEAR) {
importInfo.onDeleted(path);
aclManagement.clearACL(node);
}
} else {
if (wspFilter.getImportMode(path) == ImportMode.REPLACE) {
importInfo.onDeleted(path);
child.remove();
}
}
} else if (aclHandling == AccessControlHandling.CLEAR
&& aclManagement.isACLNode(child)
&& isIncluded(child, child.getDepth() - rootDepth)) {
importInfo.onDeleted(path);
aclManagement.clearACL(node);
}
}
if (isIncluded(node, node.getDepth() - rootDepth)) {
// ensure order
stack.restoreOrder();
}
}
stack = stack.pop();
// if (stack.isRoot()) {
// // record child names of root node
// importInfo.setNameList(childNames);
// importInfo.setNode(node);
// }
if (node != null && numChildren == 0 && !childNames.isEmpty()) {
importInfo.addNameList(node.getPath(), childNames);
}
} catch (RepositoryException e) {
throw new SAXException(e);
}