List of usage examples for org.eclipse.jgit.storage.file FileBasedConfig getEnum
public <T extends Enum<?>> T getEnum(final String section, final String subsection, final String name, final T defaultValue)
From source file:com.google.gerrit.lucene.IndexVersionCheck.java
License:Apache License
@Override public void start() { File file = gerritIndexConfig(sitePaths); try {/*from w w w. j ava 2 s. c o m*/ FileBasedConfig cfg = new FileBasedConfig(file, FS.detect()); cfg.load(); for (Map.Entry<String, Integer> e : SCHEMA_VERSIONS.entrySet()) { int schemaVersion = cfg.getInt("index", e.getKey(), "schemaVersion", 0); if (schemaVersion != e.getValue()) { throw new ProvisionException( String.format("wrong index schema version for \"%s\": expected %d, found %d%s", e.getKey(), e.getValue(), schemaVersion, upgrade())); } } @SuppressWarnings("deprecation") Version luceneVersion = cfg.getEnum("lucene", null, "version", LUCENE_CURRENT); if (luceneVersion != LUCENE_VERSION) { throw new ProvisionException(String.format("wrong Lucene version: expected %d, found %d%s", luceneVersion, LUCENE_VERSION, upgrade())); } } catch (IOException e) { throw new ProvisionException("unable to read " + file); } catch (ConfigInvalidException e) { throw new ProvisionException("invalid config file " + file); } }