diff --git a/dspace-rest/src/main/java/org/dspace/rest/common/Bitstream.java b/dspace-rest/src/main/java/org/dspace/rest/common/Bitstream.java index 61214f182f..7eac19af0a 100644 --- a/dspace-rest/src/main/java/org/dspace/rest/common/Bitstream.java +++ b/dspace-rest/src/main/java/org/dspace/rest/common/Bitstream.java @@ -8,7 +8,8 @@ package org.dspace.rest.common; import org.apache.log4j.Logger; -import org.dspace.core.Context; + +import javax.xml.bind.annotation.XmlRootElement; /** * Created with IntelliJ IDEA. @@ -17,58 +18,35 @@ import org.dspace.core.Context; * Time: 12:54 AM * To change this template use File | Settings | File Templates. */ -public class Bitstream { +@XmlRootElement(name = "bitstream") +public class Bitstream extends DSpaceObject { Logger log = Logger.getLogger(Bitstream.class); String bundleName; - String name; String description; String format; + String mimeType; String sizeBytes; String retrieveLink; - final String type = "bitstream"; - Integer bitstreamID; - - Context context; - public Bitstream() { } - public Bitstream(Integer bitstreamID) { - new Bitstream(bitstreamID, ""); - } - - public Bitstream(Integer bitstreamID, String expand) { - try { - if(context == null || !context.isValid()) { - context = new Context(); - } - - //TODO Auth check? - org.dspace.content.Bitstream bitstream = org.dspace.content.Bitstream.find(context, bitstreamID); - setup(bitstream, expand); - - } catch (Exception e) { - log.error(e.getMessage()); - } - } - public Bitstream(org.dspace.content.Bitstream bitstream, String expand) { + super(bitstream); setup(bitstream, expand); } public void setup(org.dspace.content.Bitstream bitstream, String expand) { try { - bitstreamID = bitstream.getID(); bundleName = bitstream.getBundles()[0].getName(); - name = bitstream.getName(); description = bitstream.getDescription(); format = bitstream.getFormatDescription(); sizeBytes = bitstream.getSize() + ""; - retrieveLink = "/bitstreams/" + bitstreamID + "/retrieve"; + retrieveLink = "/bitstreams/" + bitstream.getID() + "/retrieve"; + mimeType = bitstream.getFormat().getMIMEType(); } catch (Exception e) { log.error(e.getMessage()); } @@ -78,10 +56,6 @@ public class Bitstream { return bundleName; } - public String getName() { - return name; - } - public String getDescription() { return description; } @@ -90,21 +64,15 @@ public class Bitstream { return format; } + public String getMimeType() { + return mimeType; + } + public String getSizeBytes() { return sizeBytes; } - public String getType() { - return type; - } - - public Integer getBitstreamID() { - return bitstreamID; - } - public String getRetrieveLink() { return retrieveLink; } - - }