PutConfig: move static inner Input class to extension API
Also rename the existing PutDescriptionInput to DescriptionInput. Change-Id: I8291e970353b8ae6ed4f0cbe5dce746007e25291
This commit is contained in:
@@ -21,8 +21,8 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
|||||||
import com.google.gerrit.acceptance.NoHttpd;
|
import com.google.gerrit.acceptance.NoHttpd;
|
||||||
import com.google.gerrit.common.data.Permission;
|
import com.google.gerrit.common.data.Permission;
|
||||||
import com.google.gerrit.extensions.api.projects.BranchInput;
|
import com.google.gerrit.extensions.api.projects.BranchInput;
|
||||||
|
import com.google.gerrit.extensions.api.projects.DescriptionInput;
|
||||||
import com.google.gerrit.extensions.api.projects.ProjectInput;
|
import com.google.gerrit.extensions.api.projects.ProjectInput;
|
||||||
import com.google.gerrit.extensions.api.projects.PutDescriptionInput;
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
|||||||
.name(project.get())
|
.name(project.get())
|
||||||
.description())
|
.description())
|
||||||
.isEmpty();
|
.isEmpty();
|
||||||
PutDescriptionInput in = new PutDescriptionInput();
|
DescriptionInput in = new DescriptionInput();
|
||||||
in.description = "new project description";
|
in.description = "new project description";
|
||||||
gApi.projects()
|
gApi.projects()
|
||||||
.name(project.get())
|
.name(project.get())
|
||||||
|
@@ -0,0 +1,36 @@
|
|||||||
|
// Copyright (C) 2016 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.api.projects;
|
||||||
|
|
||||||
|
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||||
|
import com.google.gerrit.extensions.client.ProjectState;
|
||||||
|
import com.google.gerrit.extensions.client.SubmitType;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ConfigInput {
|
||||||
|
public String description;
|
||||||
|
public InheritableBoolean useContributorAgreements;
|
||||||
|
public InheritableBoolean useContentMerge;
|
||||||
|
public InheritableBoolean useSignedOffBy;
|
||||||
|
public InheritableBoolean createNewChangeForAllNotInTarget;
|
||||||
|
public InheritableBoolean requireChangeId;
|
||||||
|
public InheritableBoolean enableSignedPush;
|
||||||
|
public InheritableBoolean requireSignedPush;
|
||||||
|
public String maxObjectSizeLimit;
|
||||||
|
public SubmitType submitType;
|
||||||
|
public ProjectState state;
|
||||||
|
public Map<String, Map<String, ConfigValue>> pluginConfigValues;
|
||||||
|
}
|
@@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2016 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.api.projects;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ConfigValue {
|
||||||
|
public String value;
|
||||||
|
public List<String> values;
|
||||||
|
}
|
@@ -16,7 +16,7 @@ package com.google.gerrit.extensions.api.projects;
|
|||||||
|
|
||||||
import com.google.gerrit.extensions.restapi.DefaultInput;
|
import com.google.gerrit.extensions.restapi.DefaultInput;
|
||||||
|
|
||||||
public class PutDescriptionInput {
|
public class DescriptionInput {
|
||||||
@DefaultInput
|
@DefaultInput
|
||||||
public String description;
|
public String description;
|
||||||
public String commitMessage;
|
public String commitMessage;
|
@@ -28,7 +28,7 @@ public interface ProjectApi {
|
|||||||
ProjectInfo get() throws RestApiException;
|
ProjectInfo get() throws RestApiException;
|
||||||
|
|
||||||
String description() throws RestApiException;
|
String description() throws RestApiException;
|
||||||
void description(PutDescriptionInput in) throws RestApiException;
|
void description(DescriptionInput in) throws RestApiException;
|
||||||
|
|
||||||
ProjectAccessInfo access() throws RestApiException;
|
ProjectAccessInfo access() throws RestApiException;
|
||||||
ProjectAccessInfo access(ProjectAccessInput p) throws RestApiException;
|
ProjectAccessInfo access(ProjectAccessInput p) throws RestApiException;
|
||||||
@@ -146,7 +146,7 @@ public interface ProjectApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void description(PutDescriptionInput in)
|
public void description(DescriptionInput in)
|
||||||
throws RestApiException {
|
throws RestApiException {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@@ -36,9 +36,4 @@ public class ProjectInput {
|
|||||||
public InheritableBoolean createNewChangeForAllNotInTarget;
|
public InheritableBoolean createNewChangeForAllNotInTarget;
|
||||||
public String maxObjectSizeLimit;
|
public String maxObjectSizeLimit;
|
||||||
public Map<String, Map<String, ConfigValue>> pluginConfigValues;
|
public Map<String, Map<String, ConfigValue>> pluginConfigValues;
|
||||||
|
|
||||||
public static class ConfigValue {
|
|
||||||
public String value;
|
|
||||||
public List<String> values;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -21,9 +21,9 @@ import com.google.gerrit.extensions.api.access.ProjectAccessInput;
|
|||||||
import com.google.gerrit.extensions.api.projects.BranchApi;
|
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.ChildProjectApi;
|
import com.google.gerrit.extensions.api.projects.ChildProjectApi;
|
||||||
|
import com.google.gerrit.extensions.api.projects.DescriptionInput;
|
||||||
import com.google.gerrit.extensions.api.projects.ProjectApi;
|
import com.google.gerrit.extensions.api.projects.ProjectApi;
|
||||||
import com.google.gerrit.extensions.api.projects.ProjectInput;
|
import com.google.gerrit.extensions.api.projects.ProjectInput;
|
||||||
import com.google.gerrit.extensions.api.projects.PutDescriptionInput;
|
|
||||||
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.common.ProjectInfo;
|
import com.google.gerrit.extensions.common.ProjectInfo;
|
||||||
@@ -216,7 +216,7 @@ public class ProjectApiImpl implements ProjectApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void description(PutDescriptionInput in)
|
public void description(DescriptionInput in)
|
||||||
throws RestApiException {
|
throws RestApiException {
|
||||||
try {
|
try {
|
||||||
putDescription.apply(checkExists(), in);
|
putDescription.apply(checkExists(), in);
|
||||||
|
@@ -17,7 +17,7 @@ package com.google.gerrit.server.config;
|
|||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.gerrit.extensions.annotations.ExtensionPoint;
|
import com.google.gerrit.extensions.annotations.ExtensionPoint;
|
||||||
import com.google.gerrit.extensions.api.projects.ProjectInput.ConfigValue;
|
import com.google.gerrit.extensions.api.projects.ConfigValue;
|
||||||
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
|
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||||
import com.google.gerrit.extensions.registration.DynamicMap.Entry;
|
import com.google.gerrit.extensions.registration.DynamicMap.Entry;
|
||||||
|
@@ -25,6 +25,7 @@ import com.google.gerrit.common.data.GroupReference;
|
|||||||
import com.google.gerrit.common.data.Permission;
|
import com.google.gerrit.common.data.Permission;
|
||||||
import com.google.gerrit.common.data.PermissionRule;
|
import com.google.gerrit.common.data.PermissionRule;
|
||||||
import com.google.gerrit.extensions.annotations.RequiresCapability;
|
import com.google.gerrit.extensions.annotations.RequiresCapability;
|
||||||
|
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
||||||
import com.google.gerrit.extensions.api.projects.ProjectInput;
|
import com.google.gerrit.extensions.api.projects.ProjectInput;
|
||||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||||
import com.google.gerrit.extensions.client.SubmitType;
|
import com.google.gerrit.extensions.client.SubmitType;
|
||||||
@@ -214,7 +215,7 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn
|
|||||||
try {
|
try {
|
||||||
ProjectControl projectControl =
|
ProjectControl projectControl =
|
||||||
projectControlFactory.controlFor(p.getNameKey(), currentUser.get());
|
projectControlFactory.controlFor(p.getNameKey(), currentUser.get());
|
||||||
PutConfig.Input in = new PutConfig.Input();
|
ConfigInput in = new ConfigInput();
|
||||||
in.pluginConfigValues = input.pluginConfigValues;
|
in.pluginConfigValues = input.pluginConfigValues;
|
||||||
putConfig.get().apply(projectControl, in);
|
putConfig.get().apply(projectControl, in);
|
||||||
} catch (NoSuchProjectException e) {
|
} catch (NoSuchProjectException e) {
|
||||||
|
@@ -18,9 +18,8 @@ import com.google.common.base.CharMatcher;
|
|||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.gerrit.common.ChangeHooks;
|
import com.google.gerrit.common.ChangeHooks;
|
||||||
import com.google.gerrit.extensions.api.projects.ProjectInput.ConfigValue;
|
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
||||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
import com.google.gerrit.extensions.api.projects.ConfigValue;
|
||||||
import com.google.gerrit.extensions.client.SubmitType;
|
|
||||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||||
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;
|
||||||
@@ -41,7 +40,6 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
|||||||
import com.google.gerrit.server.git.MetaDataUpdate;
|
import com.google.gerrit.server.git.MetaDataUpdate;
|
||||||
import com.google.gerrit.server.git.ProjectConfig;
|
import com.google.gerrit.server.git.ProjectConfig;
|
||||||
import com.google.gerrit.server.git.TransferConfig;
|
import com.google.gerrit.server.git.TransferConfig;
|
||||||
import com.google.gerrit.server.project.PutConfig.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;
|
||||||
@@ -60,24 +58,9 @@ import java.util.Map.Entry;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class PutConfig implements RestModifyView<ProjectResource, Input> {
|
public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
|
||||||
private static final Logger log = LoggerFactory.getLogger(PutConfig.class);
|
private static final Logger log = LoggerFactory.getLogger(PutConfig.class);
|
||||||
|
|
||||||
public static class Input {
|
|
||||||
public String description;
|
|
||||||
public InheritableBoolean useContributorAgreements;
|
|
||||||
public InheritableBoolean useContentMerge;
|
|
||||||
public InheritableBoolean useSignedOffBy;
|
|
||||||
public InheritableBoolean createNewChangeForAllNotInTarget;
|
|
||||||
public InheritableBoolean requireChangeId;
|
|
||||||
public InheritableBoolean enableSignedPush;
|
|
||||||
public InheritableBoolean requireSignedPush;
|
|
||||||
public String maxObjectSizeLimit;
|
|
||||||
public SubmitType submitType;
|
|
||||||
public com.google.gerrit.extensions.client.ProjectState state;
|
|
||||||
public Map<String, Map<String, ConfigValue>> pluginConfigValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final boolean serverEnableSignedPush;
|
private final boolean serverEnableSignedPush;
|
||||||
private final Provider<MetaDataUpdate.User> metaDataUpdateFactory;
|
private final Provider<MetaDataUpdate.User> metaDataUpdateFactory;
|
||||||
private final ProjectCache projectCache;
|
private final ProjectCache projectCache;
|
||||||
@@ -122,7 +105,7 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConfigInfo apply(ProjectResource rsrc, Input input)
|
public ConfigInfo apply(ProjectResource rsrc, ConfigInput input)
|
||||||
throws ResourceNotFoundException, BadRequestException,
|
throws ResourceNotFoundException, BadRequestException,
|
||||||
ResourceConflictException {
|
ResourceConflictException {
|
||||||
if (!rsrc.getControl().isOwner()) {
|
if (!rsrc.getControl().isOwner()) {
|
||||||
@@ -131,7 +114,7 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
|
|||||||
return apply(rsrc.getControl(), input);
|
return apply(rsrc.getControl(), input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigInfo apply(ProjectControl ctrl, Input input)
|
public ConfigInfo apply(ProjectControl ctrl, ConfigInput input)
|
||||||
throws ResourceNotFoundException, BadRequestException,
|
throws ResourceNotFoundException, BadRequestException,
|
||||||
ResourceConflictException {
|
ResourceConflictException {
|
||||||
Project.NameKey projectName = ctrl.getProject().getNameKey();
|
Project.NameKey projectName = ctrl.getProject().getNameKey();
|
||||||
|
@@ -17,7 +17,7 @@ package com.google.gerrit.server.project;
|
|||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.gerrit.common.ChangeHooks;
|
import com.google.gerrit.common.ChangeHooks;
|
||||||
import com.google.gerrit.extensions.api.projects.PutDescriptionInput;
|
import com.google.gerrit.extensions.api.projects.DescriptionInput;
|
||||||
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;
|
||||||
@@ -42,7 +42,7 @@ import java.io.IOException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class PutDescription implements RestModifyView<ProjectResource, PutDescriptionInput> {
|
public class PutDescription implements RestModifyView<ProjectResource, DescriptionInput> {
|
||||||
private final ProjectCache cache;
|
private final ProjectCache cache;
|
||||||
private final MetaDataUpdate.Server updateFactory;
|
private final MetaDataUpdate.Server updateFactory;
|
||||||
private final GitRepositoryManager gitMgr;
|
private final GitRepositoryManager gitMgr;
|
||||||
@@ -64,10 +64,10 @@ public class PutDescription implements RestModifyView<ProjectResource, PutDescri
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response<String> apply(ProjectResource resource,
|
public Response<String> apply(ProjectResource resource,
|
||||||
PutDescriptionInput input) throws AuthException,
|
DescriptionInput input) throws AuthException,
|
||||||
ResourceConflictException, ResourceNotFoundException, IOException {
|
ResourceConflictException, ResourceNotFoundException, IOException {
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
input = new PutDescriptionInput(); // Delete would set description to null.
|
input = new DescriptionInput(); // Delete would set description to null.
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectControl ctl = resource.getControl();
|
ProjectControl ctl = resource.getControl();
|
||||||
|
@@ -21,8 +21,8 @@ import com.google.common.collect.Lists;
|
|||||||
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.api.GerritApi;
|
import com.google.gerrit.extensions.api.GerritApi;
|
||||||
|
import com.google.gerrit.extensions.api.projects.ConfigValue;
|
||||||
import com.google.gerrit.extensions.api.projects.ProjectInput;
|
import com.google.gerrit.extensions.api.projects.ProjectInput;
|
||||||
import com.google.gerrit.extensions.api.projects.ProjectInput.ConfigValue;
|
|
||||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||||
import com.google.gerrit.extensions.client.SubmitType;
|
import com.google.gerrit.extensions.client.SubmitType;
|
||||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||||
|
@@ -16,7 +16,7 @@ package com.google.gerrit.sshd.commands;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import com.google.gerrit.extensions.api.projects.ProjectInput.ConfigValue;
|
import com.google.gerrit.extensions.api.projects.ConfigValue;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
Reference in New Issue
Block a user