use of com.google.gerrit.extensions.registration.DynamicMap in project gerrit by GerritCodeReview.
the class GetServerInfo method getDownloadSchemeInfo.
private DownloadSchemeInfo getDownloadSchemeInfo(DownloadScheme scheme, DynamicMap<DownloadCommand> downloadCommands, DynamicMap<CloneCommand> cloneCommands) {
DownloadSchemeInfo info = new DownloadSchemeInfo();
info.url = scheme.getUrl("${project}");
info.isAuthRequired = toBoolean(scheme.isAuthRequired());
info.isAuthSupported = toBoolean(scheme.isAuthSupported());
info.commands = new HashMap<>();
for (DynamicMap.Entry<DownloadCommand> e : downloadCommands) {
String commandName = e.getExportName();
DownloadCommand command = e.getProvider().get();
String c = command.getCommand(scheme, "${project}", "${ref}");
if (c != null) {
info.commands.put(commandName, c);
}
}
info.cloneCommands = new HashMap<>();
for (DynamicMap.Entry<CloneCommand> e : cloneCommands) {
String commandName = e.getExportName();
CloneCommand command = e.getProvider().get();
String c = command.getCommand(scheme, "${project-path}/${project-base-name}");
if (c != null) {
c = c.replaceAll("\\$\\{project-path\\}/\\$\\{project-base-name\\}", "\\$\\{project\\}");
info.cloneCommands.put(commandName, c);
}
}
return info;
}
use of com.google.gerrit.extensions.registration.DynamicMap in project gerrit by GerritCodeReview.
the class GetServerInfo method getDownloadInfo.
private DownloadInfo getDownloadInfo(DynamicMap<DownloadScheme> downloadSchemes, DynamicMap<DownloadCommand> downloadCommands, DynamicMap<CloneCommand> cloneCommands, AllowedFormats archiveFormats) {
DownloadInfo info = new DownloadInfo();
info.schemes = new HashMap<>();
for (DynamicMap.Entry<DownloadScheme> e : downloadSchemes) {
DownloadScheme scheme = e.getProvider().get();
if (scheme.isEnabled() && scheme.getUrl("${project}") != null) {
info.schemes.put(e.getExportName(), getDownloadSchemeInfo(scheme, downloadCommands, cloneCommands));
}
}
info.archives = archiveFormats.getAllowed().stream().map(ArchiveFormat::getShortName).collect(toList());
return info;
}
use of com.google.gerrit.extensions.registration.DynamicMap in project gerrit by GerritCodeReview.
the class ConfigInfoImpl method getPluginConfig.
private Map<String, Map<String, ConfigParameterInfo>> getPluginConfig(ProjectState project, DynamicMap<ProjectConfigEntry> pluginConfigEntries, PluginConfigFactory cfgFactory, AllProjectsName allProjects) {
TreeMap<String, Map<String, ConfigParameterInfo>> pluginConfig = new TreeMap<>();
for (Entry<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.getProject().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;
}
use of com.google.gerrit.extensions.registration.DynamicMap in project gerrit by GerritCodeReview.
the class ChangeJson method populateFetchMap.
public static void populateFetchMap(DownloadScheme scheme, DynamicMap<DownloadCommand> commands, String projectName, String refName, FetchInfo fetchInfo) {
for (DynamicMap.Entry<DownloadCommand> e2 : commands) {
String commandName = e2.getExportName();
DownloadCommand command = e2.getProvider().get();
String c = command.getCommand(scheme, projectName, refName);
if (c != null) {
addCommand(fetchInfo, commandName, c);
}
}
}
use of com.google.gerrit.extensions.registration.DynamicMap in project gerrit by GerritCodeReview.
the class PluginGuiceEnvironment method reattachMap.
private void reattachMap(ListMultimap<TypeLiteral<?>, ReloadableRegistrationHandle<?>> oldHandles, Map<TypeLiteral<?>, DynamicMap<?>> maps, @Nullable Injector src, Plugin newPlugin) {
if (src == null || maps == null || maps.isEmpty()) {
return;
}
for (Map.Entry<TypeLiteral<?>, DynamicMap<?>> e : maps.entrySet()) {
@SuppressWarnings("unchecked") TypeLiteral<Object> type = (TypeLiteral<Object>) e.getKey();
@SuppressWarnings("unchecked") PrivateInternals_DynamicMapImpl<Object> map = (PrivateInternals_DynamicMapImpl<Object>) e.getValue();
Map<Annotation, ReloadableRegistrationHandle<?>> am = new HashMap<>();
for (ReloadableRegistrationHandle<?> h : oldHandles.get(type)) {
Annotation a = h.getKey().getAnnotation();
if (a != null && !UNIQUE_ANNOTATION.isInstance(a)) {
am.put(a, h);
}
}
for (Binding<?> binding : bindings(src, e.getKey())) {
@SuppressWarnings("unchecked") Binding<Object> b = (Binding<Object>) binding;
Key<Object> key = b.getKey();
if (key.getAnnotation() == null) {
continue;
}
@SuppressWarnings("unchecked") ReloadableRegistrationHandle<Object> h = (ReloadableRegistrationHandle<Object>) am.remove(key.getAnnotation());
if (h != null) {
replace(newPlugin, h, b);
oldHandles.remove(type, h);
} else {
newPlugin.add(map.put(newPlugin.getName(), b.getKey(), b.getProvider()));
}
}
}
}
Aggregations