+ versionableIdentifier);
}
}
SessionChangesLog changesLog = new SessionChangesLog(session.getId());
for (VersionImpl v : existedVersions.keySet())
{
try
{
NodeData node = existedVersions.get(v);
NodeData destParent = (NodeData)dataManager.getItemData(node.getParentIdentifier());
NodeData vh = (NodeData)dataManager.getItemData(v.getParentIdentifier()); // version
// parent
// it's a VH
VersionHistoryDataHelper historyHelper =
new VersionHistoryDataHelper((NodeData)vh, dataManager, nodeTypeManager);
changesLog.addAll(v.restoreLog(destParent, node.getQPath().getName(), historyHelper, session,
removeExisting, changesLog).getAllStates());
}
catch (ItemExistsException e)
{
throw new ItemExistsException("Workspace restore. Can't restore a node. "
+ v.getContainingHistory().getVersionableUUID() + ". " + e.getMessage(), e);
}
catch (RepositoryException e)
{
throw new RepositoryException("Workspace restore. Can't restore a node. "
+ v.getContainingHistory().getVersionableUUID() + ". Repository error: " + e.getMessage(), e);
}
}
for (VersionImpl v : notExistedVersions)
{
String versionableIdentifier = v.getContainingHistory().getVersionableUUID();
try
{
NodeData node = null;
for (ItemState change : changesLog.getAllStates())
{
if (change.isNode() && change.isAdded()
&& ((NodeData)change.getData()).getIdentifier().equals(versionableIdentifier))
{
node = (NodeData)change.getData();
break;
}
}
if (node != null)
{
NodeData destParent = (NodeData)dataManager.getItemData(node.getParentIdentifier());
// version parent it's a VH
NodeData vh = (NodeData)dataManager.getItemData(v.getParentIdentifier());
VersionHistoryDataHelper historyHelper =
new VersionHistoryDataHelper((NodeData)vh, dataManager, nodeTypeManager);
changesLog.addAll(v.restoreLog(destParent, node.getQPath().getName(), historyHelper, session,
removeExisting, changesLog).getAllStates());
}
else
{
throw new VersionException("No such node restored before (for version, from the array of versions, "