Search in sources :

Example 1 with CollectionType

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);
    }
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) CollectionEntries(org.jbei.ice.lib.folder.collection.CollectionEntries) CollectionType(org.jbei.ice.lib.folder.collection.CollectionType) ColumnField(org.jbei.ice.lib.shared.ColumnField) PermissionException(org.jbei.ice.lib.access.PermissionException)

Aggregations

PermissionException (org.jbei.ice.lib.access.PermissionException)1 CollectionEntries (org.jbei.ice.lib.folder.collection.CollectionEntries)1 CollectionType (org.jbei.ice.lib.folder.collection.CollectionType)1 ColumnField (org.jbei.ice.lib.shared.ColumnField)1