Ejemplo n.º 1
0
  public static void persistSSLClientConfiguration(PropertiesConfiguration clientConfig)
      throws AtlasException, IOException {
    // trust settings
    Configuration configuration = new Configuration(false);
    File sslClientFile = getSSLClientFile();
    if (!sslClientFile.exists()) {
      configuration.set("ssl.client.truststore.type", "jks");
      configuration.set(
          "ssl.client.truststore.location", clientConfig.getString(TRUSTSTORE_FILE_KEY));
      if (clientConfig.getBoolean(CLIENT_AUTH_KEY, false)) {
        // need to get client key properties
        configuration.set(
            "ssl.client.keystore.location", clientConfig.getString(KEYSTORE_FILE_KEY));
        configuration.set("ssl.client.keystore.type", "jks");
      }
      // add the configured credential provider
      configuration.set(
          CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
          clientConfig.getString(CERT_STORES_CREDENTIAL_PROVIDER_PATH));
      String hostnameVerifier = clientConfig.getString(SSLFactory.SSL_HOSTNAME_VERIFIER_KEY);
      if (hostnameVerifier != null) {
        configuration.set(SSLFactory.SSL_HOSTNAME_VERIFIER_KEY, hostnameVerifier);
      }

      configuration.writeXml(new FileWriter(sslClientFile));
    }
  }
 public static void setProperties(PropertiesConfiguration configuration) {
   configuration.getProperty("");
   getMailProperties()
       .setMailLogin(configuration.getString(MailProperties.getMailType() + ".login"));
   getMailProperties()
       .setMailPass(configuration.getString(MailProperties.getMailType() + ".password"));
   getMailProperties().setMailUrl(configuration.getString(MailProperties.getMailType() + ".url"));
 }
Ejemplo n.º 3
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.º 4
0
  /** @see Plugin#init() */
  public void init() throws PluginException {
    try {
      if (System.getProperty("roda.home") != null) {
        RODA_HOME = System.getProperty("roda.home");
      } else if (System.getenv("RODA_HOME") != null) {
        RODA_HOME = System.getenv("RODA_HOME");
      } else {
        RODA_HOME = null;
      }
      if (StringUtils.isBlank(RODA_HOME)) {
        throw new PluginException(
            "RODA_HOME enviroment variable and ${roda.home} system property are not set.");
      }
      final File pluginsConfigDirectory = new File(new File(RODA_HOME, "config"), "plugins");

      final File configFile = new File(pluginsConfigDirectory, CONFIGURATION_FILENAME);
      final PropertiesConfiguration configuration = new PropertiesConfiguration();

      if (configFile.isFile()) {
        configuration.load(configFile);
        logger.info("Loading configuration file from " + configFile);
      } else {
        configuration.load(getClass().getResourceAsStream("/" + CONFIGURATION_FILENAME));
        logger.info("Loading default configuration file from resources");
      }

      taverna_bin = configuration.getString("taverna_bin");
      logger.debug("taverna_bin=" + taverna_bin);

      xpathSelectIDs = configuration.getString("xpathSelectIDs");
      logger.debug("xpathSelectIDs=" + xpathSelectIDs);

      xpathSelectWorkflow = configuration.getString("xpathSelectWorkflow");
      logger.debug("xpathSelectWorkflow=" + xpathSelectWorkflow);

      workflowInputPort = configuration.getString("workflowInputPort");
      logger.debug("workflowInputPort=" + workflowInputPort);

      workflowOutputPort = configuration.getString("workflowOutputPort");
      logger.debug("workflowOutputPort=" + workflowOutputPort);

      workflowExtraPorts = configuration.getStringArray("workflowExtraPorts");
      logger.debug("workflowExtraPorts=" + Arrays.asList(workflowExtraPorts));

    } catch (ConfigurationException ex) {
      logger.debug("Error reading plugin configuration - " + ex.getMessage(), ex);
      throw new PluginException("Error reading plugin configuration - " + ex.getMessage(), ex);
    }

    planFile = new File(new File(RODA_HOME, "data"), PLAN_FILENAME);

    logger.debug("init() OK");
  }
  @Override
  public BluetoothConfiguration getBluetoothConfiguration() {

    // Create a new BluetoothConfiguration by reading out the parameters in the config file
    logger.trace("Loading Bluetooth Configuration");
    BluetoothConfiguration bluetoothConfiguration = new BluetoothConfiguration();
    bluetoothConfiguration.setServerName(
        propertiesConfiguration.getString(PropertiesConfigurationEntries.BLUETOOTH_SERVER));
    bluetoothConfiguration.setServiceName(
        propertiesConfiguration.getString(PropertiesConfigurationEntries.BLUETOOTH_SERVICE));
    bluetoothConfiguration.setServiceUUID(
        propertiesConfiguration.getString(PropertiesConfigurationEntries.BLUETOOTH_UUID));

    return bluetoothConfiguration;
  }
  /**
   * Converts the properties object into a JSON string.
   *
   * @param properties The properties object to convert.
   * @param envelope Envelope for resulting JSON object. Null if not needed.
   * @return A JSON string representing the object.
   */
  public static String toJson(PropertiesConfiguration properties, String envelope) {
    JsonObject json = new JsonObject();
    Iterator<String> i = properties.getKeys();

    while (i.hasNext()) {
      final String key = i.next();
      final String value = properties.getString(key);
      if (value.equals("true") || value.equals("false")) {
        json.addProperty(key.toString(), Boolean.parseBoolean(value));
      } else if (PATTERN_INTEGER.matcher(value).matches()) {
        json.addProperty(key.toString(), Integer.parseInt(value));
      } else if (PATTERN_FLOAT.matcher(value).matches()) {
        json.addProperty(key.toString(), Float.parseFloat(value));
      } else {
        json.addProperty(key.toString(), value);
      }
    }

    GsonBuilder gsonBuilder = new GsonBuilder().disableHtmlEscaping();
    Gson gson = gsonBuilder.create();
    String _json = gson.toJson(json);
    if (envelope != null && !envelope.isEmpty()) {
      _json = envelope(_json, envelope);
    }
    return _json;
  }
Ejemplo n.º 7
0
  public ModuleContainer(File directory) throws Exception {
    this.directory = directory;
    this.config = new PropertiesConfiguration(new File(directory, "module.conf"));

    String[] jars = config.getStringArray("jars");
    URL[] urls = new URL[jars.length];
    for (int i = 0; i < jars.length; i++) {
      urls[i] = new URL("file:" + new File(directory, jars[i]).getPath());
    }

    urlClassLoader = new URLClassLoader(urls);
    Class<?> classApp = Class.forName(config.getString("moduleClass"), true, urlClassLoader);
    Object object = classApp.newInstance();
    module = (Module) object;
    defaultTopologyConfig = config.subset("defaultTopology");
    defaultAlgorithmConfiguration = new File(config.getString("defaultAlgorithmConfiguration"));
  }
Ejemplo n.º 8
0
 /**
  * Get an SQL statement for the appropriate vendor from the bundle
  *
  * @param key
  * @return statement or null if none found.
  */
 private String getStatement(String key) {
   try {
     return statements.getString(key);
   } catch (NoSuchElementException e) {
     log.error("Statement: '" + key + "' could not be found in: " + statements.getFileName(), e);
     return null;
   }
 }
Ejemplo n.º 9
0
 /**
  * Dada una clave del fichero <b>Properties</b> retorna el valor de dicha propiedad. En caso de no
  * existir la propiedad retorna el valor de <i>defaultValue</i>.
  *
  * @param key de la propiedad que se quiere obtener.
  * @param defaultValue valor a retornar en caso de no existir la propiedad
  * @return valor de la propiedad indicada o <b>defaultValue</b> si la propiedad no existe en el
  *     fichero
  * @throws ConfigUtilException si el fichero no existe
  */
 @Override
 public String getProperty(String key, String defaultValue) throws ConfigUtilException {
   try {
     return (String) configuration.getString(key, defaultValue);
   } catch (Exception e) {
     throw new ConfigUtilException(e.getMessage(), e);
   }
 }
Ejemplo n.º 10
0
  /** Get the Splout configuration using double configuration: defaults + custom */
  public static SploutConfiguration get(String rootDir) {
    SploutConfiguration properties = new SploutConfiguration();

    PropertiesConfiguration config = load(rootDir, SPLOUT_PROPERTIES, false);
    if (config != null) {
      properties.addConfiguration(config);
    }
    config = load(rootDir, SPLOUT_PROPERTIES + ".default", true);
    properties.addConfiguration(config);

    // The following lines replaces the default "localhost" by the local IP for convenience:
    String myIp = "localhost";

    try {
      Collection<InetAddress> iNetAddresses = GetIPAddresses.getAllLocalIPs();
      // but only if there is Internet connectivity!
      if (iNetAddresses != null) {
        Iterator<InetAddress> it = iNetAddresses.iterator();
        if (it.hasNext()) {
          InetAddress address = it.next();
          if (address.getHostAddress() != null) {
            myIp = address.getHostAddress();
          }
        }
      }
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

    if (config.getString(QNodeProperties.HOST) != null
        && config.getString(QNodeProperties.HOST).equals("localhost")) {
      config.setProperty(QNodeProperties.HOST, myIp);
    }

    if (config.getString(DNodeProperties.HOST) != null
        && config.getString(DNodeProperties.HOST).equals("localhost")) {
      config.setProperty(DNodeProperties.HOST, myIp);
    }

    return properties;
  }
Ejemplo n.º 11
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;
  }
  /**
   * This creates a new database connector for use. It establishes a database connection immediately
   * ready for use.
   */
  public ZabbixDirectDbDataSourceAdaptor() {
    HISTORY_TABLES.add("history");
    HISTORY_TABLES.add("history_str");
    HISTORY_TABLES.add("history_uint");
    HISTORY_TABLES.add("history_text");

    try {
      PropertiesConfiguration config;
      if (new File(CONFIG_FILE).exists()) {
        config = new PropertiesConfiguration(CONFIG_FILE);
      } else {
        config = new PropertiesConfiguration();
        config.setFile(new File(CONFIG_FILE));
      }
      config.setAutoSave(
          true); // This will save the configuration file back to disk. In case the defaults need
                 // setting.
      databaseURL = config.getString("iaas.energy.modeller.zabbix.db.url", databaseURL);
      config.setProperty("iaas.energy.modeller.zabbix.db.url", databaseURL);
      databaseDriver = config.getString("iaas.energy.modeller.zabbix.db.driver", databaseDriver);
      config.setProperty("iaas.energy.modeller.zabbix.db.driver", databaseDriver);
      databasePassword =
          config.getString("iaas.energy.modeller.zabbix.db.password", databasePassword);
      config.setProperty("iaas.energy.modeller.zabbix.db.password", databasePassword);
      databaseUser = config.getString("iaas.energy.modeller.zabbix.db.user", databaseUser);
      config.setProperty("iaas.energy.modeller.zabbix.db.user", databaseUser);
      begins = config.getString("iaas.energy.modeller.filter.begins", begins);
      config.setProperty("iaas.energy.modeller.filter.begins", begins);
      isHost = config.getBoolean("iaas.energy.modeller.filter.isHost", isHost);
      config.setProperty("iaas.energy.modeller.filter.isHost", isHost);

    } catch (ConfigurationException ex) {
      DB_LOGGER.log(Level.SEVERE, "Error loading the configuration of the IaaS energy modeller");
    }
    try {
      connection = getConnection();
    } catch (IOException | SQLException | ClassNotFoundException ex) {
      DB_LOGGER.log(Level.SEVERE, "Failed to establish the connection to the Zabbix DB", ex);
    }
  }
Ejemplo n.º 13
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 void initliaze(InputStream input, WebApplicationConfiguration configuration)
      throws Exception {
    PropertiesConfiguration pc = new PropertiesConfiguration();
    pc.load(input);

    BeanUtilsBean bu = retrieveBeanUtilsBean();
    Iterator<String> keys = pc.getKeys();
    while (keys.hasNext()) {
      String key = keys.next();
      String value = pc.getString(key);
      fillConfiguration(configuration, bu, key, value);
    }
  }
Ejemplo n.º 15
0
  /** @see Plugin#init() */
  public void init() throws PluginException {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    try {

      String RODA_HOME = null;

      if (System.getProperty("roda.home") != null) {
        RODA_HOME = System.getProperty("roda.home"); // $NON-NLS-1$
      } else if (System.getenv("RODA_HOME") != null) {
        RODA_HOME = System.getenv("RODA_HOME"); // $NON-NLS-1$
      } else {
        RODA_HOME = null;
      }

      if (StringUtils.isBlank(RODA_HOME)) {
        throw new PluginException(
            "RODA_HOME enviroment variable and ${roda.home} system property are not set.");
      }

      File RODA_PLUGINS_CONFIG_DIRECTORY = new File(new File(RODA_HOME, "config"), "plugins");

      File configFile = new File(RODA_PLUGINS_CONFIG_DIRECTORY, getConfigurationFile());

      logger.debug("Trying to load configuration file from " + configFile);

      if (configFile.isFile()) {
        configuration.load(configFile);
        logger.info("Loading configuration file from " + configFile);
      } else {
        configuration.load(getClass().getResourceAsStream(getConfigurationFile()));
        logger.info("Loading default configuration file from resources");
      }

      this.converterServiceURL = configuration.getString("converterServiceURL");

      this.representationSubTypes = configuration.getStringArray("representationSubTypes");
      if (this.representationSubTypes == null) {
        this.representationSubTypes = new String[0];
      }

    } catch (ConfigurationException e) {
      logger.debug("Error reading plugin configuration - " + e.getMessage(), e);
      throw new PluginException("Error reading plugin configuration - " + e.getMessage(), e);
    }
  }
Ejemplo n.º 16
0
  private TestData() {
    try {
      // Load the configuration file
      config = new PropertiesConfiguration("./config/config.properties");

      // Make sure the test data folder exists
      dataFolder = new File(config.getString("test.folder"));
      //            if (!dataFolder.exists())
      //                dataFolder.createNewFile();

    } catch (ConfigurationException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
      //        } catch (IOException e) {
      //            e.printStackTrace();  //To change body of catch statement use File | Settings |
      // File Templates.
    }
  }
Ejemplo n.º 17
0
public class ConfigConstant {
  protected static PropertiesConfiguration config =
      PropertiesConfigurationManager.getInstance()
          .getPropertiesConfiguration(
              "/META-INF/resources/conf/mobile-service-new/system.properties");
  public static final String ERAY_ENCODING = config.getString("eray.encoding", "UTF-8");
  public static final String ERAY_DATEFORMAT =
      config.getString("eray.dateformat", "yyyy-MM-dd HH:mm:ss");
  public static final String FILE_GPS_PATH = config.getString("file.gps.path");
  public static final String SERVICE_CODE = config.getString("service.code");
  public static final String META_DATA_BASEDIR_PREVIEW =
      config.getString("meta.data.baseDir.preview", "/opt/preview");
  public static final String META_DATA_BASEDIR = config.getString("meta.data.baseDir", "/opt/meta");
}
Ejemplo n.º 18
0
  /** Load the properties contained within ou=Config node in LDAP. */
  private void loadRemoteConfig() {
    try {
      // Retrieve parameters from the config node stored in target LDAP DIT:
      String realmName = config.getString(GlobalIds.CONFIG_REALM, "DEFAULT");
      if (realmName != null && realmName.length() > 0) {
        LOG.info("static init: load config realm [{}]", realmName);
        Properties props = getRemoteConfig(realmName);
        if (props != null) {
          for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements(); ) {
            String key = (String) e.nextElement();
            String val = props.getProperty(key);
            config.setProperty(key, val);
          }
        }

        // init ldap util vals since config is stored on server
        boolean ldapfilterSizeFound = (getProperty(GlobalIds.LDAP_FILTER_SIZE_PROP) != null);
        LdapUtil.getInstance().setLdapfilterSizeFound(ldapfilterSizeFound);
        LdapUtil.getInstance().setLdapMetaChars(loadLdapEscapeChars());
        LdapUtil.getInstance().setLdapReplVals(loadValidLdapVals());
        try {
          String lenProp = getProperty(GlobalIds.LDAP_FILTER_SIZE_PROP);
          if (ldapfilterSizeFound) {
            LdapUtil.getInstance().setLdapFilterSize(Integer.valueOf(lenProp));
          }
        } catch (java.lang.NumberFormatException nfe) {
          String error = "loadRemoteConfig caught NumberFormatException=" + nfe;
          LOG.warn(error);
        }
        remoteConfigLoaded = true;
      } else {
        LOG.info("static init: config realm not setup");
      }
    } catch (SecurityException se) {
      String error = "static init: Error loading from remote config: SecurityException=" + se;
      LOG.error(error);
      throw new CfgRuntimeException(GlobalErrIds.FT_CONFIG_INITIALIZE_FAILED, error, se);
    }
  }
  /**
   * Recupera uma mensagem do arquivo de propriedades através da chave da mesma.
   *
   * @param chave A chave que representa a mensagem no arquivo de propriedades.
   * @param argumentos A lista de argumentos a serem substituidos na mensagem recuperada.
   * @return Uma {@link String} contendo a mensagem encontrada ou uma string vazia se não for
   *     possível recuperar a mensagem.
   */
  public static String recuperarMensagemProperties(String chave, Object... argumentos) {
    String mensagem = "";

    if (chave == null) {
      throw new IllegalArgumentException("A chave da mensagem deve ser informada");
    }

    try {

      if (arqProperties == null) {
        arqProperties = new PropertiesConfiguration("MessageBundle.properties");
      }

      mensagem = arqProperties.getString(chave);

      if (mensagem != null && argumentos != null) {
        mensagem = MessageFormat.format(mensagem, argumentos);
      }
    } catch (Exception e) {
      LOG.error("Erro ao recuperar mensagem de properties com a chave:" + chave, e);
    }

    return mensagem;
  }
Ejemplo n.º 20
0
  public static URLConnectionClientHandler getClientConnectionHandler(
      DefaultClientConfig config,
      PropertiesConfiguration clientConfig,
      final String doAsUser,
      final UserGroupInformation ugi) {
    config
        .getProperties()
        .put(URLConnectionClientHandler.PROPERTY_HTTP_URL_CONNECTION_SET_METHOD_WORKAROUND, true);
    Configuration conf = new Configuration();
    conf.addResource(conf.get(SSLFactory.SSL_CLIENT_CONF_KEY, "ssl-client.xml"));
    UserGroupInformation.setConfiguration(conf);
    final ConnectionConfigurator connConfigurator = newConnConfigurator(conf);
    String authType = "simple";
    if (clientConfig != null) {
      authType = clientConfig.getString("atlas.http.authentication.type", "simple");
    }
    Authenticator authenticator = new PseudoDelegationTokenAuthenticator();
    if (!authType.equals("simple")) {
      authenticator = new KerberosDelegationTokenAuthenticator();
    }
    authenticator.setConnectionConfigurator(connConfigurator);
    final DelegationTokenAuthenticator finalAuthenticator =
        (DelegationTokenAuthenticator) authenticator;
    final DelegationTokenAuthenticatedURL.Token token = new DelegationTokenAuthenticatedURL.Token();
    HttpURLConnectionFactory httpURLConnectionFactory = null;
    try {
      UserGroupInformation ugiToUse = ugi != null ? ugi : UserGroupInformation.getCurrentUser();
      final UserGroupInformation actualUgi =
          (ugiToUse.getAuthenticationMethod() == UserGroupInformation.AuthenticationMethod.PROXY)
              ? ugiToUse.getRealUser()
              : ugiToUse;
      LOG.info(
          "Real User: {}, is from ticket cache? {}", actualUgi, actualUgi.isLoginTicketBased());
      LOG.info("doAsUser: {}", doAsUser);
      httpURLConnectionFactory =
          new HttpURLConnectionFactory() {
            @Override
            public HttpURLConnection getHttpURLConnection(final URL url) throws IOException {
              try {
                return actualUgi.doAs(
                    new PrivilegedExceptionAction<HttpURLConnection>() {
                      @Override
                      public HttpURLConnection run() throws Exception {
                        try {
                          return new DelegationTokenAuthenticatedURL(
                                  finalAuthenticator, connConfigurator)
                              .openConnection(url, token, doAsUser);
                        } catch (Exception e) {
                          throw new IOException(e);
                        }
                      }
                    });
              } catch (Exception e) {
                if (e instanceof IOException) {
                  throw (IOException) e;
                } else {
                  throw new IOException(e);
                }
              }
            }
          };
    } catch (IOException e) {
      LOG.warn("Error obtaining user", e);
    }

    return new URLConnectionClientHandler(httpURLConnectionFactory);
  }
Ejemplo n.º 21
0
 public static String getString(String key) {
   return applicationConfiguration.getString(key);
 }
  public IPath publishModuleFull(IProgressMonitor monitor) throws CoreException {
    final IPath deployPath =
        LiferayServerCore.getTempLocation("direct-deploy", StringPool.EMPTY); // $NON-NLS-1$
    File warFile = deployPath.append(getProject().getName() + ".war").toFile(); // $NON-NLS-1$
    warFile.getParentFile().mkdirs();

    final Map<String, String> properties = new HashMap<String, String>();
    properties.put(ISDKConstants.PROPERTY_AUTO_DEPLOY_UNPACK_WAR, "false"); // $NON-NLS-1$

    final ILiferayRuntime runtime = ServerUtil.getLiferayRuntime(getProject());

    final String appServerDeployDirProp =
        ServerUtil.getAppServerPropertyKey(ISDKConstants.PROPERTY_APP_SERVER_DEPLOY_DIR, runtime);

    properties.put(appServerDeployDirProp, deployPath.toOSString());

    // IDE-1073 LPS-37923
    properties.put(ISDKConstants.PROPERTY_PLUGIN_FILE_DEFAULT, warFile.getAbsolutePath());

    properties.put(ISDKConstants.PROPERTY_PLUGIN_FILE, warFile.getAbsolutePath());

    final String fileTimeStamp = System.currentTimeMillis() + "";

    // IDE-1491
    properties.put(ISDKConstants.PROPERTY_LP_VERSION, fileTimeStamp);

    properties.put(ISDKConstants.PROPERTY_LP_VERSION_SUFFIX, ".0");

    final Map<String, String> appServerProperties =
        ServerUtil.configureAppServerProperties(getProject());

    final IStatus directDeployStatus =
        sdk.war(
            getProject(),
            properties,
            true,
            appServerProperties,
            new String[] {"-Duser.timezone=GMT"},
            monitor);

    if (!directDeployStatus.isOK() || (!warFile.exists())) {
      String pluginVersion = "1";

      final IPath pluginPropertiesPath = new Path("WEB-INF/liferay-plugin-package.properties");
      final IFile propertiesFile =
          CoreUtil.getDocrootFile(getProject(), pluginPropertiesPath.toOSString());

      if (propertiesFile != null) {
        try {
          if (propertiesFile.exists()) {
            final PropertiesConfiguration pluginPackageProperties = new PropertiesConfiguration();
            final InputStream is = propertiesFile.getContents();
            pluginPackageProperties.load(is);
            pluginVersion = pluginPackageProperties.getString("module-incremental-version");
            is.close();
          }
        } catch (Exception e) {
          LiferayCore.logError("error reading module-incremtnal-version. ", e);
        }
      }

      warFile =
          sdk.getLocation()
              .append("dist")
              .append(
                  getProject().getName()
                      + "-"
                      + fileTimeStamp
                      + "."
                      + pluginVersion
                      + ".0"
                      + ".war")
              .toFile();

      if (!warFile.exists()) {
        throw new CoreException(directDeployStatus);
      }
    }

    return new Path(warFile.getAbsolutePath());
  }
Ejemplo n.º 23
0
 @Override
 public String toString() {
   return config.getString("name");
 }
Ejemplo n.º 24
0
 /**
  * 获取系统配置参数
  *
  * @param key
  * @return
  */
 public String getConfigValue(String key) {
   return propConfig.getString(key);
 }
  @Override
  public KeyConfiguration getKeyConfiguration() throws ConfigurationLoadingException {

    if (keyConfiguration == null) {
      // Load values out of configuration
      logger.trace("Loading Key Configuration");
      keyConfiguration = new KeyConfiguration();

      FileReader fileReader;
      try {

        // Load Key Agreement Private Key
        fileReader =
            new FileReader(
                propertiesConfiguration.getString(
                    PropertiesConfigurationEntries.SECURITY_KEYAGREEMENT_KEYPATH));
        PEMReader pemReader = new PEMReader(fileReader);
        KeyPair keyPair = (KeyPair) pemReader.readObject();
        keyConfiguration.setKeyAgreementPrivateKey(keyPair.getPrivate());
        pemReader.close();
        fileReader.close();

        // Load Blob Private Key
        fileReader =
            new FileReader(
                propertiesConfiguration.getString(
                    PropertiesConfigurationEntries.SECURITY_BLOB_KEYPATH_PRIVATE));
        pemReader = new PEMReader(fileReader);
        keyPair = (KeyPair) pemReader.readObject();
        keyConfiguration.setBlobPrivateKey(keyPair.getPrivate());
        pemReader.close();
        fileReader.close();

        // Load Blob Public Key
        fileReader =
            new FileReader(
                propertiesConfiguration.getString(
                    PropertiesConfigurationEntries.SECURITY_BLOB_KEYPATH_PUBLIC));
        pemReader = new PEMReader(fileReader);
        X509Certificate cert = (X509Certificate) pemReader.readObject();
        PublicKey publicKey = (PublicKey) cert.getPublicKey();
        keyConfiguration.setBlobPublicKey(publicKey);
        pemReader.close();
        fileReader.close();

      } catch (FileNotFoundException e) {
        logger.error("Error loading the Key Configuration: " + e.getMessage());
        keyConfiguration = null;
        throw new ConfigurationLoadingException(
            "Error loading the Key Configuration: " + e.getMessage());
      } catch (IOException e) {
        logger.error("Error loading the Key Configuration: " + e.getMessage());
        keyConfiguration = null;
        throw new ConfigurationLoadingException(
            "Error loading the Key Configuration: " + e.getMessage());
      } catch (Exception e) {
        logger.error("Error loading the Key Configuration: " + e.getMessage());
        throw new RuntimeException(e.getMessage());
      }
    } else {
      logger.trace("Key Configuration already loaded");
    }

    return keyConfiguration;
  }
Ejemplo n.º 26
0
 /**
  * 获取系统配置参数
  *
  * @param key
  * @param defaultValue 如果没有找到参数值,则返回此默认值
  * @return
  */
 public String getConfigValue(String key, String defaultValue) {
   return propConfig.getString(key, defaultValue);
 }
Ejemplo n.º 27
0
  protected static MimetypesFileTypeMap getMimetypesFileTypeMap() {
    if (mimetypesFileTypeMap == null) {
      mimetypesFileTypeMap = new MimetypesFileTypeMap();
      PropertiesConfiguration mimetypeConfiguration = new PropertiesConfiguration();
      mimetypeConfiguration.setDelimiterParsingDisabled(false);
      // PropertiesConfiguration.setDefaultListDelimiter(',');

      try {

        mimetypeConfiguration.load(
            FormatUtility.class.getResourceAsStream("mime.types-extensions.properties"));
        Iterator<String> keysIterator = mimetypeConfiguration.getKeys();

        while (keysIterator.hasNext()) {
          String mimeType = keysIterator.next();
          String mimetypevalue = mimeType + " " + mimetypeConfiguration.getString(mimeType);
          mimetypesFileTypeMap.addMimeTypes(mimetypevalue);
        }
      } catch (ConfigurationException e) {

        logger.warn("Error reading mime.types-extensions.properties file - " + e.getMessage(), e);
        logger.warn("Using default predefined values for mimetype/extensions");

        mimetypesFileTypeMap.addMimeTypes("application/pdf pdf PDF");
        mimetypesFileTypeMap.addMimeTypes("application/msword doc DOC");
        mimetypesFileTypeMap.addMimeTypes(
            "application/vnd.openxmlformats-officedocument.wordprocessingml.document docx DOCX");
        mimetypesFileTypeMap.addMimeTypes("application/vnd.oasis.opendocument.text odt ODT");

        mimetypesFileTypeMap.addMimeTypes("text/xml xml XML");
        mimetypesFileTypeMap.addMimeTypes("text/dbml dbml DBML");

        mimetypesFileTypeMap.addMimeTypes("video/mpeg mpg MPG");
        mimetypesFileTypeMap.addMimeTypes(
            "video/mpeg2 m2p M2P m2v M2V mpv2 MPV2 mp2v MP2V vob VOB");
        mimetypesFileTypeMap.addMimeTypes("video/avi avi AVI");
        mimetypesFileTypeMap.addMimeTypes("video/x-ms-wmv wmv WMV");
        mimetypesFileTypeMap.addMimeTypes("video/quicktime mov MOV");

        mimetypesFileTypeMap.addMimeTypes("audio/wav wav WAV");
        mimetypesFileTypeMap.addMimeTypes("audio/mpeg mp1 MP1 mp2 MP2 mp3 MP3 mpa MPA");
        mimetypesFileTypeMap.addMimeTypes("audio/aiff aif AIF aiff AIFF");
        mimetypesFileTypeMap.addMimeTypes("audio/ogg ogg OGG");

        mimetypesFileTypeMap.addMimeTypes("application/vnd.ms-powerpoint ppt PPT");
        mimetypesFileTypeMap.addMimeTypes(
            "application/vnd.openxmlformats-officedocument.presentationml.presentation pptx PPTX");
        mimetypesFileTypeMap.addMimeTypes(
            "application/vnd.oasis.opendocument.presentation odp ODP");

        mimetypesFileTypeMap.addMimeTypes("application/vnd.ms-excel xls XLS");
        mimetypesFileTypeMap.addMimeTypes(
            "application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx XLSX");
        mimetypesFileTypeMap.addMimeTypes("application/vnd.oasis.opendocument.spreadsheet ods ODS");

        mimetypesFileTypeMap.addMimeTypes("application/cdr cdr CDR");
        mimetypesFileTypeMap.addMimeTypes("application/illustrator ai AI");
        mimetypesFileTypeMap.addMimeTypes("application/x-qgis shp SHP");
        mimetypesFileTypeMap.addMimeTypes("application/acad dwg DWG");

        mimetypesFileTypeMap.addMimeTypes("message/rfc822 eml EML");
        mimetypesFileTypeMap.addMimeTypes("application/msoutlook msg MSG");
      }
    }

    return mimetypesFileTypeMap;
  }
Ejemplo n.º 28
0
package isola.tags.ext.helpers;
Ejemplo n.º 29
0
 private GitRepositoryState(PropertiesConfiguration properties) {
   this.branch = properties.getString("git.branch");
   this.tags = properties.getString("git.tags");
   this.describe = properties.getString("git.commit.id.describe");
   this.describeShort = properties.getString("git.commit.id.describe-short");
   this.commitId = properties.getString("git.commit.id");
   this.commitIdAbbrev = properties.getString("git.commit.id.abbrev");
   this.buildUserName = properties.getString("git.build.user.name");
   this.buildUserEmail = properties.getString("git.build.user.email");
   this.buildTime = properties.getString("git.build.time");
   this.commitUserName = properties.getString("git.commit.user.name");
   this.commitUserEmail = properties.getString("git.commit.user.email");
   this.commitMessageShort = properties.getString("git.commit.message.short");
   this.commitMessageFull = properties.getString("git.commit.message.full");
   this.commitTime = properties.getString("git.commit.time");
 }
Ejemplo n.º 30
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);
    }
  }