Search in sources :

Example 1 with Input

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

the class PutStatus method apply.

public Response<String> apply(IdentifiedUser user, Input input) throws ResourceNotFoundException, OrmException, IOException {
    if (input == null) {
        input = new Input();
    }
    String newStatus = input.status;
    Account a = dbProvider.get().accounts().atomicUpdate(user.getAccountId(), new AtomicUpdate<Account>() {

        @Override
        public Account update(Account a) {
            a.setStatus(Strings.nullToEmpty(newStatus));
            return a;
        }
    });
    if (a == null) {
        throw new ResourceNotFoundException("account not found");
    }
    byIdCache.evict(a.getId());
    return Strings.isNullOrEmpty(a.getStatus()) ? Response.none() : Response.ok(a.getStatus());
}
Also used : Account(com.google.gerrit.reviewdb.client.Account) Input(com.google.gerrit.server.account.PutStatus.Input) DefaultInput(com.google.gerrit.extensions.restapi.DefaultInput) ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException)

Aggregations

DefaultInput (com.google.gerrit.extensions.restapi.DefaultInput)1 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)1 Account (com.google.gerrit.reviewdb.client.Account)1 Input (com.google.gerrit.server.account.PutStatus.Input)1