use of com.odysseusinc.arachne.portal.model.AbstractStudyFile in project ArachneCentralAPI by OHDSI.
the class StudyFileServiceImpl method archiveFiles.
@Override
public void archiveFiles(OutputStream os, Path filePath, List<? extends AbstractStudyFile> files) throws IOException {
ZipOutputStream zos = new ZipOutputStream(os);
for (AbstractStudyFile studyFile : files) {
ZipEntry entry = new ZipEntry(studyFile.getRealName());
Path file = filePath.resolve(studyFile.getUuid());
entry.setSize(file.toFile().length());
zos.putNextEntry(entry);
zos.write(Files.readAllBytes(file));
zos.closeEntry();
}
zos.flush();
zos.close();
}
use of com.odysseusinc.arachne.portal.model.AbstractStudyFile in project ArachneCentralAPI by OHDSI.
the class StudyFileServiceImpl method getFileInputStream.
@Override
public InputStream getFileInputStream(AbstractStudyFile studyFile) throws FileNotFoundException {
Objects.requireNonNull(studyFile, "File must not be null");
final File file = getPathToFile(studyFile).toFile();
if (!file.exists()) {
if (!StringUtils.isEmpty(studyFile.getLink())) {
InputStream response = getInputStream(studyFile);
if (response != null) {
return response;
}
}
throw new FileNotFoundException();
}
return new FileInputStream(file);
}
Aggregations