Add a REST API endpoint for getting project configuration
To start, only expose the inheritable booleans stored in the project config, and only to users who can see refs/meta/config. Change-Id: I299a5317fb641e84b899f8240764c4902a34c72a
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2013 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.server.project;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
|
||||
public class GetConfig implements RestReadView<ProjectResource> {
|
||||
public static class ConfigInfo {
|
||||
public final String kind = "gerritcodereview#project_config";
|
||||
|
||||
public Boolean useContributorAgreements;
|
||||
public Boolean useContentMerge;
|
||||
public Boolean useSignedOffBy;
|
||||
public Boolean requireChangeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigInfo apply(ProjectResource resource) {
|
||||
ConfigInfo result = new ConfigInfo();
|
||||
RefControl refConfig = resource.getControl()
|
||||
.controlForRef(GitRepositoryManager.REF_CONFIG);
|
||||
ProjectState project = resource.getControl().getProjectState();
|
||||
if (refConfig.isVisible()) {
|
||||
result.useContributorAgreements = project.isUseContributorAgreements();
|
||||
result.useContentMerge = project.isUseContentMerge();
|
||||
result.useSignedOffBy = project.isUseSignedOffBy();
|
||||
result.requireChangeId = project.isRequireChangeID();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -51,5 +51,7 @@ public class Module extends RestApiModule {
|
||||
put(DASHBOARD_KIND).to(SetDashboard.class);
|
||||
delete(DASHBOARD_KIND).to(DeleteDashboard.class);
|
||||
install(new FactoryModuleBuilder().build(CreateProject.Factory.class));
|
||||
|
||||
get(PROJECT_KIND, "config").to(GetConfig.class);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user