Revision 8614
Added by ben leinfelder about 10 years ago
SyncAccessPolicy.java | ||
---|---|---|
50 | 50 |
import org.dataone.service.exceptions.ServiceFailure; |
51 | 51 |
import org.dataone.service.exceptions.VersionMismatch; |
52 | 52 |
import org.dataone.service.types.v1.AccessPolicy; |
53 |
import org.dataone.service.types.v1.AccessRule; |
|
53 | 54 |
import org.dataone.service.types.v1.Identifier; |
54 | 55 |
import org.dataone.service.types.v1.ObjectFormatIdentifier; |
55 | 56 |
import org.dataone.service.types.v1.ObjectInfo; |
... | ... | |
63 | 64 |
import edu.ucsb.nceas.metacat.IdentifierManager; |
64 | 65 |
import edu.ucsb.nceas.metacat.McdbDocNotFoundException; |
65 | 66 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlException; |
66 |
import edu.ucsb.nceas.metacat.admin.AdminException; |
|
67 | 67 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
68 | 68 |
import edu.ucsb.nceas.metacat.shared.ServiceException; |
69 | 69 |
import edu.ucsb.nceas.utilities.GeneralPropertyException; |
... | ... | |
414 | 414 |
*/ |
415 | 415 |
public boolean isEqual(AccessPolicy ap1, AccessPolicy ap2) { |
416 | 416 |
|
417 |
// can't check when either is null |
|
418 |
if (ap1 == null || ap2 == null) { |
|
419 |
return false; |
|
420 |
} |
|
421 |
|
|
417 | 422 |
// Access Policy -> Access Rule -> (Subject, Permission) |
418 | 423 |
// i.e. Subject="slaughter", Permission="read,write,changePermission" |
419 | 424 |
// Get the list of access rules for each access policy |
420 |
List<org.dataone.service.types.v1.AccessRule> allowList1 = ap1
|
|
425 |
List<AccessRule> allowList1 = ap1 |
|
421 | 426 |
.getAllowList(); |
422 |
List<org.dataone.service.types.v1.AccessRule> allowList2 = ap2
|
|
427 |
List<AccessRule> allowList2 = ap2 |
|
423 | 428 |
.getAllowList(); |
424 | 429 |
|
425 | 430 |
HashMap<Subject, Set<Permission>> userPerms1 = new HashMap<Subject, Set<Permission>>(); |
... | ... | |
436 | 441 |
Set<Permission> perms = null; |
437 | 442 |
// Process first access policy |
438 | 443 |
// Loop through access rules of this allowList |
439 |
for (org.dataone.service.types.v1.AccessRule accessRule : allowList1) {
|
|
444 |
for (AccessRule accessRule : allowList1) { |
|
440 | 445 |
for (Subject s : accessRule.getSubjectList()) { |
441 | 446 |
if (userPerms1.containsKey(s)) { |
442 | 447 |
perms = userPerms1.get(s); |
... | ... | |
451 | 456 |
} |
452 | 457 |
|
453 | 458 |
// Process second access policy |
454 |
for (org.dataone.service.types.v1.AccessRule accessRule : allowList2) {
|
|
459 |
for (AccessRule accessRule : allowList2) { |
|
455 | 460 |
for (Subject s : accessRule.getSubjectList()) { |
456 | 461 |
if (userPerms2.containsKey(s)) { |
457 | 462 |
perms = userPerms2.get(s); |
Also available in: Unified diff
include a few tests for isEqual method. https://projects.ecoinformatics.org/ecoinfo/issues/6407