List of usage examples for org.eclipse.jgit.lib Config setStringList
public void setStringList(final String section, final String subsection, final String name, final List<String> values)
From source file:com.gitblit.authority.UserCertificateModel.java
License:Apache License
public void update(Config config) { if (expires == null) { config.unset("user", user.username, "expires"); } else {//from w w w .ja v a 2 s. c o m SimpleDateFormat df = new SimpleDateFormat(Constants.ISO8601); config.setString("user", user.username, "expires", df.format(expires)); } if (StringUtils.isEmpty(notes)) { config.unset("user", user.username, "notes"); } else { config.setString("user", user.username, "notes", notes); } if (ArrayUtils.isEmpty(revoked)) { config.unset("user", user.username, "revoked"); } else { config.setStringList("user", user.username, "revoked", revoked); } }
From source file:com.google.gerrit.acceptance.ConfigAnnotationParser.java
License:Apache License
private static void parseAnnotation(Config cfg, GerritConfig c) { ArrayList<String> l = Lists.newArrayList(splitter.split(c.name())); if (l.size() == 2) { if (!Strings.isNullOrEmpty(c.value())) { cfg.setString(l.get(0), null, l.get(1), c.value()); } else {/*from w w w.ja v a 2s.co m*/ String[] values = c.values(); cfg.setStringList(l.get(0), null, l.get(1), Arrays.asList(values)); } } else if (l.size() == 3) { if (!Strings.isNullOrEmpty(c.value())) { cfg.setString(l.get(0), l.get(1), l.get(2), c.value()); } else { cfg.setStringList(l.get(0), l.get(1), l.get(2), Arrays.asList(c.value())); } } else { throw new IllegalArgumentException( "GerritConfig.name must be of the format" + " section.subsection.name or section.name"); } }
From source file:com.google.gerrit.acceptance.rest.change.CorsIT.java
License:Apache License
@ConfigSuite.Default public static Config allowExampleDotCom() { Config cfg = new Config(); cfg.setStringList("site", null, "allowOriginRegex", ImmutableList.of("https?://(.+[.])?example[.]com", "http://friend[.]ly")); return cfg;//from w w w . j a v a 2 s .c om }
From source file:com.google.gerrit.gpg.GerritPublicKeyCheckerTest.java
License:Apache License
@Before public void setUpInjector() throws Exception { Config cfg = InMemoryModule.newDefaultConfig(); cfg.setInt("receive", null, "maxTrustDepth", 2); cfg.setStringList("receive", null, "trustedKey", ImmutableList.of(Fingerprint.toString(keyB().getPublicKey().getFingerprint()), Fingerprint.toString(keyD().getPublicKey().getFingerprint()))); Injector injector = Guice.createInjector(new InMemoryModule(cfg, new TestNotesMigration())); lifecycle = new LifecycleManager(); lifecycle.add(injector);//from w w w . j av a2s . co m injector.injectMembers(this); lifecycle.start(); db = schemaFactory.open(); schemaCreator.create(db); userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId(); Account userAccount = db.accounts().get(userId); // Note: does not match any key in TestKeys. userAccount.setPreferredEmail("user@example.com"); db.accounts().update(ImmutableList.of(userAccount)); user = reloadUser(); requestContext.setContext(new RequestContext() { @Override public CurrentUser getUser() { return user; } @Override public Provider<ReviewDb> getReviewDbProvider() { return Providers.of(db); } }); storeRepo = new InMemoryRepository(new DfsRepositoryDescription("repo")); store = new PublicKeyStore(storeRepo); }
From source file:com.google.gerrit.pgm.init.InitLabels.java
License:Apache License
@Override public void postRun() throws Exception { Config cfg = allProjectsConfig.load().getConfig(); if (installVerified) { cfg.setString(KEY_LABEL, LABEL_VERIFIED, KEY_FUNCTION, "MaxWithBlock"); cfg.setStringList(KEY_LABEL, LABEL_VERIFIED, KEY_VALUE, Arrays.asList(new String[] { "-1 Fails", " 0 No score", "+1 Verified" })); cfg.setBoolean(KEY_LABEL, LABEL_VERIFIED, KEY_COPY_ALL_SCORES_IF_NO_CODE_CHANGE, true); allProjectsConfig.save("Configure 'Verified' label"); }// w w w . j a va 2 s .c o m }
From source file:com.google.gerrit.server.account.WatchConfig.java
License:Apache License
@Override protected boolean onSave(CommitBuilder commit) throws IOException, ConfigInvalidException { checkLoaded();/* w w w . j a v a2 s. c om*/ if (Strings.isNullOrEmpty(commit.getMessage())) { commit.setMessage("Updated watch configuration\n"); } Config cfg = readConfig(WATCH_CONFIG); for (String projectName : cfg.getSubsections(PROJECT)) { cfg.unsetSection(PROJECT, projectName); } ListMultimap<String, String> notifyValuesByProject = MultimapBuilder.hashKeys().arrayListValues().build(); for (Map.Entry<ProjectWatchKey, Set<NotifyType>> e : projectWatches.entrySet()) { NotifyValue notifyValue = NotifyValue.create(e.getKey().filter(), e.getValue()); notifyValuesByProject.put(e.getKey().project().get(), notifyValue.toString()); } for (Map.Entry<String, Collection<String>> e : notifyValuesByProject.asMap().entrySet()) { cfg.setStringList(PROJECT, e.getKey(), KEY_NOTIFY, new ArrayList<>(e.getValue())); } saveConfig(WATCH_CONFIG, cfg); return true; }
From source file:com.google.gerrit.server.git.ProjectConfig.java
License:Apache License
private void loadPluginSections(Config rc) { pluginConfigs = Maps.newHashMap();/*from w ww.java2 s . co m*/ for (String plugin : rc.getSubsections(PLUGIN)) { Config pluginConfig = new Config(); pluginConfigs.put(plugin, pluginConfig); for (String name : rc.getNames(PLUGIN, plugin)) { pluginConfig.setStringList(PLUGIN, plugin, name, Arrays.asList(rc.getStringList(PLUGIN, plugin, name))); } } }
From source file:com.google.gerrit.server.git.ProjectConfig.java
License:Apache License
private void saveAccountsSection(Config rc, Set<AccountGroup.UUID> keepGroups) { if (accountsSection != null) { rc.setStringList(ACCOUNTS, null, KEY_SAME_GROUP_VISIBILITY, ruleToStringList(accountsSection.getSameGroupVisibility(), keepGroups)); }/*from ww w . ja v a2 s. com*/ }
From source file:com.google.gerrit.server.git.ProjectConfig.java
License:Apache License
private void saveContributorAgreements(Config rc, Set<AccountGroup.UUID> keepGroups) { for (ContributorAgreement ca : sort(contributorAgreements.values())) { set(rc, CONTRIBUTOR_AGREEMENT, ca.getName(), KEY_DESCRIPTION, ca.getDescription()); set(rc, CONTRIBUTOR_AGREEMENT, ca.getName(), KEY_AGREEMENT_URL, ca.getAgreementUrl()); if (ca.getAutoVerify() != null) { if (ca.getAutoVerify().getUUID() != null) { keepGroups.add(ca.getAutoVerify().getUUID()); }//from w w w.j a va 2 s . com String autoVerify = new PermissionRule(ca.getAutoVerify()).asString(false); set(rc, CONTRIBUTOR_AGREEMENT, ca.getName(), KEY_AUTO_VERIFY, autoVerify); } else { rc.unset(CONTRIBUTOR_AGREEMENT, ca.getName(), KEY_AUTO_VERIFY); } rc.setStringList(CONTRIBUTOR_AGREEMENT, ca.getName(), KEY_ACCEPTED, ruleToStringList(ca.getAccepted(), keepGroups)); } }
From source file:com.google.gerrit.server.git.ProjectConfig.java
License:Apache License
private void saveNotifySections(Config rc, Set<AccountGroup.UUID> keepGroups) { for (NotifyConfig nc : sort(notifySections.values())) { List<String> email = Lists.newArrayList(); for (GroupReference gr : nc.getGroups()) { if (gr.getUUID() != null) { keepGroups.add(gr.getUUID()); }//from www . j a v a 2s . c o m email.add(new PermissionRule(gr).asString(false)); } Collections.sort(email); List<String> addrs = Lists.newArrayList(); for (Address addr : nc.getAddresses()) { addrs.add(addr.toString()); } Collections.sort(addrs); email.addAll(addrs); set(rc, NOTIFY, nc.getName(), KEY_HEADER, nc.getHeader(), NotifyConfig.Header.BCC); if (email.isEmpty()) { rc.unset(NOTIFY, nc.getName(), KEY_EMAIL); } else { rc.setStringList(NOTIFY, nc.getName(), KEY_EMAIL, email); } if (nc.getNotify().equals(EnumSet.of(NotifyType.ALL))) { rc.unset(NOTIFY, nc.getName(), KEY_TYPE); } else { List<String> types = Lists.newArrayListWithCapacity(4); for (NotifyType t : NotifyType.values()) { if (nc.isNotify(t)) { types.add(StringUtils.toLowerCase(t.name())); } } rc.setStringList(NOTIFY, nc.getName(), KEY_TYPE, types); } set(rc, NOTIFY, nc.getName(), KEY_FILTER, nc.getFilter()); } }