use of com.google.gerrit.common.data.GroupDetail in project gerrit by GerritCodeReview.
the class GroupMembers method getGroupMembers.
private Set<Account> getGroupMembers(final AccountGroup group, final Project.NameKey project, final Set<AccountGroup.UUID> seen) throws NoSuchGroupException, OrmException, NoSuchProjectException, IOException {
seen.add(group.getGroupUUID());
final GroupDetail groupDetail = groupDetailFactory.create(group.getId()).call();
final Set<Account> members = new HashSet<>();
if (groupDetail.members != null) {
for (final AccountGroupMember member : groupDetail.members) {
members.add(accountCache.get(member.getAccountId()).getAccount());
}
}
if (groupDetail.includes != null) {
for (final AccountGroupById groupInclude : groupDetail.includes) {
final AccountGroup includedGroup = groupCache.get(groupInclude.getIncludeUUID());
if (includedGroup != null && !seen.contains(includedGroup.getGroupUUID())) {
members.addAll(listAccounts(includedGroup.getGroupUUID(), project, seen));
}
}
}
return members;
}
use of com.google.gerrit.common.data.GroupDetail in project gerrit by GerritCodeReview.
the class ListMembers method getMembers.
private Map<Account.Id, AccountInfo> getMembers(final AccountGroup.UUID groupUUID, final HashSet<AccountGroup.UUID> seenGroups) throws OrmException {
seenGroups.add(groupUUID);
final Map<Account.Id, AccountInfo> members = new HashMap<>();
final AccountGroup group = groupCache.get(groupUUID);
if (group == null) {
// the included group is an external group and can't be resolved
return Collections.emptyMap();
}
final GroupDetail groupDetail;
try {
groupDetail = groupDetailFactory.create(group.getId()).call();
} catch (NoSuchGroupException e) {
// the included group is not visible
return Collections.emptyMap();
}
if (groupDetail.members != null) {
for (final AccountGroupMember m : groupDetail.members) {
if (!members.containsKey(m.getAccountId())) {
members.put(m.getAccountId(), accountLoader.get(m.getAccountId()));
}
}
}
if (recursive) {
if (groupDetail.includes != null) {
for (final AccountGroupById includedGroup : groupDetail.includes) {
if (!seenGroups.contains(includedGroup.getIncludeUUID())) {
members.putAll(getMembers(includedGroup.getIncludeUUID(), seenGroups));
}
}
}
}
accountLoader.fill();
return members;
}
use of com.google.gerrit.common.data.GroupDetail in project gerrit by GerritCodeReview.
the class GroupDetailFactory method call.
@Override
public GroupDetail call() throws OrmException, NoSuchGroupException {
control = groupControl.validateFor(groupId);
AccountGroup group = groupCache.get(groupId);
GroupDetail detail = new GroupDetail();
detail.setGroup(group);
detail.setMembers(loadMembers());
detail.setIncludes(loadIncludes());
return detail;
}
Aggregations