Search in sources :

Example 56 with ConfigurationException

use of org.apache.commons.configuration.ConfigurationException in project ddf by codice.

the class DdfBrandingPlugin method init.

public void init() {
    try {
        PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(getClass().getResource(brandingPropertiesFilePath));
        productName = propertiesConfiguration.getString("branding.product.name", "DDF");
        productURL = propertiesConfiguration.getString("branding.product.url", "http://codice.org/ddf");
        productImage = propertiesConfiguration.getString("branding.product.image", "/ddf/ddf.png");
        vendorName = propertiesConfiguration.getString("branding.vendor.name", "Codice");
        vendorURL = propertiesConfiguration.getString("branding.vendor.url", "http://codice.org");
        vendorImage = propertiesConfiguration.getString("branding.vendor.image", "/ddf/logo.png");
        favIcon = propertiesConfiguration.getString("branding.favicon", "/ddf/favicon.png");
    } catch (ConfigurationException e) {
        LOGGER.info("Unable to read properties file {}", brandingPropertiesFilePath, e.getMessage());
        productName = "DDF";
        productURL = "http://codice.org/ddf";
        productImage = "/ddf/ddf.png";
        vendorName = "Codice";
        vendorURL = "http://codice.org";
        vendorImage = "/ddf/logo.png";
        favIcon = "/ddf/favicon.png";
    }
}
Also used : ConfigurationException(org.apache.commons.configuration.ConfigurationException) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 57 with ConfigurationException

use of org.apache.commons.configuration.ConfigurationException in project engine by craftercms.

the class MultiConfigurationBuilder method getConfiguration.

@Override
public Configuration getConfiguration() throws ConfigurationException {
    List<Configuration> configs = new ArrayList<>();
    // Last configurations should be loaded and added first so that they have greater priority.
    logger.info("Loading XML configurations in the order in which the properties will be resolved");
    for (int i = configPaths.length - 1; i >= 0; i--) {
        try {
            Resource resource = resourceLoader.getResource(configPaths[i]);
            if (resource.exists()) {
                XMLConfiguration config = new XMLConfiguration();
                config.load(resource.getInputStream());
                logger.info("XML configuration loaded from " + resource);
                configs.add(config);
            }
        } catch (Exception e) {
            throw new ConfigurationException("Unable to load configuration at " + configPaths[i], e);
        }
    }
    if (configs.size() > 1) {
        CombinedConfiguration combinedConfig = new CombinedConfiguration(new OverrideCombiner());
        for (Configuration config : configs) {
            combinedConfig.addConfiguration((AbstractConfiguration) config);
        }
        return combinedConfig;
    } else if (configs.size() == 1) {
        return configs.get(0);
    } else {
        return null;
    }
}
Also used : XMLConfiguration(org.apache.commons.configuration.XMLConfiguration) Configuration(org.apache.commons.configuration.Configuration) AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) XMLConfiguration(org.apache.commons.configuration.XMLConfiguration) CombinedConfiguration(org.apache.commons.configuration.CombinedConfiguration) ConfigurationException(org.apache.commons.configuration.ConfigurationException) ArrayList(java.util.ArrayList) Resource(org.springframework.core.io.Resource) CombinedConfiguration(org.apache.commons.configuration.CombinedConfiguration) ConfigurationException(org.apache.commons.configuration.ConfigurationException) OverrideCombiner(org.apache.commons.configuration.tree.OverrideCombiner)

Example 58 with ConfigurationException

use of org.apache.commons.configuration.ConfigurationException in project engine by craftercms.

the class SiteContextFactory method getConfig.

protected HierarchicalConfiguration getConfig(SiteContext siteContext, String[] configPaths, ResourceLoader resourceLoader) {
    String siteName = siteContext.getSiteName();
    try {
        logger.info("--------------------------------------------------");
        logger.info("<Loading configuration for site: " + siteName + ">");
        logger.info("--------------------------------------------------");
        ConfigurationBuilder builder = new MultiConfigurationBuilder(configPaths, resourceLoader);
        HierarchicalConfiguration config = (HierarchicalConfiguration) builder.getConfiguration();
        logger.info("--------------------------------------------------");
        logger.info("</Loading configuration for site: " + siteName + ">");
        logger.info("--------------------------------------------------");
        return config;
    } catch (ConfigurationException e) {
        throw new SiteContextCreationException("Unable to load configuration for site '" + siteContext.getSiteName() + "'", e);
    }
}
Also used : SiteContextCreationException(org.craftercms.engine.exception.SiteContextCreationException) MultiConfigurationBuilder(org.craftercms.engine.util.config.impl.MultiConfigurationBuilder) ConfigurationBuilder(org.apache.commons.configuration.ConfigurationBuilder) ConfigurationException(org.apache.commons.configuration.ConfigurationException) MultiConfigurationBuilder(org.craftercms.engine.util.config.impl.MultiConfigurationBuilder) HierarchicalConfiguration(org.apache.commons.configuration.HierarchicalConfiguration)

Aggregations

ConfigurationException (org.apache.commons.configuration.ConfigurationException)58 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)24 File (java.io.File)18 IOException (java.io.IOException)18 ActionEvent (java.awt.event.ActionEvent)6 ActionListener (java.awt.event.ActionListener)5 MalformedURLException (java.net.MalformedURLException)5 ArrayList (java.util.ArrayList)5 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)5 DistributedLogConfiguration (com.twitter.distributedlog.DistributedLogConfiguration)4 FileInputStream (java.io.FileInputStream)4 FileWriter (java.io.FileWriter)4 Configuration (org.apache.commons.configuration.Configuration)4 FileNotFoundException (java.io.FileNotFoundException)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 CommonsConfiguration (com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration)2 BufferedWriter (java.io.BufferedWriter)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 SQLException (java.sql.SQLException)2