List of usage examples for org.apache.commons.configuration ConfigurationException getMessage
public String getMessage()
From source file:org.springframework.data.hadoop.admin.cli.commands.TargetCommand.java
/** * set Spring Hadoop Admin service URL//from w w w . j av a 2s. c om * * @param url spring hadoop service URL. For example, "http://localhost:8080/spring-hadoop-admin" */ @CliCommand(value = "service target", help = "connect to Spring Hadoop Admin server") public void target(@CliOption(key = { "url" }, mandatory = true, help = "Spring Hadoop Admin service URL") final String url) { try { PropertyUtil.setTargetUrl(url); } catch (ConfigurationException e) { Log.error("set target url failed. " + e.getMessage()); } }
From source file:org.structr.api.config.Settings.java
public static void storeConfiguration(final String fileName) throws IOException { try {// w w w . j a v a 2 s . co m PropertiesConfiguration.setDefaultListDelimiter('\0'); final PropertiesConfiguration config = new PropertiesConfiguration(); // store settings for (final Setting setting : settings.values()) { // story only modified settings and the super user password if (setting.isModified() || "superuser.password".equals(setting.getKey())) { config.setProperty(setting.getKey(), setting.getValue()); } } config.save(fileName); } catch (ConfigurationException ex) { System.err.println("Unable to store configuration: " + ex.getMessage()); } }
From source file:org.structr.api.config.Settings.java
public static void loadConfiguration(final String fileName) { try {/*from w w w . ja v a 2s .c o m*/ PropertiesConfiguration.setDefaultListDelimiter('\0'); final PropertiesConfiguration config = new PropertiesConfiguration(fileName); final Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { final String key = keys.next(); final String value = trim(config.getString(key)); Setting<?> setting = Settings.getSetting(key); if (setting != null) { setting.fromString(value); } else { SettingsGroup targetGroup = miscGroup; // put key in cron group if it contains ".cronExpression" if (key.contains(".cronExpression")) { targetGroup = cronGroup; } // create new StringSetting for unknown key Settings.createSettingForValue(targetGroup, key, value); } } } catch (ConfigurationException ex) { System.err.println("Unable to load configuration: " + ex.getMessage()); } }
From source file:org.unitime.timetable.util.MessageResources.java
private Configuration getConfiguration(String name) { Configuration configuration = null; URL url = Thread.currentThread().getContextClassLoader().getResource(name); if (url != null) { PropertiesConfiguration pc = new PropertiesConfiguration(); pc.setURL(url);/*from w w w . ja va 2 s.c o m*/ // Set reloading strategy String dynamicReload = ApplicationProperties.getProperty("tmtbl.properties.dynamic_reload", null); if (dynamicReload != null && dynamicReload.equalsIgnoreCase("true")) { long refreshDelay = Constants.getPositiveInteger( ApplicationProperties.getProperty("tmtbl.properties.dynamic_reload_interval"), 15000); FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy(); strategy.setRefreshDelay(refreshDelay); pc.setReloadingStrategy(strategy); pc.addConfigurationListener(new MessageResourcesCfgListener(pc.getBasePath())); } try { pc.load(); configuration = pc; } catch (ConfigurationException e) { Debug.error("Message Resources configuration exception: " + e.getMessage()); } } return configuration; }
From source file:org.webcat.plugintester.ui.MainFrameBuilder.java
/** * Adds the plugin represented by the specified file or directory to the * testing chain./*w w w. j a v a2s . c o m*/ * * @param file a File object that represents either the directory * containing the grading plugin or the config.plist file inside the * plugin's directory */ private void addPlugin(File file) { String path; if (file.isDirectory()) { File configFile = new File(file, "config.plist"); if (configFile.exists()) { path = file.getAbsolutePath(); } else { path = null; JOptionPane.showMessageDialog(frame, "The selection you have made does not appear to be\n" + "a valid grading plug-in. You should either select the\n" + "directory that represents the plug-in contents, or\n" + "the config.plist file inside that directory.", "Not a valid plug-in", JOptionPane.ERROR_MESSAGE); } } else { if (file.getName().equalsIgnoreCase("config.plist")) { path = file.getParentFile().getAbsolutePath(); } else { path = null; JOptionPane.showMessageDialog(frame, "The selection you have made does not appear to be\n" + "a valid grading plug-in. You should either select the\n" + "directory that represents the plug-in contents, or\n" + "the config.plist file inside that directory.", "Not a valid plug-in", JOptionPane.ERROR_MESSAGE); } } if (path != null) { try { new PluginConfiguration(new File(path)); pluginsModel.addPlugin(path); pluginsModel.updatePropertiesFromModel(currentSettings); updateDocumentationPane(); } catch (ConfigurationException e) { JOptionPane.showMessageDialog(frame, "An error occurred while parsing the plug-in's " + "config.plist:\n\n" + e.getMessage(), "Not a valid plug-in", JOptionPane.ERROR_MESSAGE); } } }
From source file:org.wso2.andes.configuration.qpid.plugins.ConfigurationPluginTest.java
public void testContainsPositiveLong() { assertTrue("positiveLong is not positive", _plugin.containsPositiveLong("positiveLong")); assertFalse("NonExistentValue was found", _plugin.containsPositiveLong("NonExistentValue")); try {/*www.j av a 2s .c o m*/ _plugin.validatePositiveLong("positiveLong"); } catch (ConfigurationException e) { fail(e.getMessage()); } try { _plugin.validatePositiveLong("negativeLong"); fail("negativeLong should not be positive"); } catch (ConfigurationException e) { assertEquals("negativeLong should not be reported as positive", "ConfigPlugin: unable to configure invalid negativeLong:" + NEGATIVE_LONG, e.getMessage()); } }
From source file:org.wso2.andes.configuration.qpid.ServerConfigurationTest.java
/** * Test that configuration does not load when virtual hosts are specified in both the main * configuration file and an external file. Should throw a {@link ConfigurationException}. * <p>//from w w w . j av a 2 s. c om * Test for QPID-2361 */ public void testInternalAndExternalVirtualhostXMLFile() throws Exception { // Write out vhosts File vhostsFile = File.createTempFile(getClass().getName(), "vhosts"); vhostsFile.deleteOnExit(); writeVirtualHostsFile(vhostsFile, "test"); // Write out config File mainFile = File.createTempFile(getClass().getName(), "config"); mainFile.deleteOnExit(); writeConfigFile(mainFile, false, true, vhostsFile, "test"); // Load config try { ApplicationRegistry.remove(); ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile); ApplicationRegistry.initialise(reg); fail("Different virtualhost XML configurations not allowed"); } catch (ConfigurationException ce) { assertEquals("Incorrect error message", "Only one of external or embedded virtualhosts configuration allowed.", ce.getMessage()); } }
From source file:org.wso2.andes.configuration.qpid.ServerConfigurationTest.java
/** * Test that configuration does not load when virtual hosts are specified in multiple external * files. Should throw a {@link ConfigurationException}. * <p>//from w w w . j a va 2 s .com * Test for QPID-2361 */ public void testMultipleInternalVirtualhostXMLFile() throws Exception { // Write out vhosts File vhostsFileOne = File.createTempFile(getClass().getName(), "vhosts-one"); vhostsFileOne.deleteOnExit(); writeVirtualHostsFile(vhostsFileOne, "one"); File vhostsFileTwo = File.createTempFile(getClass().getName(), "vhosts-two"); vhostsFileTwo.deleteOnExit(); writeVirtualHostsFile(vhostsFileTwo, "two"); // Write out config File mainFile = File.createTempFile(getClass().getName(), "config"); mainFile.deleteOnExit(); writeMultipleVhostsConfigFile(mainFile, new File[] { vhostsFileOne, vhostsFileTwo }); // Load config try { ApplicationRegistry.remove(); ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile); ApplicationRegistry.initialise(reg); fail("Multiple virtualhost XML configurations not allowed"); } catch (ConfigurationException ce) { assertEquals("Incorrect error message", "Only one external virtualhosts configuration file allowed, multiple filenames found.", ce.getMessage()); } }
From source file:org.wso2.andes.configuration.qpid.ServerConfigurationTest.java
/** * Test that configuration loads correctly when virtual hosts are specified in an external * configuration file in the first of two configurations and embedded in the second. This * will throe a {@link ConfigurationException} since the configurations have different * types.// www . ja v a 2 s . c o m * <p> * Test for QPID-2361 */ public void testCombinedDifferentVirtualhostConfig() throws Exception { // Write out vhosts config File vhostsFile = File.createTempFile(getClass().getName(), "vhosts"); vhostsFile.deleteOnExit(); writeVirtualHostsFile(vhostsFile, "external"); // Write out combined config file File mainFile = File.createTempFile(getClass().getName(), "main"); File fileA = File.createTempFile(getClass().getName(), "a"); File fileB = File.createTempFile(getClass().getName(), "b"); mainFile.deleteOnExit(); fileA.deleteOnExit(); fileB.deleteOnExit(); writeCombinedConfigFile(mainFile, fileA, fileB); writeConfigFile(fileA, false, false, vhostsFile, null); writeConfigFile(fileB, false); // Load config try { ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile()); config.initialise(); fail("Different virtualhost XML configurations not allowed"); } catch (ConfigurationException ce) { assertEquals("Incorrect error message", "Only one of external or embedded virtualhosts configuration allowed.", ce.getMessage()); } }
From source file:org.wso2.andes.configuration.qpid.ServerConfigurationTest.java
/** * Test that a non-existant virtualhost file throws a {@link ConfigurationException}. * <p>/*from w w w.j av a 2s.co m*/ * Test for QPID-2624 */ public void testNonExistantVirtualhosts() throws Exception { // Write out combined config file File mainFile = File.createTempFile(getClass().getName(), "main"); File vhostsFile = new File("doesnotexist"); mainFile.deleteOnExit(); writeConfigFile(mainFile, true, false, vhostsFile, null); // Load config try { ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile()); config.initialise(); } catch (ConfigurationException ce) { assertEquals("Virtualhosts file does not exist", ce.getMessage()); } catch (Exception e) { fail("Should throw a ConfigurationException"); } }