use of org.jbei.ice.lib.entry.sequence.Sequences in project ice by JBEI.
the class SequenceResource method updateSequences.
@PUT
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public Response updateSequences(@FormDataParam("file") InputStream fileInputStream, @FormDataParam("file") FormDataContentDisposition contentDisposition) {
String userId = requireUserId();
try {
Sequences controller = new Sequences(userId);
List<String> errors = controller.bulkUpdate(userId, fileInputStream);
return super.respond(errors);
} catch (PermissionException e) {
throw new WebApplicationException(e.getMessage(), Response.Status.UNAUTHORIZED);
} catch (Exception e) {
Logger.error(e);
throw new WebApplicationException(e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
}
}
use of org.jbei.ice.lib.entry.sequence.Sequences in project ice by JBEI.
the class FileResource method createSequenceModel.
/**
* Create a model of the uploaded sequence file. Note that this does not associate the sequence
* with any existing entry. It just parses the uploaded file
*/
@POST
@Path("sequence/model")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public Response createSequenceModel(@FormDataParam("file") InputStream fileInputStream, @FormDataParam("file") FormDataContentDisposition contentDispositionHeader) {
final String fileName = contentDispositionHeader.getFileName();
Sequences sequences = new Sequences(requireUserId());
try {
return super.respond(sequences.parseSequence(fileInputStream, fileName));
} catch (InvalidFormatParserException e) {
throw new WebApplicationException(e.getMessage());
}
}
use of org.jbei.ice.lib.entry.sequence.Sequences in project ice by JBEI.
the class PartResource method getSequence.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/sequence")
public Response getSequence(@PathParam("id") final String partId, @DefaultValue("false") @QueryParam("remote") boolean isRemote, @QueryParam("token") String remoteUserToken, @QueryParam("userId") String remoteUserId, @QueryParam("folderId") long fid, @DefaultValue("true") @QueryParam("annotations") boolean includeAnnotations) {
final FeaturedDNASequence sequence;
final String userId = getUserId();
Sequences sequences = new Sequences(userId);
if (isRemote) {
// entry exists remotely
sequence = remoteEntries.getSequence(userId, fid, partId);
} else {
// what request is being responded to (local or remote)
if (StringUtils.isEmpty(userId)) {
RegistryPartner partner = requireWebPartner();
if (StringUtils.isEmpty(remoteUserToken) || fid == 0) {
sequence = new PartSequence(userId, partId).get(includeAnnotations);
} else {
sequence = sequences.getRequestedSequence(partner, remoteUserId, remoteUserToken, partId, fid);
}
} else {
// user id can be null if partId is public
sequence = new PartSequence(userId, partId).get(includeAnnotations);
}
}
return Response.status(Response.Status.OK).entity(sequence).build();
}
Aggregations