Switch to UUID of groups for most public methods of Groups
Change-Id: Ib17ac236117f1078b7f857bb81e42dbf8b8426a8
This commit is contained in:
@@ -94,14 +94,6 @@ public class GroupControl {
|
||||
return new GroupControl(user.get(), group, permissionBackend, groupBackend);
|
||||
}
|
||||
|
||||
public GroupControl validateFor(AccountGroup.Id groupId) throws NoSuchGroupException {
|
||||
final GroupControl c = controlFor(groupId);
|
||||
if (!c.isVisible()) {
|
||||
throw new NoSuchGroupException(groupId);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public GroupControl validateFor(AccountGroup.UUID groupUUID) throws NoSuchGroupException {
|
||||
final GroupControl c = controlFor(groupUUID);
|
||||
if (!c.isVisible()) {
|
||||
|
@@ -30,14 +30,14 @@ import java.util.concurrent.Callable;
|
||||
|
||||
public class GroupDetailFactory implements Callable<GroupDetail> {
|
||||
public interface Factory {
|
||||
GroupDetailFactory create(AccountGroup.Id groupId);
|
||||
GroupDetailFactory create(AccountGroup.UUID groupUuid);
|
||||
}
|
||||
|
||||
private final ReviewDb db;
|
||||
private final GroupControl.Factory groupControl;
|
||||
private final Groups groups;
|
||||
|
||||
private final AccountGroup.Id groupId;
|
||||
private final AccountGroup.UUID groupUuid;
|
||||
private GroupControl control;
|
||||
|
||||
@Inject
|
||||
@@ -45,24 +45,24 @@ public class GroupDetailFactory implements Callable<GroupDetail> {
|
||||
ReviewDb db,
|
||||
GroupControl.Factory groupControl,
|
||||
Groups groups,
|
||||
@Assisted AccountGroup.Id groupId) {
|
||||
@Assisted AccountGroup.UUID groupUuid) {
|
||||
this.db = db;
|
||||
this.groupControl = groupControl;
|
||||
this.groups = groups;
|
||||
|
||||
this.groupId = groupId;
|
||||
this.groupUuid = groupUuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupDetail call() throws OrmException, NoSuchGroupException {
|
||||
control = groupControl.validateFor(groupId);
|
||||
control = groupControl.validateFor(groupUuid);
|
||||
ImmutableSet<Account.Id> members = loadMembers();
|
||||
ImmutableSet<AccountGroup.UUID> includes = loadIncludes();
|
||||
return new GroupDetail(members, includes);
|
||||
}
|
||||
|
||||
private ImmutableSet<Account.Id> loadMembers() throws OrmException {
|
||||
return groups.getMembers(db, groupId).filter(control::canSeeMember).collect(toImmutableSet());
|
||||
return groups.getMembers(db, groupUuid).filter(control::canSeeMember).collect(toImmutableSet());
|
||||
}
|
||||
|
||||
private ImmutableSet<AccountGroup.UUID> loadIncludes() throws OrmException {
|
||||
@@ -70,6 +70,6 @@ public class GroupDetailFactory implements Callable<GroupDetail> {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
|
||||
return groups.getIncludes(db, groupId).collect(toImmutableSet());
|
||||
return groups.getIncludes(db, groupUuid).collect(toImmutableSet());
|
||||
}
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ public class GroupMembers {
|
||||
final AccountGroup group, Project.NameKey project, Set<AccountGroup.UUID> seen)
|
||||
throws NoSuchGroupException, OrmException, NoSuchProjectException, IOException {
|
||||
seen.add(group.getGroupUUID());
|
||||
final GroupDetail groupDetail = groupDetailFactory.create(group.getId()).call();
|
||||
final GroupDetail groupDetail = groupDetailFactory.create(group.getGroupUUID()).call();
|
||||
|
||||
final Set<Account> members = new HashSet<>();
|
||||
for (Account.Id memberId : groupDetail.getMembers()) {
|
||||
|
Reference in New Issue
Block a user