// if it's a target node
existing = sameIdentifierNode;
// remove existed node, with validation
ItemDataRemoveVisitor removeVisitor = new RemoveVisitor();
removeVisitor.visit(existing);
changes.addAll(removeVisitor.getRemovedStates());
}
else if (!sameIdentifierPath.isDescendantOf(nodePath))
{
if (removeExisting)
{
final QPath restorePath = nodePath;
// remove same uuid node, with validation
class RemoveVisitor extends ItemDataRemoveVisitor
{
RemoveVisitor() throws RepositoryException
{
super(userSession.getTransientNodesManager(), null, nodeTypeDataManager, userSession
.getAccessManager(), userSession.getUserState());
}
@Override
protected boolean isRemoveDescendant(ItemData item) throws RepositoryException
{
return item.getQPath().isDescendantOf(removedRoot.getQPath())
|| item.getQPath().isDescendantOf(restorePath);
}
};
ItemDataRemoveVisitor removeVisitor = new RemoveVisitor();
removeVisitor.visit(sameIdentifierNode);
changes.addAll(removeVisitor.getRemovedStates());
}
else
{
throw new ItemExistsException("Item with the same UUID as restored node " + nodePath.getAsString()
+ " already exists and removeExisting=false. Existed "