use of com.google.gerrit.server.restapi.group.ListGroups in project gerrit by GerritCodeReview.
the class GroupsImpl method list.
private SortedMap<String, GroupInfo> list(ListRequest req) throws RestApiException {
TopLevelResource tlr = TopLevelResource.INSTANCE;
ListGroups list = listGroups.get();
list.setOptions(req.getOptions());
for (String project : req.getProjects()) {
try {
ProjectResource rsrc = projects.parse(tlr, IdString.fromDecoded(project));
list.addProject(rsrc.getProjectState());
} catch (Exception e) {
throw asRestApiException("Error looking up project " + project, e);
}
}
for (String group : req.getGroups()) {
list.addGroup(groupResolver.parse(group).getGroupUUID());
}
list.setVisibleToAll(req.getVisibleToAll());
if (req.getOwnedBy() != null) {
list.setOwnedBy(req.getOwnedBy());
}
if (req.getUser() != null) {
try {
list.setUser(accountResolver.resolve(req.getUser()).asUnique().account().id());
} catch (Exception e) {
throw asRestApiException("Error looking up user " + req.getUser(), e);
}
}
list.setOwned(req.getOwned());
list.setLimit(req.getLimit());
list.setStart(req.getStart());
list.setMatchSubstring(req.getSubstring());
list.setMatchRegex(req.getRegex());
list.setSuggest(req.getSuggest());
try {
return list.apply(tlr).value();
} catch (Exception e) {
throw asRestApiException("Cannot list groups", e);
}
}
Aggregations