Revision 6422
Added by ben leinfelder over 13 years ago
src/edu/ucsb/nceas/metacat/accesscontrol/XMLAccessAccess.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
import org.apache.log4j.Logger; |
37 | 37 |
|
38 |
import edu.ucsb.nceas.metacat.AccessionNumber; |
|
39 |
import edu.ucsb.nceas.metacat.DBUtil; |
|
40 |
import edu.ucsb.nceas.metacat.IdentifierManager; |
|
41 |
import edu.ucsb.nceas.metacat.McdbDocNotFoundException; |
|
38 | 42 |
import edu.ucsb.nceas.metacat.database.DBConnection; |
39 | 43 |
import edu.ucsb.nceas.metacat.database.DBConnectionPool; |
40 | 44 |
import edu.ucsb.nceas.metacat.shared.AccessException; |
... | ... | |
400 | 404 |
serialNumber = conn.getCheckOutSerialNumber(); |
401 | 405 |
|
402 | 406 |
String sql = "INSERT INTO xml_access " + |
403 |
"(" + idAttribute + ", principal_name, permission, perm_type, perm_order, accessfileid, subtreeid ) " +
|
|
404 |
"VALUES (?,?,?,?,?,?,?)"; |
|
407 |
"(docid, guid, principal_name, permission, perm_type, perm_order, accessfileid, subtreeid ) " +
|
|
408 |
"VALUES (?,?,?,?,?,?,?,?)";
|
|
405 | 409 |
pstmt = conn.prepareStatement(sql); |
406 | 410 |
|
411 |
String guid = null; |
|
412 |
String docid = null; |
|
413 |
if (idAttribute.equals(GUID)) { |
|
414 |
guid = id; |
|
415 |
try { |
|
416 |
docid = IdentifierManager.getInstance().getLocalId(id); |
|
417 |
} catch (McdbDocNotFoundException e) { |
|
418 |
//ignore |
|
419 |
logMetacat.warn("No local id mapping found for guid: " + id); |
|
420 |
} |
|
421 |
} else { |
|
422 |
int rev = DBUtil.getLatestRevisionInDocumentTable(id); |
|
423 |
try { |
|
424 |
guid = IdentifierManager.getInstance().getGUID(id, rev); |
|
425 |
} catch (McdbDocNotFoundException e) { |
|
426 |
//ignore |
|
427 |
logMetacat.warn("No guid mapping found for docid: " + id + "." + rev); |
|
428 |
} |
|
429 |
docid = id; |
|
430 |
} |
|
431 |
|
|
407 | 432 |
// Bind the values to the query |
408 |
pstmt.setString(1, id); |
|
409 |
pstmt.setString(2, principalName); |
|
410 |
pstmt.setLong(3, permission); |
|
411 |
pstmt.setString(4, permType); |
|
412 |
pstmt.setString(5, permOrder); |
|
413 |
pstmt.setString(6, accessFileId); |
|
414 |
pstmt.setString(7, subTreeId); |
|
433 |
pstmt.setString(1, docid); |
|
434 |
pstmt.setString(2, guid); |
|
435 |
pstmt.setString(3, principalName); |
|
436 |
pstmt.setLong(4, permission); |
|
437 |
pstmt.setString(5, permType); |
|
438 |
pstmt.setString(6, permOrder); |
|
439 |
pstmt.setString(7, accessFileId); |
|
440 |
pstmt.setString(8, subTreeId); |
|
415 | 441 |
|
416 | 442 |
String sqlReport = "XMLAccessAccess.insertXMLAccess - SQL: " + sql; |
417 |
sqlReport += " [" + id + "," + principalName + "," + permission + "," + permType + "," + permOrder + "]"; |
|
443 |
sqlReport += " [" + docid + "," + guid + "," + principalName + "," + permission + "," + permType + "," + permOrder + "]";
|
|
418 | 444 |
|
419 | 445 |
logMetacat.info(sqlReport); |
420 | 446 |
|
Also available in: Unified diff
use both guid and docid when creating access row - then either mechanism can be used when retrieving the access rules