1624 |
1624 |
}
|
1625 |
1625 |
|
1626 |
1626 |
/**
|
|
1627 |
* remove a mapping in the identifier table
|
|
1628 |
* @param guid
|
|
1629 |
* @param localId
|
|
1630 |
*/
|
|
1631 |
public void removeMapping(String guid, String localId)
|
|
1632 |
{
|
|
1633 |
|
|
1634 |
int serialNumber = -1;
|
|
1635 |
DBConnection dbConn = null;
|
|
1636 |
try {
|
|
1637 |
|
|
1638 |
// Parse the localId into scope and rev parts
|
|
1639 |
AccessionNumber acc = new AccessionNumber(localId, "NOACTION");
|
|
1640 |
String docid = acc.getDocid();
|
|
1641 |
int rev = 1;
|
|
1642 |
if (acc.getRev() != null) {
|
|
1643 |
rev = (new Integer(acc.getRev()).intValue());
|
|
1644 |
}
|
|
1645 |
|
|
1646 |
// Get a database connection from the pool
|
|
1647 |
dbConn = DBConnectionPool.getDBConnection("IdentifierManager.removeMapping");
|
|
1648 |
serialNumber = dbConn.getCheckOutSerialNumber();
|
|
1649 |
|
|
1650 |
// Execute the insert statement
|
|
1651 |
String query = "DELETE FROM " + TYPE_IDENTIFIER + " WHERE guid = ? AND docid = ? AND rev = ?";
|
|
1652 |
PreparedStatement stmt = dbConn.prepareStatement(query);
|
|
1653 |
stmt.setString(1, guid);
|
|
1654 |
stmt.setString(2, docid);
|
|
1655 |
stmt.setInt(3, rev);
|
|
1656 |
logMetacat.debug("remove mapping query: " + stmt.toString());
|
|
1657 |
int rows = stmt.executeUpdate();
|
|
1658 |
|
|
1659 |
stmt.close();
|
|
1660 |
} catch (SQLException e) {
|
|
1661 |
e.printStackTrace();
|
|
1662 |
logMetacat.error("removeMapping: SQL error while removing a mapping to the " + TYPE_IDENTIFIER + " identifier: "
|
|
1663 |
+ e.getMessage());
|
|
1664 |
} catch (NumberFormatException e) {
|
|
1665 |
e.printStackTrace();
|
|
1666 |
logMetacat.error("removeMapping: NumberFormat error while removing a mapping to the " + TYPE_IDENTIFIER + " identifier: "
|
|
1667 |
+ e.getMessage());
|
|
1668 |
} catch (AccessionNumberException e) {
|
|
1669 |
e.printStackTrace();
|
|
1670 |
logMetacat.error("removeMapping: AccessionNumber error while removing a mapping to the " + TYPE_IDENTIFIER + " identifier: "
|
|
1671 |
+ e.getMessage());
|
|
1672 |
} finally {
|
|
1673 |
// Return database connection to the pool
|
|
1674 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber);
|
|
1675 |
}
|
|
1676 |
}
|
|
1677 |
|
|
1678 |
/**
|
1627 |
1679 |
* create the systemmetadata record
|
1628 |
1680 |
* @param guid
|
1629 |
1681 |
*/
|
remove ID mapping when a create()/"insert" call fails so that subsequent calls do not return an IdentifierNotUnique error. In this case it was due to invalid XML.
https://redmine.dataone.org/issues/2341