Revision 8852
Added by Jing Tao over 10 years ago
src/edu/ucsb/nceas/metacat/IdentifierManager.java | ||
---|---|---|
1750 | 1750 |
|
1751 | 1751 |
} |
1752 | 1752 |
|
1753 |
public void deleteSystemMetadata(String guid)
|
|
1753 |
public boolean deleteSystemMetadata(String guid)
|
|
1754 | 1754 |
{ |
1755 |
|
|
1755 |
boolean success = false; |
|
1756 | 1756 |
int serialNumber = -1; |
1757 | 1757 |
DBConnection dbConn = null; |
1758 | 1758 |
String query = null; |
... | ... | |
1760 | 1760 |
int rows = 0; |
1761 | 1761 |
try { |
1762 | 1762 |
|
1763 |
// Get a database connection from the pool
|
|
1763 |
// Get a database connection from the pool
|
|
1764 | 1764 |
dbConn = DBConnectionPool.getDBConnection("IdentifierManager.deleteSystemMetadata"); |
1765 | 1765 |
serialNumber = dbConn.getCheckOutSerialNumber(); |
1766 |
|
|
1767 |
// remove main system metadata entry |
|
1768 |
query = "delete from " + TYPE_SYSTEM_METADATA + " where guid = ? "; |
|
1769 |
stmt = dbConn.prepareStatement(query); |
|
1770 |
stmt.setString(1, guid); |
|
1771 |
logMetacat.debug("delete system metadata: " + stmt.toString()); |
|
1772 |
rows = stmt.executeUpdate(); |
|
1773 |
stmt.close(); |
|
1774 |
|
|
1766 |
dbConn.setAutoCommit(false); |
|
1767 |
|
|
1775 | 1768 |
// remove the smReplicationPolicy |
1776 | 1769 |
query = "delete from smReplicationPolicy " + |
1777 | 1770 |
"where guid = ?"; |
... | ... | |
1790 | 1783 |
rows = stmt.executeUpdate(); |
1791 | 1784 |
stmt.close(); |
1792 | 1785 |
|
1786 |
// remove main system metadata entry |
|
1787 |
query = "delete from " + TYPE_SYSTEM_METADATA + " where guid = ? "; |
|
1788 |
stmt = dbConn.prepareStatement(query); |
|
1789 |
stmt.setString(1, guid); |
|
1790 |
logMetacat.debug("delete system metadata: " + stmt.toString()); |
|
1791 |
rows = stmt.executeUpdate(); |
|
1792 |
stmt.close(); |
|
1793 |
|
|
1794 |
dbConn.commit(); |
|
1795 |
dbConn.setAutoCommit(true); |
|
1796 |
success = true; |
|
1793 | 1797 |
// TODO: remove the access? |
1794 | 1798 |
// Metacat keeps "deleted" documents so we should not remove access rules. |
1795 | 1799 |
|
... | ... | |
1805 | 1809 |
// Return database connection to the pool |
1806 | 1810 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
1807 | 1811 |
} |
1812 |
return success; |
|
1808 | 1813 |
} |
1809 | 1814 |
|
1810 | 1815 |
public void updateAuthoritativeMemberNodeId(String existingMemberNodeId, String newMemberNodeId) |
Also available in: Unified diff
Make the deleteSystemmetadata method really roll-backable.