List of usage examples for org.eclipse.jgit.lib Config getSections
public Set<String> getSections()
From source file:com.google.gerrit.acceptance.MergeableFileBasedConfig.java
License:Apache License
/** * Merge another Config into this Config. * * In case a configuration parameter exists both in this instance and in the * merged instance then the value in this instance will simply replaced by * the value from the merged instance./* w ww .j a v a2s. c o m*/ * * @param s Config to merge into this instance */ public void merge(Config s) { if (s == null) { return; } for (String section : s.getSections()) { for (String subsection : s.getSubsections(section)) { for (String name : s.getNames(section, subsection)) { setStringList(section, subsection, name, Lists.newArrayList(s.getStringList(section, subsection, name))); } } for (String name : s.getNames(section, true)) { setStringList(section, null, name, Lists.newArrayList(s.getStringList(section, null, name))); } } }
From source file:com.google.gerrit.server.git.ProjectConfig.java
License:Apache License
private void loadBranchOrderSection(Config rc) { if (rc.getSections().contains(BRANCH_ORDER)) { branchOrderSection = new BranchOrderSection(rc.getStringList(BRANCH_ORDER, null, BRANCH)); }//from ww w. jav a 2 s. c o m }
From source file:com.google.gerrit.server.git.ProjectLevelConfig.java
License:Apache License
public Config getWithInheritance() { Config cfgWithInheritance = new Config(); try {/*from w ww .j a v a2 s .c o m*/ cfgWithInheritance.fromText(get().toText()); } catch (ConfigInvalidException e) { // cannot happen } ProjectState parent = Iterables.getFirst(project.parents(), null); if (parent != null) { Config parentCfg = parent.getConfig(fileName).getWithInheritance(); for (String section : parentCfg.getSections()) { Set<String> allNames = get().getNames(section); for (String name : parentCfg.getNames(section)) { if (!allNames.contains(name)) { cfgWithInheritance.setStringList(section, null, name, Arrays.asList(parentCfg.getStringList(section, null, name))); } } for (String subsection : parentCfg.getSubsections(section)) { allNames = get().getNames(section, subsection); for (String name : parentCfg.getNames(section, subsection)) { if (!allNames.contains(name)) { cfgWithInheritance.setStringList(section, subsection, name, Arrays.asList(parentCfg.getStringList(section, subsection, name))); } } } } } return cfgWithInheritance; }
From source file:com.googlesource.gerrit.plugins.supermanifest.SuperManifestRefUpdatedListener.java
License:Apache License
private Set<ConfigEntry> parseConfiguration(PluginConfigFactory cfgFactory, String name) throws NoSuchProjectException { Config cfg = cfgFactory.getProjectPluginConfig(allProjectsName, name); Set<ConfigEntry> newConf = new HashSet<>(); Set<String> destinations = new HashSet<>(); Set<String> wildcardDestinations = new HashSet<>(); Set<String> sources = new HashSet<>(); for (String sect : cfg.getSections()) { if (!sect.equals(ConfigEntry.SECTION_NAME)) { warn("%s.config: ignoring invalid section %s", name, sect); }/* ww w . j ava 2 s . co m*/ } for (String subsect : cfg.getSubsections(ConfigEntry.SECTION_NAME)) { try { ConfigEntry configEntry = new ConfigEntry(cfg, subsect); if (destinations.contains(configEntry.srcRepoKey.get()) || sources.contains(configEntry.destRepoKey.get())) { // Don't want cyclic dependencies. throw new ConfigInvalidException( String.format("repo in entry %s cannot be both source and destination", configEntry)); } if (configEntry.destBranch.equals("*")) { if (wildcardDestinations.contains(configEntry.destRepoKey.get())) { throw new ConfigInvalidException(String.format( "repo %s already has a wildcard destination branch.", configEntry.destRepoKey)); } wildcardDestinations.add(configEntry.destRepoKey.get()); } sources.add(configEntry.srcRepoKey.get()); destinations.add(configEntry.destRepoKey.get()); newConf.add(configEntry); } catch (ConfigInvalidException e) { error("invalid configuration: %s", e); } } return newConf; }
From source file:org.eclipse.orion.server.git.servlets.GitConfigHandlerV1.java
License:Open Source License
/** * Converts whole config to JSON representation. *//*from w w w .j ava 2 s . c o m*/ JSONObject configToJSON(Config config, URI baseLocation, BaseToConfigEntryConverter uriConverter) throws JSONException, URISyntaxException { JSONObject result = new JSONObject(); JSONArray children = new JSONArray(); for (String section : config.getSections()) { // proceed configuration entries: section.name for (String name : config.getNames(section)) children.put(configEntryToJSON(config, new String[] { section, null, name }, baseLocation, uriConverter)); // proceed configuration entries: section.subsection.name for (String subsection : config.getSubsections(section)) for (String name : config.getNames(section, subsection)) children.put(configEntryToJSON(config, new String[] { section, subsection, name }, baseLocation, uriConverter)); } result.put(ProtocolConstants.KEY_CHILDREN, children); return result; }