Search in sources :

Example 1 with Experiments

use of org.jbei.ice.lib.experiment.Experiments in project ice by JBEI.

the class PartResource method deletePartExperiment.

@DELETE
@Path("/{id}/experiments/{eid}")
public Response deletePartExperiment(@PathParam("id") final String partId, @PathParam("eid") final long experimentId) {
    try {
        String userId = requireUserId();
        log(userId, "deleting experiment " + experimentId + " for entry " + partId);
        Experiments experiments = new Experiments(userId, partId);
        return super.respond(experiments.deleteStudy(experimentId));
    } catch (PermissionException e) {
        throw new WebApplicationException(Response.Status.FORBIDDEN);
    } catch (IllegalArgumentException ile) {
        throw new WebApplicationException(Response.Status.BAD_REQUEST);
    }
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) Experiments(org.jbei.ice.lib.experiment.Experiments)

Example 2 with Experiments

use of org.jbei.ice.lib.experiment.Experiments in project ice by JBEI.

the class PartResource method createPartExperiment.

@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/experiments")
public Response createPartExperiment(@PathParam("id") final String partId, final Study study) {
    try {
        final String userId = requireUserId();
        log(userId, "adding experiment " + study.toString() + " to " + partId);
        Experiments experiments = new Experiments(userId, partId);
        final Study created = experiments.createOrUpdateStudy(study);
        return respond(Response.Status.OK, created);
    } catch (PermissionException e) {
        throw new WebApplicationException(Response.Status.FORBIDDEN);
    } catch (IllegalArgumentException ile) {
        throw new WebApplicationException(Response.Status.BAD_REQUEST);
    }
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) Study(org.jbei.ice.lib.experiment.Study) Experiments(org.jbei.ice.lib.experiment.Experiments)

Example 3 with Experiments

use of org.jbei.ice.lib.experiment.Experiments in project ice by JBEI.

the class PartResource method getPartExperiments.

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/experiments")
public Response getPartExperiments(@PathParam("id") final String partId) {
    final String userId = requireUserId();
    try {
        Experiments experiments = new Experiments(userId, partId);
        final List<Study> studies = experiments.getPartStudies();
        return respond(Response.Status.OK, studies);
    } catch (PermissionException e) {
        throw new WebApplicationException(Response.Status.FORBIDDEN);
    } catch (IllegalArgumentException ile) {
        throw new WebApplicationException(Response.Status.BAD_REQUEST);
    }
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) Study(org.jbei.ice.lib.experiment.Study) Experiments(org.jbei.ice.lib.experiment.Experiments)

Aggregations

PermissionException (org.jbei.ice.lib.access.PermissionException)3 Experiments (org.jbei.ice.lib.experiment.Experiments)3 Study (org.jbei.ice.lib.experiment.Study)2