コード例 #1
0
ファイル: PluginDaemonTest.java プロジェクト: kinglcc/gerrit
 private FileBasedConfig getGerritConfigFile(SitePaths sitePath) throws IOException {
   FileBasedConfig cfg = new FileBasedConfig(sitePath.gerrit_config.toFile(), FS.DETECTED);
   if (!cfg.getFile().exists()) {
     Path etc_path = Files.createDirectories(sitePath.etc_dir);
     Files.createFile(etc_path.resolve("gerrit.config"));
   }
   return cfg;
 }
コード例 #2
0
  public IPropertyDescriptor[] getPropertyDescriptors() {
    try {
      systemConfig.load();
      userHomeConfig.load();
      repositoryConfig.load();
      effectiveConfig.load();
    } catch (IOException e) {
      showExceptionMessage(e);
    } catch (ConfigInvalidException e) {
      showExceptionMessage(e);
    }

    List<IPropertyDescriptor> resultList = new ArrayList<IPropertyDescriptor>();

    StoredConfig config;
    String category;
    String prefix;
    switch (getCurrentMode()) {
      case EFFECTIVE:
        prefix = EFFECTIVE_ID_PREFIX;
        category = UIText.RepositoryPropertySource_EffectiveConfigurationCategory;
        config = effectiveConfig;
        break;
      case REPO:
        {
          prefix = REPO_ID_PREFIX;
          String location = ""; // $NON-NLS-1$
          if (repositoryConfig instanceof FileBasedConfig) {
            location = ((FileBasedConfig) repositoryConfig).getFile().getAbsolutePath();
          }
          category =
              NLS.bind(UIText.RepositoryPropertySource_RepositoryConfigurationCategory, location);
          config = repositoryConfig;
          break;
        }
      case USER:
        {
          prefix = USER_ID_PREFIX;
          String location = userHomeConfig.getFile().getAbsolutePath();
          category =
              NLS.bind(UIText.RepositoryPropertySource_GlobalConfigurationCategory, location);
          config = userHomeConfig;
          break;
        }
      case SYSTEM:
        {
          prefix = SYSTEM_ID_PREFIX;
          String location = systemConfig.getFile().getAbsolutePath();
          category =
              NLS.bind(UIText.RepositoryPropertySource_GlobalConfigurationCategory, location);
          config = systemConfig;
          break;
        }
      default:
        return new IPropertyDescriptor[0];
    }
    for (String key : config.getSections()) {
      for (String sectionItem : config.getNames(key)) {
        String sectionId = key + "." + sectionItem; // $NON-NLS-1$
        PropertyDescriptor desc = new PropertyDescriptor(prefix + sectionId, sectionId);
        desc.setCategory(category);
        resultList.add(desc);
      }
      for (String sub : config.getSubsections(key)) {
        for (String sectionItem : config.getNames(key, sub)) {
          String sectionId = key + "." + sub + "." + sectionItem; // $NON-NLS-1$ //$NON-NLS-2$
          PropertyDescriptor desc = new PropertyDescriptor(prefix + sectionId, sectionId);
          desc.setCategory(category);
          resultList.add(desc);
        }
      }
    }

    return resultList.toArray(new IPropertyDescriptor[0]);
  }