List of usage examples for org.eclipse.jgit.lib Config setInt
public void setInt(final String section, final String subsection, final String name, final int value)
From source file:com.gitblit.authority.NewCertificateConfig.java
License:Apache License
public void store(Config c, X509Metadata metadata) { store(c, "new", "organizationalUnit", metadata.getOID("OU", null)); store(c, "new", "organization", metadata.getOID("O", null)); store(c, "new", "locality", metadata.getOID("L", null)); store(c, "new", "stateProvince", metadata.getOID("ST", null)); store(c, "new", "countryCode", metadata.getOID("C", null)); if (duration <= 0) { c.unset("new", null, "duration"); } else {//w w w . ja v a2s . co m c.setInt("new", null, "duration", duration); } }
From source file:com.google.gerrit.acceptance.GerritServer.java
License:Apache License
private static void mergeTestConfig(Config cfg) { String forceEphemeralPort = String.format("%s:0", getLocalHost().getHostName()); String url = "http://" + forceEphemeralPort + "/"; cfg.setString("gerrit", null, "canonicalWebUrl", url); cfg.setString("httpd", null, "listenUrl", url); cfg.setString("sshd", null, "listenAddress", forceEphemeralPort); cfg.setBoolean("sshd", null, "testUseInsecureRandom", true); cfg.unset("cache", null, "directory"); cfg.setString("gerrit", null, "basePath", "git"); cfg.setBoolean("sendemail", null, "enable", true); cfg.setInt("sendemail", null, "threadPoolSize", 0); cfg.setInt("cache", "projects", "checkFrequency", 0); cfg.setInt("plugins", null, "checkFrequency", 0); cfg.setInt("sshd", null, "threads", 1); cfg.setInt("sshd", null, "commandStartThreads", 1); cfg.setInt("receive", null, "threadPoolSize", 1); cfg.setInt("index", null, "threads", 1); }
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);/* www . ja v a2 s. 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.rules.GerritCommonTest.java
License:Apache License
@Before public void setUp() throws Exception { util = new Util(); load("gerrit", "gerrit_common_test.pl", new AbstractModule() { @Override/*from www .j av a 2 s.co m*/ protected void configure() { Config cfg = new Config(); cfg.setInt("rules", null, "reductionLimit", 1300); cfg.setInt("rules", null, "compileReductionLimit", (int) 1e6); bind(PrologEnvironment.Args.class) .toInstance(new PrologEnvironment.Args(null, null, null, null, null, null, cfg)); } }); local = new ProjectConfig(localKey); local.load(InMemoryRepositoryManager.newRepository(localKey)); Q.setRefPatterns(Arrays.asList("refs/heads/develop")); local.getLabelSections().put(V.getName(), V); local.getLabelSections().put(Q.getName(), Q); util.add(local); allow(local, LABEL + V.getName(), -1, +1, SystemGroupBackend.REGISTERED_USERS, "refs/heads/*"); allow(local, LABEL + Q.getName(), -1, +1, SystemGroupBackend.REGISTERED_USERS, "refs/heads/master"); }
From source file:com.google.gerrit.server.config.ConfigUtil.java
License:Apache License
/** * Store section by inspecting Java class attributes. * <p>/*from w w w . jav a2s . c o m*/ * Optimize the storage by unsetting a variable if it is * being set to default value by the server. * <p> * Fields marked with final or transient modifiers are skipped. * * @param cfg config in which the values should be stored * @param section section * @param sub subsection * @param s instance of class with config values * @param defaults instance of class with default values * @throws ConfigInvalidException */ public static <T> void storeSection(Config cfg, String section, String sub, T s, T defaults) throws ConfigInvalidException { try { for (Field f : s.getClass().getDeclaredFields()) { if (skipField(f)) { continue; } Class<?> t = f.getType(); String n = f.getName(); f.setAccessible(true); Object c = f.get(s); Object d = f.get(defaults); Preconditions.checkNotNull(d, "Default cannot be null"); if (c == null || c.equals(d)) { cfg.unset(section, sub, n); } else { if (isString(t)) { cfg.setString(section, sub, n, (String) c); } else if (isInteger(t)) { cfg.setInt(section, sub, n, (Integer) c); } else if (isLong(t)) { cfg.setLong(section, sub, n, (Long) c); } else if (isBoolean(t)) { cfg.setBoolean(section, sub, n, (Boolean) c); } else if (t.isEnum()) { cfg.setEnum(section, sub, n, (Enum<?>) c); } else { throw new ConfigInvalidException("type is unknown: " + t.getName()); } } } } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) { throw new ConfigInvalidException("cannot save values", e); } }
From source file:com.google.gerrit.server.git.ProjectConfig.java
License:Apache License
private void saveLabelSections(Config rc) { List<String> existing = Lists.newArrayList(rc.getSubsections(LABEL)); if (!Lists.newArrayList(labelSections.keySet()).equals(existing)) { // Order of sections changed, remove and rewrite them all. for (String name : existing) { rc.unsetSection(LABEL, name); }// w w w. j a va 2s . c o m } Set<String> toUnset = Sets.newHashSet(existing); for (Map.Entry<String, LabelType> e : labelSections.entrySet()) { String name = e.getKey(); LabelType label = e.getValue(); toUnset.remove(name); rc.setString(LABEL, name, KEY_FUNCTION, label.getFunctionName()); rc.setInt(LABEL, name, KEY_DEFAULT_VALUE, label.getDefaultValue()); setBooleanConfigKey(rc, name, KEY_COPY_MIN_SCORE, label.isCopyMinScore(), LabelType.DEF_COPY_MIN_SCORE); setBooleanConfigKey(rc, name, KEY_COPY_MAX_SCORE, label.isCopyMaxScore(), LabelType.DEF_COPY_MAX_SCORE); setBooleanConfigKey(rc, name, KEY_COPY_ALL_SCORES_ON_TRIVIAL_REBASE, label.isCopyAllScoresOnTrivialRebase(), LabelType.DEF_COPY_ALL_SCORES_ON_TRIVIAL_REBASE); setBooleanConfigKey(rc, name, KEY_COPY_ALL_SCORES_IF_NO_CODE_CHANGE, label.isCopyAllScoresIfNoCodeChange(), LabelType.DEF_COPY_ALL_SCORES_IF_NO_CODE_CHANGE); setBooleanConfigKey(rc, name, KEY_COPY_ALL_SCORES_IF_NO_CHANGE, label.isCopyAllScoresIfNoChange(), LabelType.DEF_COPY_ALL_SCORES_IF_NO_CHANGE); setBooleanConfigKey(rc, name, KEY_CAN_OVERRIDE, label.canOverride(), LabelType.DEF_CAN_OVERRIDE); List<String> values = Lists.newArrayListWithCapacity(label.getValues().size()); for (LabelValue value : label.getValues()) { values.add(value.format()); } rc.setStringList(LABEL, name, KEY_VALUE, values); } for (String name : toUnset) { rc.unsetSection(LABEL, name); } }
From source file:com.google.gerrit.server.query.account.AbstractQueryAccountsTest.java
License:Apache License
@ConfigSuite.Default public static Config defaultConfig() { Config cfg = new Config(); cfg.setInt("index", null, "maxPages", 10); return cfg;// w ww. j a v a 2 s.co m }
From source file:com.google.gerrit.server.query.change.AbstractQueryChangesTest.java
License:Apache License
private static Config updateConfig(Config cfg) { cfg.setInt("index", null, "maxPages", 10); return cfg;// w w w. j a v a 2 s . c o m }
From source file:com.google.gerrit.server.query.change.LuceneQueryChangesV14Test.java
License:Apache License
@Override protected Injector createInjector() { Config luceneConfig = new Config(config); InMemoryModule.setDefaults(luceneConfig); // Latest version with a Lucene 4 index. luceneConfig.setInt("index", "lucene", "testVersion", 14); return Guice.createInjector(new InMemoryModule(luceneConfig)); }
From source file:com.google.gerrit.server.query.change.LuceneQueryChangesV7Test.java
License:Apache License
protected Injector createInjector() { Config cfg = InMemoryModule.newDefaultConfig(); cfg.setInt("index", "lucene", "testVersion", 7); return Guice.createInjector(new InMemoryModule(cfg)); }