Revision 6088
Added by Chris Jones almost 13 years ago
ResourceHandler.java | ||
---|---|---|
77 | 77 |
import edu.ucsb.nceas.metacat.dataone.CrudService; |
78 | 78 |
import edu.ucsb.nceas.metacat.dataone.HealthService; |
79 | 79 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
80 |
import edu.ucsb.nceas.metacat.service.ObjectFormatService; |
|
80 | 81 |
import edu.ucsb.nceas.metacat.service.SessionService; |
81 | 82 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
82 | 83 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
... | ... | |
532 | 533 |
if(params.containsKey("format")) |
533 | 534 |
{ |
534 | 535 |
String format = params.get("format")[0]; |
535 |
of = ObjectFormat.convert(format);
|
|
536 |
of = ObjectFormatService.getFormat(format);
|
|
536 | 537 |
} |
537 | 538 |
if(params.containsKey("time")) |
538 | 539 |
{ |
... | ... | |
569 | 570 |
if(params.containsKey("format")) |
570 | 571 |
{ |
571 | 572 |
String format = params.get("format")[0]; |
572 |
of = ObjectFormat.convert(format);
|
|
573 |
of = ObjectFormatService.getFormat(format);
|
|
573 | 574 |
} |
574 | 575 |
if(params.containsKey("eventtime")) |
575 | 576 |
{ |
... | ... | |
1166 | 1167 |
cs.setParamsFromRequest(request); |
1167 | 1168 |
AuthToken token = new AuthToken(sessionId); |
1168 | 1169 |
OutputStream out = null; |
1170 |
String textCSV = ObjectFormatService.getFormat("text/csv").toString(); |
|
1171 |
String textPlain = ObjectFormatService.getFormat("text/plain").toString(); |
|
1172 |
String octetStream = ObjectFormatService.getFormat("application/octet-stream").toString(); |
|
1173 |
|
|
1169 | 1174 |
try { |
1170 | 1175 |
out = response.getOutputStream(); |
1171 | 1176 |
response.setStatus(200); |
... | ... | |
1183 | 1188 |
SystemMetadata sm = cs.getSystemMetadata(token, id); |
1184 | 1189 |
|
1185 | 1190 |
//set the content type |
1186 |
if(sm.getObjectFormat().toString().trim().equals(ObjectFormat.TEXT_CSV.toString()))
|
|
1191 |
if(sm.getObjectFormat().toString().trim().equals(textCSV))
|
|
1187 | 1192 |
{ |
1188 | 1193 |
response.setContentType("text/csv"); |
1189 | 1194 |
response.setHeader("Content-Disposition", "inline; filename=" + id.getValue() + ".csv"); |
1190 | 1195 |
} |
1191 |
else if(sm.getObjectFormat().toString().trim().equals(ObjectFormat.TEXT_PLAIN.toString()))
|
|
1196 |
else if(sm.getObjectFormat().toString().trim().equals(textPlain))
|
|
1192 | 1197 |
{ |
1193 | 1198 |
response.setContentType("text/plain"); |
1194 | 1199 |
response.setHeader("Content-Disposition", "inline; filename=" + id.getValue() + ".txt"); |
1195 | 1200 |
} |
1196 |
else if(sm.getObjectFormat().toString().trim().equals(ObjectFormat.OCTET_STREAM.toString()))
|
|
1201 |
else if(sm.getObjectFormat().toString().trim().equals(octetStream))
|
|
1197 | 1202 |
{ |
1198 | 1203 |
response.setContentType("application/octet-stream"); |
1199 | 1204 |
} |
... | ... | |
1290 | 1295 |
} |
1291 | 1296 |
else if(name.equals("objectFormat") && value != null) |
1292 | 1297 |
{ |
1293 |
objectFormat = ObjectFormat.convert(value[0]);
|
|
1298 |
objectFormat = ObjectFormatService.getFormat(value[0]);
|
|
1294 | 1299 |
} |
1295 | 1300 |
else if(name.equals("replicaStatus") && value != null) |
1296 | 1301 |
{ |
Also available in: Unified diff
Changes in the DataONE ObjectFormat class deprecate the convert() method, and we're now using Metacat's ObjectFormatService to look up object format attributes. The following changes replace ObjectFormat.convert() with ObjectFormatService.getFormat() in several classes.
Also added a few methods to ObjectFormatService where doRefresh() calls populateObjectFormatList(), which in turn calls either getCachedList() or falls back to getListFromDisk() in the case of a CN, or will call cn.listFormats() from the D1 libclient if the Metacat installation is an MN.
Added the ObjectFormatService.objectFormatMap as a static hash used for lookups of object formats based on their canonical identifier. This is populated from the ObjectFormatService.objectFormatList.
Added deserializeObjectFormatList(InputStream) to return the ObjectFormatList from the XML serialization (from Metacat or disk).