use of javax.ws.rs.ForbiddenException in project mica2 by obiba.
the class DataAccessRequestResource method submit.
//
// Private methods
//
private Response submit(String id) {
DataAccessRequest request = dataAccessRequestService.findById(id);
boolean fromOpened = request.getStatus() == DataAccessRequest.Status.OPENED;
boolean fromConditionallyApproved = request.getStatus() == DataAccessRequest.Status.CONDITIONALLY_APPROVED;
if (fromOpened && !subjectAclService.isCurrentUser(request.getApplicant())) {
// only applicant can submit an opened request
throw new ForbiddenException();
}
dataAccessRequestService.updateStatus(id, DataAccessRequest.Status.SUBMITTED);
if (fromOpened || fromConditionallyApproved) {
// applicant cannot edit, nor delete request anymore + status cannot be changed
subjectAclService.removePermission("/data-access-request", "EDIT,DELETE", id);
subjectAclService.removePermission("/data-access-request/" + id, "EDIT", "_status");
// data access officers can change the status of this request
subjectAclService.addGroupPermission(Roles.MICA_DAO, "/data-access-request/" + id, "EDIT", "_status");
}
return Response.noContent().build();
}
Aggregations