use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class ListGroups method getAllGroups.
private List<GroupInfo> getAllGroups() throws OrmException {
List<GroupInfo> groupInfos;
List<AccountGroup> groupList;
if (!projects.isEmpty()) {
Map<AccountGroup.UUID, AccountGroup> groups = new HashMap<>();
for (final ProjectControl projectControl : projects) {
final Set<GroupReference> groupsRefs = projectControl.getAllGroups();
for (final GroupReference groupRef : groupsRefs) {
final AccountGroup group = groupCache.get(groupRef.getUUID());
if (group != null) {
groups.put(group.getGroupUUID(), group);
}
}
}
groupList = filterGroups(groups.values());
} else {
groupList = filterGroups(groupCache.all());
}
groupInfos = Lists.newArrayListWithCapacity(groupList.size());
int found = 0;
int foundIndex = 0;
for (AccountGroup group : groupList) {
if (foundIndex++ < start) {
continue;
}
if (limit > 0 && ++found > limit) {
break;
}
groupInfos.add(json.addOptions(options).format(GroupDescriptions.forAccountGroup(group)));
}
return groupInfos;
}
use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class ListGroups method suggestGroups.
private List<GroupInfo> suggestGroups() throws OrmException, BadRequestException {
if (conflictingSuggestParameters()) {
throw new BadRequestException("You should only have no more than one --project and -n with --suggest");
}
List<GroupReference> groupRefs = Lists.newArrayList(Iterables.limit(groupBackend.suggest(suggest, Iterables.getFirst(projects, null)), limit <= 0 ? 10 : Math.min(limit, 10)));
List<GroupInfo> groupInfos = Lists.newArrayListWithCapacity(groupRefs.size());
for (final GroupReference ref : groupRefs) {
GroupDescription.Basic desc = groupBackend.get(ref.getUUID());
if (desc != null) {
groupInfos.add(json.addOptions(options).format(desc));
}
}
return groupInfos;
}
use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.
the class CreateGroupCommand method createGroup.
private GroupResource createGroup() throws RestApiException, OrmException, IOException {
GroupInput input = new GroupInput();
input.description = groupDescription;
input.visibleToAll = visibleToAll;
if (ownerGroupId != null) {
input.ownerId = String.valueOf(ownerGroupId.get());
}
GroupInfo group = createGroupFactory.create(groupName).apply(TopLevelResource.INSTANCE, input);
return groups.parse(TopLevelResource.INSTANCE, IdString.fromUrl(group.id));
}
Aggregations