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

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

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Usage

From source file:de.unibremen.swp.stundenplan.config.Config.java

/**
 * Methode setzt den String fuer den gegebenen Key auf den gegebenen String.
 * /*  www .  j av a2 s  .c o m*/
 * @param pKey
 *       der Key bei dem der Wert gesetzt werden soll
 * @param pValue
 *       der String-Wert, der den alten ersetzen soll
 */
public static void setStringValue(final String pKey, final String pValue) {
    if ((pKey == null || pKey.length() == 0))
        throw new IllegalArgumentException("There must be a key");
    if ((pValue == null || pValue.length() == 0))
        throw new IllegalArgumentException("There must be a key");
    propertiesConfig.setProperty(pKey, pValue);
    try {
        propertiesConfig.save();
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
}

From source file:ch.descabato.browser.BackupBrowser.java

public static void main2(final String[] args)
        throws InterruptedException, InvocationTargetException, SecurityException, IOException {
    if (args.length > 1)
        throw new IllegalArgumentException(
                "SYNTAX:  java... " + BackupBrowser.class.getName() + " [initialPath]");

    SwingUtilities.invokeAndWait(new Runnable() {

        @Override//from w  w w . j ava 2s.c o  m
        public void run() {
            tryLoadSubstanceLookAndFeel();
            final JFrame f = new JFrame("OtrosVfsBrowser demo");
            f.addWindowListener(finishedListener);
            Container contentPane = f.getContentPane();
            contentPane.setLayout(new BorderLayout());
            DataConfiguration dc = null;
            final PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
            File favoritesFile = new File("favorites.properties");
            propertiesConfiguration.setFile(favoritesFile);
            if (favoritesFile.exists()) {
                try {
                    propertiesConfiguration.load();
                } catch (ConfigurationException e) {
                    e.printStackTrace();
                }
            }
            dc = new DataConfiguration(propertiesConfiguration);
            propertiesConfiguration.setAutoSave(true);
            final VfsBrowser comp = new VfsBrowser(dc, (args.length > 0) ? args[0] : null);
            comp.setSelectionMode(SelectionMode.FILES_ONLY);
            comp.setMultiSelectionEnabled(true);
            comp.setApproveAction(new AbstractAction(Messages.getMessage("demo.showContentButton")) {
                @Override
                public void actionPerformed(ActionEvent e) {
                    FileObject[] selectedFiles = comp.getSelectedFiles();
                    System.out.println("Selected files count=" + selectedFiles.length);
                    for (FileObject selectedFile : selectedFiles) {
                        try {
                            FileSize fileSize = new FileSize(selectedFile.getContent().getSize());
                            System.out.println(selectedFile.getName().getURI() + ": " + fileSize.toString());
                            Desktop.getDesktop()
                                    .open(new File(new URI(selectedFile.getURL().toExternalForm())));
                            //                byte[] bytes = readBytes(selectedFile.getContent().getInputStream(), 150 * 1024l);
                            //                JScrollPane sp = new JScrollPane(new JTextArea(new String(bytes)));
                            //                JDialog d = new JDialog(f);
                            //                d.setTitle("Content of file: " + selectedFile.getName().getFriendlyURI());
                            //                d.getContentPane().add(sp);
                            //                d.setSize(600, 400);
                            //                d.setVisible(true);
                        } catch (Exception e1) {
                            LOGGER.error("Failed to read file", e1);
                            JOptionPane.showMessageDialog(f,
                                    (e1.getMessage() == null) ? e1.toString() : e1.getMessage(), "Error",
                                    JOptionPane.ERROR_MESSAGE);
                        }
                    }
                }
            });

            comp.setCancelAction(new AbstractAction(Messages.getMessage("general.cancelButtonText")) {
                @Override
                public void actionPerformed(ActionEvent e) {
                    f.dispose();
                    try {
                        propertiesConfiguration.save();
                    } catch (ConfigurationException e1) {
                        e1.printStackTrace();
                    }
                    System.exit(0);
                }
            });
            contentPane.add(comp);

            f.pack();
            f.setVisible(true);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        }
    });
    while (!finished)
        Thread.sleep(100);
}

From source file:edu.emory.library.tast.database.tabscommon.VisibleAttribute.java

private static void loadConfig() {
    try {/*from  w ww  .  j  av  a2  s . co  m*/
        Document document = new XMLConfiguration("table-attributes.xml").getDocument();
        Node mainNode = document.getFirstChild();
        if (mainNode != null) {
            if (mainNode.getNodeType() == Node.ELEMENT_NODE) {
                NodeList attrs = mainNode.getChildNodes();
                for (int j = 0; j < attrs.getLength(); j++) {
                    if (attrs.item(j).getNodeType() == Node.ELEMENT_NODE) {
                        VisibleAttribute attr = VisibleAttribute.fromXML(attrs.item(j));
                        visibleAttributes.put(attr.getName(), attr);
                    }
                }
            }
        }
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
}

From source file:eu.optimis.tf.sp.service.utils.PropertiesUtils.java

public static PropertiesConfiguration getPropertiesConfiguration(String configFile) {
    String filePath = null;//from w ww.ja v a2  s.c  o m
    PropertiesConfiguration config = null;
    filePath = file4OS(configFile);
    try {
        config = new PropertiesConfiguration(filePath);
    } catch (ConfigurationException e) {
        log.error("TRUST: Error reading " + filePath + " configuration file: " + e.getMessage());
        e.printStackTrace();
    }
    return config;
}

From source file:keel.Algorithms.MIL.G3PMI.Main.java

/**
 * <p>/* w  w w.ja v a 2s.  c o m*/
 * Configure the execution of the algorithm.
 * 
 * @param jobFilename Name of the KEEL file with properties of the execution
 *  </p>                  
 */

private static void configureJob(String jobFilename) {

    Properties props = new Properties();

    try {
        InputStream paramsFile = new FileInputStream(jobFilename);
        props.load(paramsFile);
        paramsFile.close();
    } catch (IOException ioe) {
        ioe.printStackTrace();
        System.exit(0);
    }

    // Files training and test
    String trainFile;
    String testFile;
    StringTokenizer tokenizer = new StringTokenizer(props.getProperty("inputData"));
    tokenizer.nextToken();
    trainFile = tokenizer.nextToken();
    trainFile = trainFile.substring(1, trainFile.length() - 1);
    testFile = tokenizer.nextToken();
    testFile = testFile.substring(1, testFile.length() - 1);

    tokenizer = new StringTokenizer(props.getProperty("outputData"));
    String reportTrainFile = tokenizer.nextToken();
    reportTrainFile = reportTrainFile.substring(1, reportTrainFile.length() - 1);
    String reportTestFile = tokenizer.nextToken();
    reportTestFile = reportTestFile.substring(1, reportTestFile.length() - 1);
    //System.out.println("SALIDA: " + reportTestFile);
    //String reportRulesFile = tokenizer.nextToken();
    //reportRulesFile = reportRulesFile.substring(1, reportRulesFile.length()-1);            

    // Algorithm auxiliar configuration
    XMLConfiguration algConf = new XMLConfiguration();
    algConf.setRootElementName("experiment");
    algConf.addProperty("process.algorithm[@type]",
            "org.ayrna.jclec.problem.classification.syntaxtree.multiinstance.G3PMIKeel.G3PMIAlgorithm");
    algConf.addProperty("process.algorithm.rand-gen-factory[@type]",
            "org.ayrna.jclec.util.random.RanecuFactory");
    algConf.addProperty("process.algorithm.rand-gen-factory[@seed]",
            Integer.parseInt(props.getProperty("seed")));
    algConf.addProperty("process.algorithm.population-size",
            Integer.parseInt(props.getProperty("population-size")));
    algConf.addProperty("process.algorithm.max-of-generations",
            Integer.parseInt(props.getProperty("max-generations")));
    algConf.addProperty("process.algorithm.max-deriv-size",
            Integer.parseInt(props.getProperty("max-deriv-size")));
    algConf.addProperty("process.algorithm.species[@type]",
            "org.ayrna.jclec.problem.classification.syntaxtree.multiinstance.G3PMIKeel.G3PMISyntaxTreeSpecies");
    algConf.addProperty("process.algorithm.species.max-deriv-size",
            Integer.parseInt(props.getProperty("max-deriv-size")));
    algConf.addProperty("process.algorithm.species.dataset[@type]",
            "org.ayrna.jclec.util.dataset.KeelMultiInstanceDataSet");
    algConf.addProperty("process.algorithm.species.dataset.file-name", trainFile);
    algConf.addProperty("process.algorithm.species.rand-gen-factory[@type]",
            "org.ayrna.jclec.util.random.RanecuFactory");
    algConf.addProperty("process.algorithm.species.rand-gen-factory[@seed]",
            Integer.parseInt(props.getProperty("seed")));
    algConf.addProperty("process.algorithm.evaluator[@type]",
            "org.ayrna.jclec.problem.classification.syntaxtree.multiinstance.G3PMIKeel.G3PMIEvaluator");
    algConf.addProperty("process.algorithm.evaluator.rand-gen-factory[@type]",
            "org.ayrna.jclec.util.random.RanecuFactory");
    algConf.addProperty("process.algorithm.evaluator.rand-gen-factory[@seed]",
            Integer.parseInt(props.getProperty("seed")));
    algConf.addProperty("process.algorithm.evaluator.dataset[@type]",
            "org.ayrna.jclec.util.dataset.KeelMultiInstanceDataSet");
    algConf.addProperty("process.algorithm.evaluator.dataset.file-name", trainFile);
    algConf.addProperty("process.algorithm.evaluator.max-deriv-size",
            Integer.parseInt(props.getProperty("max-deriv-size")));
    algConf.addProperty("process.algorithm.provider[@type]", "org.ayrna.jclec.syntaxtree.SyntaxTreeCreator");
    algConf.addProperty("process.algorithm.parents-selector[@type]",
            "org.ayrna.jclec.selector.RouletteSelector");
    algConf.addProperty("process.algorithm.recombinator.decorated[@type]",
            "org.ayrna.jclec.problem.classification.syntaxtree.multiinstance.G3PMIKeel.G3PMICrossover");
    algConf.addProperty("process.algorithm.recombinator.recombination-prob",
            Double.parseDouble(props.getProperty("rec-prob")));
    algConf.addProperty("process.algorithm.mutator.decorated[@type]",
            "org.ayrna.jclec.problem.classification.syntaxtree.multiinstance.G3PMIKeel.G3PMIMutator");
    algConf.addProperty("process.algorithm.mutator.mutation-prob",
            Double.parseDouble(props.getProperty("mut-prob")));
    algConf.addProperty("process.listeners.listener[@type]",
            "org.ayrna.jclec.problem.classification.syntaxtree.multiinstance.G3PMIKeel.G3PMIPopulationReport");
    algConf.addProperty("process.listeners.listener.report-dir-name", "./");
    algConf.addProperty("process.listeners.listener.train-report-file", reportTrainFile);
    algConf.addProperty("process.listeners.listener.test-report-file", reportTestFile);
    algConf.addProperty("process.listeners.listener.global-report-name", "resumen");
    algConf.addProperty("process.listeners.listener.report-frequency", 50);
    algConf.addProperty("process.listeners.listener.test-dataset[@type]",
            "org.ayrna.jclec.util.dataset.KeelMultiInstanceDataSet");
    algConf.addProperty("process.listeners.listener.test-dataset.file-name", testFile);

    try {
        algConf.save(new File("configure.txt"));
    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    org.ayrna.jclec.genlab.GenLab.main(new String[] { "configure.txt" });
}

From source file:com.intuit.tank.proxy.config.CommonsProxyConfiguration.java

public static boolean save(int port, boolean followRedirect, String outputFile,
        Set<ConfigInclusionExclusionRule> inclusions, Set<ConfigInclusionExclusionRule> exclusions,
        Set<ConfigInclusionExclusionRule> bodyInclusions, Set<ConfigInclusionExclusionRule> bodyExclusions,
        String fileName) {/*w  w  w .ja v a2s  .  c  om*/

    ConfigurationNode node = getConfNode("recording-proxy-config", "", false);
    ConfigurationNode portNode = getConfNode("proxy-port", String.valueOf(port), false);
    ConfigurationNode followRedirectNode = getConfNode("follow-redirects", Boolean.toString(followRedirect),
            false);
    ConfigurationNode outputFileNode = getConfNode("output-file", outputFile, false);
    ConfigurationNode inclusionsNode = getConfNode("inclusions", "", false);
    ConfigurationNode exclusionsNode = getConfNode("exclusions", "", false);
    ConfigurationNode bodyInclusionsNode = getConfNode("body-inclusions", "", false);
    ConfigurationNode bodyExclusionsNode = getConfNode("body-exclusions", "", false);

    updateRuleParentNode(inclusions, inclusionsNode);
    updateRuleParentNode(exclusions, exclusionsNode);
    updateRuleParentNode(bodyInclusions, bodyInclusionsNode);
    updateRuleParentNode(bodyExclusions, bodyExclusionsNode);

    node.addChild(portNode);
    node.addChild(followRedirectNode);
    node.addChild(outputFileNode);
    node.addChild(inclusionsNode);
    node.addChild(exclusionsNode);
    node.addChild(bodyInclusionsNode);
    node.addChild(bodyExclusionsNode);

    HierarchicalConfiguration hc = new HierarchicalConfiguration();
    hc.setRootNode(node);
    XMLConfiguration xmlConfiguration = new XMLConfiguration(hc);
    xmlConfiguration.setRootNode(node);

    try {

        xmlConfiguration.save(new File(fileName));
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
    return true;

}

From source file:com.sinfonier.util.XMLProperties.java

/**
 * Get property from component.//from  w w w .  ja  v a2  s  .co m
 * 
 * @param property Property to get
 * @param componentName Name of the component
 * @param componentType Type of the component
 * @param xmlPath Path to xml file configuration
 * @return Property value or null if doesn't exists
 */
public static String getPropertyFromComponent(String property, String componentName,
        ComponentType componentType, String xmlPath) {
    String result = null;
    XMLConfiguration xml;
    try {
        xml = new XMLConfiguration(xmlPath);
        xml.setExpressionEngine(new XPathExpressionEngine());
        switch (componentType) {
        case BOLT:
            result = xml.getString("bolts/bolt[@abstractionId='" + componentName + "']/" + property);
            break;
        case SPOUT:
            result = xml.getString("spouts/spout[@abstractionId='" + componentName + "']/" + property);
            break;
        case DRAIN:
            result = xml.getString("drains/drain[@abstractionId='" + componentName + "']/" + property);
            break;
        case OPTIONS:
            break;
        }
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
    return result;
}

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

/**
* Gets the editor's configuration.//from  www . j a  va  2  s  .  com
* 
* @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  www  . ja v  a2s.  c  o  m*/
        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  ava2 s  .c o  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;
}