List of usage examples for org.apache.commons.configuration ConfigurationException getMessage
public String getMessage()
From source file:com.codejumble.opentube.Main.java
/** * Initilizes the main frame of the program. Loads settings and initializes * the components of the view.//from w w w . ja v a 2s .c o m */ public Main() { // Load configuration try { configuration = loadConfiguration(); } catch (ConfigurationException e) { createErrorDialog(this, e.getMessage(), "Fatal error"); System.exit(1); } catch (Exception e) { createErrorDialog(this, e.getMessage(), "Fatal error"); System.exit(1); } initParameters(); initComponents(); }
From source file:com.codejumble.opentube.Main.java
/** * Opens the settings dialog and processes the changes performed (if * necessary)/*from w w w .ja va 2s . com*/ * * @param evt Swing event */ private void settingsItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_settingsItemActionPerformed JTextField setting = new JTextField(configuredFolderForDownloadedMedia); Object[] settings = { "Downloads folder", setting }; int option = JOptionPane.showConfirmDialog(null, settings, "Settings", JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION) { configuration.setProperty("downloadFolder", setting.getText()); try { logger.info("Saving settings"); configuration.save(); } catch (ConfigurationException ex) { createErrorDialog(this, ex.getMessage(), "Fatal error"); } } }
From source file:com.mirth.connect.manager.ManagerDialog.java
public boolean saveProperties() { if (managerController.getServerProperties().getReloadingStrategy().reloadingRequired()) { if (!managerController.alertOptionDialog(this, "Server properties have changed on disk since the manager was opened. Are you sure you wish to overwrite them?")) { return false; }/* w ww . j a v a 2 s . c o m*/ managerController.getServerProperties().reload(); } if (managerController.getLog4jProperties().getReloadingStrategy().reloadingRequired()) { if (!managerController.alertOptionDialog(this, "Log4j properties have changed on disk since the manager was opened. Are you sure you wish to overwrite them?")) { return false; } managerController.getLog4jProperties().reload(); } managerController.getServerProperties().setProperty(ManagerConstants.SERVER_WEBSTART_PORT, webstartPortField.getText()); managerController.getServerProperties().setProperty(ManagerConstants.SERVER_ADMINISTRATOR_PORT, adminPortField.getText()); managerController.getServerProperties().setProperty(ManagerConstants.DATABASE_TYPE, ((String) databaseTypeCombobox.getSelectedItem())); managerController.getServerProperties().setProperty(ManagerConstants.DATABASE_URL, databaseUrlField.getText()); managerController.getServerProperties().setProperty(ManagerConstants.DATABASE_USERNAME, databaseUsernameField.getText()); managerController.getServerProperties().setProperty(ManagerConstants.DATABASE_PASSWORD, new String(databasePasswordField.getPassword())); try { managerController.getServerProperties().save(); } catch (ConfigurationException e) { managerController.alertErrorDialog(this, "Error saving " + managerController.getServerProperties().getFile().getPath() + ":\n" + e.getMessage()); } String[] logLevel = managerController.getLog4jProperties() .getStringArray(ManagerConstants.LOG4J_MIRTH_LOG_LEVEL); logLevel[0] = (String) mainLogLevelCombobox.getSelectedItem(); managerController.getLog4jProperties().setProperty(ManagerConstants.LOG4J_MIRTH_LOG_LEVEL, logLevel); managerController.getLog4jProperties().setProperty(ManagerConstants.LOG4J_DATABASE_LOG_LEVEL, (String) databaseLogLevelCombobox.getSelectedItem()); String channelLogLevelCode = (String) channelLogLevelCombobox.getSelectedItem(); // Only set all of the log levels if the selected value is not blank if (!ManagerConstants.LOG4J_ERROR_CODES_WITH_BLANK[0].equals(channelLogLevelCode)) { for (String channelLogLevel : ManagerConstants.LOG4J_CHANNEL_LOG_LEVELS) { managerController.getLog4jProperties().setProperty(channelLogLevel, channelLogLevelCode); } } try { managerController.getLog4jProperties().save(); } catch (ConfigurationException e) { managerController.alertErrorDialog(this, "Error saving " + managerController.getLog4jProperties().getFile().getPath() + ":\n" + e.getMessage()); } managerController.setServiceXmx(serverMemoryField.getText()); setApplyEnabled(false); return true; }
From source file:com.qspin.qtaste.ui.TestCaseTree.java
public void loadSelectedTestCase(TreePath path) { if (path != null) { FileNode fn = getFileNode(path); if (fn != null && fn.isTestcaseDir()) { File testcaseFile = fn.getTestcaseFile(); if (testCasePane.getTestScripPane() != null) { try { if (testcaseFile.getAbsoluteFile().getCanonicalPath() .equals(testCasePane.getTestScripPane().getFileName())) { return; }//w w w .jav a2 s .c om } catch (IOException e) { logger.error(e.getMessage()); return; } } if (testcaseFile != null) { testCasePane.setCurrentSelectedFileNode(fn); if (fn.getFile().getName().equals("TestSuite")) { testCasePane.setCurrentSelectedTestsuite("TestSuite"); } else { String parentDir = testcaseFile.getParent(); testCasePane.setCurrentSelectedTestsuite(parentDir); } setTestCaseSource(testcaseFile, false); } File testcaseData = fn.getPythonTestScript().getTestcaseData(); if (testcaseData != null) { setTestCaseData(testcaseData, false); } File testcaseRequirement = fn.getPythonTestScript().getTestcaseRequirements(); if (testcaseRequirement != null) { setTestCaseRequirement(testcaseRequirement, false); } // regenerate the doc if file date of script > file date of doc PythonTestScript script = fn.getPythonTestScript(); boolean generateDoc = testCasePane.isDocTabSelected() && !script.isDocSynchronized(); if (generateDoc) { testCasePane.parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); script.generateDoc(); // Generate the documentation setTestCaseDoc(script.getTestcaseDoc(), false); testCasePane.parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } else // update the screen with the doc of the selected test script setTestCaseDoc(script.getTestcaseDoc(), false); // Get the user preferences to display the testcase tab GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); String testCaseTabOnSelect = "none"; // default if (guiConfiguration.containsKey(TEST_CASE_TAB_ON_SELECT_PROPERTY)) { testCaseTabOnSelect = guiConfiguration.getString(TEST_CASE_TAB_ON_SELECT_PROPERTY) .toLowerCase(); } else { guiConfiguration.setProperty(TEST_CASE_TAB_ON_SELECT_PROPERTY, testCaseTabOnSelect); try { guiConfiguration.save(); } catch (ConfigurationException ex) { logger.error("Error while saving GUI configuration: " + ex.getMessage()); } } if (testCaseTabOnSelect.equals("doc")) { testCasePane.getTabbedPane().setSelectedIndex(TestCasePane.DOC_INDEX); } else if (testCaseTabOnSelect.equals("source")) { testCasePane.getTabbedPane().setSelectedIndex(TestCasePane.SOURCE_INDEX); } else if (testCaseTabOnSelect.equals("results")) { testCasePane.getTabbedPane().setSelectedIndex(TestCasePane.RESULTS_INDEX); } else if (testCaseTabOnSelect.equals("logs")) { testCasePane.getTabbedPane().setSelectedIndex(TestCasePane.LOGS_INDEX); } else if (!testCaseTabOnSelect.equals("none")) { logger.warn("Invalid value for GUI configuration property " + TEST_CASE_TAB_ON_SELECT_PROPERTY + " (" + guiConfiguration.getString(TEST_CASE_TAB_ON_SELECT_PROPERTY) + ")"); } } } }
From source file:edu.hawaii.soest.hioos.storx.StorXDispatcher.java
private boolean parseConfiguration() { boolean failed = true; try {// ww w. ja v a2 s . c o m // create an XML Configuration object from the sensor XML file File xmlConfigFile = new File(this.xmlConfigurationFile); this.xmlConfiguration = new XMLConfiguration(xmlConfigFile); failed = false; } catch (NullPointerException npe) { logger.info("There was an error reading the XML configuration file. " + "The error message was: " + npe.getMessage()); } catch (ConfigurationException ce) { logger.info("There was an error creating the XML configuration. " + "The error message was: " + ce.getMessage()); } return !failed; }
From source file:edu.usc.goffish.gofs.namenode.DataNode.java
private DataNode(Path dataNodePath) throws IOException { _dataNodePath = dataNodePath.normalize().toAbsolutePath(); _dataNodeSliceDirPath = _dataNodePath.resolve(DATANODE_SLICE_DIR); _config = new PropertiesConfiguration(); _config.setDelimiterParsingDisabled(true); try {/*from w w w .j a v a2s . c o m*/ _config.load(Files.newInputStream(_dataNodePath.resolve(DATANODE_CONFIG))); } catch (ConfigurationException e) { throw new IOException(e); } // ensure this is valid data node boolean installed = _config.getBoolean(DATANODE_INSTALLED_KEY); if (!installed) { throw new InvalidPropertiesFormatException( "data node config must contain key " + DATANODE_INSTALLED_KEY); } // retrieve localhost uri { String localhostString = _config.getString(DATANODE_LOCALHOSTURI_KEY); if (localhostString == null) { throw new InvalidPropertiesFormatException( "data node config must contain key " + DATANODE_LOCALHOSTURI_KEY); } try { _localhostURI = new URI(localhostString); } catch (URISyntaxException e) { throw new InvalidPropertiesFormatException("data node config key " + DATANODE_LOCALHOSTURI_KEY + " has invalid format - " + e.getMessage()); } } // retrieve name node try { _nameNode = NameNodeProvider.loadNameNodeFromConfig(_config, DATANODE_NAMENODE_TYPE_KEY, DATANODE_NAMENODE_LOCATION_KEY); } catch (ReflectiveOperationException e) { throw new RuntimeException("Unable to load name node", e); } // retrieve slice manager _sliceSerializer = _nameNode.getSerializer(); }
From source file:com.termmed.statistics.db.importer.ImportManager.java
/** * Execute.// w w w.ja v a2s . co m * * @throws IOException Signals that an I/O exception has occurred. * @throws Exception the exception */ public void execute() throws IOException, Exception { logger.info("Starting import manager process"); createFolders(); importer = new Importer(); if (!existingTables()) { DbSetup dbSetup = new DbSetup(connection); dbSetup.execute(); dbSetup = null; } XMLConfiguration xmlConfig; try { xmlConfig = new XMLConfiguration(configFile); } catch (ConfigurationException e) { logger.error("ClassificationRunner - Error happened getting params configFile." + e.getMessage()); throw e; } refsetId = xmlConfig.getString("refsetId"); releaseDependencies = CurrentFile.get().getReleaseDependenciesFullFolders() != null && CurrentFile.get().getReleaseDependenciesFullFolders().size() > 0; this.releaseDate = xmlConfig.getString("releaseDate"); this.previousReleaseDate = xmlConfig.getString("previousReleaseDate"); this.reducedSnapshotFolder = new File("reducedSnapshotFolder"); if (!reducedSnapshotFolder.exists()) { reducedSnapshotFolder.mkdirs(); } this.previousReducedSnapshotFolder = new File("previousReducedSnapshotFolder"); if (!previousReducedSnapshotFolder.exists()) { previousReducedSnapshotFolder.mkdirs(); } if (DependentFile.get() != null) { CurrentFile.get().setSnapshotExtensionLanguage(DependentFile.get().getSnapshotLanguageFile()); } else { CurrentFile.get().setSnapshotExtensionLanguage(xmlConfig.getString("extensionLanguageSnapshotFile")); } List<HierarchicalConfiguration> fields = xmlConfig.configurationsAt("reports.reportDescriptor"); if (fields != null) { for (HierarchicalConfiguration sub : fields) { String report = sub.getString("filename"); String value = sub.getString("execute"); if (value.toLowerCase().equals("true")) { logger.info("Getting config for report " + report); ReportConfig reportCfg = ResourceUtils.getReportConfig(report); for (TABLE table : reportCfg.getInputFile()) { switch (table) { case STATEDROOTDESC: if (rootDesc) { continue; } rootDesc = true; break; case CONCEPTS: if (concepts) { continue; } concepts = true; break; case DESCRIPTIONS: if (descriptions) { continue; } descriptions = true; break; case DESCRIPTIONS_PREVIOUS: if (descriptions_pre) { continue; } descriptions_pre = true; break; case EXT_LANGUAGE: if (extLanguage) { continue; } extLanguage = true; break; case RELATIONSHIPS: if (relationships) { continue; } relationships = true; break; case STATEDRELS: if (statedRels) { continue; } statedRels = true; break; case TCLOSUREINFERRED: if (tClosureInferred) { continue; } tClosureInferred = true; break; case TCLOSURESTATED: if (tClosureStated) { continue; } tClosureStated = true; break; case CONCEPTS_PREVIOUS: if (concepts_pre) { continue; } concepts_pre = true; break; case RELATIONSHIPS_PREVIOUS: if (relationships_pre) { continue; } relationships_pre = true; break; case STATEDRELS_PREVIOUS: if (statedRels_pre) { continue; } statedRels_pre = true; break; case LANGUAGE_PREVIOUS: if (refsetId != null && !refsetId.equals("")) { Integer[] newfields = new Integer[] { 2, 4, 6 }; String[] newValues = new String[] { "1", refsetId, "900000000000548007" }; table.setFieldFilter(newfields); table.setFieldFilterValue(newValues); } if (lang_pre) { continue; } lang_pre = true; break; case LANGUAGE: if (refsetId != null && !refsetId.equals("")) { Integer[] newfields = new Integer[] { 2, 4, 6 }; String[] newValues = new String[] { "1", refsetId, "900000000000548007" }; table.setFieldFilter(newfields); table.setFieldFilterValue(newValues); } if (lang) { continue; } lang = true; break; case TCLOSURESTATED_PREVIOUS: if (tClosureStated_pre) { continue; } tClosureStated_pre = true; break; case SAME_AS_ASSOCIATIONS: if (same_associations) { continue; } same_associations = true; break; } ImportRf2Table(table); } System.out.println(report + " " + value); } } } logger.info("Updating date to " + releaseDate); saveNewDate(I_Constants.RELEASE_DATE, releaseDate); logger.info("Updating previous date to " + previousReleaseDate); saveNewDate(I_Constants.PREVIOUS_RELEASE_DATE, previousReleaseDate); fields = xmlConfig.configurationsAt("sp_params.param"); params = new HashMap<String, String>(); if (fields != null) { for (HierarchicalConfiguration sub : fields) { String paramName = sub.getString("name"); String value = sub.getString("value"); if (value.equals("$param")) { value = xmlConfig.getString(paramName); } params.put(paramName, value); } } logger.info("End of import manager process"); }
From source file:com.nridge.core.app.mgr.AppMgr.java
/** * Loads the default property files ("application.properties" and * "logback.xml") from the file system and assigns default application * properties./* w w w.j a va2 s .c o m*/ * <p> * <b>Note:</b> This method will establish a default 5 minute reloading * policy for the "application.properties" file. Therefore, any * changes to this property file while the application is running * will be recognized within a 5 minute period. * </p> * * @throws NSException Typically thrown for I/O related issues. */ public void loadPropertyFiles() throws NSException { String logFileName; try { // First, we will read our application properties. mConfiguration = new CompositeConfiguration(); mConfiguration.setDelimiterParsingDisabled(true); mConfiguration.addConfiguration(new SystemConfiguration()); mConfiguration.addConfiguration(new EnvironmentConfiguration()); PropertiesConfiguration propertyCfg = new PropertiesConfiguration(deriveCfgPathFileName()); FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy(); reloadingStrategy.setRefreshDelay(DateUtils.MILLIS_PER_MINUTE * 2L); propertyCfg.setReloadingStrategy(reloadingStrategy); mConfiguration.addConfiguration(propertyCfg); // Next, we will load our Logback properties file and configure our application logger. if (mCmdLine == null) logFileName = LOG_PROPERTY_FILE_NAME; else logFileName = mCmdLine.getOptionValue("logfile", LOG_PROPERTY_FILE_NAME); File logFile = new File(logFileName); if (!logFile.exists()) { String logPathFileName = String.format("%s%c%s", deriveCfgPathName(), File.separatorChar, logFileName); logFile = new File(logPathFileName); if (logFile.exists()) logFileName = logPathFileName; else throw new NSException("Unable to locate logging properties file: " + logFileName); } if (StringUtils.isEmpty(getString(APP_PROPERTY_INS_PATH))) mConfiguration.addProperty(APP_PROPERTY_INS_PATH, getInsPathName()); if (StringUtils.isEmpty(getString(APP_PROPERTY_CFG_PATH))) mConfiguration.addProperty(APP_PROPERTY_CFG_PATH, deriveCfgPathName()); if (StringUtils.isEmpty(getString(APP_PROPERTY_LOG_PATH))) mConfiguration.addProperty(APP_PROPERTY_LOG_PATH, deriveLogPathName()); if (StringUtils.isEmpty(getString(APP_PROPERTY_DS_PATH))) mConfiguration.addProperty(APP_PROPERTY_DS_PATH, deriveDSPathName()); if (StringUtils.isEmpty(getString(APP_PROPERTY_RDB_PATH))) mConfiguration.addProperty(APP_PROPERTY_RDB_PATH, deriveRDBMSPathName()); if (StringUtils.isEmpty(getString(APP_PROPERTY_GDB_PATH))) mConfiguration.addProperty(APP_PROPERTY_GDB_PATH, deriveGraphPathName()); LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); JoranConfigurator joranConfigurator = new JoranConfigurator(); joranConfigurator.setContext(loggerContext); loggerContext.reset(); joranConfigurator.doConfigure(logFileName); } catch (ConfigurationException e) { throw new NSException("Configuration parsing error: " + e.getMessage()); } catch (JoranException e) { throw new NSException("Logback parsing error: " + e.getMessage()); } catch (ClassCastException ignored) { /* Note that a WARNING related to java.lang.ClassCastException will trigger due to Smart GWT and NSD being dependent on different releases of the same logging framework. http://www.slf4j.org/codes.html */ } }
From source file:com.termmed.reconciliation.RelationshipReconciliation.java
/** * Gets the params.//from w w w .j a va2 s .c o m * * @return the params * @throws ConfigurationException the configuration exception */ @SuppressWarnings("unchecked") private void getParams() throws ConfigurationException { try { xmlConfig = new XMLConfiguration(config); } catch (ConfigurationException e) { logger.info("Reconciliation Runner - Error happened getting params file." + e.getMessage()); throw e; } List<String> relFiles = xmlConfig.getList(I_Constants.CURRENT_INFERRED_RELATIONSHIP_FILES); currentRelationshipsFile = new String[relFiles.size()]; relFiles.toArray(currentRelationshipsFile); List<String> prevRelFiles = xmlConfig.getList(I_Constants.PREVIOUS_INFERRED_RELATIONSHIP_FILES); if (prevRelFiles != null && prevRelFiles.size() > 0) { previousInferredRelationshipsFile = new String[prevRelFiles.size()]; prevRelFiles.toArray(previousInferredRelationshipsFile); } outputRelationships = xmlConfig.getString(I_Constants.RELATIONSHIP_FILE); logger.info("Reconciliation - Parameters:"); logger.info("Current Relationship files : "); if (currentRelationshipsFile != null) { for (String relFile : currentRelationshipsFile) { logger.info(relFile); } } logger.info("Previous Relationship files : "); if (previousInferredRelationshipsFile != null) { for (String relFile : previousInferredRelationshipsFile) { logger.info(relFile); } } logger.info("Output Relationship file : " + outputRelationships); }
From source file:jdbc.pool.JDBCPoolMySQLTest.java
/** * Tests the deletion of the pool attributes. *///from www .j a v a 2 s. com public void testDeletePoolFromPoolAttributeManager() { testGetInstanceNull(); try { CPoolAttributeManager poolAttributeManager = CPoolAttributeManager.getPoolAttributeManager( new File(this.getClass().getClassLoader().getResource("config/pool.properties").getFile())); Map<String, CPoolAttribute> map = poolAttributeManager.getAllPoolAttributes(); for (Entry<String, CPoolAttribute> entry : map.entrySet()) { CPoolAttribute attribute = entry.getValue(); if ("MYSQL2;MYSQL;TIT;FIFO;LIFO;".indexOf(attribute.getPoolName()) < 0) { assertTrue("Deleting pool #" + attribute.getPoolName(), poolAttributeManager.delete(attribute.getPoolName())); } } } catch (ConfigurationException e) { fail("Caugth Confugruation :" + e.getMessage()); } }