Search in sources :

Example 1 with StatusInput

use of com.google.gerrit.extensions.api.accounts.StatusInput in project gerrit by GerritCodeReview.

the class PutStatus method apply.

public Response<String> apply(IdentifiedUser user, StatusInput input) throws ResourceNotFoundException, IOException, ConfigInvalidException {
    if (input == null) {
        input = new StatusInput();
    }
    String newStatus = input.status;
    AccountState accountState = accountsUpdateProvider.get().update("Set Status via API", user.getAccountId(), u -> u.setStatus(newStatus)).orElseThrow(() -> new ResourceNotFoundException("account not found"));
    return Strings.isNullOrEmpty(accountState.account().status()) ? Response.none() : Response.ok(accountState.account().status());
}
Also used : ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) GlobalPermission(com.google.gerrit.server.permissions.GlobalPermission) PermissionBackendException(com.google.gerrit.server.permissions.PermissionBackendException) CurrentUser(com.google.gerrit.server.CurrentUser) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) Inject(com.google.inject.Inject) AccountResource(com.google.gerrit.server.account.AccountResource) IOException(java.io.IOException) Response(com.google.gerrit.extensions.restapi.Response) PermissionBackend(com.google.gerrit.server.permissions.PermissionBackend) RestModifyView(com.google.gerrit.extensions.restapi.RestModifyView) Strings(com.google.common.base.Strings) Provider(com.google.inject.Provider) StatusInput(com.google.gerrit.extensions.api.accounts.StatusInput) IdentifiedUser(com.google.gerrit.server.IdentifiedUser) ServerInitiated(com.google.gerrit.server.ServerInitiated) AuthException(com.google.gerrit.extensions.restapi.AuthException) AccountState(com.google.gerrit.server.account.AccountState) AccountsUpdate(com.google.gerrit.server.account.AccountsUpdate) Singleton(com.google.inject.Singleton) StatusInput(com.google.gerrit.extensions.api.accounts.StatusInput) AccountState(com.google.gerrit.server.account.AccountState) ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException)

Aggregations

Strings (com.google.common.base.Strings)1 StatusInput (com.google.gerrit.extensions.api.accounts.StatusInput)1 AuthException (com.google.gerrit.extensions.restapi.AuthException)1 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)1 Response (com.google.gerrit.extensions.restapi.Response)1 RestModifyView (com.google.gerrit.extensions.restapi.RestModifyView)1 CurrentUser (com.google.gerrit.server.CurrentUser)1 IdentifiedUser (com.google.gerrit.server.IdentifiedUser)1 ServerInitiated (com.google.gerrit.server.ServerInitiated)1 AccountResource (com.google.gerrit.server.account.AccountResource)1 AccountState (com.google.gerrit.server.account.AccountState)1 AccountsUpdate (com.google.gerrit.server.account.AccountsUpdate)1 GlobalPermission (com.google.gerrit.server.permissions.GlobalPermission)1 PermissionBackend (com.google.gerrit.server.permissions.PermissionBackend)1 PermissionBackendException (com.google.gerrit.server.permissions.PermissionBackendException)1 Inject (com.google.inject.Inject)1 Provider (com.google.inject.Provider)1 Singleton (com.google.inject.Singleton)1 IOException (java.io.IOException)1 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)1