ConfigInfo: Move to extension API
Change-Id: I165b1afbae4acb027b08c590256515f863478d7b
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// 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;
|
||||
|
||||
public class CommentLinkInfo {
|
||||
public String match;
|
||||
public String link;
|
||||
public String html;
|
||||
public Boolean enabled; // null means true
|
||||
|
||||
public transient String name;
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
// 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 com.google.gerrit.extensions.common.ActionInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConfigInfo {
|
||||
public String description;
|
||||
public InheritedBooleanInfo useContributorAgreements;
|
||||
public InheritedBooleanInfo useContentMerge;
|
||||
public InheritedBooleanInfo useSignedOffBy;
|
||||
public InheritedBooleanInfo createNewChangeForAllNotInTarget;
|
||||
public InheritedBooleanInfo requireChangeId;
|
||||
public InheritedBooleanInfo enableSignedPush;
|
||||
public InheritedBooleanInfo requireSignedPush;
|
||||
public MaxObjectSizeLimitInfo maxObjectSizeLimit;
|
||||
public SubmitType submitType;
|
||||
public ProjectState state;
|
||||
public Map<String, Map<String, ConfigParameterInfo>> pluginConfig;
|
||||
public Map<String, ActionInfo> actions;
|
||||
|
||||
public Map<String, CommentLinkInfo> commentlinks;
|
||||
public ThemeInfo theme;
|
||||
|
||||
public static class InheritedBooleanInfo {
|
||||
public Boolean value;
|
||||
public InheritableBoolean configuredValue;
|
||||
public Boolean inheritedValue;
|
||||
}
|
||||
|
||||
public static class MaxObjectSizeLimitInfo {
|
||||
public String value;
|
||||
public String configuredValue;
|
||||
public String inheritedValue;
|
||||
}
|
||||
|
||||
public static class ConfigParameterInfo {
|
||||
public String displayName;
|
||||
public String description;
|
||||
public String warning;
|
||||
public ProjectConfigEntryType type;
|
||||
public String value;
|
||||
public Boolean editable;
|
||||
public Boolean inheritable;
|
||||
public String configuredValue;
|
||||
public String inheritedValue;
|
||||
public List<String> permittedValues;
|
||||
public List<String> values;
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
// 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;
|
||||
|
||||
public enum ProjectConfigEntryType {
|
||||
STRING, INT, LONG, BOOLEAN, LIST, ARRAY
|
||||
}
|
@@ -12,16 +12,16 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.project;
|
||||
package com.google.gerrit.extensions.api.projects;
|
||||
|
||||
public class ThemeInfo {
|
||||
static final ThemeInfo INHERIT = new ThemeInfo(null, null, null);
|
||||
public static final ThemeInfo INHERIT = new ThemeInfo(null, null, null);
|
||||
|
||||
public final String css;
|
||||
public final String header;
|
||||
public final String footer;
|
||||
|
||||
ThemeInfo(String css, String header, String footer) {
|
||||
public ThemeInfo(String css, String header, String footer) {
|
||||
this.css = css;
|
||||
this.header = header;
|
||||
this.footer = footer;
|
@@ -17,6 +17,7 @@ package com.google.gerrit.pgm.util;
|
||||
import static com.google.inject.Scopes.SINGLETON;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.gerrit.extensions.api.projects.CommentLinkInfo;
|
||||
import com.google.gerrit.extensions.config.FactoryModule;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
@@ -56,7 +57,6 @@ import com.google.gerrit.server.notedb.NoteDbModule;
|
||||
import com.google.gerrit.server.patch.DiffExecutorModule;
|
||||
import com.google.gerrit.server.patch.PatchListCacheImpl;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.CommentLinkInfo;
|
||||
import com.google.gerrit.server.project.CommentLinkProvider;
|
||||
import com.google.gerrit.server.project.ProjectCacheImpl;
|
||||
import com.google.gerrit.server.project.ProjectControl;
|
||||
|
@@ -20,6 +20,7 @@ import com.google.common.cache.Cache;
|
||||
import com.google.gerrit.audit.AuditModule;
|
||||
import com.google.gerrit.common.EventListener;
|
||||
import com.google.gerrit.common.UserScopedEventListener;
|
||||
import com.google.gerrit.extensions.api.projects.CommentLinkInfo;
|
||||
import com.google.gerrit.extensions.auth.oauth.OAuthLoginProvider;
|
||||
import com.google.gerrit.extensions.auth.oauth.OAuthTokenEncrypter;
|
||||
import com.google.gerrit.extensions.config.CapabilityDefinition;
|
||||
@@ -130,7 +131,6 @@ import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||
import com.google.gerrit.server.plugins.ReloadPluginListener;
|
||||
import com.google.gerrit.server.project.AccessControlModule;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.CommentLinkInfo;
|
||||
import com.google.gerrit.server.project.CommentLinkProvider;
|
||||
import com.google.gerrit.server.project.PermissionCollection;
|
||||
import com.google.gerrit.server.project.ProjectCacheImpl;
|
||||
|
@@ -18,6 +18,7 @@ import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.extensions.annotations.ExtensionPoint;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigValue;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectConfigEntryType;
|
||||
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap.Entry;
|
||||
@@ -41,15 +42,11 @@ import java.util.List;
|
||||
|
||||
@ExtensionPoint
|
||||
public class ProjectConfigEntry {
|
||||
public enum Type {
|
||||
STRING, INT, LONG, BOOLEAN, LIST, ARRAY
|
||||
}
|
||||
|
||||
private final String displayName;
|
||||
private final String description;
|
||||
private final boolean inheritable;
|
||||
private final String defaultValue;
|
||||
private final Type type;
|
||||
private final ProjectConfigEntryType type;
|
||||
private final List<String> permittedValues;
|
||||
|
||||
public ProjectConfigEntry(String displayName, String defaultValue) {
|
||||
@@ -63,7 +60,8 @@ public class ProjectConfigEntry {
|
||||
|
||||
public ProjectConfigEntry(String displayName, String defaultValue,
|
||||
boolean inheritable, String description) {
|
||||
this(displayName, defaultValue, Type.STRING, null, inheritable, description);
|
||||
this(displayName, defaultValue, ProjectConfigEntryType.STRING, null,
|
||||
inheritable, description);
|
||||
}
|
||||
|
||||
public ProjectConfigEntry(String displayName, int defaultValue) {
|
||||
@@ -77,8 +75,8 @@ public class ProjectConfigEntry {
|
||||
|
||||
public ProjectConfigEntry(String displayName, int defaultValue,
|
||||
boolean inheritable, String description) {
|
||||
this(displayName, Integer.toString(defaultValue), Type.INT, null,
|
||||
inheritable, description);
|
||||
this(displayName, Integer.toString(defaultValue),
|
||||
ProjectConfigEntryType.INT, null, inheritable, description);
|
||||
}
|
||||
|
||||
public ProjectConfigEntry(String displayName, long defaultValue) {
|
||||
@@ -92,8 +90,8 @@ public class ProjectConfigEntry {
|
||||
|
||||
public ProjectConfigEntry(String displayName, long defaultValue,
|
||||
boolean inheritable, String description) {
|
||||
this(displayName, Long.toString(defaultValue), Type.LONG, null,
|
||||
inheritable, description);
|
||||
this(displayName, Long.toString(defaultValue),
|
||||
ProjectConfigEntryType.LONG, null, inheritable, description);
|
||||
}
|
||||
|
||||
// For inheritable boolean use 'LIST' type with InheritableBoolean
|
||||
@@ -104,8 +102,8 @@ public class ProjectConfigEntry {
|
||||
//For inheritable boolean use 'LIST' type with InheritableBoolean
|
||||
public ProjectConfigEntry(String displayName, boolean defaultValue,
|
||||
String description) {
|
||||
this(displayName, Boolean.toString(defaultValue), Type.BOOLEAN, null,
|
||||
false, description);
|
||||
this(displayName, Boolean.toString(defaultValue),
|
||||
ProjectConfigEntryType.BOOLEAN, null, false, description);
|
||||
}
|
||||
|
||||
public ProjectConfigEntry(String displayName, String defaultValue,
|
||||
@@ -120,8 +118,8 @@ public class ProjectConfigEntry {
|
||||
|
||||
public ProjectConfigEntry(String displayName, String defaultValue,
|
||||
List<String> permittedValues, boolean inheritable, String description) {
|
||||
this(displayName, defaultValue, Type.LIST, permittedValues, inheritable,
|
||||
description);
|
||||
this(displayName, defaultValue, ProjectConfigEntryType.LIST,
|
||||
permittedValues, inheritable, description);
|
||||
}
|
||||
|
||||
public <T extends Enum<?>> ProjectConfigEntry(String displayName,
|
||||
@@ -137,7 +135,8 @@ public class ProjectConfigEntry {
|
||||
public <T extends Enum<?>> ProjectConfigEntry(String displayName,
|
||||
T defaultValue, Class<T> permittedValues, boolean inheritable,
|
||||
String description) {
|
||||
this(displayName, defaultValue.name(), Type.LIST, Lists.transform(
|
||||
this(displayName, defaultValue.name(), ProjectConfigEntryType.LIST,
|
||||
Lists.transform(
|
||||
Arrays.asList(permittedValues.getEnumConstants()),
|
||||
new Function<Enum<?>, String>() {
|
||||
@Override
|
||||
@@ -148,15 +147,15 @@ public class ProjectConfigEntry {
|
||||
}
|
||||
|
||||
public ProjectConfigEntry(String displayName, String defaultValue,
|
||||
Type type, List<String> permittedValues, boolean inheritable,
|
||||
String description) {
|
||||
ProjectConfigEntryType type, List<String> permittedValues,
|
||||
boolean inheritable, String description) {
|
||||
this.displayName = displayName;
|
||||
this.defaultValue = defaultValue;
|
||||
this.type = type;
|
||||
this.permittedValues = permittedValues;
|
||||
this.inheritable = inheritable;
|
||||
this.description = description;
|
||||
if (type == Type.ARRAY && inheritable) {
|
||||
if (type == ProjectConfigEntryType.ARRAY && inheritable) {
|
||||
throw new ProvisionException(
|
||||
"ARRAY doesn't support inheritable values");
|
||||
}
|
||||
@@ -178,7 +177,7 @@ public class ProjectConfigEntry {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
public ProjectConfigEntryType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@@ -53,7 +53,7 @@ import com.google.gerrit.server.account.GroupBackend;
|
||||
import com.google.gerrit.server.config.ConfigUtil;
|
||||
import com.google.gerrit.server.config.PluginConfig;
|
||||
import com.google.gerrit.server.mail.Address;
|
||||
import com.google.gerrit.server.project.CommentLinkInfo;
|
||||
import com.google.gerrit.server.project.CommentLinkInfoImpl;
|
||||
import com.google.gerrit.server.project.RefPattern;
|
||||
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
@@ -171,7 +171,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
private Map<String, LabelType> labelSections;
|
||||
private ConfiguredMimeTypes mimeTypes;
|
||||
private Map<Project.NameKey, SubscribeSection> subscribeSections;
|
||||
private List<CommentLinkInfo> commentLinkSections;
|
||||
private List<CommentLinkInfoImpl> commentLinkSections;
|
||||
private List<ValidationError> validationErrors;
|
||||
private ObjectId rulesId;
|
||||
private long maxObjectSizeLimit;
|
||||
@@ -192,7 +192,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
return r;
|
||||
}
|
||||
|
||||
public static CommentLinkInfo buildCommentLink(Config cfg, String name,
|
||||
public static CommentLinkInfoImpl buildCommentLink(Config cfg, String name,
|
||||
boolean allowRaw) throws IllegalArgumentException {
|
||||
String match = cfg.getString(COMMENTLINK, name, KEY_MATCH);
|
||||
if (match != null) {
|
||||
@@ -220,11 +220,11 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
if (Strings.isNullOrEmpty(match) && Strings.isNullOrEmpty(link) && !hasHtml
|
||||
&& enabled != null) {
|
||||
if (enabled) {
|
||||
return new CommentLinkInfo.Enabled(name);
|
||||
return new CommentLinkInfoImpl.Enabled(name);
|
||||
}
|
||||
return new CommentLinkInfo.Disabled(name);
|
||||
return new CommentLinkInfoImpl.Disabled(name);
|
||||
}
|
||||
return new CommentLinkInfo(name, match, link, html, enabled);
|
||||
return new CommentLinkInfoImpl(name, match, link, html, enabled);
|
||||
}
|
||||
|
||||
public ProjectConfig(Project.NameKey projectName) {
|
||||
@@ -374,7 +374,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
return labelSections;
|
||||
}
|
||||
|
||||
public Collection<CommentLinkInfo> getCommentLinkSections() {
|
||||
public Collection<CommentLinkInfoImpl> getCommentLinkSections() {
|
||||
return commentLinkSections;
|
||||
}
|
||||
|
||||
|
@@ -63,6 +63,7 @@ import com.google.gerrit.common.data.PermissionRule;
|
||||
import com.google.gerrit.extensions.api.changes.HashtagsInput;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput.NotifyHandling;
|
||||
import com.google.gerrit.extensions.api.changes.SubmitInput;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectConfigEntryType;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap.Entry;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
@@ -995,7 +996,7 @@ public class ReceiveCommits {
|
||||
projectControl.getProjectState().getConfig()
|
||||
.getPluginConfig(e.getPluginName())
|
||||
.getString(e.getExportName());
|
||||
if (configEntry.getType() == ProjectConfigEntry.Type.ARRAY) {
|
||||
if (configEntry.getType() == ProjectConfigEntryType.ARRAY) {
|
||||
List<String> l =
|
||||
Arrays.asList(projectControl.getProjectState()
|
||||
.getConfig().getPluginConfig(e.getPluginName())
|
||||
@@ -1012,7 +1013,7 @@ public class ReceiveCommits {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ProjectConfigEntry.Type.LIST.equals(configEntry.getType())
|
||||
if (ProjectConfigEntryType.LIST.equals(configEntry.getType())
|
||||
&& value != null && !configEntry.getPermittedValues().contains(value)) {
|
||||
reject(cmd, String.format(
|
||||
"invalid project configuration: The value '%s' is "
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.git.validators;
|
||||
|
||||
import com.google.gerrit.extensions.api.projects.ProjectConfigEntryType;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap.Entry;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
@@ -158,7 +159,7 @@ public class MergeValidators {
|
||||
throw new MergeValidationException(PLUGIN_VALUE_NOT_EDITABLE);
|
||||
}
|
||||
|
||||
if (ProjectConfigEntry.Type.LIST.equals(configEntry.getType())
|
||||
if (ProjectConfigEntryType.LIST.equals(configEntry.getType())
|
||||
&& value != null && !configEntry.getPermittedValues().contains(value)) {
|
||||
throw new MergeValidationException(PLUGIN_VALUE_NOT_PERMITTED);
|
||||
}
|
||||
|
@@ -17,10 +17,11 @@ package com.google.gerrit.server.project;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.extensions.api.projects.CommentLinkInfo;
|
||||
|
||||
/** Info about a single commentlink section in a config. */
|
||||
public class CommentLinkInfo {
|
||||
public static class Enabled extends CommentLinkInfo {
|
||||
public class CommentLinkInfoImpl extends CommentLinkInfo {
|
||||
public static class Enabled extends CommentLinkInfoImpl {
|
||||
public Enabled(String name) {
|
||||
super(name, true);
|
||||
}
|
||||
@@ -31,7 +32,7 @@ public class CommentLinkInfo {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Disabled extends CommentLinkInfo {
|
||||
public static class Disabled extends CommentLinkInfoImpl {
|
||||
public Disabled(String name) {
|
||||
super(name, false);
|
||||
}
|
||||
@@ -42,14 +43,7 @@ public class CommentLinkInfo {
|
||||
}
|
||||
}
|
||||
|
||||
public final String match;
|
||||
public final String link;
|
||||
public final String html;
|
||||
public final Boolean enabled; // null means true
|
||||
|
||||
public final transient String name;
|
||||
|
||||
public CommentLinkInfo(String name, String match, String link, String html,
|
||||
public CommentLinkInfoImpl(String name, String match, String link, String html,
|
||||
Boolean enabled) {
|
||||
checkArgument(name != null, "invalid commentlink.name");
|
||||
checkArgument(!Strings.isNullOrEmpty(match),
|
||||
@@ -66,7 +60,7 @@ public class CommentLinkInfo {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
private CommentLinkInfo(CommentLinkInfo src, boolean enabled) {
|
||||
private CommentLinkInfoImpl(CommentLinkInfo src, boolean enabled) {
|
||||
this.name = src.name;
|
||||
this.match = src.match;
|
||||
this.link = src.link;
|
||||
@@ -74,7 +68,7 @@ public class CommentLinkInfo {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
private CommentLinkInfo(String name, boolean enabled) {
|
||||
private CommentLinkInfoImpl(String name, boolean enabled) {
|
||||
this.name = name;
|
||||
this.match = null;
|
||||
this.link = null;
|
||||
@@ -87,6 +81,6 @@ public class CommentLinkInfo {
|
||||
}
|
||||
|
||||
CommentLinkInfo inherit(CommentLinkInfo src) {
|
||||
return new CommentLinkInfo(src, enabled);
|
||||
return new CommentLinkInfoImpl(src, enabled);
|
||||
}
|
||||
}
|
@@ -16,6 +16,7 @@ package com.google.gerrit.server.project;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.extensions.api.projects.CommentLinkInfo;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.git.ProjectConfig;
|
||||
import com.google.inject.Inject;
|
||||
@@ -41,7 +42,7 @@ public class CommentLinkProvider implements Provider<List<CommentLinkInfo>> {
|
||||
List<CommentLinkInfo> cls =
|
||||
Lists.newArrayListWithCapacity(subsections.size());
|
||||
for (String name : subsections) {
|
||||
CommentLinkInfo cl = ProjectConfig.buildCommentLink(cfg, name, true);
|
||||
CommentLinkInfoImpl cl = ProjectConfig.buildCommentLink(cfg, name, true);
|
||||
if (cl.isOverrideOnly()) {
|
||||
throw new ProvisionException(
|
||||
"commentlink " + name + " empty except for \"enabled\"");
|
||||
|
@@ -16,8 +16,9 @@ package com.google.gerrit.server.project;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||
import com.google.gerrit.extensions.client.SubmitType;
|
||||
import com.google.gerrit.extensions.api.projects.CommentLinkInfo;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInfo;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectConfigEntryType;
|
||||
import com.google.gerrit.extensions.common.ActionInfo;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap.Entry;
|
||||
@@ -34,29 +35,12 @@ import com.google.inject.util.Providers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class ConfigInfo {
|
||||
public String description;
|
||||
public InheritedBooleanInfo useContributorAgreements;
|
||||
public InheritedBooleanInfo useContentMerge;
|
||||
public InheritedBooleanInfo useSignedOffBy;
|
||||
public InheritedBooleanInfo createNewChangeForAllNotInTarget;
|
||||
public InheritedBooleanInfo requireChangeId;
|
||||
public InheritedBooleanInfo enableSignedPush;
|
||||
public InheritedBooleanInfo requireSignedPush;
|
||||
public MaxObjectSizeLimitInfo maxObjectSizeLimit;
|
||||
public SubmitType submitType;
|
||||
public com.google.gerrit.extensions.client.ProjectState state;
|
||||
public Map<String, Map<String, ConfigParameterInfo>> pluginConfig;
|
||||
public Map<String, ActionInfo> actions;
|
||||
public class ConfigInfoImpl extends ConfigInfo {
|
||||
|
||||
public Map<String, CommentLinkInfo> commentlinks;
|
||||
public ThemeInfo theme;
|
||||
|
||||
public ConfigInfo(boolean serverEnableSignedPush,
|
||||
public ConfigInfoImpl(boolean serverEnableSignedPush,
|
||||
ProjectControl control,
|
||||
TransferConfig config,
|
||||
DynamicMap<ProjectConfigEntry> pluginConfigEntries,
|
||||
@@ -177,7 +161,7 @@ public class ConfigInfo {
|
||||
p.configuredValue = configuredValue;
|
||||
p.inheritedValue = getInheritedValue(project, cfgFactory, e);
|
||||
} else {
|
||||
if (configEntry.getType() == ProjectConfigEntry.Type.ARRAY) {
|
||||
if (configEntry.getType() == ProjectConfigEntryType.ARRAY) {
|
||||
p.values = configEntry.onRead(project,
|
||||
Arrays.asList(cfg.getStringList(e.getExportName())));
|
||||
} else {
|
||||
@@ -211,30 +195,4 @@ public class ConfigInfo {
|
||||
}
|
||||
return inheritedValue;
|
||||
}
|
||||
|
||||
public static class InheritedBooleanInfo {
|
||||
public Boolean value;
|
||||
public InheritableBoolean configuredValue;
|
||||
public Boolean inheritedValue;
|
||||
}
|
||||
|
||||
public static class MaxObjectSizeLimitInfo {
|
||||
public String value;
|
||||
public String configuredValue;
|
||||
public String inheritedValue;
|
||||
}
|
||||
|
||||
public static class ConfigParameterInfo {
|
||||
public String displayName;
|
||||
public String description;
|
||||
public String warning;
|
||||
public ProjectConfigEntry.Type type;
|
||||
public String value;
|
||||
public Boolean editable;
|
||||
public Boolean inheritable;
|
||||
public String configuredValue;
|
||||
public String inheritedValue;
|
||||
public List<String> permittedValues;
|
||||
public List<String> values;
|
||||
}
|
||||
}
|
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.project;
|
||||
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInfo;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.extensions.restapi.RestView;
|
||||
@@ -51,7 +52,7 @@ public class GetConfig implements RestReadView<ProjectResource> {
|
||||
|
||||
@Override
|
||||
public ConfigInfo apply(ProjectResource resource) {
|
||||
return new ConfigInfo(serverEnableSignedPush, resource.getControl(), config,
|
||||
pluginConfigEntries, cfgFactory, allProjects, views);
|
||||
return new ConfigInfoImpl(serverEnableSignedPush, resource.getControl(),
|
||||
config, pluginConfigEntries, cfgFactory, allProjects, views);
|
||||
}
|
||||
}
|
||||
|
@@ -28,6 +28,8 @@ import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.common.data.PermissionRule;
|
||||
import com.google.gerrit.common.data.SubscribeSection;
|
||||
import com.google.gerrit.extensions.api.projects.CommentLinkInfo;
|
||||
import com.google.gerrit.extensions.api.projects.ThemeInfo;
|
||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
@@ -463,7 +465,7 @@ public class ProjectState {
|
||||
cls.put(cl.name.toLowerCase(), cl);
|
||||
}
|
||||
for (ProjectState s : treeInOrder()) {
|
||||
for (CommentLinkInfo cl : s.getConfig().getCommentLinkSections()) {
|
||||
for (CommentLinkInfoImpl cl : s.getConfig().getCommentLinkSections()) {
|
||||
String name = cl.name.toLowerCase();
|
||||
if (cl.isOverrideOnly()) {
|
||||
CommentLinkInfo parent = cls.get(name);
|
||||
|
@@ -18,8 +18,10 @@ import com.google.common.base.CharMatcher;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.common.ChangeHooks;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInfo;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigValue;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectConfigEntryType;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
@@ -197,7 +199,7 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
|
||||
}
|
||||
|
||||
ProjectState state = projectStateFactory.create(projectConfig);
|
||||
return new ConfigInfo(serverEnableSignedPush,
|
||||
return new ConfigInfoImpl(serverEnableSignedPush,
|
||||
state.controlFor(user.get()), config, pluginConfigEntries,
|
||||
cfgFactory, allProjects, views);
|
||||
} catch (RepositoryNotFoundException notFound) {
|
||||
@@ -226,7 +228,7 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
|
||||
}
|
||||
String oldValue = cfg.getString(v.getKey());
|
||||
String value = v.getValue().value;
|
||||
if (projectConfigEntry.getType() == ProjectConfigEntry.Type.ARRAY) {
|
||||
if (projectConfigEntry.getType() == ProjectConfigEntryType.ARRAY) {
|
||||
List<String> l = Arrays.asList(cfg.getStringList(v.getKey()));
|
||||
oldValue = Joiner.on("\n").join(l);
|
||||
value = Joiner.on("\n").join(v.getValue().values);
|
||||
|
@@ -40,6 +40,7 @@ import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.PermissionRange;
|
||||
import com.google.gerrit.common.data.PermissionRule;
|
||||
import com.google.gerrit.common.errors.InvalidNameException;
|
||||
import com.google.gerrit.extensions.api.projects.CommentLinkInfo;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
|
Submodule plugins/cookbook-plugin updated: 3e801bd7d4...6eecd42fd6
Reference in New Issue
Block a user