use of com.google.gerrit.extensions.api.projects.ConfigInfo.ConfigParameterInfo in project gerrit by GerritCodeReview.
the class ConfigInfoCreator method getPluginConfig.
private static Map<String, Map<String, ConfigParameterInfo>> getPluginConfig(ProjectState project, DynamicMap<ProjectConfigEntry> pluginConfigEntries, PluginConfigFactory cfgFactory, AllProjectsName allProjects) {
TreeMap<String, Map<String, ConfigParameterInfo>> pluginConfig = new TreeMap<>();
for (Extension<ProjectConfigEntry> e : pluginConfigEntries) {
ProjectConfigEntry configEntry = e.getProvider().get();
PluginConfig cfg = cfgFactory.getFromProjectConfig(project, e.getPluginName());
String configuredValue = cfg.getString(e.getExportName());
ConfigParameterInfo p = new ConfigParameterInfo();
p.displayName = configEntry.getDisplayName();
p.description = configEntry.getDescription();
p.warning = configEntry.getWarning(project);
p.type = configEntry.getType();
p.permittedValues = configEntry.getPermittedValues();
p.editable = configEntry.isEditable(project) ? true : null;
if (configEntry.isInheritable() && !allProjects.equals(project.getNameKey())) {
PluginConfig cfgWithInheritance = cfgFactory.getFromProjectConfigWithInheritance(project, e.getPluginName());
p.inheritable = true;
p.value = configEntry.onRead(project, cfgWithInheritance.getString(e.getExportName(), configEntry.getDefaultValue()));
p.configuredValue = configuredValue;
p.inheritedValue = getInheritedValue(project, cfgFactory, e);
} else {
if (configEntry.getType() == ProjectConfigEntryType.ARRAY) {
p.values = configEntry.onRead(project, Arrays.asList(cfg.getStringList(e.getExportName())));
} else {
p.value = configEntry.onRead(project, configuredValue != null ? configuredValue : configEntry.getDefaultValue());
}
}
Map<String, ConfigParameterInfo> pc = pluginConfig.get(e.getPluginName());
if (pc == null) {
pc = new TreeMap<>();
pluginConfig.put(e.getPluginName(), pc);
}
pc.put(e.getExportName(), p);
}
return !pluginConfig.isEmpty() ? pluginConfig : null;
}
Aggregations