Exemplo n.º 1
0
 public String getPluginConfigString() {
   SubnodeConfiguration sObj = iniConfObj.getSection("general");
   // final Map<String,String> result=new TreeMap<String,String>();
   StringBuilder sb = new StringBuilder();
   final Iterator it = sObj.getKeys();
   while (it.hasNext()) {
     final Object key = it.next();
     final String value = sObj.getString(key.toString());
     // result.put(key.toString(),value);
     sb.append(key.toString() + "=" + value + ",");
   }
   return sb.toString().substring(0, sb.length() - 1);
   // return result;
 }
Exemplo n.º 2
0
  public static void populateConfiguration(OGraphDatabase db)
      throws IOException, ConfigurationException {
    Logger.info("Load initial configuration...");
    InputStream is;
    if (Play.application().isProd())
      is = Play.application().resourceAsStream(CONFIGURATION_FILE_NAME);
    else is = new FileInputStream(Play.application().getFile("conf/" + CONFIGURATION_FILE_NAME));
    HierarchicalINIConfiguration c = new HierarchicalINIConfiguration();
    c.setEncoding("UTF-8");
    c.load(is);
    CharSequence doubleDot = "..";
    CharSequence dot = ".";

    Set<String> sections = c.getSections();
    for (String section : sections) {
      Class en = PropertiesConfigurationHelper.configurationSections.get(section);
      if (en == null) {
        Logger.warn(section + " is not a valid configuration section, it will be skipped!");
        continue;
      }
      SubnodeConfiguration subConf = c.getSection(section);
      Iterator<String> it = subConf.getKeys();
      while (it.hasNext()) {
        String key = (it.next());
        Object value = subConf.getString(key);
        key =
            key.replace(
                doubleDot,
                dot); // bug on the Apache library: if the key contain a dot, it will be doubled!
        try {
          PropertiesConfigurationHelper.setByKey(en, key, value);
        } catch (Exception e) {
          Logger.warn(
              "Error loading initial configuration: Section "
                  + section
                  + ", key: "
                  + key
                  + ", value: "
                  + value,
              e);
        }
      }
    }
    is.close();
    Logger.info("...done");
  }