Ejemplo n.º 1
0
  public UserStore(String nombre, PropertiesConfiguration configuration) {
    BasicDataSource ds = null;
    String driver = configuration.getString("userstore.driver");
    if (driver != null) {
      ds = new BasicDataSource();
      ds.setDriverClassName(driver);
      ds.setUrl(configuration.getString("userstore.url"));
      ds.setUsername(configuration.getString("userstore.username"));
      ds.setPassword(configuration.getString("userstore.password"));
      ds.setMaxActive(configuration.getInt("userstore.maxActive"));
      ds.setMinIdle(configuration.getInt("userstore.minIdle"));
      ds.setMaxWait(configuration.getInt("userstore.maxWait"));
    }
    this.dataSource = ds;
    System.out.println(ds);
    this.selectUser = configuration.getString("userstore.selectUser");
    this.encoding = configuration.getString("userstore.encoding");
    String algorithm = configuration.getString("userstore.algorithm");
    if (algorithm != null && !algorithm.isEmpty()) {
      try {
        messageDigest = MessageDigest.getInstance(algorithm);
      } catch (NoSuchAlgorithmException algorithmException) {

        System.out.println(
            "Algoritmo " + algorithm + "no encontrado... no se cifrararan los passwords");
        messageDigest = null;
      }
      this.nombre = nombre;
    }
  }
  @Override
  public SystemConfiguration getSystemConfiguration() {

    // Create a new SystemConfiguration by reading out the parameters in the config file
    logger.trace("Loading System Configuration");
    SystemConfiguration systemConfiguration = new SystemConfiguration();
    systemConfiguration.setThreadPoolSize(
        propertiesConfiguration.getInt(PropertiesConfigurationEntries.THREAD_POOL_SIZE));
    systemConfiguration.setDaemonThreadTimer(
        propertiesConfiguration.getInt(PropertiesConfigurationEntries.SYSTEM_DAEMON_TIMER));

    return systemConfiguration;
  }
Ejemplo n.º 3
0
 /**
  * Gets the int attribute of the Config class or default value if not found.
  *
  * @param key name of the property name.
  * @param defaultValue to use if property not found.
  * @return The int value or default value if not found.
  */
 public int getInt(String key, int defaultValue) {
   int value = 0;
   if (config != null) {
     value = config.getInt(key, defaultValue);
   } else {
     String warn = "getInt invalid config, can't read prop [" + key + "]";
     LOG.warn(warn);
   }
   return value;
 }
Ejemplo n.º 4
0
 protected void readConfig() throws ConfigurationException {
   PropertiesConfiguration config = new PropertiesConfiguration(confPath);
   logstashConfPath = config.getString("logstash.conf.path");
   templatePath = config.getString("logstash.conf.template");
   redisHost = config.getString("logstash.redis.host");
   elasticSearchHost = config.getString("logstash.elasticsearch.host");
   elasticSearchHttpPort = config.getInt("logstash.elasticsearch.http-port");
   LOGGER.debug("host is " + elasticSearchHost);
   LOGGER.debug("http port is " + elasticSearchHttpPort);
 }
Ejemplo n.º 5
0
  // Loads the settings from config file. If no values defined, the deafult values are returned.
  public static Settings loadSettings() {
    config.setListDelimiter('|');
    Settings s = new Settings();
    try {
      config.load("vidor.config");
    } catch (ConfigurationException ex) {
      ex.printStackTrace();
    }

    s.setVlcLocation(config.getString("vlclocation", ""));
    s.setThumbnailCount(config.getInt("thumbnailcount", 10));
    s.setThumbnailWidth(config.getInt("thumbnailwidth", 200));
    s.setThumbnailHighlightColor(config.getString("thumbnailhighlightcolor", ""));

    List<String> f = new ArrayList(Arrays.asList(config.getStringArray("folders")));
    if (!f.get(0).trim().isEmpty()) { // Bug fix - Empty folder check
      s.setFolders(f);
    }

    return s;
  }
Ejemplo n.º 6
0
  static {
    try {
      solenoidValvesOfInterest.add(Double.valueOf(0.0));
      solenoidValvesOfInterest.add(Double.valueOf(1.0));
      solenoidValvesOfInterest.add(Double.valueOf(2.0));
      solenoidValvesOfInterest.add(Double.valueOf(4.0));
      solenoidValvesOfInterest.add(Double.valueOf(8.0));
      solenoidValvesOfInterest.add(Double.valueOf(16.0));

      allSolenoidValves.add(Double.valueOf(0.0));
      allSolenoidValves.add(Double.valueOf(1.0));
      allSolenoidValves.add(Double.valueOf(2.0));
      allSolenoidValves.add(Double.valueOf(4.0));
      allSolenoidValves.add(Double.valueOf(8.0));
      allSolenoidValves.add(Double.valueOf(16.0));

      configuration = new PropertiesConfiguration(FileConfiguration.getConfigurationFile());
      configuration.setAutoSave(true);

      if (!JarUtil.isRunningOnWindows7()) {
        inputFolder = new File(configuration.getString(FileConfiguration.INPUT_FOLDER, "input"));
        outputFolder = new File(configuration.getString(FileConfiguration.OUTPUT_FOLDER, "output"));
        temperatureInputFolder =
            new File(configuration.getString(FileConfiguration.TEMPERATURE_FOLDER, "input/temp"));
      } else {
        File userDir = JarUtil.getPlantEvaluationUserHomeDir();
        inputFolder =
            new File(
                configuration.getString(
                    FileConfiguration.INPUT_FOLDER, userDir.getAbsolutePath() + "/input"));
        outputFolder =
            new File(
                configuration.getString(
                    FileConfiguration.OUTPUT_FOLDER, userDir.getAbsolutePath() + "/output"));
        temperatureInputFolder =
            new File(
                configuration.getString(
                    FileConfiguration.TEMPERATURE_FOLDER,
                    userDir.getAbsolutePath() + "/input/temp"));
      }

      if (!inputFolder.exists()) inputFolder.mkdir();
      if (!outputFolder.exists()) outputFolder.mkdir();
      if (!temperatureInputFolder.exists()) temperatureInputFolder.mkdir();

      TypeAEvaluationOptions.shiftByOneHour =
          configuration.getBoolean(TypeAEvaluationOptions.OPTION_SHIFT_BY_ONE_HOUR, false);
      TypeAEvaluationOptions.recordReferenceValve =
          configuration.getBoolean(TypeAEvaluationOptions.OPTIONS_RECORD_REFERENCE_VALVE, false);
      TypeAEvaluationOptions.sampleRate =
          configuration.getDouble(TypeAEvaluationOptions.OPTIONS_SAMPLE_RATE, 10.0);

      solenoidValvesOfInterest =
          configuration.getList(
              Options.OPTIONS_SOLENOID_VALVES_OF_INTEREST, solenoidValvesOfInterest);

      checkSolenoidValves();

      // options for co2 absolute only evaluation
      CO2AbsoluteOnlyEvaluationOptions.isAutoScaleCO2Absolute =
          configuration.getBoolean(
              CO2AbsoluteOnlyEvaluationOptions.OPTIONS_CO2_ABSOLUTE_IS_CO2_ABSOLUTE_AUTOSCALE,
              true);
      CO2AbsoluteOnlyEvaluationOptions.isAutoScaleDeltaFiveMinutes =
          configuration.getBoolean(
              CO2AbsoluteOnlyEvaluationOptions.OPTIONS_CO2_ABSOLUTE_IS_DELTA_FIVE_MINUTES_AUTOSCALE,
              true);
      CO2AbsoluteOnlyEvaluationOptions.co2AbsoluteDatasetMinimum =
          configuration.getDouble(
              CO2AbsoluteOnlyEvaluationOptions.OPTIONS_CO2_ABSOLUTE_SCALE_MINIMUM_CO2_ABSOLUTE,
              Integer.MIN_VALUE);
      CO2AbsoluteOnlyEvaluationOptions.co2AbsoluteDatasetMaximum =
          configuration.getDouble(
              CO2AbsoluteOnlyEvaluationOptions.OPTIONS_CO2_ABSOLUTE_SCALE_MAXIMUM_CO2_ABSOLUTE,
              Integer.MAX_VALUE);
      CO2AbsoluteOnlyEvaluationOptions.deltaFiveMinutesMinimum =
          configuration.getDouble(
              CO2AbsoluteOnlyEvaluationOptions
                  .OPTIONS_CO2_ABSOLUTE_SCALE_MINIMUM_DELTA_FIVE_MINUTES,
              Integer.MIN_VALUE);
      CO2AbsoluteOnlyEvaluationOptions.deltaFiveMinutesMaximum =
          configuration.getDouble(
              CO2AbsoluteOnlyEvaluationOptions
                  .OPTIONS_CO2_ABSOLUTE_SCALE_MAXIMUM_DELTA_FIVE_MINUTES,
              Integer.MAX_VALUE);

      // options for type B (= Ingo's evaluation)
      TypeBEvaluationOptions.density =
          configuration.getInt(TypeBEvaluationOptions.OPTIONS_TYPE_B_DENSITY, 60);
      TypeBEvaluationOptions.isCo2AbsoluteAutoscale =
          configuration.getBoolean(
              TypeBEvaluationOptions.OPTIONS_TYPE_B_IS_CO2_ABSOLUTE_AUTOSCALE, true);
      TypeBEvaluationOptions.isDeltaRawAutoscale =
          configuration.getBoolean(
              TypeBEvaluationOptions.OPTIONS_TYPE_B_IS_DELTA_RAW_AUTOSCALE, true);
      TypeBEvaluationOptions.co2AbsoluteDatasetMinimum =
          configuration.getDouble(
              TypeBEvaluationOptions.OPTIONS_TYPE_B_CO2_ABSOLUTE_SCALE_MINIMUM, Integer.MIN_VALUE);
      TypeBEvaluationOptions.co2AbsoluteDatasetMaximum =
          configuration.getDouble(
              TypeBEvaluationOptions.OPTIONS_TYPE_B_CO2_ABSOLUTE_SCALE_MAXIMUM, Integer.MAX_VALUE);
      TypeBEvaluationOptions.deltaRawDatasetMinimum =
          configuration.getDouble(
              TypeBEvaluationOptions.OPTIONS_TYPE_B_DELTA_RAW_SCALE_MINIMUM, Integer.MIN_VALUE);
      TypeBEvaluationOptions.deltaRawDatasetMaximum =
          configuration.getDouble(
              TypeBEvaluationOptions.OPTIONS_TYPE_B_DELTA_RAW_SCALE_MAXIMUM, Integer.MAX_VALUE);
    } catch (ConfigurationException ce) {
      log.error("Could not update configuration.", ce);
    }
  }
Ejemplo n.º 7
0
 public static int getInt(String key) {
   return applicationConfiguration.getInt(key);
 }
Ejemplo n.º 8
0
 private int getInt(String name, int defaultValue) {
   return mProperties.getInt(name, defaultValue);
 }
Ejemplo n.º 9
0
 private int getInt(String name) {
   checkProperty(name);
   return mProperties.getInt(name);
 }