Added GroupMembership for group membership checks.

This replaces existing uses of a Set to determine membership and
will make it possible to integrate with group systems that do not
allow efficient enumentation of memberships.

Change-Id: Iba9842ca1a355fc100fb4a02d7954d89032cdba0
This commit is contained in:
Colby Ranger
2012-03-23 10:19:11 -07:00
parent 53f0f79da8
commit 05f2bc1c60
30 changed files with 329 additions and 127 deletions

View File

@@ -25,6 +25,7 @@ import com.google.gerrit.rules.PrologEnvironment;
import com.google.gerrit.rules.RulesCache;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.CapabilityCollection;
import com.google.gerrit.server.account.GroupMembership;
import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.ProjectConfig;
@@ -237,13 +238,13 @@ public class ProjectState {
* @return true if any of the groups listed in {@code groups} was declared to
* be an owner of this project, or one of its parent projects..
*/
boolean isOwner(Set<AccountGroup.UUID> groups) {
boolean isOwner(GroupMembership groups) {
Set<Project.NameKey> seen = new HashSet<Project.NameKey>();
seen.add(getProject().getNameKey());
ProjectState s = this;
do {
if (CollectionsUtil.isAnyIncludedIn(s.localOwners, groups)) {
if (groups.containsAnyOf(s.localOwners)) {
return true;
}