Search in sources :

Example 1 with CreateNewProjectResult

use of edu.stanford.bmir.protege.web.shared.project.CreateNewProjectResult in project webprotege by protegeproject.

the class CreateNewProjectActionHandler method execute.

@Nonnull
@Override
public CreateNewProjectResult execute(@Nonnull CreateNewProjectAction action, @Nonnull ExecutionContext executionContext) {
    try {
        UserId userId = executionContext.getUserId();
        if (!accessManager.hasPermission(forUser(userId), ApplicationResource.get(), CREATE_EMPTY_PROJECT)) {
            throw new PermissionDeniedException("You do not have permission to create new projects", userInSessionFactory.getUserInSession(userId));
        }
        NewProjectSettings newProjectSettings = action.getNewProjectSettings();
        if (newProjectSettings.hasSourceDocument()) {
            if (!accessManager.hasPermission(forUser(userId), ApplicationResource.get(), UPLOAD_PROJECT)) {
                throw new PermissionDeniedException("You do not have permission to upload projects", userInSessionFactory.getUserInSession(userId));
            }
        }
        ProjectId projectId = pm.createNewProject(newProjectSettings);
        if (!projectDetailsManager.isExistingProject(projectId)) {
            projectDetailsManager.registerProject(projectId, newProjectSettings);
            applyDefaultPermissions(projectId, userId);
        }
        return new CreateNewProjectResult(projectDetailsManager.getProjectDetails(projectId));
    } catch (OWLOntologyCreationException | OWLOntologyStorageException | IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : OWLOntologyCreationException(org.semanticweb.owlapi.model.OWLOntologyCreationException) NewProjectSettings(edu.stanford.bmir.protege.web.shared.project.NewProjectSettings) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) PermissionDeniedException(edu.stanford.bmir.protege.web.shared.permissions.PermissionDeniedException) CreateNewProjectResult(edu.stanford.bmir.protege.web.shared.project.CreateNewProjectResult) IOException(java.io.IOException) OWLOntologyStorageException(org.semanticweb.owlapi.model.OWLOntologyStorageException) Nonnull(javax.annotation.Nonnull)

Aggregations

PermissionDeniedException (edu.stanford.bmir.protege.web.shared.permissions.PermissionDeniedException)1 CreateNewProjectResult (edu.stanford.bmir.protege.web.shared.project.CreateNewProjectResult)1 NewProjectSettings (edu.stanford.bmir.protege.web.shared.project.NewProjectSettings)1 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)1 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)1 IOException (java.io.IOException)1 Nonnull (javax.annotation.Nonnull)1 OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)1 OWLOntologyStorageException (org.semanticweb.owlapi.model.OWLOntologyStorageException)1