Search in sources :

Example 1 with QueryAccounts

use of com.google.gerrit.server.restapi.account.QueryAccounts in project gerrit by GerritCodeReview.

the class AccountsImpl method query.

private List<AccountInfo> query(QueryRequest r) throws RestApiException {
    try {
        QueryAccounts myQueryAccounts = queryAccountsProvider.get();
        myQueryAccounts.setQuery(r.getQuery());
        myQueryAccounts.setLimit(r.getLimit());
        myQueryAccounts.setStart(r.getStart());
        myQueryAccounts.setSuggest(r.getSuggest());
        for (ListAccountsOption option : r.getOptions()) {
            myQueryAccounts.addOption(option);
        }
        return myQueryAccounts.apply(TopLevelResource.INSTANCE).value();
    } catch (Exception e) {
        throw asRestApiException("Cannot retrieve suggested accounts", e);
    }
}
Also used : QueryAccounts(com.google.gerrit.server.restapi.account.QueryAccounts) ListAccountsOption(com.google.gerrit.extensions.client.ListAccountsOption) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) AuthException(com.google.gerrit.extensions.restapi.AuthException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException)

Example 2 with QueryAccounts

use of com.google.gerrit.server.restapi.account.QueryAccounts in project gerrit by GerritCodeReview.

the class AccountsImpl method suggestAccounts.

private List<AccountInfo> suggestAccounts(SuggestAccountsRequest r) throws RestApiException {
    try {
        QueryAccounts myQueryAccounts = queryAccountsProvider.get();
        myQueryAccounts.setSuggest(true);
        myQueryAccounts.setQuery(r.getQuery());
        myQueryAccounts.setLimit(r.getLimit());
        return myQueryAccounts.apply(TopLevelResource.INSTANCE).value();
    } catch (Exception e) {
        throw asRestApiException("Cannot retrieve suggested accounts", e);
    }
}
Also used : QueryAccounts(com.google.gerrit.server.restapi.account.QueryAccounts) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) AuthException(com.google.gerrit.extensions.restapi.AuthException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException)

Aggregations

AuthException (com.google.gerrit.extensions.restapi.AuthException)2 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)2 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)2 ApiUtil.asRestApiException (com.google.gerrit.server.api.ApiUtil.asRestApiException)2 QueryAccounts (com.google.gerrit.server.restapi.account.QueryAccounts)2 ListAccountsOption (com.google.gerrit.extensions.client.ListAccountsOption)1