Revision 6079
Added by ben leinfelder almost 13 years ago
IdentifierManager.java | ||
---|---|---|
622 | 622 |
} |
623 | 623 |
|
624 | 624 |
/** |
625 |
* update a mapping |
|
625 |
* update a system metadata mapping
|
|
626 | 626 |
* @param guid |
627 | 627 |
* @param localId |
628 | 628 |
*/ |
629 | 629 |
public void updateSystemMetadataMapping(String guid, String localId) |
630 | 630 |
{ |
631 |
System.out.println("$$$$$$$$$$$$$$ updating systemmetadata table with additional info"); |
|
631 |
updateMapping(guid, localId, TYPE_SYSTEM_METADATA); |
|
632 |
} |
|
633 |
|
|
634 |
/** |
|
635 |
* update a mapping |
|
636 |
* @param guid |
|
637 |
* @param localId |
|
638 |
*/ |
|
639 |
public void updateMapping(String guid, String localId) |
|
640 |
{ |
|
641 |
updateMapping(guid, localId, TYPE_IDENTIFIER); |
|
642 |
} |
|
643 |
|
|
644 |
/** |
|
645 |
* update a mapping |
|
646 |
* @param guid |
|
647 |
* @param localId |
|
648 |
*/ |
|
649 |
private void updateMapping(String guid, String localId, String type) |
|
650 |
{ |
|
651 |
if (!type.equals(TYPE_IDENTIFIER) && !type.equals(TYPE_SYSTEM_METADATA)) { |
|
652 |
throw new RuntimeException("Cannot create mapping for type " + type + |
|
653 |
". Please choose 'identifier' or 'systemmetadata'."); |
|
654 |
} |
|
655 |
|
|
656 |
System.out.println("$$$$$$$$$$$$$$ updating mapping table"); |
|
632 | 657 |
int serialNumber = -1; |
633 | 658 |
DBConnection dbConn = null; |
634 | 659 |
try { |
... | ... | |
643 | 668 |
|
644 | 669 |
// Get a database connection from the pool |
645 | 670 |
dbConn = |
646 |
DBConnectionPool.getDBConnection("IdentifierManager.createMapping");
|
|
671 |
DBConnectionPool.getDBConnection("IdentifierManager.updateMapping");
|
|
647 | 672 |
serialNumber = dbConn.getCheckOutSerialNumber(); |
648 | 673 |
|
649 | 674 |
// Execute the insert statement |
650 |
String query = "update systemmetadata set (docid, rev) = (?, ?) where guid='" + guid + "'";
|
|
675 |
String query = "update " + type + " set (docid, rev) = (?, ?) where guid='" + guid + "'";
|
|
651 | 676 |
//System.out.println("query: " + query + " for params: (guid:" + guid + ", docid=" + docid + ", rev=" + rev + ")"); |
652 | 677 |
PreparedStatement stmt = dbConn.prepareStatement(query); |
653 | 678 |
stmt.setString(1, docid); |
... | ... | |
657 | 682 |
stmt.close(); |
658 | 683 |
} catch (SQLException e) { |
659 | 684 |
e.printStackTrace(); |
660 |
logMetacat.error("SQL error while updating a mapping to the system metadata identifier: "
|
|
685 |
logMetacat.error("SQL error while updating a mapping identifier: " |
|
661 | 686 |
+ e.getMessage()); |
662 | 687 |
} catch (NumberFormatException e) { |
663 | 688 |
e.printStackTrace(); |
664 |
logMetacat.error("NumberFormat error while updating a mapping to the system metadata identifier: "
|
|
689 |
logMetacat.error("NumberFormat error while updating a mapping identifier: " |
|
665 | 690 |
+ e.getMessage()); |
666 | 691 |
} catch (AccessionNumberException e) { |
667 | 692 |
e.printStackTrace(); |
668 |
logMetacat.error("AccessionNumber error while updating a mapping to the system metadata identifier: "
|
|
693 |
logMetacat.error("AccessionNumber error while updating a mapping identifier: " |
|
669 | 694 |
+ e.getMessage()); |
670 | 695 |
} finally { |
671 | 696 |
// Return database connection to the pool |
672 | 697 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
673 | 698 |
} |
674 |
System.out.println("done updating systemmetadata");
|
|
699 |
System.out.println("done updating mapping");
|
|
675 | 700 |
} |
676 | 701 |
|
677 | 702 |
/** |
Also available in: Unified diff
use update method to update the mapping between local and guid (d1) when we get a force replication request that is an "update