Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>com.springsource.org.apache.commons.io</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down Expand Up @@ -199,6 +203,11 @@
</dependency>

<!--Util-->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.15.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,11 @@ public void exportCitation(@PathVariable String id,
response.setContentType(contentType);
response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");

InputStream in = new ByteArrayInputStream(citationString.getBytes(StandardCharsets.UTF_8));
OutputStream out = response.getOutputStream();
IOUtils.copy(in, out);
out.flush();
out.close();
in.close();
try (InputStream in = new ByteArrayInputStream(citationString.getBytes(StandardCharsets.UTF_8))) {
OutputStream out = response.getOutputStream();
IOUtils.copy(in, out);
out.flush();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,11 @@ public synchronized void diagramPPTX(@Parameter(description = "Stable Identifier
// when returning a FileSystemResource using Spring, then the file won't be deleted because it still has the
// reference to the file and then we cannot delete. Writing the file directly in the response allows us to
// delete only the temporary file.
OutputStream out = response.getOutputStream();
FileInputStream in = new FileInputStream(pptx);
IOUtils.copy(in, out);
out.flush();
out.close();
in.close();
try (FileInputStream in = new FileInputStream(pptx)) {
OutputStream out = response.getOutputStream();
IOUtils.copy(in, out);
out.flush();
}

// deleting the file in case it is decorated.
if (decorator.isDecorated() && !pptx.delete()) {
Expand Down Expand Up @@ -160,12 +159,11 @@ public synchronized void reactionPPTX(@Parameter(description = "DbId or StId of
// when returning a FileSystemResource using Spring, then the file won't be deleted because it still has the
// reference to the file and then we cannot delete. Writing the file directly in the response allows us to
// delete only the temporary file.
OutputStream out = response.getOutputStream();
FileInputStream in = new FileInputStream(pptx);
IOUtils.copy(in, out);
out.flush();
out.close();
in.close();
try (FileInputStream in = new FileInputStream(pptx)) {
OutputStream out = response.getOutputStream();
IOUtils.copy(in, out);
out.flush();
}

// deleting the file in case it is decorated.
if (decorator.isDecorated() && !pptx.delete()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ public synchronized void eventSBGN(@Parameter(description = "DbId or StId of the
String fileName = event.getStId() + SBGN_FILE_EXTENSION;
response.setContentType("application/sbgn+xml");
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
OutputStream out = response.getOutputStream();
IOUtils.copy(getSBGN(event, fileName), out);
out.flush();
out.close();
try (InputStream sbgn = getSBGN(event, fileName)) {
OutputStream out = response.getOutputStream();
IOUtils.copy(sbgn, out);
out.flush();
}
}

private InputStream getSBGN(Event event, String fileName) throws FileNotFoundException {
Expand Down Expand Up @@ -106,10 +107,11 @@ public synchronized void eventSBML(@Parameter(description = "DbId or StId of the
String fileName = event.getStId() + SBML_FILE_EXTENSION;
response.setContentType("application/sbml+xml");
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
OutputStream out = response.getOutputStream();
IOUtils.copy(getSBML(event, fileName), out);
out.flush();
out.close();
try (InputStream sbml = getSBML(event, fileName)) {
OutputStream out = response.getOutputStream();
IOUtils.copy(sbml, out);
out.flush();
}
}

private InputStream getSBML(Event event, String fileName) throws FileNotFoundException {
Expand Down