use of org.jbei.ice.lib.entry.sequence.ByteArrayWrapper in project ice by JBEI.
the class EntriesAsCSV method writeZip.
private boolean writeZip(String userId, Set<Long> sequenceSet) {
SequenceController sequenceController = new SequenceController();
Path tmpPath = Paths.get(Utils.getConfigValue(ConfigurationKey.TEMPORARY_DIRECTORY));
try {
File tmpZip = File.createTempFile("zip-", ".zip", tmpPath.toFile());
// out
FileOutputStream fos = new FileOutputStream(tmpZip);
ZipOutputStream zos = new ZipOutputStream(fos);
// get sequence formats
for (long entryId : sequenceSet) {
for (String format : formats) {
ByteArrayWrapper wrapper = sequenceController.getSequenceFile(userId, entryId, format);
putZipEntry(wrapper, zos);
}
}
// write the csv file
FileInputStream fis = new FileInputStream(csvPath.toFile());
ByteArrayWrapper wrapper = new ByteArrayWrapper(IOUtils.toByteArray(fis), "entries.csv");
putZipEntry(wrapper, zos);
zos.close();
csvPath = tmpZip.toPath();
return true;
} catch (Exception e) {
Logger.error(e);
return false;
}
}
Aggregations