Change SetInactiveFlag to accept account id instead of IdentifiedUser
Change-Id: I173903d26b28aa0e55cce76e1e3a29923e82a31c
This commit is contained in:
parent
512eb25dcd
commit
df2b315886
@ -49,6 +49,6 @@ public class DeleteActive implements RestModifyView<AccountResource, Input> {
|
||||
if (self.get() == rsrc.getUser()) {
|
||||
throw new ResourceConflictException("cannot deactivate own account");
|
||||
}
|
||||
return setInactiveFlag.deactivate(rsrc.getUser());
|
||||
return setInactiveFlag.deactivate(rsrc.getUser().getAccountId());
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,6 @@ public class PutActive implements RestModifyView<AccountResource, Input> {
|
||||
@Override
|
||||
public Response<String> apply(AccountResource rsrc, Input input)
|
||||
throws ResourceNotFoundException, OrmException, IOException, ConfigInvalidException {
|
||||
return setInactiveFlag.activate(rsrc.getUser());
|
||||
return setInactiveFlag.activate(rsrc.getUser().getAccountId());
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@ -36,14 +35,14 @@ public class SetInactiveFlag {
|
||||
this.accountsUpdate = accountsUpdate;
|
||||
}
|
||||
|
||||
public Response<?> deactivate(IdentifiedUser user)
|
||||
public Response<?> deactivate(Account.Id accountId)
|
||||
throws RestApiException, IOException, ConfigInvalidException {
|
||||
AtomicBoolean alreadyInactive = new AtomicBoolean(false);
|
||||
Account account =
|
||||
accountsUpdate
|
||||
.create()
|
||||
.update(
|
||||
user.getAccountId(),
|
||||
accountId,
|
||||
a -> {
|
||||
if (!a.isActive()) {
|
||||
alreadyInactive.set(true);
|
||||
@ -60,14 +59,14 @@ public class SetInactiveFlag {
|
||||
return Response.none();
|
||||
}
|
||||
|
||||
public Response<String> activate(IdentifiedUser user)
|
||||
public Response<String> activate(Account.Id accountId)
|
||||
throws ResourceNotFoundException, IOException, ConfigInvalidException {
|
||||
AtomicBoolean alreadyActive = new AtomicBoolean(false);
|
||||
Account account =
|
||||
accountsUpdate
|
||||
.create()
|
||||
.update(
|
||||
user.getAccountId(),
|
||||
accountId,
|
||||
a -> {
|
||||
if (a.isActive()) {
|
||||
alreadyActive.set(true);
|
||||
|
Loading…
Reference in New Issue
Block a user