Ejemplo n.º 1
0
  protected Properties loadProperties(String path_under_conf_dir) {

    Properties result = null;

    InputStream in = this.getClass().getResourceAsStream(PLUGIN_CONFIG_FILENAME);
    Properties properties = new Properties();

    try {
      properties.load(in);
    } catch (IOException ex) {
      logger.error(ex);
    }

    String file_path = properties.getProperty(PROP_SIPX_CONF_DIR) + path_under_conf_dir;
    logger.info("Domain config file path is  " + file_path);

    try {
      FileInputStream fis = new FileInputStream(file_path);
      result = new Properties();
      result.load(fis);

    } catch (Exception e) {
      logger.error("Failed to read '" + file_path + "':");
      System.err.println("Failed to read '" + file_path + "':");
      e.printStackTrace(System.err);
    }

    return result;
  }
Ejemplo n.º 2
0
 public void loadDatabaseConfiguration() {
   Properties props = new Properties();
   try {
     File configFile = this.getFile(this.getDataFolder() + "/database/", "MassiveDatabase.ini");
     if (!configFile.exists()) {
       configFile.createNewFile();
       props.load(new FileReader(configFile));
       props.setProperty("mysql_server_name", "localhost");
       props.setProperty("mysql_port", "");
       props.setProperty("mysql_database_name", "massive_database");
       props.setProperty("mysql_user_name", "root");
       props.setProperty("mysql_password", "");
       props.setProperty("mysql_table_prefix", "mrpg");
       props.store(new FileWriter(configFile), "Database Configurations");
     } else {
       props.load(new FileReader(configFile));
     }
     GeneralData.MySQLServerName = props.getProperty("mysql_server_name", "localhost");
     GeneralData.MySQLPort = props.getProperty("mysql_port", "");
     GeneralData.MySQLDBName = props.getProperty("mysql_database_name", "massive_database");
     GeneralData.MySQLUserName = props.getProperty("mysql_user_name", "root");
     GeneralData.MySQLPassword = props.getProperty("mysql_password", "");
     GeneralData.MySQLPrefix = props.getProperty("mysql_table_prefix", "mrpg");
   } catch (Exception ex) {
     log.log(Level.WARNING, "Unable to load MassiveDatabase.ini");
   }
 }
Ejemplo n.º 3
0
  /**
   * Initializes the settings all Settings objects will use. This should be called before any
   * setting requests. Subsequent calls replace all old settings and then Settings contains only the
   * new settings. The file {@link #DEF_SETTINGS_FILE}, if exists, is always read.
   *
   * @param propFile Path to the property file where additional settings are read from or null if no
   *     additional settings files are needed.
   * @throws SettingsError If loading the settings file(s) didn't succeed
   */
  public static void init(String propFile) throws SettingsError {
    String outFile;
    try {
      if (new File(DEF_SETTINGS_FILE).exists()) {
        Properties defProperties = new Properties();
        defProperties.load(new FileInputStream(DEF_SETTINGS_FILE));
        props = new Properties(defProperties);
      } else {
        props = new Properties();
      }
      if (propFile != null) {
        props.load(new FileInputStream(propFile));
      }
    } catch (IOException e) {
      throw new SettingsError(e);
    }

    outFile = props.getProperty(SETTING_OUTPUT_S);
    if (outFile != null) {
      if (outFile.trim().length() == 0) {
        out = System.out;
      } else {
        try {
          out = new PrintStream(new File(outFile));
        } catch (FileNotFoundException e) {
          throw new SettingsError("Can't open Settings output file:" + e);
        }
      }
    }
  }
Ejemplo n.º 4
0
 /**
  * get the value in the config.properties
  *
  * @param key
  * @return
  * @throws Exception
  */
 public synchronized String getValue(String key) {
   Properties properties = new Properties();
   String value = null;
   try {
     String filePath = getClass().getClassLoader().getResource(file).getPath();
     File configFile = new File(filePath);
     if (configFile.exists()) {
       logger.info("config file Path:" + filePath);
       FileInputStream fis = new FileInputStream(new File(filePath));
       properties.load(fis);
       fis.close();
     } else {
       properties.load(this.getClass().getClassLoader().getResourceAsStream(file));
     }
     value = (String) properties.get(key);
   } catch (FileNotFoundException e) {
     logger.error(key + " value cant find in " + file);
   } catch (IOException e) {
     logger.error(file + "  config file io exception");
   } catch (Exception e) {
     logger.error(file + "  config file get value error !");
   } finally {
     if (value == null) {
       logger.info(
           "can't get the right value of " + key + " from " + file + " , you will get null .");
     }
   }
   return value;
 }
Ejemplo n.º 5
0
 public void loadBlockConfiguration(String dataWorld) {
   Properties props = new Properties();
   try {
     // Create the file if it doesn't exist.
     File configFile =
         this.getFile(this.getDataWorldFile(dataWorld) + "/blockData/", "MassiveBlockEXP.ini");
     if (!configFile.exists()) {
       configFile.createNewFile();
       props.load(new FileReader(configFile));
       props.setProperty("blocks_num", "96");
       for (int i = 0; i < 96; i++) {
         props.setProperty(Material.getMaterial(i).name(), "0");
       }
       props.store(new FileWriter(configFile), "Block Configuration for world " + dataWorld);
     } else {
       props.load(new FileReader(configFile));
     }
     // Load the configuration.
     numBlock = Integer.parseInt(props.getProperty("blocks_num", "96"));
     for (int i = 0; i < numBlock; i++) {
       GeneralData.blockEXP.add(Integer.parseInt(props.getProperty(Integer.toString(i), "0")));
     }
   } catch (Exception ex) {
     log.log(Level.WARNING, "Unable to load MassiveBlockEXP.ini");
   }
 }
Ejemplo n.º 6
0
  /**
   * Initialize the configurations for JavaAPI
   *
   * @throws VtnServiceException the vtn service exception
   */
  private void init() throws VtnServiceException {
    LOG.trace("Start VtnServiceConfiguration#init()");
    try {
      // read and load static properties
      synchronized (appConfigProperties) {
        appConfigProperties.load(
            Thread.currentThread()
                .getContextClassLoader()
                .getResourceAsStream(VtnServiceConsts.APP_CONF_FILEPATH));
      }

      if (Thread.currentThread()
          .getContextClassLoader()
          .toString()
          .contains(VtnServiceOpenStackConsts.VTN_WEB_API_ROOT)) {
        synchronized (mapModeConfigProperties) {
          mapModeConfigProperties.load(
              Thread.currentThread()
                  .getContextClassLoader()
                  .getResourceAsStream(VtnServiceConsts.MAPMODE_CONF_FILEPATH));
        }
      }

    } catch (final IOException e) {
      VtnServiceInitManager.getExceptionHandler()
          .raise(
              Thread.currentThread().getStackTrace()[1].getClassName()
                  + VtnServiceConsts.HYPHEN
                  + Thread.currentThread().getStackTrace()[1].getMethodName(),
              UncJavaAPIErrorCode.APP_CONFIG_ERROR.getErrorCode(),
              UncJavaAPIErrorCode.APP_CONFIG_ERROR.getErrorMessage(),
              e);
    }
    LOG.trace("Complete VtnServiceConfiguration#init()");
  }
Ejemplo n.º 7
0
 public Properties searchForVersionProperties() {
   try {
     FMLLog.log(
         getModId(),
         Level.FINE,
         "Attempting to load the file version.properties from %s to locate a version number for %s",
         getSource().getName(),
         getModId());
     Properties version = null;
     if (getSource().isFile()) {
       ZipFile source = new ZipFile(getSource());
       ZipEntry versionFile = source.getEntry("version.properties");
       if (versionFile != null) {
         version = new Properties();
         version.load(source.getInputStream(versionFile));
       }
       source.close();
     } else if (getSource().isDirectory()) {
       File propsFile = new File(getSource(), "version.properties");
       if (propsFile.exists() && propsFile.isFile()) {
         version = new Properties();
         FileInputStream fis = new FileInputStream(propsFile);
         version.load(fis);
         fis.close();
       }
     }
     return version;
   } catch (Exception e) {
     Throwables.propagateIfPossible(e);
     FMLLog.log(getModId(), Level.FINEST, "Failed to find a usable version.properties file");
     return null;
   }
 }
Ejemplo n.º 8
0
  static {
    try {
      // 判断是否是生产环境的开关,1:加载生产环境的配置,0:加在测试环境的配置
      InputStream in =
          MySQLHelper.class.getClassLoader().getResourceAsStream("/config/switch.properties");
      properties.load(in);
      isProduction = properties.getProperty("isProduction");
      properties.clear();

      if ("1".equals(isProduction)) {
        in = MySQLHelper.class.getResourceAsStream("/config/db/jdbc_prod.properties");
      } else {
        in = MySQLHelper.class.getResourceAsStream("/config/db/jdbc_test.properties");
      }
      // InputStream  in=MySQLHelper.class.getResourceAsStream("/system_test.properties");
      properties.load(in);
      driver = properties.getProperty("mydb.driverClass");
      url = properties.getProperty("mydb.url");
      user = properties.getProperty("mydb.username");
      password = properties.getProperty("mydb.password");
      properties.clear();

      Class.forName(driver);

    } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException("failed to connect to MySQL");
    }
  }
Ejemplo n.º 9
0
  @Test
  public void testImplicitExplicitTemplate() throws IOException {
    final Invocation.Builder request = target("implicit-explicit").request();

    Properties p = new Properties();
    p.load(request.get(InputStream.class));
    assertEquals(
        "/org/glassfish/jersey/tests/e2e/server/mvc/FlatViewProcessorTest.ImplicitExplicitTemplate.index.testp",
        p.getProperty("path"));
    assertEquals("ImplicitExplicitTemplate", p.getProperty("model"));

    p = new Properties();
    p.load(request.post(Entity.entity("", MediaType.TEXT_PLAIN_TYPE), InputStream.class));
    assertEquals(
        "/org/glassfish/jersey/tests/e2e/server/mvc/FlatViewProcessorTest.ImplicitExplicitTemplate.show.testp",
        p.getProperty("path"));
    assertEquals("post", p.getProperty("model"));

    p = new Properties();
    p.load(target("implicit-explicit").path("sub").request().get(InputStream.class));
    assertEquals(
        "/org/glassfish/jersey/tests/e2e/server/mvc/FlatViewProcessorTest.ImplicitExplicitTemplate.show.testp",
        p.getProperty("path"));
    assertEquals("get", p.getProperty("model"));
  }
    private void loadOpenSSL(String password) throws IOException {

      if (!mStoreFile.exists()) return;

      if (mStoreFile.length() == 0) return;

      FileInputStream fis = null;
      OpenSSLPBEInputStream encIS = null;
      try {

        fis = new FileInputStream(mStoreFile);

        // Decrypt the bytes
        encIS = new OpenSSLPBEInputStream(fis, STORE_ALGORITHM, 1, password.toCharArray());
        mProperties.load(encIS);
      } catch (IllegalArgumentException iae) {
        // might be a unicode character in the password
        encIS =
            new OpenSSLPBEInputStream(
                fis, STORE_ALGORITHM, 1, Base64.encodeBytes(password.getBytes()).toCharArray());
        mProperties.load(encIS);

      } catch (FileNotFoundException fnfe) {
        OtrDebugLogger.log("Properties store file not found: First time?");
        mStoreFile.getParentFile().mkdirs();
      } finally {
        encIS.close();
        fis.close();
      }
    }
Ejemplo n.º 11
0
  public static Properties getProperties() {
    if (properties == null) {
      try {
        URL url = null;

        url = getResourceURL("kr/co/petmd/allpet.properties");

        if (url != null) {
          InputStream is = url.openStream();
          properties = new Properties();
          properties.load(is);
          is.close();

          if (properties.containsKey("content.reference.url")) {
            String realFileURL = (String) properties.get("content.reference.url");
            is = new URL(realFileURL).openStream();
            properties.load(is);
            is.close();
          }

          System.out.println("Loading " + url);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    return properties;
  }
  public DriverScript() throws IOException, NoSuchMethodException, RuntimeException {

    Keywords = new Keywords();
    method = Keywords.getClass().getMethods();
    capturescreenShot_method =
        Keywords.getClass().getMethod("captureScreenshot", String.class, String.class);

    // properties file initilization
    CONFIG = new Properties();
    FileInputStream fs =
        new FileInputStream(
            System.getProperty("user.dir") + "//src//com//qtpselenium//config//config.properties");
    // CONFIG= new Properties();
    CONFIG.load(fs);

    OR = new Properties();
    fs =
        new FileInputStream(
            System.getProperty("user.dir") + "//src//com//qtpselenium//config//OR.poperties");
    // OR= new Properties();
    OR.load(fs);

    // System.out.print(data + "data from OR is "+ CONFIG.getProperty("sign_in_button") +" OR prop
    // for browser in keywords.java \n" );

  }
Ejemplo n.º 13
0
 public void testTranslationKeyExistence() throws IOException {
   // use English version as the reference:
   final File englishFile = getEnglishTranslationFile();
   final Properties enProps = new Properties();
   enProps.load(new FileInputStream(englishFile));
   final Set<Object> englishKeys = enProps.keySet();
   for (Language lang : Language.REAL_LANGUAGES) {
     if (lang.getShortName().equals("en")) {
       continue;
     }
     final Properties langProps = new Properties();
     final File langFile = getTranslationFile(lang);
     if (!langFile.exists()) {
       continue;
     }
     try (FileInputStream stream = new FileInputStream(langFile)) {
       langProps.load(stream);
       final Set<Object> langKeys = langProps.keySet();
       for (Object englishKey : englishKeys) {
         if (!langKeys.contains(englishKey)) {
           System.err.println("***** No key '" + englishKey + "' in file " + langFile);
         }
       }
     }
   }
 }
Ejemplo n.º 14
0
  @Test
  public void loadProperties() {
    Properties cacheProps = new Properties();
    String cachePath = "hibernate-redis.properties";
    try {
      log.info("Loading cache properties... path=[{}]", cachePath);

      // NOTE: getClass().getResourceAsStream() 과 getClassLoader().getResourceAsStream() 의 경로 해석이
      // 다르다.
      // NOTE: getClass() 는 "/" 를 넣어야 하고, getClassLoader() 는 "/" 이 없어야 한다.
      cachePath = "/hibernate-redis.properties";
      InputStream is1 = getClass().getResourceAsStream(cachePath);
      assertThat(is1).isNotNull();
      cacheProps.load(is1);

      System.out.println("properties... " + cacheProps.toString());

      cachePath = "hibernate-redis.properties";
      InputStream is2 = PropertiesTest.class.getClassLoader().getResourceAsStream(cachePath);
      assertThat(is2).isNotNull();
      cacheProps.load(is2);

      System.out.println("properties... " + cacheProps.toString());

    } catch (Exception e) {
      log.warn("Cache용 환경설정 정보를 로드하는데 실패했습니다. cachePath=" + cachePath, e);
    }
  }
Ejemplo n.º 15
0
  static {
    File defaultConf = new File(CONF + File.separator + DEFAULT_CONF);
    File lastUsedConf = new File(CONF + File.separator + LAST_USED_CONF);

    if (defaultConf.exists()) {
      try {
        BufferedReader defaultOne =
            new BufferedReader(new BufferedReader(new FileReader(defaultConf)));
        Properties properties = new Properties();
        properties.load(defaultOne);
        log.info("default properties: " + properties);
        if (lastUsedConf.exists()) {

          BufferedReader usedOne =
              new BufferedReader(new BufferedReader(new FileReader(lastUsedConf)));
          properties.load(usedOne);
          log.info("after merging in last used conf:" + properties);
        } else {
          log.info("last used conf:" + LAST_USED_CONF + " does not exist");
        }
      } catch (FileNotFoundException e) {
        // ignored
      } catch (IOException e) {
        // ignored
      }
    }
  }
  static {
    // load mappings from resources
    attributeMappings = (Map) readResourceFromXML("/roadarcs.xml");

    InputStream aggregationStream = null;
    InputStream bersaglioStream = null;
    try {
      aggregationStream = ArcsIngestionProcess.class.getResourceAsStream("/aggregation.properties");
      bersaglioStream = ArcsIngestionProcess.class.getResourceAsStream("/bersaglio.properties");
      aggregation.load(aggregationStream);
      bersaglio.load(bersaglioStream);
    } catch (IOException e) {
      LOGGER.error("Unable to load configuration: " + e.getMessage(), e);
    } finally {
      try {
        if (bersaglioStream != null) {
          bersaglioStream.close();
        }
      } catch (IOException e) {
        LOGGER.error(e.getMessage(), e);
      }
      try {
        if (aggregationStream != null) {
          aggregationStream.close();
        }
      } catch (IOException e) {
        LOGGER.error(e.getMessage(), e);
      }
    }
  }
Ejemplo n.º 17
0
  /**
   * Method to return the Persistence Properties from the specified file.
   *
   * @param filename Name of the file containing the properties
   * @return the Persistence Properties in this file
   * @throws NucleusUserException if file not readable
   */
  public static synchronized Properties setPropertiesUsingFile(String filename) {
    if (filename == null) {
      return null;
    }

    // try to load the properties file
    Properties props = new Properties();
    File file = new File(filename);
    if (file.exists()) {
      try {
        InputStream is = new FileInputStream(file);
        props.load(is);
        is.close();
      } catch (FileNotFoundException e) {
        throw new NucleusUserException(Localiser.msg("008014", filename), e).setFatal();
      } catch (IOException e) {
        throw new NucleusUserException(Localiser.msg("008014", filename), e).setFatal();
      }
    } else {
      // Try to load it as a resource in the CLASSPATH
      try {
        InputStream is = Configuration.class.getClassLoader().getResourceAsStream(filename);
        props.load(is);
        is.close();
      } catch (Exception e) {
        // Still not loadable so throw exception
        throw new NucleusUserException(Localiser.msg("008014", filename), e).setFatal();
      }
    }

    return props;
  }
Ejemplo n.º 18
0
 public static Container setup() throws IOException {
   Properties properties = new Properties();
   File revProps = new File("revenj.properties");
   if (revProps.exists() && revProps.isFile()) {
     properties.load(new FileReader(revProps));
   } else {
     String location = System.getProperty("revenj.properties");
     if (location != null) {
       revProps = new File(location);
       if (revProps.exists() && revProps.isFile()) {
         properties.load(new FileReader(revProps));
       } else {
         throw new IOException(
             "Unable to find revenj.properties in alternative location. Searching in: "
                 + revProps.getAbsolutePath());
       }
     } else {
       throw new IOException(
           "Unable to find revenj.properties. Searching in: " + revProps.getAbsolutePath());
     }
   }
   String plugins = properties.getProperty("revenj.pluginsPath");
   File pluginsPath = null;
   if (plugins != null) {
     File pp = new File(plugins);
     pluginsPath = pp.isDirectory() ? pp : null;
   }
   return setup(
       dataSource(properties),
       properties,
       Optional.ofNullable(pluginsPath),
       Optional.ofNullable(Thread.currentThread().getContextClassLoader()));
 }
 private GlobalConfiguration() {
   try {
     settings.load(getClass().getResourceAsStream("/" + CONFIG_FILE));
   } catch (IOException e) {
     logger.error("Cannot load default settings!", e);
   }
   try {
     logger.debug("Reading configuration file " + CONFIG_FILE);
     settings.load(new FileInputStream(CONFIG_FILE));
   } catch (IOException e) {
     logger.warn("Cannot load configuration file, using defaults");
   }
   try {
     logger.debug(
         "Trying to read configuation file for dataset in "
             + getString(SettingsKeys.DATA_FILES_DIRECTORY));
     settings.load(
         new FileInputStream(
             concatenateDirWithFileName(
                 getString(SettingsKeys.DATA_FILES_DIRECTORY), CONFIG_FILE)));
     logger.debug("Loaded successfully");
   } catch (IOException e) {
     logger.debug("Not found, doesn't matter...");
   }
 }
Ejemplo n.º 20
0
  /**
   * Build a PDF report for the Sonar project on "sonar.base.url" instance of Sonar. The property
   * "sonar.base.url" is set in report.properties, this file will be provided by the artifact
   * consumer.
   *
   * <p>The key of the project is not place in properties, this is provided in execution time.
   *
   * @throws ReportException
   */
  @Test(
      enabled = true,
      groups = {"report"},
      dependsOnGroups = {"metrics"})
  public void getReportTest()
      throws DocumentException, IOException, org.dom4j.DocumentException, ReportException {
    URL resource = this.getClass().getClassLoader().getResource("report.properties");
    Properties config = new Properties();
    config.load(resource.openStream());
    config.setProperty("sonar.base.url", "http://localhost:9000");

    URL resourceText = this.getClass().getClassLoader().getResource("report-texts-en.properties");
    Properties configText = new Properties();
    configText.load(resourceText.openStream());

    PDFReporter reporter =
        new TeamWorkbookPDFReporter(
            this.getClass().getResource("/sonar.png"),
            "org.apache.struts:struts-parent",
            "http://localhost:9000",
            config,
            configText);

    ByteArrayOutputStream baos = reporter.getReport();
    FileOutputStream fos = null;

    fos = new FileOutputStream("target/testReport.pdf");

    baos.writeTo(fos);
    fos.flush();
    fos.close();
  }
  private static String load(String currentLanguage) {

    defaultMappings.clear();
    mappings.clear();

    try {
      InputStream langStream =
          InvTweaksLocalization.class.getResourceAsStream(
              "lang/" + currentLanguage + ".properties");
      InputStream defaultLangStream =
          InvTweaksLocalization.class.getResourceAsStream(
              "lang/" + DEFAULT_LANGUAGE + ".properties");

      mappings.load((langStream == null) ? defaultLangStream : langStream);
      defaultMappings.load(defaultLangStream);

      if (langStream != null) {
        langStream.close();
      }
      defaultLangStream.close();
    } catch (Exception e) {
      e.printStackTrace();
    }

    return currentLanguage;
  }
  public void run() {
    try {
      vLogger.LogInfo("emcWorldDownloader: Start up");
      Properties prop = new Properties();
      File fecsconfig = new File("/mosaic/setting/ecsconfig.properties");
      if (fecsconfig.exists()) {
        vLogger.LogInfo("emcWorldDownloader: Read Conf file from mosaic folder");
        prop.load(new FileInputStream(fecsconfig));
      } else {
        vLogger.LogInfo("emcWorldDownloader: Read Conf file from local folder");
        ClassLoader classLoader = getClass().getClassLoader();
        prop.load(new FileInputStream(classLoader.getResource("ecsconfig.properties").getFile()));
      }

      S3_ACCESS_KEY_ID = prop.getProperty("username");
      S3_SECRET_KEY = prop.getProperty("password");
      S3_ENDPOINT = prop.getProperty("proxy");

      SWIFT_ACCESS_KEY_ID = prop.getProperty("swiftusername");
      SWIFT_SECRET_KEY = prop.getProperty("swiftpassword");
      SWIFT_ENDPOINT = prop.getProperty("swiftproxy");
      SWIFT_BUCKET = prop.getProperty("swiftcollectbucket");

      S3_BUCKET = prop.getProperty("s3collectbucket");
      LOCAL_DIR = prop.getProperty("emclocal");

      PROTOCOL = prop.getProperty("objectType");
      if (PROTOCOL.equals("S3")) DownloadUsingS3();
      else DownloadUsingSWIFT();

    } catch (Exception e) {
      vLogger.LogError("emcWorldDownloader:" + e.getMessage());
      e.printStackTrace();
    }
  }
  private static Properties loadPropertiesFile(String propertiesFilePath) {
    File propertiesFile = new File(propertiesFilePath);
    Properties clientProperties = new Properties();
    FileInputStream in;
    try {
      in = new FileInputStream(propertiesFile);
      clientProperties.load(in);
      in.close();
    } catch (FileNotFoundException e) {

      InputStream stream =
          SampleRasPiDMAgent.class.getClass().getResourceAsStream(PROPERTIES_FILE_NAME);
      try {
        clientProperties.load(stream);
      } catch (IOException e1) {
        System.err.println(
            "Could not find file "
                + PROPERTIES_FILE_NAME
                + " Please run the application with file specified as an argument");
        System.exit(-1);
      }

      return clientProperties;
    } catch (IOException e) {
      e.printStackTrace();
      System.err.println(
          "Could not find file "
              + PROPERTIES_FILE_NAME
              + " Please run the application with file specified as an argument");
      System.exit(-1);
    }
    return clientProperties;
  }
Ejemplo n.º 24
0
  private static void initializeProperties() throws IOException, FileNotFoundException {
    {
      // Default properties are in resource 'one-jar.properties'.
      Properties properties = new Properties();
      String props = "one-jar.properties";
      InputStream is = Boot.class.getResourceAsStream("/" + props);
      if (is != null) {
        LOGGER.info("loading properties from " + props);
        properties.load(is);
      }

      // Merge in anything in a local file with the same name.
      if (new File(props).exists()) {
        is = new FileInputStream(props);
        if (is != null) {
          LOGGER.info("merging properties from " + props);
          properties.load(is);
        }
      }

      // Set system properties only if not already specified.
      Enumeration _enum = properties.propertyNames();
      while (_enum.hasMoreElements()) {
        String name = (String) _enum.nextElement();
        if (System.getProperty(name) == null) {
          System.setProperty(name, properties.getProperty(name));
        }
      }
    }
  }
Ejemplo n.º 25
0
 public void loadGeneralWorldConfiguration() {
   Properties props = new Properties();
   try {
     File configFile = new File(this.getDataFolder(), "MassiveWorldProperties.ini");
     if (!configFile.exists()) {
       configFile.createNewFile();
       props.load(new FileReader(configFile));
       props.setProperty("worlds_enabled", "world,nether");
       props.store(new FileWriter(configFile), "General Server Configurations");
     } else {
       props.load(new FileReader(configFile));
     }
     // I know, not very effective way of removing white space characters, but this allows for more
     // dynamic specifications
     String[] worlds =
         props.getProperty("worlds_enabled", "world,nether").replace(" ", "").split(",");
     for (String world : worlds) {
       if (this.getServer().getWorld(world) != null) {
         this.worlds.add(world);
       }
     }
   } catch (Exception ex) {
     log.log(Level.WARNING, "Unable to read MassiveProperties.ini");
   }
 }
Ejemplo n.º 26
0
  private void initProperties(ITestContext context) {
    LOGGER.info("Initializing config.properties");
    PROPS = new Properties();
    try {
      WORKING_DIRECTORY = System.getProperty("user.dir");
      LOGGER.info("Working Directory = " + System.getProperty("user.dir"));
      try {
        String configFile = context.getCurrentXmlTest().getParameter(CONFIG_FILE_NAME);
        PROPS.load(new FileInputStream(configFile));
      } catch (NullPointerException e) {
        LOGGER.warn(
            "could not find the config file name in the xml suite, going to use the default "
                + CONFIG_FILE);
        try {
          String configFile = CONFIG_FILE;
          PROPS.load(new FileInputStream(configFile));
        } catch (NullPointerException e2) {
          LOGGER.fatal("could not find the default config file in the project");
        }
      }

    } catch (IOException e) {
      LOGGER.fatal("There was a problem to load the config file from " + CONFIG_FILE);
      e.printStackTrace();
    }
    VERSION = PROPS.getProperty(PROPERTIES.VERSION.name());
    PLATFORM = PROPS.getProperty(PROPERTIES.PLATFORM.name());
    BROWSER = PROPS.getProperty(PROPERTIES.BROWSER.name());
    LOCALE = PROPS.getProperty(PROPERTIES.LOCALE.name());
    SERVER = PROPS.getProperty(PROPERTIES.SERVER.name());
    LOGGER_LEVEL = PROPS.getProperty(PROPERTIES.LOGGER_LEVEL.name());
    LOGGER.info("Finished to initialize properties");
  }
  /** Load config. */
  private void loadConfig() {
    try {

      if (properties.isEmpty()) {
        URL url = new URL(this.getCodeBase(), Constants.FTP_CONFIG_FILE_NAME);
        URLConnection uc = url.openConnection();
        properties.load(uc.getInputStream());
      }

      List<FtpConfig> ftpConfigs =
          JSON.parseObject(
              properties.getProperty(Constants.FTP_CONFIGS),
              new TypeReference<List<FtpConfig>>() {});
      int cfgIndex = (int) (Math.random() * (ftpConfigs.size() - 1));
      this.ftpConfig = ftpConfigs.get(cfgIndex);
      this.separator = ftpConfig.getOs() == OS.WINDOWS ? "\\" : "/";

      if (messageSource.isEmpty()) {
        URL murl = new URL(this.getCodeBase(), Constants.MESSAGE_SOURCE_NAME);
        URLConnection muc = murl.openConnection();
        messageSource.load(muc.getInputStream());
      }
    } catch (IOException e) {
      JOptionPane.showMessageDialog(this, getMessage(MessageCode.FTP_CONFIG_ERROR));
    }
  }
Ejemplo n.º 28
0
  public static void main(String[] str) {
    Project project = new Project();

    RawSequences rawSequences =
        (new com.bugaco.mioritic.impl.data.raw.RawSequencesFactory()).createRawSequences();
    com.bugaco.mioritic.model.data.sequences.Sequences seqs =
        (new com.bugaco.mioritic.impl.data.sequences.SequencesFactory()).createSequences();
    com.bugaco.mioritic.model.data.distancematrix.DistanceMatrix distanceMatrix =
        new com.bugaco.mioritic.impl.data.distancematrix.DistanceMatrix();
    com.bugaco.mioritic.model.data.clusters.Clusters clusters =
        new com.bugaco.mioritic.impl.data.clusters.Clusters();

    com.bugaco.ui.models.AlgorithmModel algModelSeq =
        new com.bugaco.ui.models.impl.DefaultAlgorithmModel();
    algModelSeq.setText("Select file format:");
    try {
      Properties p = new Properties();
      p.load(algModelSeq.getClass().getResourceAsStream("/conf/SequenceImporter.properties"));
      System.err.println(p);
      algModelSeq.setItemsFromProperties(p);
    } catch (Exception e) {
      e.printStackTrace();
    }
    // algModelSeq.addElement( new com.bugaco.ui.models.impl.DefaultAlgorithmItem( "Fasta" ,
    // "com.bugaco.mioritic.impl.algorithm.rawcompiler.FastaCompilerFactory" ) ) ;
    // algModelSeq.addElement( new com.bugaco.ui.models.impl.DefaultAlgorithmItem( "Nexus" ,
    // "com.bugaco.mioritic.impl.algorithm.rawcompiler.NexusCompilerFactory" ) ) ;

    com.bugaco.ui.models.AlgorithmModel algModelDM =
        new com.bugaco.ui.models.impl.DefaultAlgorithmModel();
    algModelDM.setText("Select algorithm:");
    try {
      Properties p = new Properties();
      p.load(algModelDM.getClass().getResourceAsStream("/conf/DistanceCompiler.properties"));
      algModelDM.setItemsFromProperties(p);
    } catch (Exception e) {
      e.printStackTrace();
    }
    // algModelDM.addElement( new com.bugaco.ui.models.impl.DefaultAlgorithmItem( "Simple" ,
    // "com.bugaco.mioritic.impl.algorithm.distancematrix.VerySimpleCompilerFactory" ) ) ;

    com.l2fprod.common.swing.JTaskPane taskPane = new com.l2fprod.common.swing.JTaskPane();
    taskPane.add(project.projectFeedback(5000));
    taskPane.add(
        project.sequenceBuilder(
            new com.bugaco.mioritic.impl.module.sequencebuilder.SequenceBuilderFactory(),
            rawSequences,
            seqs,
            algModelSeq));
    taskPane.add(project.distanceMatrixBuilder(seqs, distanceMatrix, algModelDM));
    taskPane.add(project.clusterBuilder(distanceMatrix, clusters));
    taskPane.add(project.multiClusterStatistics(seqs, distanceMatrix, clusters));

    javax.swing.JFrame frame = project.getMainFrame(taskPane);

    if (!project.acceptLicense(taskPane)) {
      frame.setVisible(false);
      frame = null;
    }
  }
Ejemplo n.º 29
0
  public static Properties loadProperties(Class<?> clazz, String name, String extraProperty)
      throws IOException {
    Closer closer = Closer.create();
    Properties prop = new Properties();
    try {
      InputStream in = closer.register(clazz.getResourceAsStream(name));
      prop.load(in);
      String extraPath = System.getProperty(extraProperty);
      if (extraPath != null) {
        log.info(
            "Loading extra properties for "
                + clazz.getCanonicalName()
                + ":"
                + name
                + " from "
                + extraPath
                + "...");
        in =
            closer.register(
                new BufferedInputStream(closer.register(new FileInputStream(extraPath))));
        prop.load(in);
      }
    } finally {
      closer.close();
    }

    return prop;
  }
Ejemplo n.º 30
0
  /** * Loads in all the localization files from the Localizations library class */
  public static void loadConfig() {
    config = new TagFile();
    InputStream var0 =
        Harmonion.class.getResourceAsStream("/net/Harmonion/client/lang/default.cfg");
    config.readStream(var0);
    File var1;

    if (configDir == null) {
      var1 = Loader.instance().getConfigDir();
      var1 = new File(var1, "/Harmonion/");
      var1.mkdir();
      configDir = var1;
      configFile = new File(var1, "Harmonion.cfg");
    }

    if (configFile.exists()) {
      config.readFile(configFile);
    }

    config.commentFile("Harmonion Configuration");
    String var2;
    Iterator var4;

    for (var4 = config.query("blocks.%.%.id").iterator();
        var4.hasNext();
        reservedIds[config.getInt(var2)] = true) {
      var2 = (String) var4.next();
    }

    for (var4 = config.query("items.%.%.id").iterator();
        var4.hasNext();
        reservedIds[config.getInt(var2) + 256] = true) {
      var2 = (String) var4.next();
    }

    if (hmcTranslateTable == null) {
      hmcTranslateTable = new Properties();
    }

    try {
      hmcTranslateTable.load(
          Harmonion.class.getResourceAsStream("/net/Harmonion/client/lang/Harmonion.lang"));
      var1 = new File(configDir, "Harmonion.lang");

      if (var1.exists()) {
        FileInputStream var5 = new FileInputStream(var1);
        hmcTranslateTable.load(var5);
      }
    } catch (IOException var3) {
      var3.printStackTrace();
    }
    var4 = hmcTranslateTable.entrySet().iterator();

    while (var4.hasNext()) {
      Entry var6 = (Entry) var4.next();
      LanguageRegistry.instance()
          .addStringLocalization((String) var6.getKey(), (String) var6.getValue());
    }
  }