sessionDelegate.perform(new SessionOperation<Void>(true) {
@Override
public Void perform() throws RepositoryException {
// check for pending changes
checkPendingChangesForRestore(sessionDelegate);
NodeDelegate n = sessionDelegate.getNodeByIdentifier(versionableId);
if (n == null) {
throw new VersionException("Unable to restore version. " +
"No versionable node with identifier: " + versionableId);
}
// check lock status
checkNotLocked(n.getPath());
// check for existing nodes
List<NodeDelegate> existing = getExisting(version,
Collections.singleton(n.getPath()));
boolean success = false;
try {
if (!existing.isEmpty()) {
if (removeExisting) {
removeExistingNodes(existing);
} else {
List<String> paths = new ArrayList<String>();
for (NodeDelegate nd : existing) {
paths.add(nd.getPath());
}
throw new ItemExistsException("Unable to restore with " +
"removeExisting=false. Existing nodes in " +
"workspace: " + paths);
}
}
// ready for restore
VersionDelegate vd = versionManagerDelegate.getVersionByIdentifier(
version.getIdentifier());
versionManagerDelegate.restore(
n.getParent(), n.getName(), vd);
sessionDelegate.getRoot().commit();
success = true;
} catch (CommitFailedException e) {
throw new RepositoryException(e);
} finally {