Revision 7510
Added by ben leinfelder about 11 years ago
MNodeService.java | ||
---|---|---|
28 | 28 |
import java.io.InputStream; |
29 | 29 |
import java.math.BigInteger; |
30 | 30 |
import java.security.NoSuchAlgorithmException; |
31 |
import java.text.SimpleDateFormat; |
|
31 | 32 |
import java.util.ArrayList; |
32 | 33 |
import java.util.Calendar; |
33 | 34 |
import java.util.Date; |
... | ... | |
96 | 97 |
import org.dataone.service.types.v1_1.QueryEngineList; |
97 | 98 |
import org.dataone.service.types.v1_1.QueryField; |
98 | 99 |
import org.dataone.service.util.Constants; |
99 |
import org.dataone.service.util.DateTimeMarshaller; |
|
100 | 100 |
|
101 | 101 |
import edu.ucsb.nceas.ezid.EZIDException; |
102 | 102 |
import edu.ucsb.nceas.ezid.EZIDService; |
103 | 103 |
import edu.ucsb.nceas.ezid.profile.DataCiteProfile; |
104 |
import edu.ucsb.nceas.ezid.profile.ErcMissingValueCode; |
|
104 | 105 |
import edu.ucsb.nceas.ezid.profile.InternalProfile; |
105 | 106 |
import edu.ucsb.nceas.metacat.DBQuery; |
106 | 107 |
import edu.ucsb.nceas.metacat.EventLog; |
... | ... | |
413 | 414 |
try { |
414 | 415 |
registerDOI(sysmeta); |
415 | 416 |
} catch (EZIDException e) { |
416 |
throw new ServiceFailure("1190", "Could not register DOI: " + e.getMessage()); |
|
417 |
ServiceFailure sf = new ServiceFailure("1190", "Could not register DOI: " + e.getMessage()); |
|
418 |
sf.initCause(e); |
|
419 |
throw sf; |
|
417 | 420 |
} |
418 | 421 |
|
419 | 422 |
// return |
... | ... | |
1268 | 1271 |
throw new InvalidRequest("2193", "DOI scheme is not enabled at this node."); |
1269 | 1272 |
} |
1270 | 1273 |
|
1271 |
// do not enter metadata about this identifier since we do not know anything about it |
|
1272 |
HashMap<String, String> metadata = null; |
|
1274 |
// add only the minimal metadata required for this DOI |
|
1275 |
HashMap<String, String> metadata = new HashMap<String, String>(); |
|
1276 |
metadata.put(DataCiteProfile.TITLE.toString(), ErcMissingValueCode.UNKNOWN.toString()); |
|
1277 |
metadata.put(DataCiteProfile.CREATOR.toString(), ErcMissingValueCode.UNKNOWN.toString()); |
|
1278 |
metadata.put(DataCiteProfile.PUBLISHER.toString(), ErcMissingValueCode.UNKNOWN.toString()); |
|
1279 |
metadata.put(DataCiteProfile.PUBLICATION_YEAR.toString(), ErcMissingValueCode.UNKNOWN.toString()); |
|
1273 | 1280 |
try { |
1274 | 1281 |
// call the EZID service |
1275 | 1282 |
String ezidServiceBaseUrl = null; |
... | ... | |
1556 | 1563 |
|
1557 | 1564 |
// check for existing metadata |
1558 | 1565 |
boolean create = false; |
1559 |
metadata = ezid.getMetadata(identifier); |
|
1566 |
try { |
|
1567 |
metadata = ezid.getMetadata(identifier); |
|
1568 |
} catch (EZIDException e) { |
|
1569 |
// expected much of the time |
|
1570 |
logMetacat.warn("No metadata found for given identifier: " + e.getMessage()); |
|
1571 |
} |
|
1560 | 1572 |
if (metadata == null) { |
1561 | 1573 |
create = true; |
1562 |
metadata = new HashMap<String, String>(); |
|
1563 | 1574 |
} |
1575 |
// confuses the API if we send the original metadata that it gave us, so start from scratch |
|
1576 |
metadata = new HashMap<String, String>(); |
|
1564 | 1577 |
|
1565 |
// TODO: set values in the metadata with better values
|
|
1578 |
// TODO: set title and creator to better values
|
|
1566 | 1579 |
Node node = getCapabilities(); |
1567 |
metadata.put(DataCiteProfile.TITLE.toString(), "TBD"); |
|
1580 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); |
|
1581 |
String year = sdf .format(sysMeta.getDateUploaded()); |
|
1582 |
metadata.put(DataCiteProfile.TITLE.toString(), ErcMissingValueCode.UNKNOWN.toString()); |
|
1568 | 1583 |
metadata.put(DataCiteProfile.CREATOR.toString(), sysMeta.getRightsHolder().getValue()); |
1569 | 1584 |
metadata.put(DataCiteProfile.PUBLISHER.toString(), node.getName()); |
1570 |
metadata.put(DataCiteProfile.PUBLICATION_YEAR.toString(), DateTimeMarshaller.serializeDateToUTC(sysMeta.getDateUploaded()));
|
|
1585 |
metadata.put(DataCiteProfile.PUBLICATION_YEAR.toString(), year);
|
|
1571 | 1586 |
metadata.put(InternalProfile.TARGET.toString(), node.getBaseURL() + "/v1/object/" + identifier); |
1572 |
metadata.put(InternalProfile.PROFILE.toString(), "datacite"); |
|
1573 | 1587 |
|
1574 | 1588 |
// set using the API |
1575 | 1589 |
if (create) { |
Also available in: Unified diff
Correctly mint and register DOIs in teh MN API implementation. Add tests to exercise minting and creating. http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5513