use of com.google.gerrit.common.errors.NoSuchGroupException 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.errors.NoSuchGroupException in project gerrit by GerritCodeReview.
the class GetGroups method apply.
@Override
public List<GroupInfo> apply(AccountResource resource) throws OrmException {
IdentifiedUser user = resource.getUser();
Account.Id userId = user.getAccountId();
List<GroupInfo> groups = new ArrayList<>();
for (AccountGroup.UUID uuid : user.getEffectiveGroups().getKnownGroups()) {
GroupControl ctl;
try {
ctl = groupControlFactory.controlFor(uuid);
} catch (NoSuchGroupException e) {
continue;
}
if (ctl.isVisible() && ctl.canSeeMember(userId)) {
groups.add(json.format(ctl.getGroup()));
}
}
return groups;
}
Aggregations