Revision 6134
Added by ben leinfelder almost 13 years ago
MetacatHandler.java | ||
---|---|---|
74 | 74 |
import org.apache.commons.io.input.XmlStreamReader; |
75 | 75 |
import org.apache.log4j.Logger; |
76 | 76 |
import org.dataone.client.ObjectFormatCache; |
77 |
import org.dataone.eml.DataoneEMLParser; |
|
78 |
import org.dataone.eml.EMLDocument; |
|
79 |
import org.dataone.eml.EMLDocument.DistributionMetadata; |
|
80 | 77 |
import org.dataone.service.exceptions.BaseException; |
81 | 78 |
import org.dataone.service.exceptions.NotFound; |
82 | 79 |
import org.dataone.service.types.Checksum; |
... | ... | |
87 | 84 |
import org.dataone.service.types.Subject; |
88 | 85 |
import org.dataone.service.types.SystemMetadata; |
89 | 86 |
import org.dataone.service.types.util.ServiceTypeUtil; |
87 |
import org.ecoinformatics.datamanager.DataManager; |
|
88 |
import org.ecoinformatics.datamanager.database.DatabaseConnectionPoolInterface; |
|
89 |
import org.ecoinformatics.datamanager.parser.DataPackage; |
|
90 |
import org.ecoinformatics.datamanager.parser.TextComplexDataFormat; |
|
90 | 91 |
import org.ecoinformatics.eml.EMLParser; |
91 | 92 |
import org.jibx.runtime.JiBXException; |
92 | 93 |
import org.xml.sax.SAXException; |
... | ... | |
107 | 108 |
import edu.ucsb.nceas.metacat.database.DBConnection; |
108 | 109 |
import edu.ucsb.nceas.metacat.database.DBConnectionPool; |
109 | 110 |
import edu.ucsb.nceas.metacat.dataquery.DataQuery; |
111 |
import edu.ucsb.nceas.metacat.dataquery.MetacatDatabaseConnectionPoolFactory; |
|
110 | 112 |
import edu.ucsb.nceas.metacat.event.MetacatDocumentEvent; |
111 | 113 |
import edu.ucsb.nceas.metacat.event.MetacatEventService; |
112 | 114 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
... | ... | |
3611 | 3613 |
format == ObjectFormatCache.getFormat("eml://ecoinformatics.org/eml-2.1.1") ) { |
3612 | 3614 |
|
3613 | 3615 |
try { |
3614 |
DataoneEMLParser emlParser = DataoneEMLParser.getInstance(); |
|
3615 |
EMLDocument emlDocument = emlParser.parseDocument(inputStream); |
|
3616 |
|
|
3617 |
DatabaseConnectionPoolInterface connectionPool = MetacatDatabaseConnectionPoolFactory.getDatabaseConnectionPoolInterface(); |
|
3618 |
DataManager dataManager = DataManager.getInstance(connectionPool, connectionPool.getDBAdapterName()); |
|
3619 |
DataPackage dataPackage = dataManager.parseMetadata(inputStream); |
|
3616 | 3620 |
|
3617 | 3621 |
// iterate through the data objects in the EML doc and add sysmeta |
3618 | 3622 |
logMetacat.debug("In createSystemMetadata() the number of data " + |
3619 |
"entities is: " + emlDocument.distributionMetadata.size());
|
|
3623 |
"entities is: " + dataPackage.getEntityNumber());
|
|
3620 | 3624 |
|
3621 | 3625 |
// iterate through data objects described by the EML |
3622 |
for( int j = 0; j < emlDocument.distributionMetadata.size(); j++ ) {
|
|
3626 |
for (int j = 0; j < dataPackage.getEntityList().length; j++) {
|
|
3623 | 3627 |
|
3624 |
DistributionMetadata distMetadata = |
|
3625 |
emlDocument.distributionMetadata.elementAt(j);
|
|
3626 |
String dataDocUrl = distMetadata.url;
|
|
3627 |
String dataDocMimeType = "";
|
|
3628 |
if (distMetadata.mimeType == null) {
|
|
3628 |
|
|
3629 |
String dataDocUrl = dataPackage.getEntityList()[j].getURL();
|
|
3630 |
String dataDocMimeType = dataPackage.getEntityList()[j].getDataFormat();
|
|
3631 |
// default to binary
|
|
3632 |
if (dataDocMimeType == null) {
|
|
3629 | 3633 |
dataDocMimeType = |
3630 | 3634 |
ObjectFormatCache.getFormat("application/octet-stream").getFmtid().getValue(); |
3631 |
} else { |
|
3632 |
dataDocMimeType = distMetadata.mimeType; |
|
3633 | 3635 |
} |
3634 | 3636 |
String dataDocLocalId = ""; |
3635 | 3637 |
logMetacat.debug("Data local ID: " + dataDocLocalId); |
... | ... | |
3726 | 3728 |
} catch ( XPathExpressionException xpee ) { |
3727 | 3729 |
logMetacat.debug("There was a problem searching the EML document. " + |
3728 | 3730 |
"The error message was: " + xpee.getMessage()); |
3731 |
} catch ( Exception e ) { |
|
3732 |
logMetacat.debug("There was a problem creating System Metadata. " + |
|
3733 |
"The error message was: " + e.getMessage()); |
|
3729 | 3734 |
} // end try() |
3730 | 3735 |
|
3731 | 3736 |
} // end if() |
Also available in: Unified diff
use Data Manager Library to parse EML when needed in DataONE classes.
(augmented DML to parse data format elements in EML to estimate MIME type)
https://redmine.dataone.org/issues/1634