I'm trying to move a Node with its children to another Node in a JCR repository, but I keep getting this error:
A node definition that allows same name siblings could not be found for the node "/A/B[2]" in workspace "default".
If I understood it correctly, it's trying to tell me that I'm trying to create a Node in the destination path with an ID that allready exists over there. But it doesn't!
My structure consists of two parents, each with one child:
A --> B
C --> D
I'm trying to move D to B so the structure afterwards would be:
A --> B --> D
C
Here's my code, I hope that the paths are set correctly:
private void moveNode(final Node movedNode, final Node destinationNode)
throws RepositoryException {
System.out.println(movedNode.getPath()); // prints "/C/D"
System.out.println(destinationNode.getPath()); // prints "/A/B"
modeshape.execute(new JcrHandler<Object>() {
@Override
public Object execute(Session session) throws RepositoryException {
session.move(movedNode.getPath(), destinationNode.getPath());
return null;
}
});
}
Thanks for advice!