public void restoreNodes(List<JcrNode> nodes, final JcrNode targetRootNode) {
if (nodes.isEmpty()) {
throw new IllegalStateException("List 'nodes' must contain at least one node.");
}
ParentLimiter limiter = null;
// targetRootNode is only applicable for regular Site nodes (not even
// global container)
final String siteRoot = SitePlugin.get().getSiteRootPath();
if (targetRootNode.getDepth() > 0) {
final String commonParent = getCommonParentPath(nodes);
limiter = new ParentLimiter() {
public boolean isFinalParent(JcrNode node, JcrNode parent) {
if (node.getPath().startsWith(siteRoot) && node instanceof GlobalContainerNode == false) {
return parent.getPath().equals(commonParent);
} else {
return parent.getDepth() == 0;