Search in sources :

Example 1 with ObjectNotFoundException

use of de.tudarmstadt.ukp.clarin.webanno.webapp.remoteapi.v2.exception.ObjectNotFoundException in project webanno by webanno.

the class RemoteApiController2 method getProject.

private Project getProject(long aProjectId) throws ObjectNotFoundException, AccessForbiddenException {
    // Get current user - this will throw an exception if the current user does not exit
    User user = getCurrentUser();
    // Get project
    Project project;
    try {
        project = projectService.getProject(aProjectId);
    } catch (NoResultException e) {
        throw new ObjectNotFoundException("Project [" + aProjectId + "] not found.");
    }
    // Check for the access
    assertPermission("User [" + user.getUsername() + "] is not allowed to access project [" + aProjectId + "]", isProjectAdmin(project, projectService, user) || isSuperAdmin(projectService, user));
    return project;
}
Also used : RProject(de.tudarmstadt.ukp.clarin.webanno.webapp.remoteapi.v2.model.RProject) Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) ObjectNotFoundException(de.tudarmstadt.ukp.clarin.webanno.webapp.remoteapi.v2.exception.ObjectNotFoundException) NoResultException(javax.persistence.NoResultException)

Aggregations

Project (de.tudarmstadt.ukp.clarin.webanno.model.Project)1 User (de.tudarmstadt.ukp.clarin.webanno.security.model.User)1 ObjectNotFoundException (de.tudarmstadt.ukp.clarin.webanno.webapp.remoteapi.v2.exception.ObjectNotFoundException)1 RProject (de.tudarmstadt.ukp.clarin.webanno.webapp.remoteapi.v2.model.RProject)1 NoResultException (javax.persistence.NoResultException)1