Skip to content

Commit

Permalink
Merge pull request #80 from diging/develop
Browse files Browse the repository at this point in the history
bugfix for null content files
  • Loading branch information
jdamerow authored Oct 22, 2019
2 parents e6e20a5 + 3a6a73f commit d378957
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
18 changes: 9 additions & 9 deletions giles-eco/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<org.slf4j-version>1.7.5</org.slf4j-version>
<com.fasterxml.jackson.version>2.8.4</com.fasterxml.jackson.version>

<geco.requests.version>0.7</geco.requests.version>
<geco.util.version>0.4.3</geco.util.version>
<geco.requests.version>0.9</geco.requests.version>
<geco.util.version>0.6</geco.util.version>
<geco.september.util.version>0.2</geco.september.util.version>
<geco.kafka-util.version>0.1</geco.kafka-util.version>
<geco.kafka-util.version>0.2</geco.kafka-util.version>

<tomcat.deploy.path></tomcat.deploy.path>
<tomcat.app.name>geco-giles</tomcat.app.name>
Expand Down Expand Up @@ -99,8 +99,8 @@
<!-- Giles Ecosystem -->

<dependency>
<groupId>edu.asu.diging.giles-eco</groupId>
<artifactId>kafka-util</artifactId>
<groupId>edu.asu.diging</groupId>
<artifactId>giles-eco-kafka-util</artifactId>
<version>${geco.kafka-util.version}</version>
</dependency>
<dependency>
Expand All @@ -109,13 +109,13 @@
<version>${geco.september.util.version}</version>
</dependency>
<dependency>
<groupId>edu.asu.diging.giles-eco</groupId>
<artifactId>requests</artifactId>
<groupId>edu.asu.diging</groupId>
<artifactId>giles-eco-requests</artifactId>
<version>${geco.requests.version}</version>
</dependency>
<dependency>
<groupId>edu.asu.diging.giles-eco</groupId>
<artifactId>util</artifactId>
<groupId>edu.asu.diging</groupId>
<artifactId>giles-eco-util</artifactId>
<version>${geco.util.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ public ResponseEntity<String> getFile(

byte[] content = filesManager.getFileContent(file);
response.setContentType(file.getContentType());
response.setContentLength(content.length);

response.setHeader("Content-disposition", "filename=\"" + file.getFilename() + "\"");
try {
response.getOutputStream().write(content);
response.getOutputStream().close();
if (content != null) {
response.setContentLength(content.length);
response.getOutputStream().write(content);
response.getOutputStream().close();
}
} catch (IOException e) {
messageHandler.handleMessage("Could not write to output stream.", e, MessageType.ERROR);
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Lob;
import javax.persistence.Table;

import edu.asu.diging.gilesecosystem.web.domain.DocumentAccess;
Expand All @@ -23,14 +24,14 @@ public class File implements IFile {

@Id private String id;
private String uploadId;
private String filename;
@Lob private String filename;
private String username;
private String documentId;
private String uploadDate;
private DocumentAccess access;
private String contentType;
private long size;
private String filepath;
@Lob private String filepath;
private String derivedFrom;
private String usernameForStorage;
private String requestId;
Expand Down
4 changes: 2 additions & 2 deletions giles-eco/src/main/resources/META-INF/hibernate/orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
</id>
<property name="pageNr" type="int" />
<property name="filename" type="string" />
<property name="pathToFile" type="string" />
<property name="downloadUrl" type="string" />
<property name="pathToFile" type="text" />
<property name="downloadUrl" type="text" />
<property name="contentType" type="string" />
<property name="size" type="long" />
</class>
Expand Down

0 comments on commit d378957

Please sign in to comment.