Revision 6536
Added by ben leinfelder about 13 years ago
src/edu/ucsb/nceas/metacat/accesscontrol/XMLAccessAccess.java | ||
---|---|---|
587 | 587 |
DBConnection conn = null; |
588 | 588 |
int serialNumber = -1; |
589 | 589 |
try { |
590 |
|
|
591 |
String guid = null; |
|
592 |
String docid = null; |
|
593 |
if (idAttribute.equals(GUID)) { |
|
594 |
guid = id; |
|
595 |
try { |
|
596 |
String localId = IdentifierManager.getInstance().getLocalId(id); |
|
597 |
// Parse the localId into scope and rev parts, strip off the rev |
|
598 |
AccessionNumber acc = new AccessionNumber(localId, "NOACTION"); |
|
599 |
docid = acc.getDocid(); |
|
600 |
} catch (McdbDocNotFoundException e) { |
|
601 |
//ignore |
|
602 |
logMetacat.warn("No local id mapping found for guid: " + id); |
|
603 |
} catch (NumberFormatException e) { |
|
604 |
logMetacat.warn("LocalId could not be parsed for guid: " + id); |
|
605 |
} catch (AccessionNumberException e) { |
|
606 |
logMetacat.warn("LocalId could not be parsed for guid: " + id); |
|
607 |
} |
|
608 |
} else { |
|
609 |
int rev = DBUtil.getLatestRevisionInDocumentTable(id); |
|
610 |
try { |
|
611 |
guid = IdentifierManager.getInstance().getGUID(id, rev); |
|
612 |
} catch (McdbDocNotFoundException e) { |
|
613 |
//ignore |
|
614 |
logMetacat.warn("No guid mapping found for docid: " + id + "." + rev); |
|
615 |
} |
|
616 |
docid = id; |
|
617 |
} |
|
618 |
|
|
590 | 619 |
// check out DBConnection |
591 | 620 |
conn = DBConnectionPool.getDBConnection("XMLAccessAccess.deleteXMLAccessForDoc"); |
592 | 621 |
serialNumber = conn.getCheckOutSerialNumber(); |
593 | 622 |
|
594 |
String sql = "DELETE FROM xml_access WHERE " + idAttribute + " = ?";
|
|
623 |
String sql = "DELETE FROM xml_access WHERE docid = ? OR guid = ?";
|
|
595 | 624 |
pstmt = conn.prepareStatement(sql); |
596 | 625 |
|
597 | 626 |
// Bind the values to the query |
598 |
pstmt.setString(1, id); |
|
627 |
pstmt.setString(1, docid); |
|
628 |
pstmt.setString(2, guid); |
|
599 | 629 |
|
630 |
|
|
600 | 631 |
String sqlReport = "XMLAccessAccess.deleteXMLAccessForDoc - SQL: " + sql; |
601 | 632 |
sqlReport += " [" + id + "]"; |
602 | 633 |
|
Also available in: Unified diff
delete the xml access rules by either docid or guid to make sure we have the most up to date information