@Override public List<MenuEntry> getEntries() { if (cfg == null || cfgSnapshot.isModified(cfgFile)) { cfgSnapshot = FileSnapshot.save(cfgFile); cfg = new FileBasedConfig(cfgFile, FS.DETECTED); try { cfg.load(); } catch (ConfigInvalidException | IOException e) { return Collections.emptyList(); } } List<MenuEntry> menuEntries = new ArrayList<>(); for (String url : cfg.getSubsections(SECTION_MENU_ITEM)) { String name = cfg.getString(SECTION_MENU_ITEM, url, KEY_NAME); if (Strings.isNullOrEmpty(name)) { continue; } String topMenu = cfg.getString(SECTION_MENU_ITEM, url, KEY_TOP_MENU); if (topMenu == null) { topMenu = DEFAULT_TOP_MENU; } String target = cfg.getString(SECTION_MENU_ITEM, url, KEY_TARGET); String id = cfg.getString(SECTION_MENU_ITEM, url, KEY_ID); menuEntries.add( new MenuEntry(topMenu, Collections.singletonList(new MenuItem(name, url, target, id)))); } return menuEntries; }
private static String getSecureStoreClassFromGerritConfig(SitePaths sitePaths) { FileBasedConfig cfg = new FileBasedConfig(sitePaths.gerrit_config.toFile(), FS.DETECTED); try { cfg.load(); } catch (IOException | ConfigInvalidException e) { throw new RuntimeException("Cannot read gerrit.config file", e); } return cfg.getString("gerrit", null, "secureStoreClass"); }