Revision 6124
Added by Chris Jones almost 13 years ago
MetacatHandler.java | ||
---|---|---|
112 | 112 |
import org.apache.log4j.Logger; |
113 | 113 |
import org.ecoinformatics.eml.EMLParser; |
114 | 114 |
|
115 |
import org.dataone.client.ObjectFormatCache; |
|
115 | 116 |
import org.dataone.eml.DataoneEMLParser; |
116 | 117 |
import org.dataone.eml.EMLDocument; |
117 | 118 |
import org.dataone.eml.EMLDocument.DistributionMetadata; |
... | ... | |
3588 | 3589 |
Hashtable<String, Object> docInfo = IdentifierManager.getInstance().getDocumentInfo(localId); |
3589 | 3590 |
//set the default object format |
3590 | 3591 |
String doctype = (String) docInfo.get("doctype"); |
3591 |
ObjectFormat format = ObjectFormat.convert(doctype); |
|
3592 |
if (format == null) { |
|
3593 |
if (doctype.trim().equals("BIN")) { |
|
3594 |
format = ObjectFormat.OCTET_STREAM; |
|
3595 |
} else { |
|
3596 |
format = ObjectFormat.convert("text/plain"); |
|
3597 |
} |
|
3592 |
ObjectFormat format = null; |
|
3593 |
|
|
3594 |
// set the object format, fall back to defaults |
|
3595 |
try { |
|
3596 |
format = ObjectFormatCache.getFormat(doctype); |
|
3597 |
|
|
3598 |
} catch (NotFound nfe) { |
|
3599 |
|
|
3600 |
try { |
|
3601 |
// format is not registered, use default |
|
3602 |
if (doctype.trim().equals("BIN")) { |
|
3603 |
format = ObjectFormatCache.getFormat("application/octet-stream"); |
|
3604 |
|
|
3605 |
} else { |
|
3606 |
format = ObjectFormatCache.getFormat("text/plain"); |
|
3607 |
} |
|
3608 |
|
|
3609 |
} catch (NotFound nf) { |
|
3610 |
logMetacat.error("There was a problem getting the default format " + |
|
3611 |
"from the ObjectFormatCache: " + nf.getMessage()); |
|
3612 |
throw nf; |
|
3613 |
} |
|
3614 |
|
|
3598 | 3615 |
} |
3616 |
|
|
3599 | 3617 |
sysMeta.setObjectFormat(format); |
3600 | 3618 |
logMetacat.debug("The ObjectFormat for " + localId + " is " + format.toString()); |
3601 | 3619 |
|
3602 | 3620 |
// further parse EML documents to get data object format, |
3603 | 3621 |
// describes and describedBy information |
3604 |
if ( format == ObjectFormat.EML_2_0_0 ||
|
|
3605 |
format == ObjectFormat.EML_2_0_1 ||
|
|
3606 |
format == ObjectFormat.EML_2_1_0 ||
|
|
3607 |
format == ObjectFormat.EML_2_1_1 ) {
|
|
3622 |
if ( format == ObjectFormatCache.getFormat("eml://ecoinformatics.org/eml-2.0.0") ||
|
|
3623 |
format == ObjectFormatCache.getFormat("eml://ecoinformatics.org/eml-2.0.1") ||
|
|
3624 |
format == ObjectFormatCache.getFormat("eml://ecoinformatics.org/eml-2.1.0") ||
|
|
3625 |
format == ObjectFormatCache.getFormat("eml://ecoinformatics.org/eml-2.1.1") ) {
|
|
3608 | 3626 |
|
3609 | 3627 |
try { |
3610 | 3628 |
DataoneEMLParser emlParser = DataoneEMLParser.getInstance(); |
... | ... | |
3622 | 3640 |
String dataDocUrl = distMetadata.url; |
3623 | 3641 |
String dataDocMimeType = ""; |
3624 | 3642 |
if (distMetadata.mimeType == null) { |
3625 |
dataDocMimeType = ObjectFormat.OCTET_STREAM.name(); |
|
3643 |
dataDocMimeType = |
|
3644 |
ObjectFormatCache.getFormat("application/octet-stream").getFmtid().getValue(); |
|
3626 | 3645 |
} else { |
3627 | 3646 |
dataDocMimeType = distMetadata.mimeType; |
3628 | 3647 |
} |
... | ... | |
3670 | 3689 |
|
3671 | 3690 |
// set object format |
3672 | 3691 |
logMetacat.debug("Updating system metadata for " + dataGuid.getValue() + " to " + dataDocMimeType); |
3673 |
ObjectFormat f = ObjectFormat.convert(dataDocMimeType);
|
|
3692 |
ObjectFormat f = ObjectFormatCache.getFormat(dataDocMimeType);
|
|
3674 | 3693 |
if (f == null) { |
3675 |
f = ObjectFormat.OCTET_STREAM;
|
|
3694 |
f = ObjectFormatCache.getFormat("application/octet-stream");
|
|
3676 | 3695 |
} |
3677 | 3696 |
dataSysMeta.setObjectFormat(f); |
3678 | 3697 |
|
Also available in: Unified diff
Merged in the D1_0_6_2_BRANCH changes that include the transition from ObjectFormat calls to ObjectFormatCache calls.