Example usage for org.apache.commons.configuration PropertiesConfiguration getProperty

List of usage examples for org.apache.commons.configuration PropertiesConfiguration getProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration PropertiesConfiguration getProperty.

Prototype

public Object getProperty(String key) 

Source Link

Usage

From source file:org.apache.atlas.Atlas.java

private static void showStartupInfo(PropertiesConfiguration buildConfiguration, boolean enableTLS,
        int appPort) {
    StringBuilder buffer = new StringBuilder();
    buffer.append("\n############################################");
    buffer.append("############################################");
    buffer.append("\n                               Atlas Server (STARTUP)");
    buffer.append("\n");
    try {//ww w.ja  v a  2  s.  c o m
        final Iterator<String> keys = buildConfiguration.getKeys();
        while (keys.hasNext()) {
            String key = keys.next();
            buffer.append('\n').append('\t').append(key).append(":\t")
                    .append(buildConfiguration.getProperty(key));
        }
    } catch (Throwable e) {
        buffer.append("*** Unable to get build info ***");
    }
    buffer.append("\n############################################");
    buffer.append("############################################");
    LOG.info(buffer.toString());
    LOG.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    LOG.info("Server starting with TLS ? {} on port {}", enableTLS, appPort);
    LOG.info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
}

From source file:org.apache.cloudstack.network.contrail.management.TestDbSetup.java

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();//from ww w .  j a va  2  s  .  c  om
}

From source file:org.janusgraph.hadoop.CassandraInputFormatIT.java

protected Graph getGraph() throws ConfigurationException, IOException {
    final PropertiesConfiguration config = new PropertiesConfiguration(
            "target/test-classes/cassandra-read.properties");
    Path baseOutDir = Paths.get((String) config.getProperty("gremlin.hadoop.outputLocation"));
    baseOutDir.toFile().mkdirs();/*from www.  ja v  a2s .c o  m*/
    String outDir = Files.createTempDirectory(baseOutDir, null).toAbsolutePath().toString();
    config.setProperty("gremlin.hadoop.outputLocation", outDir);
    return GraphFactory.open(config);
}

From source file:org.janusgraph.hadoop.HBaseInputFormatIT.java

protected Graph getGraph() throws IOException, ConfigurationException {
    final PropertiesConfiguration config = new PropertiesConfiguration(
            "target/test-classes/hbase-read.properties");
    Path baseOutDir = Paths.get((String) config.getProperty("gremlin.hadoop.outputLocation"));
    baseOutDir.toFile().mkdirs();//from  w  w  w .  j av  a  2s. com
    String outDir = Files.createTempDirectory(baseOutDir, null).toAbsolutePath().toString();
    config.setProperty("gremlin.hadoop.outputLocation", outDir);
    return GraphFactory.open(config);
}

From source file:org.janusgraph.hadoop.HBaseSnapshotInputFormatIT.java

protected Graph getGraph() throws IOException, ConfigurationException {
    final PropertiesConfiguration config = new PropertiesConfiguration(
            "target/test-classes/hbase-read-snapshot.properties");
    Path baseOutDir = Paths.get((String) config.getProperty("gremlin.hadoop.outputLocation"));
    baseOutDir.toFile().mkdirs();/*from   www  .j a  v  a  2  s.c  om*/
    String outDir = Files.createTempDirectory(baseOutDir, null).toAbsolutePath().toString();
    config.setProperty("gremlin.hadoop.outputLocation", outDir);
    // Set the hbase.rootdir property. This is needed by HBaseSnapshotInputFormat.
    config.setProperty("janusgraphmr.ioformat.conf.storage.hbase.ext.hbase.rootdir",
            HBaseStorageSetup.getHBaseRootdir());
    return GraphFactory.open(config);
}

From source file:org.sakuli.utils.SakuliPropertyPlaceholderConfigurer.java

/**
 * Reads in the properties for a specific file
 *
 * @param props    Properties to update//from   w  w w  .  j  a  v  a2  s  .co  m
 * @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);
        }
    }
}

From source file:org.sakuli.utils.SakuliPropertyPlaceholderConfigurer.java

/**
 * Modifies the properties file 'propFilePathToConfig' with assigned key from the resource properties.
 *///from  w  w  w.j av a 2  s  . c  o  m
protected void modifyPropertiesConfiguration(String propFilePathToConfig, List<String> updateKeys,
        Properties resourceProps) {
    try {
        PropertiesConfiguration propConfig = new PropertiesConfiguration(propFilePathToConfig);
        propConfig.setAutoSave(true);
        Properties temProps = new Properties();
        for (String propKey : updateKeys) {
            String resolve = resolve(resourceProps.getProperty(propKey), resourceProps);
            if (resolve != null) {
                if (propConfig.containsKey(propKey)) {
                    addToModifiedPropertiesMap(propFilePathToConfig, propKey, propConfig.getProperty(propKey));
                    propConfig.clearProperty(propKey);
                }
                temProps.put(propKey, resolve);
                propConfig.addProperty(propKey, resolve);
            }
        }
        logger.debug("modify properties file '{}' with '{}'", propFilePathToConfig, temProps.toString());
    } catch (ConfigurationException e) {
        logger.error("modify sahi properties went wrong", e);
    }

}

From source file:org.silverpeas.settings.file.ModifProperties.java

/**
 * lance la modification du fichier properties
 * @throws Exception//from   w ww . j a v a 2 s. c  om
 */
@Override
public void executeModification() throws Exception {
    File file = new File(path);
    if (file.exists()) {
        PropertiesConfiguration configuration = new PropertiesConfiguration(file);
        for (ElementModif em : listeModifications) {
            if (configuration.containsKey(em.getSearch())) {
                if (!em.getModif().equals(configuration.getProperty(em.getSearch()))) {
                    if (!isModified) {
                        isModified = true;
                        BackupFile bf = new BackupFile(new File(path));
                        bf.makeBackup();
                    }
                    configuration.setProperty(em.getSearch(), em.getModif());
                }
            } else {
                configuration.setProperty(em.getSearch(), em.getModif());
            }
        }
        configuration.save(file);
    } else {
        throw new Exception("ATTENTION le fichier:" + path + " n'existe pas");
    }
}

From source file:org.xwiki.contrib.confluence.filter.internal.ConfluenceXMLPackage.java

private void readPageObject(XMLStreamReader xmlReader)
        throws XMLStreamException, ConfigurationException, FilterException {
    PropertiesConfiguration properties = newProperties();

    long pageId = readObjectProperties(xmlReader, properties);

    // Save page//from   w  ww . j a va 2  s .co m
    savePageProperties(properties, pageId);

    // Register only current pages (they will take care of handling there history)
    Long originalVersion = (Long) properties.getProperty("originalVersion");
    if (originalVersion == null) {
        Long spaceId = properties.getLong("space", null);
        List<Long> spacePages = this.pages.get(spaceId);
        if (spacePages == null) {
            spacePages = new LinkedList<>();
            this.pages.put(spaceId, spacePages);
        }
        spacePages.add(pageId);
    }
}

From source file:org.xwiki.filter.confluence.xml.internal.ConfluenceXMLPackage.java

private void readPageObject(XMLStreamReader xmlReader)
        throws IOException, NumberFormatException, XMLStreamException, ConfigurationException, FilterException {
    PropertiesConfiguration properties = newProperties();

    int pageId = readObjectProperties(xmlReader, properties);

    // Save page// w w w .  j a va 2  s.c  om
    savePageProperties(properties, pageId);

    // Register only current pages (they will take care of handling there history)
    Integer originalVersion = (Integer) properties.getProperty("originalVersion");
    if (originalVersion == null) {
        Integer spaceId = (Integer) properties.getInteger("space", null);
        List<Integer> spacePages = this.pages.get(spaceId);
        if (spacePages == null) {
            spacePages = new LinkedList<Integer>();
            this.pages.put(spaceId, spacePages);
        }
        spacePages.add(pageId);
    }
}