Merge changes from topic "static-inputs-cleanup"

* changes:
  PutOwner: Move static Input to separate class in extension API
  DescriptionInput [projects]: Extend DescriptionInput from extension API
  PutDescription [group]: Reuse Input class from extension API
  PutDescription [change]: Move static Input to separate class in extension API
  PutTopic: Move static Input to separate class in extension API
  PutName [group]: Reuse NameInput from extension API
  PutName [account]: Move static Input to separate class in extension API
  PutUsername: Move static Input to separate class in extension API
  PutHttpPassword: Move static Input to separate class in extension API
  PostGpgKeys: Move static Input to separate class in extension API
  AddSshKey: Extract static Input to separate class in extension API
  Get rid of empty static Input classes
This commit is contained in:
David Pursehouse
2017-10-06 13:16:32 +00:00
committed by Gerrit Code Review
67 changed files with 344 additions and 215 deletions

View File

@@ -18,13 +18,13 @@ import static com.google.common.truth.Truth.assertThat;
import com.google.gerrit.acceptance.AbstractDaemonTest; import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.RestResponse; import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.server.account.PutUsername; import com.google.gerrit.extensions.common.UsernameInput;
import org.junit.Test; import org.junit.Test;
public class PutUsernameIT extends AbstractDaemonTest { public class PutUsernameIT extends AbstractDaemonTest {
@Test @Test
public void set() throws Exception { public void set() throws Exception {
PutUsername.Input in = new PutUsername.Input(); UsernameInput in = new UsernameInput();
in.username = "myUsername"; in.username = "myUsername";
RestResponse r = RestResponse r =
adminRestSession.put("/accounts/" + accountCreator.create().id.get() + "/username", in); adminRestSession.put("/accounts/" + accountCreator.create().id.get() + "/username", in);
@@ -34,7 +34,7 @@ public class PutUsernameIT extends AbstractDaemonTest {
@Test @Test
public void setExisting_Conflict() throws Exception { public void setExisting_Conflict() throws Exception {
PutUsername.Input in = new PutUsername.Input(); UsernameInput in = new UsernameInput();
in.username = admin.username; in.username = admin.username;
adminRestSession adminRestSession
.put("/accounts/" + accountCreator.create().id.get() + "/username", in) .put("/accounts/" + accountCreator.create().id.get() + "/username", in)
@@ -43,7 +43,7 @@ public class PutUsernameIT extends AbstractDaemonTest {
@Test @Test
public void setNew_MethodNotAllowed() throws Exception { public void setNew_MethodNotAllowed() throws Exception {
PutUsername.Input in = new PutUsername.Input(); UsernameInput in = new UsernameInput();
in.username = "newUsername"; in.username = "newUsername";
adminRestSession.put("/accounts/" + admin.username + "/username", in).assertMethodNotAllowed(); adminRestSession.put("/accounts/" + admin.username + "/username", in).assertMethodNotAllowed();
} }

View File

@@ -43,6 +43,7 @@ import com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput;
import com.google.gerrit.extensions.api.changes.ReviewInput.DraftHandling; import com.google.gerrit.extensions.api.changes.ReviewInput.DraftHandling;
import com.google.gerrit.extensions.client.Side; import com.google.gerrit.extensions.client.Side;
import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.common.CommentInfo;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
@@ -326,7 +327,7 @@ public class ChangeRebuilderIT extends AbstractDaemonTest {
public void restApiNotFoundWhenNoteDbDisabled() throws Exception { public void restApiNotFoundWhenNoteDbDisabled() throws Exception {
PushOneCommit.Result r = createChange(); PushOneCommit.Result r = createChange();
exception.expect(ResourceNotFoundException.class); exception.expect(ResourceNotFoundException.class);
rebuildHandler.apply(parseChangeResource(r.getChangeId()), new Rebuild.Input()); rebuildHandler.apply(parseChangeResource(r.getChangeId()), new Input());
} }
@Test @Test
@@ -336,7 +337,7 @@ public class ChangeRebuilderIT extends AbstractDaemonTest {
setNotesMigration(true, false); setNotesMigration(true, false);
checker.assertNoChangeRef(project, id); checker.assertNoChangeRef(project, id);
rebuildHandler.apply(parseChangeResource(r.getChangeId()), new Rebuild.Input()); rebuildHandler.apply(parseChangeResource(r.getChangeId()), new Input());
checker.checkChanges(id); checker.checkChanges(id);
} }

View File

@@ -14,9 +14,6 @@
package com.google.gerrit.extensions.api.projects; package com.google.gerrit.extensions.api.projects;
import com.google.gerrit.extensions.restapi.DefaultInput; public class DescriptionInput extends com.google.gerrit.extensions.common.DescriptionInput {
public class DescriptionInput {
@DefaultInput public String description;
public String commitMessage; public String commitMessage;
} }

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.common;
import com.google.gerrit.extensions.restapi.DefaultInput;
public class DescriptionInput {
@DefaultInput public String description;
}

View File

@@ -0,0 +1,22 @@
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.common;
import java.util.List;
public class GpgKeysInput {
public List<String> add;
public List<String> delete;
}

View File

@@ -0,0 +1,20 @@
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.common;
public class HttpPasswordInput {
public String httpPassword;
public boolean generate;
}

View File

@@ -0,0 +1,20 @@
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.common;
/** A generic empty input. */
public class Input {
public Input() {}
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.common;
import com.google.gerrit.extensions.restapi.DefaultInput;
public class NameInput {
@DefaultInput public String name;
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.common;
import com.google.gerrit.extensions.restapi.DefaultInput;
public class OwnerInput {
@DefaultInput public String owner;
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.common;
import com.google.gerrit.extensions.restapi.RawInput;
public class SshKeyInput {
public RawInput raw;
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.common;
import com.google.gerrit.extensions.restapi.DefaultInput;
public class TopicInput {
@DefaultInput public String topic;
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.common;
import com.google.gerrit.extensions.restapi.DefaultInput;
public class UsernameInput {
@DefaultInput public String username;
}

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.gpg.api;
import com.google.gerrit.extensions.api.accounts.GpgKeyApi; import com.google.gerrit.extensions.api.accounts.GpgKeyApi;
import com.google.gerrit.extensions.common.GpgKeyInfo; import com.google.gerrit.extensions.common.GpgKeyInfo;
import com.google.gerrit.extensions.common.GpgKeysInput;
import com.google.gerrit.extensions.common.PushCertificateInfo; import com.google.gerrit.extensions.common.PushCertificateInfo;
import com.google.gerrit.extensions.restapi.IdString; import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
@@ -75,7 +76,7 @@ public class GpgApiAdapterImpl implements GpgApiAdapter {
public Map<String, GpgKeyInfo> putGpgKeys( public Map<String, GpgKeyInfo> putGpgKeys(
AccountResource account, List<String> add, List<String> delete) AccountResource account, List<String> add, List<String> delete)
throws RestApiException, GpgException { throws RestApiException, GpgException {
PostGpgKeys.Input in = new PostGpgKeys.Input(); GpgKeysInput in = new GpgKeysInput();
in.add = add; in.add = add;
in.delete = delete; in.delete = delete;
try { try {

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.gpg.api;
import com.google.gerrit.extensions.api.accounts.GpgKeyApi; import com.google.gerrit.extensions.api.accounts.GpgKeyApi;
import com.google.gerrit.extensions.common.GpgKeyInfo; import com.google.gerrit.extensions.common.GpgKeyInfo;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.gpg.server.DeleteGpgKey; import com.google.gerrit.gpg.server.DeleteGpgKey;
import com.google.gerrit.gpg.server.GpgKey; import com.google.gerrit.gpg.server.GpgKey;
@@ -55,7 +56,7 @@ public class GpgKeyApiImpl implements GpgKeyApi {
@Override @Override
public void delete() throws RestApiException { public void delete() throws RestApiException {
try { try {
delete.apply(rsrc, new DeleteGpgKey.Input()); delete.apply(rsrc, new Input());
} catch (PGPException | OrmException | IOException | ConfigInvalidException e) { } catch (PGPException | OrmException | IOException | ConfigInvalidException e) {
throw new RestApiException("Cannot delete GPG key", e); throw new RestApiException("Cannot delete GPG key", e);
} }

View File

@@ -18,11 +18,11 @@ import static com.google.gerrit.gpg.PublicKeyStore.keyIdToString;
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GPGKEY; import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GPGKEY;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.gpg.PublicKeyStore; import com.google.gerrit.gpg.PublicKeyStore;
import com.google.gerrit.gpg.server.DeleteGpgKey.Input;
import com.google.gerrit.server.GerritPersonIdent; import com.google.gerrit.server.GerritPersonIdent;
import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.account.externalids.ExternalIdsUpdate; import com.google.gerrit.server.account.externalids.ExternalIdsUpdate;
@@ -38,7 +38,6 @@ import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.lib.RefUpdate;
public class DeleteGpgKey implements RestModifyView<GpgKey, Input> { public class DeleteGpgKey implements RestModifyView<GpgKey, Input> {
public static class Input {}
private final Provider<PersonIdent> serverIdent; private final Provider<PersonIdent> serverIdent;
private final Provider<PublicKeyStore> storeProvider; private final Provider<PublicKeyStore> storeProvider;

View File

@@ -29,6 +29,7 @@ import com.google.common.collect.Sets;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
import com.google.gerrit.common.errors.EmailException; import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.extensions.common.GpgKeyInfo; import com.google.gerrit.extensions.common.GpgKeyInfo;
import com.google.gerrit.extensions.common.GpgKeysInput;
import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
@@ -38,7 +39,6 @@ import com.google.gerrit.gpg.Fingerprint;
import com.google.gerrit.gpg.GerritPublicKeyChecker; import com.google.gerrit.gpg.GerritPublicKeyChecker;
import com.google.gerrit.gpg.PublicKeyChecker; import com.google.gerrit.gpg.PublicKeyChecker;
import com.google.gerrit.gpg.PublicKeyStore; import com.google.gerrit.gpg.PublicKeyStore;
import com.google.gerrit.gpg.server.PostGpgKeys.Input;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.GerritPersonIdent; import com.google.gerrit.server.GerritPersonIdent;
@@ -75,12 +75,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@Singleton @Singleton
public class PostGpgKeys implements RestModifyView<AccountResource, Input> { public class PostGpgKeys implements RestModifyView<AccountResource, GpgKeysInput> {
public static class Input {
public List<String> add;
public List<String> delete;
}
private final Logger log = LoggerFactory.getLogger(getClass()); private final Logger log = LoggerFactory.getLogger(getClass());
private final Provider<PersonIdent> serverIdent; private final Provider<PersonIdent> serverIdent;
private final Provider<CurrentUser> self; private final Provider<CurrentUser> self;
@@ -112,7 +107,7 @@ public class PostGpgKeys implements RestModifyView<AccountResource, Input> {
} }
@Override @Override
public Map<String, GpgKeyInfo> apply(AccountResource rsrc, Input input) public Map<String, GpgKeyInfo> apply(AccountResource rsrc, GpgKeysInput input)
throws ResourceNotFoundException, BadRequestException, ResourceConflictException, throws ResourceNotFoundException, BadRequestException, ResourceConflictException,
PGPException, OrmException, IOException, ConfigInvalidException { PGPException, OrmException, IOException, ConfigInvalidException {
GpgKeys.checkVisible(self, rsrc); GpgKeys.checkVisible(self, rsrc);
@@ -148,7 +143,8 @@ public class PostGpgKeys implements RestModifyView<AccountResource, Input> {
} }
} }
private Set<Fingerprint> readKeysToRemove(Input input, Collection<ExternalId> existingExtIds) { private Set<Fingerprint> readKeysToRemove(
GpgKeysInput input, Collection<ExternalId> existingExtIds) {
if (input.delete == null || input.delete.isEmpty()) { if (input.delete == null || input.delete.isEmpty()) {
return ImmutableSet.of(); return ImmutableSet.of();
} }
@@ -163,7 +159,7 @@ public class PostGpgKeys implements RestModifyView<AccountResource, Input> {
return fingerprints; return fingerprints;
} }
private List<PGPPublicKeyRing> readKeysToAdd(Input input, Set<Fingerprint> toRemove) private List<PGPPublicKeyRing> readKeysToAdd(GpgKeysInput input, Set<Fingerprint> toRemove)
throws BadRequestException, IOException { throws BadRequestException, IOException {
if (input.add == null || input.add.isEmpty()) { if (input.add == null || input.add.isEmpty()) {
return ImmutableList.of(); return ImmutableList.of();

View File

@@ -20,6 +20,7 @@ import com.google.common.io.ByteSource;
import com.google.gerrit.common.errors.EmailException; import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.common.errors.InvalidSshKeyException; import com.google.gerrit.common.errors.InvalidSshKeyException;
import com.google.gerrit.extensions.common.SshKeyInfo; import com.google.gerrit.extensions.common.SshKeyInfo;
import com.google.gerrit.extensions.common.SshKeyInput;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.RawInput; import com.google.gerrit.extensions.restapi.RawInput;
@@ -28,7 +29,6 @@ import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.reviewdb.client.AccountSshKey; import com.google.gerrit.reviewdb.client.AccountSshKey;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AddSshKey.Input;
import com.google.gerrit.server.mail.send.AddKeySender; import com.google.gerrit.server.mail.send.AddKeySender;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
@@ -45,13 +45,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@Singleton @Singleton
public class AddSshKey implements RestModifyView<AccountResource, Input> { public class AddSshKey implements RestModifyView<AccountResource, SshKeyInput> {
private static final Logger log = LoggerFactory.getLogger(AddSshKey.class); private static final Logger log = LoggerFactory.getLogger(AddSshKey.class);
public static class Input {
public RawInput raw;
}
private final Provider<CurrentUser> self; private final Provider<CurrentUser> self;
private final PermissionBackend permissionBackend; private final PermissionBackend permissionBackend;
private final VersionedAuthorizedKeys.Accessor authorizedKeys; private final VersionedAuthorizedKeys.Accessor authorizedKeys;
@@ -73,7 +69,7 @@ public class AddSshKey implements RestModifyView<AccountResource, Input> {
} }
@Override @Override
public Response<SshKeyInfo> apply(AccountResource rsrc, Input input) public Response<SshKeyInfo> apply(AccountResource rsrc, SshKeyInput input)
throws AuthException, BadRequestException, OrmException, IOException, ConfigInvalidException, throws AuthException, BadRequestException, OrmException, IOException, ConfigInvalidException,
PermissionBackendException { PermissionBackendException {
if (self.get() != rsrc.getUser()) { if (self.get() != rsrc.getUser()) {
@@ -82,10 +78,10 @@ public class AddSshKey implements RestModifyView<AccountResource, Input> {
return apply(rsrc.getUser(), input); return apply(rsrc.getUser(), input);
} }
public Response<SshKeyInfo> apply(IdentifiedUser user, Input input) public Response<SshKeyInfo> apply(IdentifiedUser user, SshKeyInput input)
throws BadRequestException, IOException, ConfigInvalidException { throws BadRequestException, IOException, ConfigInvalidException {
if (input == null) { if (input == null) {
input = new Input(); input = new SshKeyInput();
} }
if (input.raw == null) { if (input.raw == null) {
throw new BadRequestException("SSH public key missing"); throw new BadRequestException("SSH public key missing");

View File

@@ -16,12 +16,12 @@ package com.google.gerrit.server.account;
import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.DeleteActive.Input;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
@@ -32,7 +32,6 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
@RequiresCapability(GlobalCapability.MODIFY_ACCOUNT) @RequiresCapability(GlobalCapability.MODIFY_ACCOUNT)
@Singleton @Singleton
public class DeleteActive implements RestModifyView<AccountResource, Input> { public class DeleteActive implements RestModifyView<AccountResource, Input> {
public static class Input {}
private final Provider<IdentifiedUser> self; private final Provider<IdentifiedUser> self;
private final SetInactiveFlag setInactiveFlag; private final SetInactiveFlag setInactiveFlag;

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.server.account;
import static java.util.stream.Collectors.toSet; import static java.util.stream.Collectors.toSet;
import com.google.gerrit.extensions.client.AccountFieldName; import com.google.gerrit.extensions.client.AccountFieldName;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
@@ -25,7 +26,6 @@ import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.DeleteEmail.Input;
import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.account.externalids.ExternalIds; import com.google.gerrit.server.account.externalids.ExternalIds;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
@@ -41,7 +41,6 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
@Singleton @Singleton
public class DeleteEmail implements RestModifyView<AccountResource.Email, Input> { public class DeleteEmail implements RestModifyView<AccountResource.Email, Input> {
public static class Input {}
private final Provider<CurrentUser> self; private final Provider<CurrentUser> self;
private final Realm realm; private final Realm realm;

View File

@@ -14,11 +14,11 @@
package com.google.gerrit.server.account; package com.google.gerrit.server.account;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.DeleteSshKey.Input;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.PermissionBackendException;
@@ -33,7 +33,6 @@ import org.eclipse.jgit.errors.RepositoryNotFoundException;
@Singleton @Singleton
public class DeleteSshKey implements RestModifyView<AccountResource.SshKey, Input> { public class DeleteSshKey implements RestModifyView<AccountResource.SshKey, Input> {
public static class Input {}
private final Provider<CurrentUser> self; private final Provider<CurrentUser> self;
private final PermissionBackend permissionBackend; private final PermissionBackend permissionBackend;

View File

@@ -14,11 +14,11 @@
package com.google.gerrit.server.account; package com.google.gerrit.server.account;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.Index.Input;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.PermissionBackendException;
@@ -29,7 +29,6 @@ import java.io.IOException;
@Singleton @Singleton
public class Index implements RestModifyView<AccountResource, Input> { public class Index implements RestModifyView<AccountResource, Input> {
public static class Input {}
private final AccountCache accountCache; private final AccountCache accountCache;
private final PermissionBackend permissionBackend; private final PermissionBackend permissionBackend;

View File

@@ -16,10 +16,10 @@ package com.google.gerrit.server.account;
import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.account.PutActive.Input;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -29,7 +29,6 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
@RequiresCapability(GlobalCapability.MODIFY_ACCOUNT) @RequiresCapability(GlobalCapability.MODIFY_ACCOUNT)
@Singleton @Singleton
public class PutActive implements RestModifyView<AccountResource, Input> { public class PutActive implements RestModifyView<AccountResource, Input> {
public static class Input {}
private final SetInactiveFlag setInactiveFlag; private final SetInactiveFlag setInactiveFlag;

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.server.account;
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_USERNAME; import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_USERNAME;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.gerrit.extensions.common.HttpPasswordInput;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
@@ -24,7 +25,6 @@ import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.PutHttpPassword.Input;
import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.account.externalids.ExternalIds; import com.google.gerrit.server.account.externalids.ExternalIds;
import com.google.gerrit.server.account.externalids.ExternalIdsUpdate; import com.google.gerrit.server.account.externalids.ExternalIdsUpdate;
@@ -40,12 +40,7 @@ import java.security.SecureRandom;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.ConfigInvalidException;
public class PutHttpPassword implements RestModifyView<AccountResource, Input> { public class PutHttpPassword implements RestModifyView<AccountResource, HttpPasswordInput> {
public static class Input {
public String httpPassword;
public boolean generate;
}
private static final int LEN = 31; private static final int LEN = 31;
private static final SecureRandom rng; private static final SecureRandom rng;
@@ -75,7 +70,7 @@ public class PutHttpPassword implements RestModifyView<AccountResource, Input> {
} }
@Override @Override
public Response<String> apply(AccountResource rsrc, Input input) public Response<String> apply(AccountResource rsrc, HttpPasswordInput input)
throws AuthException, ResourceNotFoundException, ResourceConflictException, OrmException, throws AuthException, ResourceNotFoundException, ResourceConflictException, OrmException,
IOException, ConfigInvalidException, PermissionBackendException { IOException, ConfigInvalidException, PermissionBackendException {
if (self.get() != rsrc.getUser()) { if (self.get() != rsrc.getUser()) {
@@ -83,7 +78,7 @@ public class PutHttpPassword implements RestModifyView<AccountResource, Input> {
} }
if (input == null) { if (input == null) {
input = new Input(); input = new HttpPasswordInput();
} }
input.httpPassword = Strings.emptyToNull(input.httpPassword); input.httpPassword = Strings.emptyToNull(input.httpPassword);

View File

@@ -16,8 +16,8 @@ package com.google.gerrit.server.account;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.gerrit.extensions.client.AccountFieldName; import com.google.gerrit.extensions.client.AccountFieldName;
import com.google.gerrit.extensions.common.NameInput;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.DefaultInput;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
@@ -25,7 +25,6 @@ import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.PutName.Input;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.PermissionBackendException;
@@ -37,11 +36,7 @@ import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.ConfigInvalidException;
@Singleton @Singleton
public class PutName implements RestModifyView<AccountResource, Input> { public class PutName implements RestModifyView<AccountResource, NameInput> {
public static class Input {
@DefaultInput public String name;
}
private final Provider<CurrentUser> self; private final Provider<CurrentUser> self;
private final Realm realm; private final Realm realm;
private final PermissionBackend permissionBackend; private final PermissionBackend permissionBackend;
@@ -60,7 +55,7 @@ public class PutName implements RestModifyView<AccountResource, Input> {
} }
@Override @Override
public Response<String> apply(AccountResource rsrc, Input input) public Response<String> apply(AccountResource rsrc, NameInput input)
throws AuthException, MethodNotAllowedException, ResourceNotFoundException, OrmException, throws AuthException, MethodNotAllowedException, ResourceNotFoundException, OrmException,
IOException, PermissionBackendException, ConfigInvalidException { IOException, PermissionBackendException, ConfigInvalidException {
if (self.get() != rsrc.getUser()) { if (self.get() != rsrc.getUser()) {
@@ -69,11 +64,11 @@ public class PutName implements RestModifyView<AccountResource, Input> {
return apply(rsrc.getUser(), input); return apply(rsrc.getUser(), input);
} }
public Response<String> apply(IdentifiedUser user, Input input) public Response<String> apply(IdentifiedUser user, NameInput input)
throws MethodNotAllowedException, ResourceNotFoundException, IOException, throws MethodNotAllowedException, ResourceNotFoundException, IOException,
ConfigInvalidException { ConfigInvalidException {
if (input == null) { if (input == null) {
input = new Input(); input = new NameInput();
} }
if (!realm.allowsEdit(AccountFieldName.FULL_NAME)) { if (!realm.allowsEdit(AccountFieldName.FULL_NAME)) {

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.account; package com.google.gerrit.server.account;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
@@ -21,7 +22,6 @@ import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.PutPreferred.Input;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.PermissionBackendException;
@@ -35,7 +35,6 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
@Singleton @Singleton
public class PutPreferred implements RestModifyView<AccountResource.Email, Input> { public class PutPreferred implements RestModifyView<AccountResource.Email, Input> {
static class Input {}
private final Provider<CurrentUser> self; private final Provider<CurrentUser> self;
private final PermissionBackend permissionBackend; private final PermissionBackend permissionBackend;

View File

@@ -16,14 +16,13 @@ package com.google.gerrit.server.account;
import com.google.gerrit.common.errors.NameAlreadyUsedException; import com.google.gerrit.common.errors.NameAlreadyUsedException;
import com.google.gerrit.extensions.client.AccountFieldName; import com.google.gerrit.extensions.client.AccountFieldName;
import com.google.gerrit.extensions.common.UsernameInput;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.DefaultInput;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.PutUsername.Input;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.PermissionBackendException;
@@ -35,11 +34,7 @@ import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.ConfigInvalidException;
@Singleton @Singleton
public class PutUsername implements RestModifyView<AccountResource, Input> { public class PutUsername implements RestModifyView<AccountResource, UsernameInput> {
public static class Input {
@DefaultInput public String username;
}
private final Provider<CurrentUser> self; private final Provider<CurrentUser> self;
private final ChangeUserName.Factory changeUserNameFactory; private final ChangeUserName.Factory changeUserNameFactory;
private final PermissionBackend permissionBackend; private final PermissionBackend permissionBackend;
@@ -58,7 +53,7 @@ public class PutUsername implements RestModifyView<AccountResource, Input> {
} }
@Override @Override
public String apply(AccountResource rsrc, Input input) public String apply(AccountResource rsrc, UsernameInput input)
throws AuthException, MethodNotAllowedException, UnprocessableEntityException, throws AuthException, MethodNotAllowedException, UnprocessableEntityException,
ResourceConflictException, OrmException, IOException, ConfigInvalidException, ResourceConflictException, OrmException, IOException, ConfigInvalidException,
PermissionBackendException { PermissionBackendException {
@@ -71,7 +66,7 @@ public class PutUsername implements RestModifyView<AccountResource, Input> {
} }
if (input == null) { if (input == null) {
input = new Input(); input = new UsernameInput();
} }
try { try {

View File

@@ -34,7 +34,9 @@ import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.EmailInfo; import com.google.gerrit.extensions.common.EmailInfo;
import com.google.gerrit.extensions.common.GpgKeyInfo; import com.google.gerrit.extensions.common.GpgKeyInfo;
import com.google.gerrit.extensions.common.GroupInfo; import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.common.SshKeyInfo; import com.google.gerrit.extensions.common.SshKeyInfo;
import com.google.gerrit.extensions.common.SshKeyInput;
import com.google.gerrit.extensions.restapi.IdString; import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
@@ -219,9 +221,9 @@ public class AccountApiImpl implements AccountApi {
public void setActive(boolean active) throws RestApiException { public void setActive(boolean active) throws RestApiException {
try { try {
if (active) { if (active) {
putActive.apply(account, new PutActive.Input()); putActive.apply(account, new Input());
} else { } else {
deleteActive.apply(account, new DeleteActive.Input()); deleteActive.apply(account, new Input());
} }
} catch (Exception e) { } catch (Exception e) {
throw asRestApiException("Cannot set active", e); throw asRestApiException("Cannot set active", e);
@@ -423,7 +425,7 @@ public class AccountApiImpl implements AccountApi {
@Override @Override
public SshKeyInfo addSshKey(String key) throws RestApiException { public SshKeyInfo addSshKey(String key) throws RestApiException {
AddSshKey.Input in = new AddSshKey.Input(); SshKeyInput in = new SshKeyInput();
in.raw = RawInputUtil.create(key); in.raw = RawInputUtil.create(key);
try { try {
return addSshKey.apply(account, in).value(); return addSshKey.apply(account, in).value();
@@ -490,7 +492,7 @@ public class AccountApiImpl implements AccountApi {
@Override @Override
public void index() throws RestApiException { public void index() throws RestApiException {
try { try {
index.apply(account, new Index.Input()); index.apply(account, new Input());
} catch (Exception e) { } catch (Exception e) {
throw asRestApiException("Cannot index account", e); throw asRestApiException("Cannot index account", e);
} }

View File

@@ -41,10 +41,12 @@ import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.common.CommentInfo;
import com.google.gerrit.extensions.common.CommitMessageInput; import com.google.gerrit.extensions.common.CommitMessageInput;
import com.google.gerrit.extensions.common.EditInfo; import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.common.MergePatchSetInput; import com.google.gerrit.extensions.common.MergePatchSetInput;
import com.google.gerrit.extensions.common.PureRevertInfo; import com.google.gerrit.extensions.common.PureRevertInfo;
import com.google.gerrit.extensions.common.RobotCommentInfo; import com.google.gerrit.extensions.common.RobotCommentInfo;
import com.google.gerrit.extensions.common.SuggestedReviewerInfo; import com.google.gerrit.extensions.common.SuggestedReviewerInfo;
import com.google.gerrit.extensions.common.TopicInput;
import com.google.gerrit.extensions.restapi.IdString; import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
@@ -435,7 +437,7 @@ class ChangeApiImpl implements ChangeApi {
@Override @Override
public void topic(String topic) throws RestApiException { public void topic(String topic) throws RestApiException {
PutTopic.Input in = new PutTopic.Input(); TopicInput in = new TopicInput();
in.topic = topic; in.topic = topic;
try { try {
putTopic.apply(change, in); putTopic.apply(change, in);
@@ -646,7 +648,7 @@ class ChangeApiImpl implements ChangeApi {
@Override @Override
public void index() throws RestApiException { public void index() throws RestApiException {
try { try {
index.apply(change, new Index.Input()); index.apply(change, new Input());
} catch (Exception e) { } catch (Exception e) {
throw asRestApiException("Cannot index change", e); throw asRestApiException("Cannot index change", e);
} }
@@ -658,9 +660,9 @@ class ChangeApiImpl implements ChangeApi {
// StarredChangesUtil. // StarredChangesUtil.
try { try {
if (ignore) { if (ignore) {
this.ignore.apply(change, new Ignore.Input()); this.ignore.apply(change, new Input());
} else { } else {
unignore.apply(change, new Unignore.Input()); unignore.apply(change, new Input());
} }
} catch (OrmException | IllegalLabelException e) { } catch (OrmException | IllegalLabelException e) {
throw asRestApiException("Cannot ignore change", e); throw asRestApiException("Cannot ignore change", e);
@@ -682,9 +684,9 @@ class ChangeApiImpl implements ChangeApi {
// StarredChangesUtil. // StarredChangesUtil.
try { try {
if (reviewed) { if (reviewed) {
markAsReviewed.apply(change, new MarkAsReviewed.Input()); markAsReviewed.apply(change, new Input());
} else { } else {
markAsUnreviewed.apply(change, new MarkAsUnreviewed.Input()); markAsUnreviewed.apply(change, new Input());
} }
} catch (OrmException | IllegalLabelException e) { } catch (OrmException | IllegalLabelException e) {
throw asRestApiException( throw asRestApiException(

View File

@@ -19,6 +19,7 @@ import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
import com.google.gerrit.extensions.api.changes.ChangeEditApi; import com.google.gerrit.extensions.api.changes.ChangeEditApi;
import com.google.gerrit.extensions.api.changes.PublishChangeEditInput; import com.google.gerrit.extensions.api.changes.PublishChangeEditInput;
import com.google.gerrit.extensions.common.EditInfo; import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BinaryResult; import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.IdString; import com.google.gerrit.extensions.restapi.IdString;
@@ -106,7 +107,7 @@ public class ChangeEditApiImpl implements ChangeEditApi {
@Override @Override
public void delete() throws RestApiException { public void delete() throws RestApiException {
try { try {
deleteChangeEdit.apply(changeResource, new DeleteChangeEdit.Input()); deleteChangeEdit.apply(changeResource, new Input());
} catch (Exception e) { } catch (Exception e) {
throw asRestApiException("Cannot delete change edit", e); throw asRestApiException("Cannot delete change edit", e);
} }

View File

@@ -36,8 +36,10 @@ import com.google.gerrit.extensions.client.SubmitType;
import com.google.gerrit.extensions.common.ActionInfo; import com.google.gerrit.extensions.common.ActionInfo;
import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.common.CommentInfo;
import com.google.gerrit.extensions.common.CommitInfo; import com.google.gerrit.extensions.common.CommitInfo;
import com.google.gerrit.extensions.common.DescriptionInput;
import com.google.gerrit.extensions.common.EditInfo; import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.FileInfo; import com.google.gerrit.extensions.common.FileInfo;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.common.MergeableInfo; import com.google.gerrit.extensions.common.MergeableInfo;
import com.google.gerrit.extensions.common.RobotCommentInfo; import com.google.gerrit.extensions.common.RobotCommentInfo;
import com.google.gerrit.extensions.common.TestSubmitRuleInput; import com.google.gerrit.extensions.common.TestSubmitRuleInput;
@@ -300,13 +302,13 @@ class RevisionApiImpl implements RevisionApi {
@Override @Override
public void setReviewed(String path, boolean reviewed) throws RestApiException { public void setReviewed(String path, boolean reviewed) throws RestApiException {
try { try {
RestModifyView<FileResource, Reviewed.Input> view; RestModifyView<FileResource, Input> view;
if (reviewed) { if (reviewed) {
view = putReviewed; view = putReviewed;
} else { } else {
view = deleteReviewed; view = deleteReviewed;
} }
view.apply(files.parse(revision, IdString.fromDecoded(path)), new Reviewed.Input()); view.apply(files.parse(revision, IdString.fromDecoded(path)), new Input());
} catch (Exception e) { } catch (Exception e) {
throw asRestApiException("Cannot update reviewed flag", e); throw asRestApiException("Cannot update reviewed flag", e);
} }
@@ -565,7 +567,7 @@ class RevisionApiImpl implements RevisionApi {
@Override @Override
public void description(String description) throws RestApiException { public void description(String description) throws RestApiException {
PutDescription.Input in = new PutDescription.Input(); DescriptionInput in = new DescriptionInput();
in.description = description; in.description = description;
try { try {
putDescription.apply(revision, in); putDescription.apply(revision, in);

View File

@@ -18,9 +18,13 @@ import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
import com.google.gerrit.extensions.api.groups.GroupApi; import com.google.gerrit.extensions.api.groups.GroupApi;
import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.extensions.common.DescriptionInput;
import com.google.gerrit.extensions.common.GroupAuditEventInfo; import com.google.gerrit.extensions.common.GroupAuditEventInfo;
import com.google.gerrit.extensions.common.GroupInfo; import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.common.GroupOptionsInfo; import com.google.gerrit.extensions.common.GroupOptionsInfo;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.common.NameInput;
import com.google.gerrit.extensions.common.OwnerInput;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.server.group.AddMembers; import com.google.gerrit.server.group.AddMembers;
import com.google.gerrit.server.group.AddSubgroups; import com.google.gerrit.server.group.AddSubgroups;
@@ -138,7 +142,7 @@ class GroupApiImpl implements GroupApi {
@Override @Override
public void name(String name) throws RestApiException { public void name(String name) throws RestApiException {
PutName.Input in = new PutName.Input(); NameInput in = new NameInput();
in.name = name; in.name = name;
try { try {
putName.apply(rsrc, in); putName.apply(rsrc, in);
@@ -158,7 +162,7 @@ class GroupApiImpl implements GroupApi {
@Override @Override
public void owner(String owner) throws RestApiException { public void owner(String owner) throws RestApiException {
PutOwner.Input in = new PutOwner.Input(); OwnerInput in = new OwnerInput();
in.owner = owner; in.owner = owner;
try { try {
putOwner.apply(rsrc, in); putOwner.apply(rsrc, in);
@@ -174,7 +178,7 @@ class GroupApiImpl implements GroupApi {
@Override @Override
public void description(String description) throws RestApiException { public void description(String description) throws RestApiException {
PutDescription.Input in = new PutDescription.Input(); DescriptionInput in = new DescriptionInput();
in.description = description; in.description = description;
try { try {
putDescription.apply(rsrc, in); putDescription.apply(rsrc, in);
@@ -269,7 +273,7 @@ class GroupApiImpl implements GroupApi {
@Override @Override
public void index() throws RestApiException { public void index() throws RestApiException {
try { try {
index.apply(rsrc, new Index.Input()); index.apply(rsrc, new Input());
} catch (Exception e) { } catch (Exception e) {
throw asRestApiException("Cannot index group", e); throw asRestApiException("Cannot index group", e);
} }

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.api.plugins; package com.google.gerrit.server.api.plugins;
import com.google.gerrit.extensions.api.plugins.PluginApi; import com.google.gerrit.extensions.api.plugins.PluginApi;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.common.PluginInfo; import com.google.gerrit.extensions.common.PluginInfo;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.server.plugins.DisablePlugin; import com.google.gerrit.server.plugins.DisablePlugin;
@@ -57,16 +58,16 @@ public class PluginApiImpl implements PluginApi {
@Override @Override
public void enable() throws RestApiException { public void enable() throws RestApiException {
enable.apply(resource, new EnablePlugin.Input()); enable.apply(resource, new Input());
} }
@Override @Override
public void disable() throws RestApiException { public void disable() throws RestApiException {
disable.apply(resource, new DisablePlugin.Input()); disable.apply(resource, new Input());
} }
@Override @Override
public void reload() throws RestApiException { public void reload() throws RestApiException {
reload.apply(resource, new ReloadPlugin.Input()); reload.apply(resource, new Input());
} }
} }

View File

@@ -20,6 +20,7 @@ import com.google.gerrit.extensions.api.projects.BranchApi;
import com.google.gerrit.extensions.api.projects.BranchInfo; import com.google.gerrit.extensions.api.projects.BranchInfo;
import com.google.gerrit.extensions.api.projects.BranchInput; import com.google.gerrit.extensions.api.projects.BranchInput;
import com.google.gerrit.extensions.api.projects.ReflogEntryInfo; import com.google.gerrit.extensions.api.projects.ReflogEntryInfo;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.BinaryResult; import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.IdString; import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
@@ -98,7 +99,7 @@ public class BranchApiImpl implements BranchApi {
@Override @Override
public void delete() throws RestApiException { public void delete() throws RestApiException {
try { try {
deleteBranch.apply(resource(), new DeleteBranch.Input()); deleteBranch.apply(resource(), new Input());
} catch (Exception e) { } catch (Exception e) {
throw asRestApiException("Cannot delete branch", e); throw asRestApiException("Cannot delete branch", e);
} }

View File

@@ -19,6 +19,7 @@ import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
import com.google.gerrit.extensions.api.projects.TagApi; import com.google.gerrit.extensions.api.projects.TagApi;
import com.google.gerrit.extensions.api.projects.TagInfo; import com.google.gerrit.extensions.api.projects.TagInfo;
import com.google.gerrit.extensions.api.projects.TagInput; import com.google.gerrit.extensions.api.projects.TagInput;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.IdString; import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.server.project.CreateTag; import com.google.gerrit.server.project.CreateTag;
@@ -81,7 +82,7 @@ public class TagApiImpl implements TagApi {
@Override @Override
public void delete() throws RestApiException { public void delete() throws RestApiException {
try { try {
deleteTag.apply(resource(), new DeleteTag.Input()); deleteTag.apply(resource(), new Input());
} catch (Exception e) { } catch (Exception e) {
throw asRestApiException("Cannot delete tag", e); throw asRestApiException("Cannot delete tag", e);
} }

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.server.change;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.gerrit.extensions.common.DiffWebLinkInfo; import com.google.gerrit.extensions.common.DiffWebLinkInfo;
import com.google.gerrit.extensions.common.EditInfo; import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.restapi.AcceptsCreate; import com.google.gerrit.extensions.restapi.AcceptsCreate;
import com.google.gerrit.extensions.restapi.AcceptsDelete; import com.google.gerrit.extensions.restapi.AcceptsDelete;
@@ -159,8 +160,7 @@ public class ChangeEdits
} }
} }
public static class DeleteFile implements RestModifyView<ChangeResource, DeleteFile.Input> { public static class DeleteFile implements RestModifyView<ChangeResource, Input> {
public static class Input {}
interface Factory { interface Factory {
DeleteFile create(String path); DeleteFile create(String path);
@@ -176,7 +176,7 @@ public class ChangeEdits
} }
@Override @Override
public Response<?> apply(ChangeResource rsrc, DeleteFile.Input in) public Response<?> apply(ChangeResource rsrc, Input in)
throws IOException, AuthException, ResourceConflictException, OrmException, throws IOException, AuthException, ResourceConflictException, OrmException,
PermissionBackendException { PermissionBackendException {
return deleteContent.apply(rsrc, path); return deleteContent.apply(rsrc, path);
@@ -342,9 +342,7 @@ public class ChangeEdits
* restoring a file to its previous contents. * restoring a file to its previous contents.
*/ */
@Singleton @Singleton
public static class DeleteContent public static class DeleteContent implements RestModifyView<ChangeEditResource, Input> {
implements RestModifyView<ChangeEditResource, DeleteContent.Input> {
public static class Input {}
private final ChangeEditModifier editModifier; private final ChangeEditModifier editModifier;
private final GitRepositoryManager repositoryManager; private final GitRepositoryManager repositoryManager;
@@ -356,7 +354,7 @@ public class ChangeEdits
} }
@Override @Override
public Response<?> apply(ChangeEditResource rsrc, DeleteContent.Input input) public Response<?> apply(ChangeEditResource rsrc, Input input)
throws AuthException, ResourceConflictException, OrmException, IOException, throws AuthException, ResourceConflictException, OrmException, IOException,
PermissionBackendException { PermissionBackendException {
return apply(rsrc.getChangeResource(), rsrc.getPath()); return apply(rsrc.getChangeResource(), rsrc.getPath());

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.server.change;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
@@ -25,7 +26,6 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.ChangeMessagesUtil; import com.google.gerrit.server.ChangeMessagesUtil;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountLoader; import com.google.gerrit.server.account.AccountLoader;
import com.google.gerrit.server.change.DeleteAssignee.Input;
import com.google.gerrit.server.extensions.events.AssigneeChanged; import com.google.gerrit.server.extensions.events.AssigneeChanged;
import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.notedb.ChangeUpdate;
import com.google.gerrit.server.permissions.ChangePermission; import com.google.gerrit.server.permissions.ChangePermission;
@@ -45,7 +45,6 @@ import com.google.inject.Singleton;
@Singleton @Singleton
public class DeleteAssignee public class DeleteAssignee
extends RetryingRestModifyView<ChangeResource, Input, Response<AccountInfo>> { extends RetryingRestModifyView<ChangeResource, Input, Response<AccountInfo>> {
public static class Input {}
private final ChangeMessagesUtil cmUtil; private final ChangeMessagesUtil cmUtil;
private final Provider<ReviewDb> db; private final Provider<ReviewDb> db;

View File

@@ -17,13 +17,13 @@ package com.google.gerrit.server.change;
import static com.google.gerrit.extensions.conditions.BooleanCondition.and; import static com.google.gerrit.extensions.conditions.BooleanCondition.and;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.webui.UiAction; import com.google.gerrit.extensions.webui.UiAction;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.change.DeleteChange.Input;
import com.google.gerrit.server.permissions.ChangePermission; import com.google.gerrit.server.permissions.ChangePermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.PermissionBackendException;
@@ -39,7 +39,6 @@ import com.google.inject.Singleton;
@Singleton @Singleton
public class DeleteChange extends RetryingRestModifyView<ChangeResource, Input, Response<?>> public class DeleteChange extends RetryingRestModifyView<ChangeResource, Input, Response<?>>
implements UiAction<ChangeResource> { implements UiAction<ChangeResource> {
public static class Input {}
private final Provider<ReviewDb> db; private final Provider<ReviewDb> db;
private final Provider<DeleteChangeOp> opProvider; private final Provider<DeleteChangeOp> opProvider;

View File

@@ -14,11 +14,11 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.change.DeleteChangeEdit.Input;
import com.google.gerrit.server.edit.ChangeEdit; import com.google.gerrit.server.edit.ChangeEdit;
import com.google.gerrit.server.edit.ChangeEditUtil; import com.google.gerrit.server.edit.ChangeEditUtil;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
@@ -29,7 +29,6 @@ import java.util.Optional;
@Singleton @Singleton
public class DeleteChangeEdit implements RestModifyView<ChangeResource, Input> { public class DeleteChangeEdit implements RestModifyView<ChangeResource, Input> {
public static class Input {}
private final ChangeEditUtil editUtil; private final ChangeEditUtil editUtil;

View File

@@ -18,6 +18,7 @@ import static com.google.gerrit.server.CommentsUtil.setCommentRevId;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.common.CommentInfo;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
@@ -26,7 +27,6 @@ import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.CommentsUtil;
import com.google.gerrit.server.PatchSetUtil; import com.google.gerrit.server.PatchSetUtil;
import com.google.gerrit.server.change.DeleteDraftComment.Input;
import com.google.gerrit.server.patch.PatchListCache; import com.google.gerrit.server.patch.PatchListCache;
import com.google.gerrit.server.update.BatchUpdate; import com.google.gerrit.server.update.BatchUpdate;
import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.BatchUpdateOp;
@@ -44,7 +44,6 @@ import java.util.Optional;
@Singleton @Singleton
public class DeleteDraftComment public class DeleteDraftComment
extends RetryingRestModifyView<DraftCommentResource, Input, Response<CommentInfo>> { extends RetryingRestModifyView<DraftCommentResource, Input, Response<CommentInfo>> {
static class Input {}
private final Provider<ReviewDb> db; private final Provider<ReviewDb> db;
private final CommentsUtil commentsUtil; private final CommentsUtil commentsUtil;

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
@@ -30,12 +31,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@Singleton @Singleton
public class Ignore public class Ignore implements RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
implements RestModifyView<ChangeResource, Ignore.Input>, UiAction<ChangeResource> {
private static final Logger log = LoggerFactory.getLogger(Ignore.class); private static final Logger log = LoggerFactory.getLogger(Ignore.class);
public static class Input {}
private final StarredChangesUtil stars; private final StarredChangesUtil stars;
@Inject @Inject

View File

@@ -14,11 +14,11 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.change.Index.Input;
import com.google.gerrit.server.index.change.ChangeIndexer; import com.google.gerrit.server.index.change.ChangeIndexer;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
@@ -34,7 +34,6 @@ import java.io.IOException;
@Singleton @Singleton
public class Index extends RetryingRestModifyView<ChangeResource, Input, Response<?>> { public class Index extends RetryingRestModifyView<ChangeResource, Input, Response<?>> {
public static class Input {}
private final Provider<ReviewDb> db; private final Provider<ReviewDb> db;
private final PermissionBackend permissionBackend; private final PermissionBackend permissionBackend;

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
@@ -31,11 +32,9 @@ import org.slf4j.LoggerFactory;
@Singleton @Singleton
public class MarkAsReviewed public class MarkAsReviewed
implements RestModifyView<ChangeResource, MarkAsReviewed.Input>, UiAction<ChangeResource> { implements RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
private static final Logger log = LoggerFactory.getLogger(MarkAsReviewed.class); private static final Logger log = LoggerFactory.getLogger(MarkAsReviewed.class);
public static class Input {}
private final Provider<ReviewDb> dbProvider; private final Provider<ReviewDb> dbProvider;
private final ChangeData.Factory changeDataFactory; private final ChangeData.Factory changeDataFactory;
private final StarredChangesUtil stars; private final StarredChangesUtil stars;

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.extensions.webui.UiAction; import com.google.gerrit.extensions.webui.UiAction;
@@ -30,11 +31,9 @@ import org.slf4j.LoggerFactory;
@Singleton @Singleton
public class MarkAsUnreviewed public class MarkAsUnreviewed
implements RestModifyView<ChangeResource, MarkAsUnreviewed.Input>, UiAction<ChangeResource> { implements RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
private static final Logger log = LoggerFactory.getLogger(MarkAsUnreviewed.class); private static final Logger log = LoggerFactory.getLogger(MarkAsUnreviewed.class);
public static class Input {}
private final Provider<ReviewDb> dbProvider; private final Provider<ReviewDb> dbProvider;
private final ChangeData.Factory changeDataFactory; private final ChangeData.Factory changeDataFactory;
private final StarredChangesUtil stars; private final StarredChangesUtil stars;

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.server.change;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.restapi.DefaultInput; import com.google.gerrit.extensions.common.DescriptionInput;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.webui.UiAction; import com.google.gerrit.extensions.webui.UiAction;
@@ -42,16 +42,12 @@ import java.util.Collections;
@Singleton @Singleton
public class PutDescription public class PutDescription
extends RetryingRestModifyView<RevisionResource, PutDescription.Input, Response<String>> extends RetryingRestModifyView<RevisionResource, DescriptionInput, Response<String>>
implements UiAction<RevisionResource> { implements UiAction<RevisionResource> {
private final Provider<ReviewDb> dbProvider; private final Provider<ReviewDb> dbProvider;
private final ChangeMessagesUtil cmUtil; private final ChangeMessagesUtil cmUtil;
private final PatchSetUtil psUtil; private final PatchSetUtil psUtil;
public static class Input {
@DefaultInput public String description;
}
@Inject @Inject
PutDescription( PutDescription(
Provider<ReviewDb> dbProvider, Provider<ReviewDb> dbProvider,
@@ -66,11 +62,11 @@ public class PutDescription
@Override @Override
protected Response<String> applyImpl( protected Response<String> applyImpl(
BatchUpdate.Factory updateFactory, RevisionResource rsrc, Input input) BatchUpdate.Factory updateFactory, RevisionResource rsrc, DescriptionInput input)
throws UpdateException, RestApiException, PermissionBackendException { throws UpdateException, RestApiException, PermissionBackendException {
rsrc.permissions().check(ChangePermission.EDIT_DESCRIPTION); rsrc.permissions().check(ChangePermission.EDIT_DESCRIPTION);
Op op = new Op(input != null ? input : new Input(), rsrc.getPatchSet().getId()); Op op = new Op(input != null ? input : new DescriptionInput(), rsrc.getPatchSet().getId());
try (BatchUpdate u = try (BatchUpdate u =
updateFactory.create( updateFactory.create(
dbProvider.get(), rsrc.getChange().getProject(), rsrc.getUser(), TimeUtil.nowTs())) { dbProvider.get(), rsrc.getChange().getProject(), rsrc.getUser(), TimeUtil.nowTs())) {
@@ -83,13 +79,13 @@ public class PutDescription
} }
private class Op implements BatchUpdateOp { private class Op implements BatchUpdateOp {
private final Input input; private final DescriptionInput input;
private final PatchSet.Id psId; private final PatchSet.Id psId;
private String oldDescription; private String oldDescription;
private String newDescription; private String newDescription;
Op(Input input, PatchSet.Id psId) { Op(DescriptionInput input, PatchSet.Id psId) {
this.input = input; this.input = input;
this.psId = psId; this.psId = psId;
} }

View File

@@ -16,8 +16,8 @@ package com.google.gerrit.server.change;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.common.TopicInput;
import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.DefaultInput;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.webui.UiAction; import com.google.gerrit.extensions.webui.UiAction;
@@ -26,7 +26,6 @@ import com.google.gerrit.reviewdb.client.ChangeMessage;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.ChangeMessagesUtil; import com.google.gerrit.server.ChangeMessagesUtil;
import com.google.gerrit.server.ChangeUtil; import com.google.gerrit.server.ChangeUtil;
import com.google.gerrit.server.change.PutTopic.Input;
import com.google.gerrit.server.extensions.events.TopicEdited; import com.google.gerrit.server.extensions.events.TopicEdited;
import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.notedb.ChangeUpdate;
import com.google.gerrit.server.permissions.ChangePermission; import com.google.gerrit.server.permissions.ChangePermission;
@@ -44,16 +43,12 @@ import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@Singleton @Singleton
public class PutTopic extends RetryingRestModifyView<ChangeResource, Input, Response<String>> public class PutTopic extends RetryingRestModifyView<ChangeResource, TopicInput, Response<String>>
implements UiAction<ChangeResource> { implements UiAction<ChangeResource> {
private final Provider<ReviewDb> dbProvider; private final Provider<ReviewDb> dbProvider;
private final ChangeMessagesUtil cmUtil; private final ChangeMessagesUtil cmUtil;
private final TopicEdited topicEdited; private final TopicEdited topicEdited;
public static class Input {
@DefaultInput public String topic;
}
@Inject @Inject
PutTopic( PutTopic(
Provider<ReviewDb> dbProvider, Provider<ReviewDb> dbProvider,
@@ -68,7 +63,7 @@ public class PutTopic extends RetryingRestModifyView<ChangeResource, Input, Resp
@Override @Override
protected Response<String> applyImpl( protected Response<String> applyImpl(
BatchUpdate.Factory updateFactory, ChangeResource req, Input input) BatchUpdate.Factory updateFactory, ChangeResource req, TopicInput input)
throws UpdateException, RestApiException, PermissionBackendException { throws UpdateException, RestApiException, PermissionBackendException {
req.permissions().check(ChangePermission.EDIT_TOPIC_NAME); req.permissions().check(ChangePermission.EDIT_TOPIC_NAME);
@@ -79,7 +74,7 @@ public class PutTopic extends RetryingRestModifyView<ChangeResource, Input, Resp
String.format("topic length exceeds the limit (%s)", ChangeUtil.TOPIC_MAX_LENGTH)); String.format("topic length exceeds the limit (%s)", ChangeUtil.TOPIC_MAX_LENGTH));
} }
Op op = new Op(input != null ? input : new Input()); Op op = new Op(input != null ? input : new TopicInput());
try (BatchUpdate u = try (BatchUpdate u =
updateFactory.create( updateFactory.create(
dbProvider.get(), req.getChange().getProject(), req.getUser(), TimeUtil.nowTs())) { dbProvider.get(), req.getChange().getProject(), req.getUser(), TimeUtil.nowTs())) {
@@ -90,13 +85,13 @@ public class PutTopic extends RetryingRestModifyView<ChangeResource, Input, Resp
} }
private class Op implements BatchUpdateOp { private class Op implements BatchUpdateOp {
private final Input input; private final TopicInput input;
private Change change; private Change change;
private String oldTopicName; private String oldTopicName;
private String newTopicName; private String newTopicName;
Op(Input input) { Op(TopicInput input) {
this.input = input; this.input = input;
} }

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.restapi.AcceptsPost; import com.google.gerrit.extensions.restapi.AcceptsPost;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
@@ -68,8 +69,7 @@ public class RebaseChangeEdit
} }
@Singleton @Singleton
public static class Rebase implements RestModifyView<ChangeResource, Rebase.Input> { public static class Rebase implements RestModifyView<ChangeResource, Input> {
public static class Input {}
private final GitRepositoryManager repositoryManager; private final GitRepositoryManager repositoryManager;
private final ChangeEditModifier editModifier; private final ChangeEditModifier editModifier;
@@ -81,7 +81,7 @@ public class RebaseChangeEdit
} }
@Override @Override
public Response<?> apply(ChangeResource rsrc, Rebase.Input in) public Response<?> apply(ChangeResource rsrc, Input in)
throws AuthException, ResourceConflictException, IOException, OrmException, throws AuthException, ResourceConflictException, IOException, OrmException,
PermissionBackendException { PermissionBackendException {
Project.NameKey project = rsrc.getProject(); Project.NameKey project = rsrc.getProject();

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.server.change;
import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.joining;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.BinaryResult; import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.IdString; import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
@@ -23,7 +24,6 @@ import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.reviewdb.server.ReviewDbUtil; import com.google.gerrit.reviewdb.server.ReviewDbUtil;
import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.CommentsUtil;
import com.google.gerrit.server.change.Rebuild.Input;
import com.google.gerrit.server.notedb.ChangeBundle; import com.google.gerrit.server.notedb.ChangeBundle;
import com.google.gerrit.server.notedb.ChangeBundleReader; import com.google.gerrit.server.notedb.ChangeBundleReader;
import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.notedb.ChangeNotes;
@@ -40,7 +40,6 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
@Singleton @Singleton
public class Rebuild implements RestModifyView<ChangeResource, Input> { public class Rebuild implements RestModifyView<ChangeResource, Input> {
public static class Input {}
private final Provider<ReviewDb> db; private final Provider<ReviewDb> db;
private final NotesMigration migration; private final NotesMigration migration;

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
@@ -22,7 +23,6 @@ import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
public class Reviewed { public class Reviewed {
public static class Input {}
@Singleton @Singleton
public static class PutReviewed implements RestModifyView<FileResource, Input> { public static class PutReviewed implements RestModifyView<FileResource, Input> {

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.extensions.webui.UiAction; import com.google.gerrit.extensions.webui.UiAction;
@@ -26,12 +27,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@Singleton @Singleton
public class Unignore public class Unignore implements RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
implements RestModifyView<ChangeResource, Unignore.Input>, UiAction<ChangeResource> {
private static final Logger log = LoggerFactory.getLogger(Unignore.class); private static final Logger log = LoggerFactory.getLogger(Unignore.class);
public static class Input {}
private final StarredChangesUtil stars; private final StarredChangesUtil stars;
@Inject @Inject

View File

@@ -19,16 +19,15 @@ import static com.google.gerrit.common.data.GlobalCapability.MAINTAIN_SERVER;
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR; import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
import com.google.gerrit.extensions.annotations.RequiresAnyCapability; import com.google.gerrit.extensions.annotations.RequiresAnyCapability;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.config.DeleteTask.Input;
import com.google.gerrit.server.git.WorkQueue.Task; import com.google.gerrit.server.git.WorkQueue.Task;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@Singleton @Singleton
@RequiresAnyCapability({KILL_TASK, MAINTAIN_SERVER}) @RequiresAnyCapability({KILL_TASK, MAINTAIN_SERVER})
public class DeleteTask implements RestModifyView<TaskResource, Input> { public class DeleteTask implements RestModifyView<TaskResource, Input> {
public static class Input {}
@Override @Override
public Response<?> apply(TaskResource rsrc, Input input) { public Response<?> apply(TaskResource rsrc, Input input) {

View File

@@ -18,11 +18,11 @@ import static com.google.gerrit.common.data.GlobalCapability.FLUSH_CACHES;
import static com.google.gerrit.common.data.GlobalCapability.MAINTAIN_SERVER; import static com.google.gerrit.common.data.GlobalCapability.MAINTAIN_SERVER;
import com.google.gerrit.extensions.annotations.RequiresAnyCapability; import com.google.gerrit.extensions.annotations.RequiresAnyCapability;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.config.FlushCache.Input;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.PermissionBackendException;
@@ -33,7 +33,6 @@ import com.google.inject.Singleton;
@RequiresAnyCapability({FLUSH_CACHES, MAINTAIN_SERVER}) @RequiresAnyCapability({FLUSH_CACHES, MAINTAIN_SERVER})
@Singleton @Singleton
public class FlushCache implements RestModifyView<CacheResource, Input> { public class FlushCache implements RestModifyView<CacheResource, Input> {
public static class Input {}
public static final String WEB_SESSIONS = "web_sessions"; public static final String WEB_SESSIONS = "web_sessions";

View File

@@ -204,8 +204,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
return result; return result;
} }
static class PutMember implements RestModifyView<GroupResource, PutMember.Input> { static class PutMember implements RestModifyView<GroupResource, Input> {
static class Input {}
private final AddMembers put; private final AddMembers put;
private final String id; private final String id;
@@ -216,7 +215,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
} }
@Override @Override
public AccountInfo apply(GroupResource resource, PutMember.Input input) public AccountInfo apply(GroupResource resource, Input input)
throws AuthException, MethodNotAllowedException, ResourceNotFoundException, OrmException, throws AuthException, MethodNotAllowedException, ResourceNotFoundException, OrmException,
IOException, ConfigInvalidException { IOException, ConfigInvalidException {
AddMembers.Input in = new AddMembers.Input(); AddMembers.Input in = new AddMembers.Input();
@@ -234,7 +233,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
} }
@Singleton @Singleton
static class UpdateMember implements RestModifyView<MemberResource, PutMember.Input> { static class UpdateMember implements RestModifyView<MemberResource, Input> {
private final GetMember get; private final GetMember get;
@Inject @Inject
@@ -243,7 +242,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
} }
@Override @Override
public AccountInfo apply(MemberResource resource, PutMember.Input input) throws OrmException { public AccountInfo apply(MemberResource resource, Input input) throws OrmException {
// Do nothing, the user is already a member. // Do nothing, the user is already a member.
return get.apply(resource); return get.apply(resource);
} }

View File

@@ -114,8 +114,7 @@ public class AddSubgroups implements RestModifyView<GroupResource, Input> {
return result; return result;
} }
static class PutSubgroup implements RestModifyView<GroupResource, PutSubgroup.Input> { static class PutSubgroup implements RestModifyView<GroupResource, Input> {
static class Input {}
private final AddSubgroups addSubgroups; private final AddSubgroups addSubgroups;
private final String id; private final String id;
@@ -144,7 +143,7 @@ public class AddSubgroups implements RestModifyView<GroupResource, Input> {
} }
@Singleton @Singleton
static class UpdateSubgroup implements RestModifyView<SubgroupResource, PutSubgroup.Input> { static class UpdateSubgroup implements RestModifyView<SubgroupResource, Input> {
private final Provider<GetSubgroup> get; private final Provider<GetSubgroup> get;
@Inject @Inject
@@ -153,7 +152,7 @@ public class AddSubgroups implements RestModifyView<GroupResource, Input> {
} }
@Override @Override
public GroupInfo apply(SubgroupResource resource, PutSubgroup.Input input) throws OrmException { public GroupInfo apply(SubgroupResource resource, Input input) throws OrmException {
// Do nothing, the group is already included. // Do nothing, the group is already included.
return get.get().apply(resource); return get.get().apply(resource);
} }

View File

@@ -82,8 +82,7 @@ public class DeleteMembers implements RestModifyView<GroupResource, Input> {
} }
@Singleton @Singleton
static class DeleteMember implements RestModifyView<MemberResource, DeleteMember.Input> { static class DeleteMember implements RestModifyView<MemberResource, Input> {
static class Input {}
private final Provider<DeleteMembers> delete; private final Provider<DeleteMembers> delete;

View File

@@ -82,8 +82,7 @@ public class DeleteSubgroups implements RestModifyView<GroupResource, Input> {
} }
@Singleton @Singleton
static class DeleteSubgroup implements RestModifyView<SubgroupResource, DeleteSubgroup.Input> { static class DeleteSubgroup implements RestModifyView<SubgroupResource, Input> {
static class Input {}
private final Provider<DeleteSubgroups> delete; private final Provider<DeleteSubgroups> delete;

View File

@@ -14,13 +14,13 @@
package com.google.gerrit.server.group; package com.google.gerrit.server.group;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.account.GroupCache; import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.group.Index.Input;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.io.IOException; import java.io.IOException;
@@ -28,7 +28,6 @@ import java.util.Optional;
@Singleton @Singleton
public class Index implements RestModifyView<GroupResource, Input> { public class Index implements RestModifyView<GroupResource, Input> {
public static class Input {}
private final GroupCache groupCache; private final GroupCache groupCache;

View File

@@ -17,15 +17,14 @@ package com.google.gerrit.server.group;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.common.errors.NoSuchGroupException; import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.extensions.common.DescriptionInput;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.DefaultInput;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.group.PutDescription.Input;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
@@ -34,11 +33,7 @@ import java.io.IOException;
import java.util.Objects; import java.util.Objects;
@Singleton @Singleton
public class PutDescription implements RestModifyView<GroupResource, Input> { public class PutDescription implements RestModifyView<GroupResource, DescriptionInput> {
public static class Input {
@DefaultInput public String description;
}
private final Provider<ReviewDb> db; private final Provider<ReviewDb> db;
private final Provider<GroupsUpdate> groupsUpdateProvider; private final Provider<GroupsUpdate> groupsUpdateProvider;
@@ -50,11 +45,11 @@ public class PutDescription implements RestModifyView<GroupResource, Input> {
} }
@Override @Override
public Response<String> apply(GroupResource resource, Input input) public Response<String> apply(GroupResource resource, DescriptionInput input)
throws AuthException, MethodNotAllowedException, ResourceNotFoundException, OrmException, throws AuthException, MethodNotAllowedException, ResourceNotFoundException, OrmException,
IOException { IOException {
if (input == null) { if (input == null) {
input = new Input(); // Delete would set description to null. input = new DescriptionInput(); // Delete would set description to null.
} }
GroupDescription.Internal internalGroup = GroupDescription.Internal internalGroup =

View File

@@ -18,16 +18,15 @@ import com.google.common.base.Strings;
import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.common.errors.NameAlreadyUsedException; import com.google.gerrit.common.errors.NameAlreadyUsedException;
import com.google.gerrit.common.errors.NoSuchGroupException; import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.extensions.common.NameInput;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.DefaultInput;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.group.PutName.Input;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
@@ -35,11 +34,7 @@ import com.google.inject.Singleton;
import java.io.IOException; import java.io.IOException;
@Singleton @Singleton
public class PutName implements RestModifyView<GroupResource, Input> { public class PutName implements RestModifyView<GroupResource, NameInput> {
public static class Input {
@DefaultInput public String name;
}
private final Provider<ReviewDb> db; private final Provider<ReviewDb> db;
private final Provider<GroupsUpdate> groupsUpdateProvider; private final Provider<GroupsUpdate> groupsUpdateProvider;
@@ -50,7 +45,7 @@ public class PutName implements RestModifyView<GroupResource, Input> {
} }
@Override @Override
public String apply(GroupResource rsrc, Input input) public String apply(GroupResource rsrc, NameInput input)
throws MethodNotAllowedException, AuthException, BadRequestException, throws MethodNotAllowedException, AuthException, BadRequestException,
ResourceConflictException, ResourceNotFoundException, OrmException, IOException { ResourceConflictException, ResourceNotFoundException, OrmException, IOException {
GroupDescription.Internal internalGroup = GroupDescription.Internal internalGroup =

View File

@@ -18,16 +18,15 @@ import com.google.common.base.Strings;
import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.common.errors.NoSuchGroupException; import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.extensions.common.GroupInfo; import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.common.OwnerInput;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.DefaultInput;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.group.PutOwner.Input;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
@@ -35,11 +34,7 @@ import com.google.inject.Singleton;
import java.io.IOException; import java.io.IOException;
@Singleton @Singleton
public class PutOwner implements RestModifyView<GroupResource, Input> { public class PutOwner implements RestModifyView<GroupResource, OwnerInput> {
public static class Input {
@DefaultInput public String owner;
}
private final GroupsCollection groupsCollection; private final GroupsCollection groupsCollection;
private final Provider<GroupsUpdate> groupsUpdateProvider; private final Provider<GroupsUpdate> groupsUpdateProvider;
private final Provider<ReviewDb> db; private final Provider<ReviewDb> db;
@@ -58,7 +53,7 @@ public class PutOwner implements RestModifyView<GroupResource, Input> {
} }
@Override @Override
public GroupInfo apply(GroupResource resource, Input input) public GroupInfo apply(GroupResource resource, OwnerInput input)
throws ResourceNotFoundException, MethodNotAllowedException, AuthException, throws ResourceNotFoundException, MethodNotAllowedException, AuthException,
BadRequestException, UnprocessableEntityException, OrmException, IOException { BadRequestException, UnprocessableEntityException, OrmException, IOException {
GroupDescription.Internal internalGroup = GroupDescription.Internal internalGroup =

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.plugins; package com.google.gerrit.server.plugins;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.common.PluginInfo; import com.google.gerrit.extensions.common.PluginInfo;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
@@ -22,14 +23,12 @@ import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.plugins.DisablePlugin.Input;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@Singleton @Singleton
public class DisablePlugin implements RestModifyView<PluginResource, Input> { public class DisablePlugin implements RestModifyView<PluginResource, Input> {
public static class Input {}
private final PluginLoader loader; private final PluginLoader loader;
private final Provider<IdentifiedUser> user; private final Provider<IdentifiedUser> user;

View File

@@ -17,11 +17,11 @@ package com.google.gerrit.server.plugins;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.common.PluginInfo; import com.google.gerrit.extensions.common.PluginInfo;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.plugins.EnablePlugin.Input;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.io.PrintWriter; import java.io.PrintWriter;
@@ -30,7 +30,6 @@ import java.io.StringWriter;
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER) @RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
@Singleton @Singleton
public class EnablePlugin implements RestModifyView<PluginResource, Input> { public class EnablePlugin implements RestModifyView<PluginResource, Input> {
public static class Input {}
private final PluginLoader loader; private final PluginLoader loader;

View File

@@ -17,10 +17,10 @@ package com.google.gerrit.server.plugins;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.common.PluginInfo; import com.google.gerrit.extensions.common.PluginInfo;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.plugins.ReloadPlugin.Input;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.io.PrintWriter; import java.io.PrintWriter;
@@ -29,7 +29,6 @@ import java.io.StringWriter;
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER) @RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
@Singleton @Singleton
public class ReloadPlugin implements RestModifyView<PluginResource, Input> { public class ReloadPlugin implements RestModifyView<PluginResource, Input> {
public static class Input {}
private final PluginLoader loader; private final PluginLoader loader;

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.server.project;
import static org.eclipse.jgit.lib.Constants.R_HEADS; import static org.eclipse.jgit.lib.Constants.R_HEADS;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
@@ -24,7 +25,6 @@ import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.permissions.RefPermission; import com.google.gerrit.server.permissions.RefPermission;
import com.google.gerrit.server.project.DeleteBranch.Input;
import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.query.change.InternalChangeQuery;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
@@ -34,7 +34,6 @@ import java.io.IOException;
@Singleton @Singleton
public class DeleteBranch implements RestModifyView<BranchResource, Input> { public class DeleteBranch implements RestModifyView<BranchResource, Input> {
public static class Input {}
private final Provider<InternalChangeQuery> queryProvider; private final Provider<InternalChangeQuery> queryProvider;
private final DeleteRef.Factory deleteRefFactory; private final DeleteRef.Factory deleteRefFactory;

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.project; package com.google.gerrit.server.project;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
@@ -28,8 +29,7 @@ import com.google.inject.Singleton;
import java.io.IOException; import java.io.IOException;
@Singleton @Singleton
public class DeleteTag implements RestModifyView<TagResource, DeleteTag.Input> { public class DeleteTag implements RestModifyView<TagResource, Input> {
public static class Input {}
private final PermissionBackend permissionBackend; private final PermissionBackend permissionBackend;
private final Provider<CurrentUser> user; private final Provider<CurrentUser> user;

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.sshd.commands; package com.google.gerrit.sshd.commands;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.change.ChangeResource;
import com.google.gerrit.server.change.Index; import com.google.gerrit.server.change.Index;
@@ -55,7 +56,7 @@ final class IndexChangesCommand extends SshCommand {
boolean ok = true; boolean ok = true;
for (ChangeResource rsrc : changes.values()) { for (ChangeResource rsrc : changes.values()) {
try { try {
index.apply(rsrc, new Index.Input()); index.apply(rsrc, new Input());
} catch (Exception e) { } catch (Exception e) {
ok = false; ok = false;
writeError( writeError(

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.sshd.commands; package com.google.gerrit.sshd.commands;
import com.google.gerrit.extensions.common.NameInput;
import com.google.gerrit.extensions.restapi.IdString; import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.TopLevelResource; import com.google.gerrit.extensions.restapi.TopLevelResource;
@@ -48,7 +49,7 @@ public class RenameGroupCommand extends SshCommand {
protected void run() throws Failure { protected void run() throws Failure {
try { try {
GroupResource rsrc = groups.parse(TopLevelResource.INSTANCE, IdString.fromDecoded(groupName)); GroupResource rsrc = groups.parse(TopLevelResource.INSTANCE, IdString.fromDecoded(groupName));
PutName.Input input = new PutName.Input(); NameInput input = new NameInput();
input.name = newGroupName; input.name = newGroupName;
putName.apply(rsrc, input); putName.apply(rsrc, input);
} catch (RestApiException | OrmException | IOException e) { } catch (RestApiException | OrmException | IOException e) {

View File

@@ -23,7 +23,11 @@ import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.api.accounts.EmailInput; import com.google.gerrit.extensions.api.accounts.EmailInput;
import com.google.gerrit.extensions.common.EmailInfo; import com.google.gerrit.extensions.common.EmailInfo;
import com.google.gerrit.extensions.common.HttpPasswordInput;
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.common.SshKeyInfo;
import com.google.gerrit.extensions.common.SshKeyInput;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
@@ -193,13 +197,13 @@ final class SetAccountCommand extends SshCommand {
} }
if (fullName != null) { if (fullName != null) {
PutName.Input in = new PutName.Input(); NameInput in = new NameInput();
in.name = fullName; in.name = fullName;
putName.apply(rsrc, in); putName.apply(rsrc, in);
} }
if (httpPassword != null || clearHttpPassword) { if (httpPassword != null || clearHttpPassword) {
PutHttpPassword.Input in = new PutHttpPassword.Input(); HttpPasswordInput in = new HttpPasswordInput();
in.httpPassword = httpPassword; in.httpPassword = httpPassword;
putHttpPassword.apply(rsrc, in); putHttpPassword.apply(rsrc, in);
} }
@@ -232,7 +236,7 @@ final class SetAccountCommand extends SshCommand {
throws RestApiException, OrmException, IOException, ConfigInvalidException, throws RestApiException, OrmException, IOException, ConfigInvalidException,
PermissionBackendException { PermissionBackendException {
for (String sshKey : sshKeys) { for (String sshKey : sshKeys) {
AddSshKey.Input in = new AddSshKey.Input(); SshKeyInput in = new SshKeyInput();
in.raw = RawInputUtil.create(sshKey.getBytes(UTF_8), "plain/text"); in.raw = RawInputUtil.create(sshKey.getBytes(UTF_8), "plain/text");
addSshKey.apply(rsrc, in); addSshKey.apply(rsrc, in);
} }
@@ -284,10 +288,10 @@ final class SetAccountCommand extends SshCommand {
if (email.equals("ALL")) { if (email.equals("ALL")) {
List<EmailInfo> emails = getEmails.apply(rsrc); List<EmailInfo> emails = getEmails.apply(rsrc);
for (EmailInfo e : emails) { for (EmailInfo e : emails) {
deleteEmail.apply(new AccountResource.Email(user, e.email), new DeleteEmail.Input()); deleteEmail.apply(new AccountResource.Email(user, e.email), new Input());
} }
} else { } else {
deleteEmail.apply(new AccountResource.Email(user, email), new DeleteEmail.Input()); deleteEmail.apply(new AccountResource.Email(user, email), new Input());
} }
} }