Example usage for org.apache.commons.configuration ConfigurationException getMessage

List of usage examples for org.apache.commons.configuration ConfigurationException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.configuration ConfigurationException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:net.daimonin.client3d.editor.main.Editor3D.java

/**
* Gets the editor's configuration./*ww  w  .ja  v a 2 s.  c  om*/
* 
* @return The editor's configuration.
*/
private static PropertiesConfiguration readConfig() {
    try {
        final String config = "editor3d.config";
        // test if confFile exists
        if (!new File(config).exists()) {
            exit(1, "Configuration file '" + config + "' does not exist!");
        }
        return new PropertiesConfiguration(config);
    } catch (ConfigurationException e) {
        e.printStackTrace();
        printError(e.getMessage());
        return null;
    }
}

From source file:net.daimonin.client3d.editor.main.Editor3D.java

private static void saveConfig(GeneratePanel allPanel) {
    boolean confChanged = false;
    if (allPanel.jCheckBoxStartingDir.isSelected() && !startingDir.equals(conf.getString(CONF_IMAGES_DIR))) {
        confChanged = true;//from   w  ww  .  j av  a  2s  .com
        conf.setProperty(CONF_IMAGES_DIR, startingDir);
    }
    if (allPanel.jCheckBoxBorderSize.isSelected() && !borderSize.equals(conf.getString(CONF_BORDER_SIZE))) {
        confChanged = true;
        conf.setProperty(CONF_BORDER_SIZE, borderSize);
    }
    if (allPanel.jCheckBoxBorderColor.isSelected()
            && !borderColorR.equals(conf.getString(CONF_BORDER_COLOR_RED))) {
        confChanged = true;
        conf.setProperty(CONF_BORDER_COLOR_RED, borderColorR);
    }
    if (allPanel.jCheckBoxBorderColor.isSelected()
            && !borderColorG.equals(conf.getString(CONF_BORDER_COLOR_GREEN))) {
        confChanged = true;
        conf.setProperty(CONF_BORDER_COLOR_GREEN, borderColorG);
    }
    if (allPanel.jCheckBoxBorderColor.isSelected()
            && !borderColorB.equals(conf.getString(CONF_BORDER_COLOR_BLUE))) {
        confChanged = true;
        conf.setProperty(CONF_BORDER_COLOR_BLUE, borderColorB);
    }

    try {
        if (confChanged) {
            conf.save(conf.getFile());
            printInfo("Configuration saved");
        }
    } catch (ConfigurationException e) {
        e.printStackTrace();
        printError(e.getMessage());
    }
}

From source file:net.daimonin.client3d.editor.main.Editor3D.java

/**
* Saves preferences if they were changed.
* 
* @param prefPanel prefPanel//from  w  w  w . j  av a  2s. co  m
*/
public static void savePreferences(PreferencesPanel prefPanel) {
    boolean prefsChanged = false;

    final String filenamePNG = prefPanel.jTextFieldFilenamePNG.getText();
    if (filenamePNG != null && !filenamePNG.equals(conf.getString(CONF_FILENAME_IMAGESET))) {
        prefsChanged = true;
        conf.setProperty(CONF_FILENAME_IMAGESET, filenamePNG);
        imageset = filenamePNG;
    }

    final String filenameXML = prefPanel.jTextFieldFilenameXML.getText();
    if (filenameXML != null && !filenameXML.equals(conf.getString(CONF_FILENAME_IMAGESET_XML))) {
        prefsChanged = true;
        conf.setProperty(CONF_FILENAME_IMAGESET_XML, filenameXML);
        imagesetxml = filenameXML;
    }

    final boolean restrictSize = prefPanel.jCheckBoxRestrictPNGSize.isSelected();
    if (!String.valueOf(restrictSize).equals(conf.getString(CONF_RESTRICT_SIZE))) {
        prefsChanged = true;
        conf.setProperty(CONF_RESTRICT_SIZE, String.valueOf(restrictSize));
        restrictImageSize = restrictSize;
    }

    final String restrictedWidth = prefPanel.jTextFieldRestrictedWidth.getText();
    if (restrictedWidth != null && !restrictedWidth.equals(conf.getString(CONF_RESTRICT_SIZE_WIDTH))) {
        prefsChanged = true;
        conf.setProperty(CONF_RESTRICT_SIZE_WIDTH, restrictedWidth);
        maxWidth = Integer.valueOf(restrictedWidth);
    }

    final String restrictedHeight = prefPanel.jTextFieldRestrictedHeight.getText();
    if (restrictedHeight != null && !restrictedHeight.equals(conf.getString(CONF_RESTRICT_SIZE_HEIGHT))) {
        prefsChanged = true;
        conf.setProperty(CONF_RESTRICT_SIZE_HEIGHT, restrictedHeight);
        maxHeight = Integer.valueOf(restrictedHeight);
    }

    try {
        if (prefsChanged) {
            conf.save(conf.getFile());
            printInfo("Preferences saved");
        }
    } catch (ConfigurationException e) {
        e.printStackTrace();
        printError(e.getMessage());
    }

    // clean up
    frame.jScrollPaneMain.setViewportView(null);
    frame.prefPanel = null;
}

From source file:com.innovyt.transit.util.TopologyConfig.java

public TopologyConfig(String fileName) {

    config = new PropertiesConfiguration();
    try {//from   w w  w.  j  a  v  a2  s .  c o m
        config.load(this.getClass().getResourceAsStream("/" + fileName));
    } catch (ConfigurationException e) {
        throw new RuntimeException(e.getMessage());
    }
}

From source file:com.rinxor.example.in.memory.datagrid.cache.AppConf.java

private void load(String cfgFilePath) {
    try {// w w  w . ja va  2  s  .  c  o  m
        XMLConfiguration reader = new XMLConfiguration(cfgFilePath);

        zoneId = reader.getString("server.zoneId");
        nodeId = reader.getString("server.uniqueNodeId");

    } catch (ConfigurationException ex) {
        LOG.error(ex.getMessage());
    }
}

From source file:iddb.web.security.SecurityConfig.java

private SecurityConfig() {
    try {// w  w  w  .  j  a v a 2s .c  o  m
        HierarchicalINIConfiguration configFile = new HierarchicalINIConfiguration(
                this.getClass().getClassLoader().getResource("security.properties"));
        for (Object section : configFile.getSections()) {
            SubnodeConfiguration node = configFile.getSection((String) section);
            Map<String, String> map = new LinkedHashMap<String, String>();
            for (@SuppressWarnings("unchecked")
            Iterator<Object> it = node.getKeys(); it.hasNext();) {
                String key = it.next().toString();
                if (log.isTraceEnabled()) {
                    log.trace("Loading '{}' with value '{}' on section '{}'",
                            new String[] { key, node.getString(key), section.toString() });
                }
                map.put(key, node.getString(key));
            }
            config.put(section.toString(), map);
        }
    } catch (ConfigurationException e) {
        log.error(e.getMessage());
    }
}

From source file:de.anhquan.vtv.VTVConfig.java

public void loadConfig(String filePath) {
    try {//  ww  w  . j  a v a 2s .  com
        config = new PropertiesConfiguration(filePath);
    } catch (ConfigurationException e) {
        config = null;
        log.error("ConfigurationException : " + e.getMessage());
    }
}

From source file:com.sm.store.cluster.BuildStoreConfig.java

private void init() {
    try {/*from w ww. ja  v a  2 s  . co m*/
        config = new XMLConfiguration(fileName);

    } catch (ConfigurationException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:com.sm.store.BuildRemoteConfig.java

private void init() {
    try {//from   w  ww. ja v a 2  s  . c  o m
        config = new XMLConfiguration(fileName);
    } catch (ConfigurationException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:com.github.rnewson.couchdb.lucene.ConfigTest.java

@Test
public void testGetConfiguration() {
    try {//from ww w  . ja v  a2 s  .  co  m
        final Config config = new Config();
        HierarchicalINIConfiguration configuration = config.getConfiguration();
        assertEquals("localhost", configuration.getString("lucene.host"));
        assertEquals(5985, configuration.getInt("lucene.port"));
    } catch (ConfigurationException ce) {
        fail("ConfigurationException shouldn't have been thrown." + ce.getMessage());
    }
}