Search in sources :

Example 1 with NewNamespacesNotSupersetException

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;
}
Also used : NewNamespacesNotSupersetException(org.eclipse.vorto.repository.tenant.NewNamespacesNotSupersetException) ChangeSet(org.eclipse.vorto.model.refactor.ChangeSet) Namespace(org.eclipse.vorto.repository.domain.Namespace)

Aggregations

ChangeSet (org.eclipse.vorto.model.refactor.ChangeSet)1 Namespace (org.eclipse.vorto.repository.domain.Namespace)1 NewNamespacesNotSupersetException (org.eclipse.vorto.repository.tenant.NewNamespacesNotSupersetException)1