Merge "RestApiModule: Support binding a RestView for resource creation"
This commit is contained in:
@@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.extensions.annotations.RequiresCapability;
|
||||
import com.google.gerrit.extensions.api.accounts.AccountInput;
|
||||
import com.google.gerrit.extensions.restapi.IdString;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
@@ -66,7 +67,7 @@ final class CreateAccountCommand extends SshCommand {
|
||||
@Argument(index = 0, required = true, metaVar = "USERNAME", usage = "name of the user account")
|
||||
private String username;
|
||||
|
||||
@Inject private CreateAccount.Factory createAccountFactory;
|
||||
@Inject private CreateAccount createAccount;
|
||||
|
||||
@Override
|
||||
protected void run() throws OrmException, IOException, ConfigInvalidException, UnloggedFailure {
|
||||
@@ -78,7 +79,7 @@ final class CreateAccountCommand extends SshCommand {
|
||||
input.httpPassword = httpPassword;
|
||||
input.groups = Lists.transform(groups, AccountGroup.Id::toString);
|
||||
try {
|
||||
createAccountFactory.create(username).apply(TopLevelResource.INSTANCE, input);
|
||||
createAccount.apply(TopLevelResource.INSTANCE, IdString.fromDecoded(username), input);
|
||||
} catch (RestApiException e) {
|
||||
throw die(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ final class CreateGroupCommand extends SshCommand {
|
||||
initialGroups.add(id);
|
||||
}
|
||||
|
||||
@Inject private CreateGroup.Factory createGroupFactory;
|
||||
@Inject private CreateGroup createGroup;
|
||||
|
||||
@Inject private GroupsCollection groups;
|
||||
|
||||
@@ -126,7 +126,8 @@ final class CreateGroupCommand extends SshCommand {
|
||||
input.ownerId = String.valueOf(ownerGroupId.get());
|
||||
}
|
||||
|
||||
GroupInfo group = createGroupFactory.create(groupName).apply(TopLevelResource.INSTANCE, input);
|
||||
GroupInfo group =
|
||||
createGroup.apply(TopLevelResource.INSTANCE, IdString.fromDecoded(groupName), input);
|
||||
return groups.parse(TopLevelResource.INSTANCE, IdString.fromUrl(group.id));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.google.gerrit.extensions.common.Input;
|
||||
import com.google.gerrit.extensions.common.NameInput;
|
||||
import com.google.gerrit.extensions.common.SshKeyInfo;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.IdString;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -119,7 +120,7 @@ final class SetAccountCommand extends SshCommand {
|
||||
|
||||
@Inject private IdentifiedUser.GenericFactory genericUserFactory;
|
||||
|
||||
@Inject private CreateEmail.Factory createEmailFactory;
|
||||
@Inject private CreateEmail createEmail;
|
||||
|
||||
@Inject private GetEmails getEmails;
|
||||
|
||||
@@ -269,7 +270,7 @@ final class SetAccountCommand extends SshCommand {
|
||||
in.email = email;
|
||||
in.noConfirmation = true;
|
||||
try {
|
||||
createEmailFactory.create(email).apply(rsrc, in);
|
||||
createEmail.apply(rsrc, IdString.fromDecoded(email), in);
|
||||
} catch (EmailException e) {
|
||||
throw die(e.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user