Search in sources :

Example 1 with CreateAccount

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

the class AccountsImpl method create.

@Override
public AccountApi create(AccountInput in) throws RestApiException {
    if (checkNotNull(in, "AccountInput").username == null) {
        throw new BadRequestException("AccountInput must specify username");
    }
    try {
        CreateAccount impl = createAccount.create(in.username);
        permissionBackend.user(self).checkAny(GlobalPermission.fromAnnotation(impl.getClass()));
        AccountInfo info = impl.apply(TopLevelResource.INSTANCE, in).value();
        return id(info._accountId);
    } catch (Exception e) {
        throw asRestApiException("Cannot create account " + in.username, e);
    }
}
Also used : CreateAccount(com.google.gerrit.server.account.CreateAccount) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) 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

AccountInfo (com.google.gerrit.extensions.common.AccountInfo)1 AuthException (com.google.gerrit.extensions.restapi.AuthException)1 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)1 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)1 CreateAccount (com.google.gerrit.server.account.CreateAccount)1 ApiUtil.asRestApiException (com.google.gerrit.server.api.ApiUtil.asRestApiException)1