List of usage examples for org.eclipse.jgit.lib Config getStringList
public String[] getStringList(final String section, String subsection, final String name)
If this instance was created with a base, the base's values are returned first (if any).
From source file:com.ericsson.gerrit.plugins.highavailability.peers.jgroups.MyUrlProvider.java
License:Apache License
private static String getMyUrlFromListenUrl(Config srvConfig) throws MyUrlProviderException { String[] listenUrls = srvConfig.getStringList(HTTPD_SECTION, null, LISTEN_URL_KEY); if (listenUrls.length != 1) { throw new MyUrlProviderException(String.format( "Can only determine myUrl from %s when there is exactly 1 value configured; found %d", LISTEN_URL, listenUrls.length)); }/*from w ww.ja v a2s . c o m*/ String url = listenUrls[0]; if (url.startsWith(PROXY_PREFIX)) { throw new MyUrlProviderException(String.format( "Cannot determine myUrl from %s when configured as reverse-proxy: %s", LISTEN_URL, url)); } if (url.contains("*")) { throw new MyUrlProviderException(String .format("Cannot determine myUrl from %s when configured with wildcard: %s", LISTEN_URL, url)); } try { URIish u = new URIish(url); return u.setHost(InetAddress.getLocalHost().getHostName()).toString(); } catch (URISyntaxException | UnknownHostException e) { throw new MyUrlProviderException(String.format("Unable to determine myUrl from %s value [%s]: %s", LISTEN_URL, url, e.getMessage())); } }
From source file:com.gitblit.authority.UserCertificateConfig.java
License:Apache License
private UserCertificateConfig(final Config c) { SimpleDateFormat df = new SimpleDateFormat(Constants.ISO8601); list = new ArrayList<UserCertificateModel>(); for (String username : c.getSubsections("user")) { UserCertificateModel uc = new UserCertificateModel(new UserModel(username)); try {/*w w w . j a va 2 s .c om*/ uc.expires = df.parse(c.getString("user", username, "expires")); } catch (ParseException e) { LoggerFactory.getLogger(UserCertificateConfig.class).error("Failed to parse date!", e); } catch (NullPointerException e) { } uc.notes = c.getString("user", username, "notes"); uc.revoked = new ArrayList<String>(Arrays.asList(c.getStringList("user", username, "revoked"))); list.add(uc); } }
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.//from ww w. ja v a2 s . 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.gpg.GerritPublicKeyChecker.java
License:Apache License
private static List<Fingerprint> getTrustedFingerprints(Config cfg) { String[] strs = cfg.getStringList("receive", null, "trustedKey"); if (strs == null || strs.length == 0) { return null; }//from ww w.j a v a 2 s. c o m List<Fingerprint> fps = new ArrayList<>(strs.length); for (String str : strs) { str = CharMatcher.WHITESPACE.removeFrom(str).toUpperCase(); fps.add(new Fingerprint(BaseEncoding.base16().decode(str))); } return fps; }
From source file:com.google.gerrit.pgm.http.jetty.JettyServer.java
License:Apache License
static URI[] listenURLs(final Config cfg) { String[] urls = cfg.getStringList("httpd", null, "listenurl"); if (urls.length == 0) { urls = new String[] { "http://*:8080/" }; }// w w w.jav a2 s .c o m final URI[] r = new URI[urls.length]; for (int i = 0; i < r.length; i++) { final String s = urls[i]; try { r[i] = new URI(s); } catch (URISyntaxException e) { throw new IllegalArgumentException("Invalid httpd.listenurl " + s, e); } } return r; }
From source file:com.google.gerrit.pgm.init.Libraries.java
License:Apache License
private void init(Field field, Config cfg) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { String n = field.getName();//from w w w. j ava 2s . c om LibraryDownloader dl = (LibraryDownloader) field.get(this); dl.setName(get(cfg, n, "name")); dl.setJarUrl(get(cfg, n, "url")); dl.setSHA1(getOptional(cfg, n, "sha1")); dl.setRemove(get(cfg, n, "remove")); for (String d : cfg.getStringList("library", n, "needs")) { dl.addNeeds((LibraryDownloader) getClass().getDeclaredField(d).get(this)); } }
From source file:com.google.gerrit.server.account.WatchConfig.java
License:Apache License
@VisibleForTesting public static Map<ProjectWatchKey, Set<NotifyType>> parse(Account.Id accountId, Config cfg, ValidationError.Sink validationErrorSink) { Map<ProjectWatchKey, Set<NotifyType>> projectWatches = new HashMap<>(); for (String projectName : cfg.getSubsections(PROJECT)) { String[] notifyValues = cfg.getStringList(PROJECT, projectName, KEY_NOTIFY); for (String nv : notifyValues) { if (Strings.isNullOrEmpty(nv)) { continue; }//from ww w . j a v a2 s . c o m NotifyValue notifyValue = NotifyValue.parse(accountId, projectName, nv, validationErrorSink); if (notifyValue == null) { continue; } ProjectWatchKey key = ProjectWatchKey.create(new Project.NameKey(projectName), notifyValue.filter()); if (!projectWatches.containsKey(key)) { projectWatches.put(key, EnumSet.noneOf(NotifyType.class)); } projectWatches.get(key).addAll(notifyValue.notifyTypes()); } } return projectWatches; }
From source file:com.google.gerrit.server.auth.ldap.LdapRealm.java
License:Apache License
static List<String> optionalList(final Config config, final String name) { String[] s = config.getStringList("ldap", null, name); return Arrays.asList(s); }
From source file:com.google.gerrit.server.auth.ldap.LdapRealm.java
License:Apache License
static String optdef(final Config c, final String n, final String d) { final String[] v = c.getStringList("ldap", null, n); if (v == null || v.length == 0) { return d; } else if (v[0] == null || "".equals(v[0])) { return null; } else {/*from w ww .ja v a 2s . c o m*/ return v[0]; } }
From source file:com.google.gerrit.server.config.AdministrateServerGroupsProvider.java
License:Apache License
@Inject public AdministrateServerGroupsProvider(GroupBackend groupBackend, @GerritServerConfig Config config, ThreadLocalRequestContext threadContext, ServerRequestContext serverCtx) { RequestContext ctx = threadContext.setContext(serverCtx); try {//from www .ja v a 2 s . c o m ImmutableSet.Builder<GroupReference> builder = ImmutableSet.builder(); for (String value : config.getStringList("capability", null, "administrateServer")) { PermissionRule rule = PermissionRule.fromString(value, false); String name = rule.getGroup().getName(); GroupReference g = GroupBackends.findBestSuggestion(groupBackend, name); if (g != null) { builder.add(g); } else { Logger log = LoggerFactory.getLogger(getClass()); log.warn("Group \"{}\" not available, skipping.", name); } } groups = builder.build(); } finally { threadContext.setContext(ctx); } }