Skip to content

Commit

Permalink
Merge branch '5.8.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
hplahar committed Jan 14, 2021
2 parents 08beee6 + 2c309b1 commit cb2a7a7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/jbei/ice/lib/entry/EntriesAsCSV.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private void writeZip(Set<Long> sequenceSet) {
for (long entryId : sequenceSet) {
for (String format : formats) {
InputStreamWrapper wrapper = new PartSequence(userId, Long.toString(entryId))
.toFile(SequenceFormat.fromString(format), true, false);
.toFile(SequenceFormat.fromString(format), true);
putZipEntry(wrapper, zos);
}
}
Expand Down Expand Up @@ -318,7 +318,7 @@ public ByteArrayOutputStream customize(EntrySelection selection, SequenceFormat
}

// get the sequence
InputStreamWrapper wrapper = new PartSequence(userId, Long.toString(entryId)).toFile(format, onePerFolder, false);
InputStreamWrapper wrapper = new PartSequence(userId, Long.toString(entryId)).toFile(format, onePerFolder);
if (wrapper == null) {
Logger.error("ERROR : no sequence " + entryId);
continue;
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/org/jbei/ice/lib/entry/sequence/PartSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -518,21 +518,20 @@ private boolean checkSameFeature(SequenceFeature existingSequenceFeature, Sequen
/**
* Convert sequence to a byte array of the specified format with the intention of being written to a file
*
* @param format specified format for sequence conversion
* @param useFileName whether to use the original filename of the sequence if the original uploaded sequence is
* available
* @param useOriginalIfAvailable whether to use specified format if is it the same as the uploaded format
* @param format specified format for sequence conversion
* @param useFileName whether to use the original filename of the sequence if the original uploaded sequence is
* available
* @return wrapper around the outputstream for the converted format and name
*/
public InputStreamWrapper toFile(SequenceFormat format, boolean useFileName, boolean useOriginalIfAvailable) {
public InputStreamWrapper toFile(SequenceFormat format, boolean useFileName) {
entryAuthorization.expectRead(userId, entry);
Sequence sequence = sequenceDAO.getByEntry(entry);
if (sequence == null)
return null;

// if requested format is the same as the original format (if original exist) then get the original instead
if (useOriginalIfAvailable && sequenceDAO.hasOriginalSequence(entry.getId()))
format = SequenceFormat.ORIGINAL;
// default format of genbank
if (format == null)
format = SequenceFormat.GENBANK;

return new SequenceAsString(format, entry.getId(), useFileName).get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public SequenceAsString(SequenceFormat format, long partId, boolean useFileName)
switch (format) {
case ORIGINAL:
sequenceString = sequence.getSequenceUser();
if (!useFileName && !StringUtils.isEmpty(sequence.getFileName())) {
if (StringUtils.isEmpty(sequence.getFileName()) || !useFileName) {
name = entry.getPartNumber() + ".gb";
} else {
name = sequence.getFileName();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jbei/ice/services/rest/FileResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public Response downloadSequence(

return addHeaders(Response.ok(stream), wrapper.getName());
} else {
InputStreamWrapper wrapper = new PartSequence(userId, partId).toFile(SequenceFormat.fromString(downloadType), true, true);
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());
}
Expand Down

0 comments on commit cb2a7a7

Please sign in to comment.