Search in sources :

Example 81 with Configuration

use of org.apache.commons.configuration.Configuration 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)

Example 82 with Configuration

use of org.apache.commons.configuration.Configuration in project metron by apache.

the class SettingsLoader method loadKnownHosts.

public static Map<String, JSONObject> loadKnownHosts(String config_path) throws ConfigurationException, ParseException {
    Configuration hosts = new PropertiesConfiguration(config_path);
    Iterator<String> keys = hosts.getKeys();
    Map<String, JSONObject> known_hosts = new HashMap<String, JSONObject>();
    JSONParser parser = new JSONParser();
    while (keys.hasNext()) {
        String key = keys.next().trim();
        JSONArray value = (JSONArray) parser.parse(hosts.getProperty(key).toString());
        known_hosts.put(key, (JSONObject) value.get(0));
    }
    return known_hosts;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) XMLConfiguration(org.apache.commons.configuration.XMLConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) JSONObject(org.json.simple.JSONObject) HashMap(java.util.HashMap) JSONArray(org.json.simple.JSONArray) JSONParser(org.json.simple.parser.JSONParser) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 83 with Configuration

use of org.apache.commons.configuration.Configuration in project metron by apache.

the class SettingsLoader method loadTopologyIdnetifier.

@SuppressWarnings("unchecked")
public static JSONObject loadTopologyIdnetifier(String config_path) throws ConfigurationException {
    Configuration config = new PropertiesConfiguration(config_path);
    String topology = config.getString("topology.id", "unknown");
    String instance = config.getString("instance.id", "unknown");
    JSONObject identifier = new JSONObject();
    identifier.put("topology", topology);
    identifier.put("topology_instance", instance);
    return identifier;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) XMLConfiguration(org.apache.commons.configuration.XMLConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) JSONObject(org.json.simple.JSONObject) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 84 with Configuration

use of org.apache.commons.configuration.Configuration in project winery by eclipse.

the class CsarExporter method addNamespacePrefixes.

/**
 * Writes the configured mapping namespaceprefix -> namespace to the archive
 * <p>
 * This is kind of a quick hack. TODO: during the import, the prefixes should be extracted using JAXB and stored in
 * the NamespacesResource
 */
private void addNamespacePrefixes(ArchiveOutputStream zos, IRepository repository) throws IOException {
    Configuration configuration = repository.getConfiguration(new NamespacesId());
    if (configuration instanceof PropertiesConfiguration) {
        // Quick hack: direct serialization only works for PropertiesConfiguration
        PropertiesConfiguration pconf = (PropertiesConfiguration) configuration;
        ArchiveEntry archiveEntry = new ZipArchiveEntry(CsarExporter.PATH_TO_NAMESPACES_PROPERTIES);
        zos.putArchiveEntry(archiveEntry);
        try {
            pconf.save(zos);
        } catch (ConfigurationException e) {
            CsarExporter.LOGGER.debug(e.getMessage(), e);
            zos.write("#Could not export properties".getBytes());
            zos.write(("#" + e.getMessage()).getBytes());
        }
        zos.closeArchiveEntry();
    }
}
Also used : Configuration(org.apache.commons.configuration.Configuration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) NamespacesId(org.eclipse.winery.common.ids.admin.NamespacesId) ConfigurationException(org.apache.commons.configuration.ConfigurationException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ZipArchiveEntry(org.apache.commons.compress.archivers.zip.ZipArchiveEntry) ZipArchiveEntry(org.apache.commons.compress.archivers.zip.ZipArchiveEntry) ArchiveEntry(org.apache.commons.compress.archivers.ArchiveEntry) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 85 with Configuration

use of org.apache.commons.configuration.Configuration in project wcomponents by BorderTech.

the class StandaloneLauncher method main.

/**
 * The entry point when the launcher is run as a java application.
 *
 * @param args command-line arguments, ignored.
 * @throws Exception on error
 */
public static void main(final String[] args) throws Exception {
    // Set the logger to use the text area logger
    System.setProperty("org.apache.commons.logging.Log", "com.github.bordertech.wcomponents.lde.StandaloneLauncher$TextAreaLogger");
    // Set the port number to a random port
    Configuration internalWComponentConfig = Config.getInstance();
    CompositeConfiguration config = new CompositeConfiguration(new MapConfiguration(new HashMap<String, Object>()));
    // Internal WComponent config next
    config.addConfiguration(internalWComponentConfig);
    config.setProperty(ConfigurationProperties.LDE_SERVER_PORT, 0);
    Config.setConfiguration(config);
    getInstance().launcher.run();
    getInstance().log("LDE now running on " + getInstance().launcher.getUrl() + '\n');
}
Also used : Configuration(org.apache.commons.configuration.Configuration) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) MapConfiguration(org.apache.commons.configuration.MapConfiguration) HashMap(java.util.HashMap) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) MapConfiguration(org.apache.commons.configuration.MapConfiguration)

Aggregations

Configuration (org.apache.commons.configuration.Configuration)185 Test (org.junit.Test)51 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)44 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)23 Test (org.testng.annotations.Test)22 File (java.io.File)14 AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)13 MidpointConfiguration (com.evolveum.midpoint.common.configuration.api.MidpointConfiguration)11 Properties (java.util.Properties)10 HashMap (java.util.HashMap)9 AtlasException (org.apache.atlas.AtlasException)9 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)9 ArrayList (java.util.ArrayList)8 ZkUtils (kafka.utils.ZkUtils)8 ConfigurationException (org.apache.commons.configuration.ConfigurationException)8 IndexLoadingConfigMetadata (com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata)7 AtlasClient (org.apache.atlas.AtlasClient)6 BeforeClass (org.testng.annotations.BeforeClass)6 MockResponse (com.github.bordertech.wcomponents.util.mock.MockResponse)5 IOException (java.io.IOException)5