[dryad] r5696 committed - get the required header fields into the Describe service

0 views
Skip to first unread message

dr...@googlecode.com

unread,
Sep 17, 2012, 5:36:03 PM9/17/12
to dryad-...@googlegroups.com
Revision: 5696
Author: peter....@gmail.com
Date: Mon Sep 17 14:35:48 2012
Log: get the required header fields into the Describe service
http://code.google.com/p/dryad/source/detail?r=5696

Modified:

/trunk/dryad/dspace/modules/dataone-mn/dataone-mn-webapp/src/main/java/org/dspace/dataonemn/DataOneMN.java

=======================================
---
/trunk/dryad/dspace/modules/dataone-mn/dataone-mn-webapp/src/main/java/org/dspace/dataonemn/DataOneMN.java
Thu Sep 13 14:12:22 2012
+++
/trunk/dryad/dspace/modules/dataone-mn/dataone-mn-webapp/src/main/java/org/dspace/dataonemn/DataOneMN.java
Mon Sep 17 14:35:48 2012
@@ -711,24 +711,44 @@
try {
long length = objManager.getObjectSize(id);
response.setContentLength((int) length);
-
+
if (id.endsWith("/bitstream")) {
- ServletContext context = getServletContext();
+ ServletContext context = getServletContext();

- log.warn("NEED TO GET CORRECT MIME TYPE");
- String mimeType = "application/octet-stream";
- //String mimeType = context.getMimeType("f." + format);
-
- if (mimeType == null || mimeType.equals("")) {
- mimeType = "application/octet-stream";
- }
-
- log.debug("Setting data file MIME type to: "
- + mimeType + " (this is configurable)");
-
- response.setContentType(mimeType);
+ log.warn("NEED TO GET CORRECT MIME TYPE");
+ String mimeType = "application/octet-stream";
+ //String mimeType = context.getMimeType("f." + format);
+
+ if (mimeType == null || mimeType.equals("")) {
+ mimeType = "application/octet-stream";
+ }
+ Item item = objManager.getDSpaceItem(id);
+
+ Bitstream bitstream = objManager.getFirstBitstream(item);
+
+ String format =
translateMIMEToDataOneFormat(bitstream.getFormat().getMIMEType());
+
+ response.setHeader("DataONE-formatId", format);
+ final String[] checksumDetails = objManager.getObjectChecksum(id);
+ final String checkSumAlg = checksumDetails[1];
+ final String checkSum = checksumDetails[0];
+ final String checkSumStr = checkSumAlg + "," + checkSum;
+ response.setHeader("DataONE-Checksum",checkSumStr);
+ response.setHeader("DataONE-SerialVersion", "1");
+
+ log.debug("Setting data file MIME type to: "
+ + mimeType + " (this is configurable)");
+
+ response.setContentType(mimeType);
} else {
- response.setContentType(XML_CONTENT_TYPE);
+ response.setHeader("DataONE-formatId", DRYAD_NAMESPACE);
+ response.setContentType(XML_CONTENT_TYPE);
+ final String[] checksumDetails = objManager.getObjectChecksum(id);
+ final String checkSumAlg = checksumDetails[1];
+ final String checkSum = checksumDetails[0];
+ final String checkSumStr = checkSumAlg + "," + checkSum;
+ response.setHeader("DataONE-Checksum",checkSumStr);
+ response.setHeader("DataONE-SerialVersion", "1");
}
}
catch (SQLException details) {
Reply all
Reply to author
Forward
0 new messages