{
log.warn("Attempting to move the root node. Not taking any action, treating this as a no-op.");
return;
}
WorkspaceNode oldParent = fetchWorkspaceNode(ctx, nodeFqn.getParent(), ws, false, true);
if (oldParent == null) throw new NodeNotExistsException("Node " + nodeFqn.getParent() + " does not exist!");
if (parentFqn.equals(oldParent.getFqn()))
{
log.warn("Attempting to move a node in same place. Not taking any action, treating this as a no-op.");
return;
}
// retrieve parent
WorkspaceNode parent = fetchWorkspaceNode(ctx, parentFqn, ws, false, true);
if (parent == null) throw new NodeNotExistsException("Node " + parentFqn + " does not exist!");
Object nodeName = nodeFqn.getLastElement();
// now that we have the parent and target nodes:
// first correct the pointers at the pruning point
oldParent.removeChild(nodeName);
// parent pointer is calculated on the fly using Fqns.
// now adjust Fqns of node and all children.
Fqn nodeNewFqn = Fqn.fromRelativeElements(parent.getFqn(), nodeFqn.getLastElement());
// pre-notify
notifier.notifyNodeMoved(nodeFqn, nodeNewFqn, true, ctx);
recursiveMoveNode(ctx, node, parent.getFqn(), ws);
// remove old nodes. this may mark some nodes which have already been moved as deleted
removeNode(ws, node, false, ctx);
// post-notify