Search in sources :

Example 1 with PropertiesFileConfiguration

use of org.pentaho.platform.config.PropertiesFileConfiguration in project pentaho-platform by pentaho.

the class PentahoSystemPluginManager method registerSettings.

private void registerSettings(IPlatformPlugin plugin, ClassLoader loader) {
    IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
    InputStream stream = resLoader.getResourceAsStream(loader, "settings.xml");
    if (stream == null) {
        // No settings.xml is fine
        return;
    }
    Properties properties = new Properties();
    try {
        Document docFromStream = XmlDom4JHelper.getDocFromStream(stream);
        for (Object element : docFromStream.getRootElement().elements()) {
            Element ele = (Element) element;
            String name = ele.getName();
            String value = ele.getText();
            properties.put("settings/" + name, value);
        }
    } catch (DocumentException | IOException e) {
        logger.error("Error parsing settings.xml for plugin: " + plugin.getId(), e);
    }
    try {
        systemConfig.registerConfiguration(new PropertiesFileConfiguration(plugin.getId(), properties));
    } catch (IOException e) {
        logger.error("Error registering settings.xml for plugin: " + plugin.getId(), e);
    }
}
Also used : PropertiesFileConfiguration(org.pentaho.platform.config.PropertiesFileConfiguration) InputStream(java.io.InputStream) Element(org.dom4j.Element) DocumentException(org.dom4j.DocumentException) IOException(java.io.IOException) Properties(java.util.Properties) Document(org.dom4j.Document) IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 Document (org.dom4j.Document)1 DocumentException (org.dom4j.DocumentException)1 Element (org.dom4j.Element)1 IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)1 PropertiesFileConfiguration (org.pentaho.platform.config.PropertiesFileConfiguration)1