use of org.jbei.ice.lib.folder.collection.CollectionType in project ice by JBEI.
the class CollectionResource method read.
/**
* Retrieve entries by collection type using paging parameters, including a filter
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{type}/entries")
public Response read(@PathParam("type") String collectionType, @DefaultValue("0") @QueryParam("offset") final int offset, @DefaultValue("15") @QueryParam("limit") final int limit, @DefaultValue("created") @QueryParam("sort") final String sort, @DefaultValue("false") @QueryParam("asc") final boolean asc, @DefaultValue("") @QueryParam("filter") String filter, @QueryParam("fields") List<String> queryParam) {
String userId = requireUserId();
try {
CollectionType type = CollectionType.valueOf(collectionType.toUpperCase());
ColumnField sortField = ColumnField.valueOf(sort.toUpperCase());
log(userId, "retrieving entries for collection " + type);
CollectionEntries entries = new CollectionEntries(userId, type);
return super.respond(entries.getEntries(sortField, asc, offset, limit, filter));
} catch (PermissionException pe) {
return super.respond(Response.Status.FORBIDDEN);
} catch (IllegalArgumentException ie) {
throw new WebApplicationException(Response.Status.BAD_REQUEST);
} catch (Exception e) {
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
}
}
Aggregations