Revision 6998
Added by ben leinfelder almost 13 years ago
src/edu/ucsb/nceas/metacat/dataone/SystemMetadataFactory.java | ||
---|---|---|
593 | 593 |
{ |
594 | 594 |
|
595 | 595 |
for (String localId : idList) { |
596 |
//for each id, add a system metadata doc |
|
597 |
createAndInsertSystemMetadata(localId, includeOre, downloadData); |
|
596 |
logMetacat.debug("Creating SystemMetadata for localId " + localId); |
|
597 |
SystemMetadata sm = null; |
|
598 |
|
|
599 |
//generate required system metadata fields from the document |
|
600 |
sm = SystemMetadataFactory.createSystemMetadata(localId, includeOre, downloadData); |
|
601 |
|
|
602 |
//insert the systemmetadata object or just update it as needed |
|
603 |
boolean exists = IdentifierManager.getInstance().systemMetadataExists(sm.getIdentifier().getValue()); |
|
604 |
if (!exists) { |
|
605 |
IdentifierManager.getInstance().insertSystemMetadata(sm); |
|
606 |
logMetacat.info("Generated SystemMetadata for " + localId); |
|
607 |
} else { |
|
608 |
IdentifierManager.getInstance().updateSystemMetadata(sm); |
|
609 |
logMetacat.info("Updated SystemMetadata for " + localId); |
|
610 |
} |
|
598 | 611 |
} |
599 | 612 |
logMetacat.info("done generating system metadata for given list"); |
600 | 613 |
} |
601 | 614 |
|
602 |
|
|
603 |
/** |
|
604 |
* Generate SystemMetadata for a particular object with identifier localId. |
|
605 |
* This is a utility method for migration of existing objects |
|
606 |
* to DataONE where SystemMetadata is required for all objects. |
|
607 |
* @param localId |
|
608 |
* @param includeOre |
|
609 |
* @param downloadData |
|
610 |
* @throws PropertyNotFoundException |
|
611 |
* @throws NoSuchAlgorithmException |
|
612 |
* @throws AccessionNumberException |
|
613 |
* @throws SQLException |
|
614 |
* @throws SAXException |
|
615 |
* @throws HandlerException |
|
616 |
* @throws JiBXException |
|
617 |
* @throws BaseException |
|
618 |
* @throws ParseLSIDException |
|
619 |
* @throws InsufficientKarmaException |
|
620 |
* @throws ClassNotFoundException |
|
621 |
* @throws IOException |
|
622 |
* @throws McdbException |
|
623 |
* @throws AccessException |
|
624 |
* @throws AccessControlException |
|
625 |
*/ |
|
626 |
private static void createAndInsertSystemMetadata(String localId, boolean includeOre, boolean downloadData) |
|
627 |
throws PropertyNotFoundException, NoSuchAlgorithmException, AccessionNumberException, SQLException, AccessControlException, AccessException, McdbException, IOException, ClassNotFoundException, InsufficientKarmaException, ParseLSIDException, BaseException, JiBXException, HandlerException, SAXException |
|
628 |
{ |
|
629 |
logMetacat.debug("Creating SystemMetadata for localId " + localId); |
|
630 |
SystemMetadata sm = null; |
|
631 |
|
|
632 |
//generate required system metadata fields from the document |
|
633 |
sm = SystemMetadataFactory.createSystemMetadata(localId, includeOre, downloadData); |
|
634 |
|
|
635 |
//insert the systemmetadata object or just update it as needed |
|
636 |
boolean exists = IdentifierManager.getInstance().systemMetadataExists(sm.getIdentifier().getValue()); |
|
637 |
if (!exists) { |
|
638 |
IdentifierManager.getInstance().insertSystemMetadata(sm); |
|
639 |
logMetacat.info("Generated SystemMetadata for " + localId); |
|
640 |
} else { |
|
641 |
IdentifierManager.getInstance().updateSystemMetadata(sm); |
|
642 |
logMetacat.info("Updated SystemMetadata for " + localId); |
|
643 |
} |
|
644 |
} |
|
645 |
|
|
646 | 615 |
/** |
647 | 616 |
* Determines if we already have registered an ORE map for this package |
648 | 617 |
* @param guid of the EML/packaging object |
Also available in: Unified diff
remove createAndInsertSystemMetadat() method that acts on a single localId -- incorporated this into the localId-list-based method.