Search in sources :

Example 36 with PropertiesConfiguration

use of org.apache.commons.configuration.PropertiesConfiguration in project cloudstack by apache.

the class TestDbSetup method updateSqlPort.

public static void updateSqlPort(int port, String propertyFileOverride) throws Exception {
    PropertiesConfiguration config = new PropertiesConfiguration(propertyFileOverride);
    System.out.println("File: " + propertyFileOverride + "; old: db.properties port: " + config.getProperty("db.cloud.port") + ", new port: " + port);
    config.setProperty("db.cloud.port", "" + port);
    config.setProperty("db.cloud.username", System.getProperty("user.name"));
    config.setProperty("db.cloud.password", "");
    config.setProperty("db.usage.port", "" + port);
    config.setProperty("db.usage.username", System.getProperty("user.name"));
    config.setProperty("db.usage.password", "");
    config.setProperty("db.simulator.port", "" + port);
    config.setProperty("db.simulator.username", System.getProperty("user.name"));
    config.setProperty("db.simulator.password", "");
    config.save();
}
Also used : PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 37 with PropertiesConfiguration

use of org.apache.commons.configuration.PropertiesConfiguration in project oxTrust by GluuFederation.

the class UpdateCASAction method disable.

public void disable() {
    try {
        log.info("disable() CAS call");
        // enable server-side storage in idp.properties
        String idpConfFolder = shibboleth3ConfService.getIdpConfDir();
        PropertiesConfiguration idpPropertiesConfiguration = new PropertiesConfiguration(idpConfFolder + Shibboleth3ConfService.SHIB3_IDP_PROPERTIES_FILE);
        PropertiesConfigurationLayout layoutConfiguration = new PropertiesConfigurationLayout(idpPropertiesConfiguration);
        // Restore default - client session storage
        layoutConfiguration.getConfiguration().setProperty(IDP_SESSION_STORAGESERVICE, CLIENT_SESSION_STORAGESERVICE);
        layoutConfiguration.getConfiguration().setProperty(IDP_CAS_STORAGESERVICE, configuration.getSessionStorageType());
        layoutConfiguration.getConfiguration().save();
        // disable CAS beans in relying-party.xml
        updateShibboleth3Configuration();
        log.info("disable() CAS - enabled");
    } catch (Exception e) {
        log.error("disable() CAS exception", e);
    }
}
Also used : PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) PropertiesConfigurationLayout(org.apache.commons.configuration.PropertiesConfigurationLayout)

Example 38 with PropertiesConfiguration

use of org.apache.commons.configuration.PropertiesConfiguration in project sakuli by ConSol.

the class SakuliPropertyPlaceholderConfigurer method modifySahiProxyPortPropertiesConfiguration.

/**
     * writes the {@link SahiProxyProperties#PROXY_PORT} value as {@link SahiProxyProperties#SAHI_PROPERTY_PROXY_PORT_MAPPING}
     * property to sahiConfigPropertyFilePath!
     */
protected void modifySahiProxyPortPropertiesConfiguration(String sahiConfigPropertyFilePath, Properties props) {
    final String sahiProxyPort = props.getProperty(SahiProxyProperties.PROXY_PORT);
    if (sahiProxyPort != null) {
        try {
            PropertiesConfiguration propConfig = new PropertiesConfiguration(sahiConfigPropertyFilePath);
            propConfig.setAutoSave(true);
            final String sahiMappingPropertyProxyPort = SahiProxyProperties.SAHI_PROPERTY_PROXY_PORT_MAPPING;
            if (propConfig.containsKey(sahiMappingPropertyProxyPort)) {
                propConfig.clearProperty(sahiMappingPropertyProxyPort);
            }
            //remove property after the test execution, so that the installation can't break
            addToModifiedPropertiesMap(sahiConfigPropertyFilePath, sahiMappingPropertyProxyPort, null);
            propConfig.addProperty(sahiMappingPropertyProxyPort, sahiProxyPort);
            logger.debug("modify properties file '{}' with '{}={}'", sahiConfigPropertyFilePath, sahiMappingPropertyProxyPort, sahiProxyPort);
        } catch (ConfigurationException e) {
            logger.error("modify sahi properties went wrong", e);
        }
    }
}
Also used : ConfigurationException(org.apache.commons.configuration.ConfigurationException) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 39 with PropertiesConfiguration

use of org.apache.commons.configuration.PropertiesConfiguration in project sakuli by ConSol.

the class SakuliPropertyPlaceholderConfigurer method addPropertiesFromFile.

/**
     * Reads in the properties for a specific file
     *
     * @param props    Properties to update
     * @param filePath path to readable properties file
     * @param active   activate or deactivate the  function
     */
protected void addPropertiesFromFile(Properties props, String filePath, boolean active) {
    if (active) {
        logger.info("read in properties from '{}'", filePath);
        try {
            PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(filePath);
            Iterator<String> keyIt = propertiesConfiguration.getKeys();
            while (keyIt.hasNext()) {
                String key = keyIt.next();
                Object value = propertiesConfiguration.getProperty(key);
                props.put(key, value);
            }
        } catch (ConfigurationException | NullPointerException e) {
            throw new RuntimeException("Error by reading the property file '" + filePath + "'", e);
        }
    }
}
Also used : ConfigurationException(org.apache.commons.configuration.ConfigurationException) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 40 with PropertiesConfiguration

use of org.apache.commons.configuration.PropertiesConfiguration in project opennms by OpenNMS.

the class DefaultOtrsConfigDao method getProperties.

/**
 * Retrieves the properties defined in the otrs.properties file.
 *
 * @return a
 *         <code>java.util.Properties object containing otrs plugin defined properties
 * @throws IOException
 */
private Configuration getProperties() {
    Configuration config = new PropertiesConfiguration();
    String propsFile = null;
    try {
        propsFile = new File(new File(System.getProperty("opennms.home"), "etc"), "otrs.properties").getCanonicalPath();
        LOG.debug("loading properties from: {}", propsFile);
        config = new PropertiesConfiguration(propsFile);
    } catch (final ConfigurationException e) {
        LOG.error("Unable to load properties from {}", propsFile, e);
    } catch (final IOException e) {
        LOG.error("Exception when trying to find OTRS configuration properties from {}", propsFile, e);
    }
    return config;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) ConfigurationException(org.apache.commons.configuration.ConfigurationException) IOException(java.io.IOException) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) File(java.io.File)

Aggregations

PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)118 File (java.io.File)38 Configuration (org.apache.commons.configuration.Configuration)33 ConfigurationException (org.apache.commons.configuration.ConfigurationException)33 IOException (java.io.IOException)12 Test (org.testng.annotations.Test)11 BeforeClass (org.testng.annotations.BeforeClass)10 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)9 IndexLoadingConfigMetadata (com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata)8 FileBasedInstanceDataManager (com.linkedin.pinot.core.data.manager.offline.FileBasedInstanceDataManager)8 FileInputStream (java.io.FileInputStream)7 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)7 URL (java.net.URL)6 ServerQueryExecutorV1Impl (com.linkedin.pinot.core.query.executor.ServerQueryExecutorV1Impl)5 ServerConf (com.linkedin.pinot.server.conf.ServerConf)5 FileNotFoundException (java.io.FileNotFoundException)5 Path (java.nio.file.Path)5 HashMap (java.util.HashMap)5 Properties (java.util.Properties)5 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4