StagedNode srcParent = getStagedNode(srcParentPath, false);
if (srcParent == null) {
// the subtree to be copied has not been modified
ChildNodeEntry entry = getStoredNode(srcParentPath).getChildNodeEntry(srcNodeName);
if (entry == null) {
throw new NotFoundException(srcPath);
}
StagedNode destParent = getStagedNode(destParentPath, true);
if (destParent.getChildNodeEntry(destNodeName) != null) {
throw new Exception("node already exists at copy destination path: " + destPath);
}
destParent.add(new ChildNodeEntry(destNodeName, entry.getId()));
return;
}
ChildNodeEntry srcEntry = srcParent.getChildNodeEntry(srcNodeName);
if (srcEntry == null) {
throw new NotFoundException(srcPath);
}
StagedNode destParent = getStagedNode(destParentPath, true);
StagedNode srcNode = getStagedNode(srcPath, false);
if (srcNode != null) {