use of org.broadinstitute.consent.http.models.DarCollection in project consent by DataBiosphere.
the class DarCollectionResource method getCollectionsByToken.
@GET
@Path("role/{roleName}/paginated")
@Produces("application/json")
@RolesAllowed(RESEARCHER)
public Response getCollectionsByToken(@Auth AuthUser authUser, @QueryParam("token") String token, @PathParam("roleName") String roleName) {
try {
User user = userService.findUserByEmail(authUser.getEmail());
validateUserHasRoleName(user, roleName);
String json = getDecodedJson(token);
PaginationToken paginationToken = convertJsonToPaginationToken(json);
PaginationResponse<DarCollection> paginationResponse = darCollectionService.queryCollectionsByFiltersAndUserRoles(user, paginationToken, roleName);
return Response.ok().entity(paginationResponse).build();
} catch (Exception e) {
return createExceptionResponse(e);
}
}
use of org.broadinstitute.consent.http.models.DarCollection in project consent by DataBiosphere.
the class DarCollectionResource method resubmitDarCollection.
@PUT
@Path("{id}/resubmit")
@Produces("application/json")
@RolesAllowed(RESEARCHER)
public Response resubmitDarCollection(@Auth AuthUser authUser, @PathParam("id") Integer collectionId) {
try {
User user = userService.findUserByEmail(authUser.getEmail());
DarCollection sourceCollection = darCollectionService.getByCollectionId(collectionId);
isCollectionPresent(sourceCollection);
validateUserIsCreator(user, sourceCollection);
validateCollectionIsCanceled(sourceCollection);
DataAccessRequest draftDar = dataAccessRequestService.createDraftDarFromCanceledCollection(user, sourceCollection);
return Response.ok().entity(draftDar).build();
} catch (Exception e) {
return createExceptionResponse(e);
}
}
use of org.broadinstitute.consent.http.models.DarCollection in project consent by DataBiosphere.
the class DarCollectionResource method createElectionsForCollection.
@POST
@Path("{collectionId}/election")
@Consumes("application/json")
@RolesAllowed({ ADMIN, CHAIRPERSON })
public Response createElectionsForCollection(@Auth AuthUser authUser, @PathParam("collectionId") Integer collectionId) {
try {
DarCollection sourceCollection = darCollectionService.getByCollectionId(collectionId);
isCollectionPresent(sourceCollection);
User user = userService.findUserByEmail(authUser.getEmail());
DarCollection updatedCollection = darCollectionService.createElectionsForDarCollection(user, sourceCollection);
return Response.ok(updatedCollection).build();
} catch (Exception e) {
return createExceptionResponse(e);
}
}
use of org.broadinstitute.consent.http.models.DarCollection in project consent by DataBiosphere.
the class DarCollectionResource method getCollectionsForUserByRole.
@GET
@Path("role/{roleName}")
@Produces("application/json")
@RolesAllowed({ ADMIN, CHAIRPERSON, MEMBER, SIGNINGOFFICIAL })
public Response getCollectionsForUserByRole(@Auth AuthUser authUser, @PathParam("roleName") String roleName) {
try {
User user = userService.findUserByEmail(authUser.getEmail());
validateUserHasRoleName(user, roleName);
List<DarCollection> collections = darCollectionService.getCollectionsForUserByRoleName(user, roleName);
return Response.ok().entity(collections).build();
} catch (Exception e) {
return createExceptionResponse(e);
}
}
use of org.broadinstitute.consent.http.models.DarCollection in project consent by DataBiosphere.
the class DarCollectionResource method getCollectionById.
@GET
@Path("{collectionId}")
@Produces("application/json")
@PermitAll
public Response getCollectionById(@Auth AuthUser authUser, @PathParam("collectionId") Integer collectionId) {
try {
DarCollection collection = darCollectionService.getByCollectionId(collectionId);
User user = userService.findUserByEmail(authUser.getEmail());
if (checkAdminPermissions(user) || checkSoPermissions(user, collection) || checkDacPermissions(user, collection)) {
return Response.ok().entity(collection).build();
}
validateUserIsCreator(user, collection);
return Response.ok().entity(collection).build();
} catch (Exception e) {
return createExceptionResponse(e);
}
}
Aggregations