Revision 9017
Added by Jing Tao over 9 years ago
IdentifierManager.java | ||
---|---|---|
766 | 766 |
* @param guid the global identifier to look up |
767 | 767 |
* @return boolean true if the identifier exists |
768 | 768 |
*/ |
769 |
public boolean identifierExists(String guid) |
|
769 |
public boolean identifierExists(String guid) throws SQLException
|
|
770 | 770 |
{ |
771 | 771 |
boolean idExists = false; |
772 | 772 |
try { |
... | ... | |
776 | 776 |
} |
777 | 777 |
} catch (McdbDocNotFoundException e) { |
778 | 778 |
// try system metadata only |
779 |
try { |
|
780 |
idExists = systemMetadataExists(guid); |
|
781 |
} catch (Exception e2) { |
|
782 |
idExists = false; |
|
783 |
} |
|
779 |
//this will check if the guid field on the system metadata table has the id |
|
780 |
idExists = systemMetadataGUIDExists(guid); |
|
781 |
if(!idExists) { |
|
782 |
//if the guid field of the system metadata table doesn't have the id, |
|
783 |
//we will check if the serial_id field of the system metadata table has it |
|
784 |
idExists=systemMetadataSIDExists(guid); |
|
785 |
} |
|
786 |
|
|
784 | 787 |
} |
785 | 788 |
return idExists; |
786 | 789 |
} |
... | ... | |
967 | 970 |
* @param id |
968 | 971 |
* @return true if it exists; false otherwise. |
969 | 972 |
*/ |
970 |
public boolean serialIdExists(String sid) throws SQLException {
|
|
973 |
public boolean systemMetadataSIDExists(String sid) throws SQLException {
|
|
971 | 974 |
boolean exists = false; |
972 | 975 |
if(sid != null && !sid.trim().equals("")) { |
973 | 976 |
logMetacat.debug("Check if the sid: " + sid +" exists on the series_id field of the system metadata table."); |
... | ... | |
999 | 1002 |
return exists; |
1000 | 1003 |
} |
1001 | 1004 |
|
1002 |
public boolean systemMetadataExists(String guid) throws SQLException { |
|
1005 |
public boolean systemMetadataGUIDExists(String guid) throws SQLException {
|
|
1003 | 1006 |
logMetacat.debug("looking up system metadata for guid " + guid); |
1004 | 1007 |
boolean exists = false; |
1005 | 1008 |
String query = "select guid from systemmetadata where guid = ?"; |
... | ... | |
1054 | 1057 |
dbConn.setAutoCommit(false); |
1055 | 1058 |
|
1056 | 1059 |
// insert the record if needed |
1057 |
if (!IdentifierManager.getInstance().systemMetadataExists(guid)) { |
|
1060 |
if (!IdentifierManager.getInstance().systemMetadataGUIDExists(guid)) {
|
|
1058 | 1061 |
insertSystemMetadata(guid, dbConn); |
1059 | 1062 |
} |
1060 | 1063 |
// update with the values |
Also available in: Unified diff
1. In the identifierExists method, the code to check if the identifier exist on the serial-id fields of the system metadata table.
2. Fixed a bug on the identifierExists - it considered an identifier didn't exist when the determining process threw an exception.