return;
}
while (childrenIterator.hasNext() || nodeChildrenListIt.hasNext()) {
ResourceProxy childResource = childrenIterator.next();
Node childNode = nodeChildrenListIt.next();
// order is as expected, skip reordering
if (Text.getName(childResource.getPath()).equals(childNode.getName())) {
// descend into covered child resources once they are properly arranged and perform reordering
if (resourceToReorder.covers(childResource.getPath())) {
reorderChildNodes(childNode, childResource);
}
continue;
}
// don't perform any reordering if this particular node does not have reorderable children
if (!nodeToReorder.getPrimaryNodeType().hasOrderableChildNodes()) {
getLogger().trace("Node at {0} does not have orderable child nodes, skipping reordering of {1}",
nodeToReorder.getPath(), childResource.getPath());
continue;
}
String expectedParentName;
if (childrenIterator.hasNext()) {
expectedParentName = Text.getName(childrenIterator.next().getPath());
childrenIterator.previous(); // move back
} else {
expectedParentName = null;
}
getLogger().trace("For node at {0} ordering {1} before {2}", nodeToReorder.getPath(),
Text.getName(childResource.getPath()), expectedParentName);
nodeToReorder.orderBefore(Text.getName(childResource.getPath()), expectedParentName);
}
}