Revision 6088
Added by Chris Jones almost 13 years ago
CrudService.java | ||
---|---|---|
109 | 109 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
110 | 110 |
import edu.ucsb.nceas.metacat.replication.ForceReplicationHandler; |
111 | 111 |
import edu.ucsb.nceas.metacat.service.SessionService; |
112 |
import edu.ucsb.nceas.metacat.service.ObjectFormatService; |
|
112 | 113 |
import edu.ucsb.nceas.metacat.util.DocumentUtil; |
113 | 114 |
import edu.ucsb.nceas.metacat.util.SessionData; |
114 | 115 |
|
... | ... | |
2069 | 2070 |
|
2070 | 2071 |
//set the default object format |
2071 | 2072 |
String doctype = (String) docInfo.get("doctype"); |
2072 |
ObjectFormat format = ObjectFormat.convert(doctype);
|
|
2073 |
ObjectFormat format = ObjectFormatService.getFormat(doctype);
|
|
2073 | 2074 |
if (format == null) { |
2074 | 2075 |
if (doctype.trim().equals("BIN")) { |
2075 |
format = ObjectFormat.OCTET_STREAM;
|
|
2076 |
format = ObjectFormatService.getFormat("application/octet-stream");
|
|
2076 | 2077 |
} else { |
2077 |
format = ObjectFormat.convert("text/plain");
|
|
2078 |
format = ObjectFormatService.getFormat("text/plain");
|
|
2078 | 2079 |
} |
2079 | 2080 |
} |
2080 | 2081 |
sm.setObjectFormat(format); |
... | ... | |
2082 | 2083 |
|
2083 | 2084 |
// further parse EML documents to get data object format, |
2084 | 2085 |
// describes and describedBy information |
2085 |
if ( format == ObjectFormat.EML_2_0_0 ||
|
|
2086 |
format == ObjectFormat.EML_2_0_1 ||
|
|
2087 |
format == ObjectFormat.EML_2_1_0 ) {
|
|
2086 |
if ( format == ObjectFormatService.getFormat("eml://ecoinformatics.org/eml/2.0.0") ||
|
|
2087 |
format == ObjectFormatService.getFormat("eml://ecoinformatics.org/eml/2.0.1") ||
|
|
2088 |
format == ObjectFormatService.getFormat("eml://ecoinformatics.org/eml/2.1.0") ) {
|
|
2088 | 2089 |
|
2089 | 2090 |
try { |
2090 | 2091 |
DataoneEMLParser emlParser = DataoneEMLParser.getInstance(); |
... | ... | |
2127 | 2128 |
logCrud.debug("Setting describedBy for " + dataDocId.getValue() + |
2128 | 2129 |
" to " + identifier.getValue()); |
2129 | 2130 |
dataSysMeta.addDescribedBy(identifier); |
2130 |
dataSysMeta.setObjectFormat(ObjectFormat.convert(dataDocMimeType));
|
|
2131 |
dataSysMeta.setObjectFormat(ObjectFormatService.getFormat(dataDocMimeType));
|
|
2131 | 2132 |
this.updateSystemMetadata(dataSysMeta, getSessionData(token)); |
2132 | 2133 |
|
2133 | 2134 |
} catch ( NotFound nf ) { |
... | ... | |
2140 | 2141 |
dataSysMeta.addDescribedBy(identifier); |
2141 | 2142 |
|
2142 | 2143 |
logCrud.debug("Setting mimeType for " + dataDocId.getValue() + " to " + dataDocMimeType); |
2143 |
dataSysMeta.setObjectFormat(ObjectFormat.convert(dataDocMimeType));
|
|
2144 |
dataSysMeta.setObjectFormat(ObjectFormatService.getFormat(dataDocMimeType));
|
|
2144 | 2145 |
|
2145 | 2146 |
logCrud.debug("Updating system metadata for " + dataDocId.getValue() + " to " + dataDocMimeType); |
2146 | 2147 |
this.updateSystemMetadata(dataSysMeta, getSessionData(token)); |
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).