if (original == null) {
switch (request.cloneConflictBehavior()) {
case DO_NOT_CLONE:
String msg = GraphI18n.workspaceDoesNotExistInRepository.text(nameOfWorkspaceToBeCloned,
repository.getSourceName());
request.setError(new InvalidWorkspaceException(msg));
return;
case SKIP_CLONE:
target = repository.createWorkspace(context, targetWorkspaceName, request.targetConflictBehavior());
if (target == null) {
msg = GraphI18n.workspaceAlreadyExistsInRepository.text(targetWorkspaceName, repository.getSourceName());
request.setError(new InvalidWorkspaceException(msg));
} else {
MapNode root = target.getRoot();
request.setActualRootLocation(Location.create(pathFactory.createRootPath(), root.getUuid()));
request.setActualWorkspaceName(target.getName());
}
return;
}
}
assert original != null;
target = repository.createWorkspace(context,
targetWorkspaceName,
request.targetConflictBehavior(),
nameOfWorkspaceToBeCloned);
if (target == null) {
// Since the original was there, the only reason the target wasn't created was because the workspace already existed
// ...
String msg = GraphI18n.workspaceAlreadyExistsInRepository.text(targetWorkspaceName, repository.getSourceName());
request.setError(new InvalidWorkspaceException(msg));
} else {
MapNode root = target.getRoot();
request.setActualRootLocation(Location.create(pathFactory.createRootPath(), root.getUuid()));
request.setActualWorkspaceName(target.getName());
recordChange(request);