Revision 6720
Added by ben leinfelder almost 13 years ago
src/edu/ucsb/nceas/metacat/IdentifierManager.java | ||
---|---|---|
528 | 528 |
Vector<String> ids = new Vector<String>(); |
529 | 529 |
String sql = "select docid, rev from xml_documents " + |
530 | 530 |
"where docid not in " + |
531 |
"(select docid from identifier where guid in (select guid from systemmetadata)))";
|
|
531 |
"(select docid from identifier where guid in (select guid from systemmetadata))"; |
|
532 | 532 |
|
533 | 533 |
String revisionSql = "select docid, revisionid from xml_revisions " + |
534 | 534 |
"where docid not in " + |
535 |
"(select docid from identifier where guid in (select guid from systemmetadata)))";
|
|
535 |
"(select docid from identifier where guid in (select guid from systemmetadata))"; |
|
536 | 536 |
|
537 | 537 |
if (includeRevisions) { |
538 | 538 |
sql = sql + " UNION ALL " + revisionSql; |
... | ... | |
1253 | 1253 |
* @throws McdbDocNotFoundException |
1254 | 1254 |
* @throws AccessException |
1255 | 1255 |
*/ |
1256 |
private AccessPolicy getAccessPolicy(String guid) throws McdbDocNotFoundException, AccessException {
|
|
1256 |
public AccessPolicy getAccessPolicy(String guid) throws McdbDocNotFoundException, AccessException {
|
|
1257 | 1257 |
AccessPolicy accessPolicy = new AccessPolicy(); |
1258 | 1258 |
|
1259 | 1259 |
// use GUID to look up the access |
1260 | 1260 |
XMLAccessAccess accessController = new XMLAccessAccess(true); |
1261 |
List<XMLAccessDAO> accessDAOs = accessController.getXMLAccessForDoc(guid); |
|
1261 |
List<XMLAccessDAO> accessDAOs = accessController.getXMLAccessForDoc(guid); |
|
1262 |
|
|
1262 | 1263 |
for (XMLAccessDAO accessDAO: accessDAOs) { |
1263 | 1264 |
AccessRule accessRule = new AccessRule(); |
1264 | 1265 |
Permission permission = convertPermission(accessDAO.getPermission().intValue()); |
... | ... | |
1271 | 1272 |
return accessPolicy; |
1272 | 1273 |
} |
1273 | 1274 |
|
1275 |
/** |
|
1276 |
* Lookup access policy from Metacat |
|
1277 |
* @param guid |
|
1278 |
* @return |
|
1279 |
* @throws McdbDocNotFoundException |
|
1280 |
* @throws AccessException |
|
1281 |
*/ |
|
1282 |
public AccessPolicy getAccessPolicyByLocalId(String docid) throws McdbDocNotFoundException, AccessException { |
|
1283 |
AccessPolicy accessPolicy = new AccessPolicy(); |
|
1284 |
|
|
1285 |
// use GUID to look up the access |
|
1286 |
XMLAccessAccess accessController = new XMLAccessAccess(false); |
|
1287 |
List<XMLAccessDAO> accessDAOs = accessController.getXMLAccessForDoc(docid); |
|
1288 |
|
|
1289 |
for (XMLAccessDAO accessDAO: accessDAOs) { |
|
1290 |
AccessRule accessRule = new AccessRule(); |
|
1291 |
Permission permission = convertPermission(accessDAO.getPermission().intValue()); |
|
1292 |
accessRule.addPermission(permission); |
|
1293 |
Subject subject = new Subject(); |
|
1294 |
subject.setValue(accessDAO.getPrincipalName()); |
|
1295 |
accessRule.addSubject(subject); |
|
1296 |
accessPolicy.addAllow(accessRule); |
|
1297 |
} |
|
1298 |
return accessPolicy; |
|
1299 |
} |
|
1300 |
|
|
1274 | 1301 |
public int convertPermission(Permission permission) { |
1275 | 1302 |
if (permission.equals(Permission.READ)) { |
1276 | 1303 |
return AccessControlInterface.READ; |
... | ... | |
1294 | 1321 |
if (permission == AccessControlInterface.CHMOD) { |
1295 | 1322 |
return Permission.CHANGE_PERMISSION; |
1296 | 1323 |
} |
1324 |
if (permission == AccessControlInterface.ALL) { |
|
1325 |
return Permission.CHANGE_PERMISSION; |
|
1326 |
} |
|
1297 | 1327 |
return null; |
1298 | 1328 |
} |
1299 | 1329 |
|
Also available in: Unified diff
look up access policy by guid or local id
TODO: resolve the Metacat/EML "all" permission as it relates to DataONE (there is only READ, WRITE, CHANGE_PERMISSION). for now I am using CHANGE_PERMISSION when it is a Metacat "all"