Search in sources :

Example 1 with ListGroups

use of com.google.gerrit.server.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 {
            list.addProject(projects.parse(tlr, IdString.fromDecoded(project)).getControl());
        } catch (Exception e) {
            throw asRestApiException("Error looking up project " + project, e);
        }
    }
    for (String group : req.getGroups()) {
        list.addGroup(groups.parse(group).getGroupUUID());
    }
    list.setVisibleToAll(req.getVisibleToAll());
    if (req.getUser() != null) {
        try {
            list.setUser(accounts.parse(req.getUser()).getAccountId());
        } 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.setSuggest(req.getSuggest());
    try {
        return list.apply(tlr);
    } catch (Exception e) {
        throw asRestApiException("Cannot list groups", e);
    }
}
Also used : TopLevelResource(com.google.gerrit.extensions.restapi.TopLevelResource) ListGroups(com.google.gerrit.server.group.ListGroups) IdString(com.google.gerrit.extensions.restapi.IdString) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException)

Aggregations

BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)1 IdString (com.google.gerrit.extensions.restapi.IdString)1 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)1 TopLevelResource (com.google.gerrit.extensions.restapi.TopLevelResource)1 ApiUtil.asRestApiException (com.google.gerrit.server.api.ApiUtil.asRestApiException)1 ListGroups (com.google.gerrit.server.group.ListGroups)1