use of org.eclipse.vorto.repository.tenant.NewNamespacesNotSupersetException in project vorto by eclipse.
the class ModelRepository method rename.
@Override
public ModelInfo rename(ModelId oldModelId, ModelId newModelId, IUserContext user) {
Namespace namespace = namespaceService.findNamespaceByWorkspaceId(getWorkspaceId());
if (getById(newModelId) != null) {
throw new ModelAlreadyExistsException();
} else if (!newModelId.getNamespace().startsWith(namespace.getName())) {
throw new NewNamespacesNotSupersetException();
}
ModelInfo oldModel = getById(oldModelId);
ChangeSet changeSet = refactorModelWithNewId(oldModel, newModelId);
saveChangeSetIntoRepository(changeSet, user);
ModelInfo newModel = getById(newModelId);
newModel = copy(oldModel, newModel, user);
removeModel(oldModel.getId());
return newModel;
}
Aggregations