Search in sources :

Example 1 with RemoteSequence

use of org.jbei.ice.lib.net.RemoteSequence in project ice by JBEI.

the class FileResource method downloadSequence.

@GET
@Path("{partId}/sequence/{type}")
public Response downloadSequence(@PathParam("partId") final String partId, @PathParam("type") final String downloadType, @DefaultValue("-1") @QueryParam("remoteId") long remoteId, @QueryParam("sid") String sid) {
    if (StringUtils.isEmpty(sessionId))
        sessionId = sid;
    final String userId = getUserId(sessionId);
    if (remoteId != -1) {
        RemoteSequence sequence = new RemoteSequence(remoteId, Long.decode(partId));
        final InputStreamWrapper wrapper = sequence.get(downloadType);
        StreamingOutput stream = output -> IOUtils.copy(wrapper.getInputStream(), output);
        return addHeaders(Response.ok(stream), wrapper.getName());
    } else {
        InputStreamWrapper wrapper = new PartSequence(userId, partId).toFile(SequenceFormat.fromString(downloadType), true);
        StreamingOutput stream = output -> IOUtils.copy(wrapper.getInputStream(), output);
        return addHeaders(Response.ok(stream), wrapper.getName());
    }
}
Also used : RemoteSequence(org.jbei.ice.lib.net.RemoteSequence) AttachmentInfo(org.jbei.ice.lib.dto.entry.AttachmentInfo) FormDataContentDisposition(org.glassfish.jersey.media.multipart.FormDataContentDisposition) ConfigurationSettings(org.jbei.ice.lib.config.ConfigurationSettings) Sequences(org.jbei.ice.lib.entry.sequence.Sequences) PartSequence(org.jbei.ice.lib.entry.sequence.PartSequence) Setting(org.jbei.ice.lib.dto.Setting) TraceSequences(org.jbei.ice.lib.entry.sequence.analysis.TraceSequences) ConfigurationKey(org.jbei.ice.lib.dto.ConfigurationKey) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) Entries(org.jbei.ice.lib.entry.Entries) MediaType(javax.ws.rs.core.MediaType) DAOFactory(org.jbei.ice.storage.DAOFactory) Logger(org.jbei.ice.lib.common.logging.Logger) ByteArrayInputStream(java.io.ByteArrayInputStream) FileBulkUpload(org.jbei.ice.lib.bulkupload.FileBulkUpload) SequenceInfo(org.jbei.ice.lib.dto.entry.SequenceInfo) SequenceFormat(org.jbei.ice.lib.entry.sequence.SequenceFormat) EntryType(org.jbei.ice.lib.dto.entry.EntryType) Utils(org.jbei.ice.lib.utils.Utils) EntrySelection(org.jbei.ice.lib.entry.EntrySelection) Files(java.nio.file.Files) FileUtils(org.apache.commons.io.FileUtils) StreamingOutput(javax.ws.rs.core.StreamingOutput) IOException(java.io.IOException) InputStreamWrapper(org.jbei.ice.lib.entry.sequence.InputStreamWrapper) Collectors(java.util.stream.Collectors) EntryFieldLabel(org.jbei.ice.lib.dto.entry.EntryFieldLabel) File(java.io.File) IOUtils(org.apache.commons.io.IOUtils) Attachments(org.jbei.ice.lib.entry.attachment.Attachments) RemoteEntries(org.jbei.ice.lib.net.RemoteEntries) FormDataParam(org.glassfish.jersey.media.multipart.FormDataParam) List(java.util.List) javax.ws.rs(javax.ws.rs) Response(javax.ws.rs.core.Response) Paths(java.nio.file.Paths) ShotgunSequenceDAO(org.jbei.ice.storage.hibernate.dao.ShotgunSequenceDAO) TraceSequence(org.jbei.ice.storage.model.TraceSequence) EntriesAsCSV(org.jbei.ice.lib.entry.EntriesAsCSV) InvalidFormatParserException(org.jbei.ice.lib.parsers.InvalidFormatParserException) ShotgunSequence(org.jbei.ice.storage.model.ShotgunSequence) InputStream(java.io.InputStream) InputStreamWrapper(org.jbei.ice.lib.entry.sequence.InputStreamWrapper) PartSequence(org.jbei.ice.lib.entry.sequence.PartSequence) StreamingOutput(javax.ws.rs.core.StreamingOutput) RemoteSequence(org.jbei.ice.lib.net.RemoteSequence)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 javax.ws.rs (javax.ws.rs)1 MediaType (javax.ws.rs.core.MediaType)1 Response (javax.ws.rs.core.Response)1 StreamingOutput (javax.ws.rs.core.StreamingOutput)1 FileUtils (org.apache.commons.io.FileUtils)1 IOUtils (org.apache.commons.io.IOUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 FormDataContentDisposition (org.glassfish.jersey.media.multipart.FormDataContentDisposition)1 FormDataParam (org.glassfish.jersey.media.multipart.FormDataParam)1 FileBulkUpload (org.jbei.ice.lib.bulkupload.FileBulkUpload)1 Logger (org.jbei.ice.lib.common.logging.Logger)1