Search in sources :

Example 1 with ConfigurationException

use of org.craftercms.commons.config.ConfigurationException in project engine by craftercms.

the class SiteContextFactory method getProxyConfig.

protected HierarchicalConfiguration getProxyConfig(SiteContext siteContext, List<String> configPaths, ResourceLoader resourceLoader) {
    String siteName = siteContext.getSiteName();
    logger.info("-------------------------------------------------------");
    logger.info("<Loading proxy configuration for site: " + siteName + ">");
    logger.info("-------------------------------------------------------");
    try {
        ListIterator<String> iterator = configPaths.listIterator(configPaths.size());
        while (iterator.hasPrevious()) {
            Resource resource = resourceLoader.getResource(iterator.previous());
            if (resource.exists()) {
                return configurationReader.readXmlConfiguration(resource);
            }
        }
        return null;
    } catch (ConfigurationException e) {
        throw new SiteContextCreationException("Unable to load proxy configuration for site '" + siteName + "'", e);
    } finally {
        logger.info("---------------------------------------------------------");
        logger.info("</Loading proxy configuration for site: " + siteName + ">");
        logger.info("---------------------------------------------------------");
    }
}
Also used : SiteContextCreationException(org.craftercms.engine.exception.SiteContextCreationException) ConfigurationException(org.craftercms.commons.config.ConfigurationException) Resource(org.springframework.core.io.Resource)

Example 2 with ConfigurationException

use of org.craftercms.commons.config.ConfigurationException in project engine by craftercms.

the class SiteContextFactory method getConfig.

protected HierarchicalConfiguration getConfig(SiteContext siteContext, String[] configPaths, ResourceLoader resourceLoader) {
    String siteName = siteContext.getSiteName();
    logger.info("--------------------------------------------------");
    logger.info("<Loading configuration for site: " + siteName + ">");
    logger.info("--------------------------------------------------");
    try {
        for (int i = configPaths.length - 1; i >= 0; i--) {
            Resource config = resourceLoader.getResource(configPaths[i]);
            if (config.exists()) {
                return configurationReader.readXmlConfiguration(config);
            }
        }
        return null;
    } catch (ConfigurationException e) {
        throw new SiteContextCreationException("Unable to load configuration for site '" + siteName + "'", e);
    } finally {
        logger.info("--------------------------------------------------");
        logger.info("</Loading configuration for site: " + siteName + ">");
        logger.info("--------------------------------------------------");
    }
}
Also used : SiteContextCreationException(org.craftercms.engine.exception.SiteContextCreationException) ConfigurationException(org.craftercms.commons.config.ConfigurationException) Resource(org.springframework.core.io.Resource)

Aggregations

ConfigurationException (org.craftercms.commons.config.ConfigurationException)2 SiteContextCreationException (org.craftercms.engine.exception.SiteContextCreationException)2 Resource (org.springframework.core.io.Resource)2