List of usage examples for org.apache.commons.configuration ConfigurationException getMessage
public String getMessage()
From source file:org.kitodo.editor.XMLEditor.java
/** * Load the content of the XML configuration file with the given name * 'configurationFile'./*from w w w . j a va2s . c o m*/ * * @param configurationFile * name of the configuration to be loaded */ public void loadXMLConfiguration(String configurationFile) { try (StringWriter stringWriter = new StringWriter()) { currentConfigurationFile = configurationFile; XMLConfiguration currentConfiguration = new XMLConfiguration( ConfigCore.getKitodoConfigDirectory() + currentConfigurationFile); currentConfiguration.save(stringWriter); this.xmlConfigurationString = stringWriter.toString(); } catch (ConfigurationException e) { String errorMessage = "ERROR: Unable to load configuration file '" + configurationFile + "'."; logger.error(errorMessage + " " + e.getMessage()); this.xmlConfigurationString = errorMessage; } catch (IOException e) { logger.error(e.getMessage()); } }
From source file:org.kitodo.export.ExportDms.java
private boolean executeDataCopierProcess(LegacyMetsModsDigitalDocumentHelper gdzfile, Process process, String rules) {/* w w w. j a v a 2 s . c om*/ try { new DataCopier(rules).process(new CopierData(gdzfile, process)); } catch (ConfigurationException e) { if (Objects.nonNull(exportDmsTask)) { exportDmsTask.setException(e); } else { Helper.setErrorMessage("dataCopier.syntaxError", e.getMessage(), logger, e); return false; } } return true; }
From source file:org.kitodo.production.editor.XMLEditor.java
/** * Load the content of the XML configuration file with the given name * 'configurationFile'.// ww w.j a v a 2s . co m * * @param configurationFile * name of the configuration to be loaded */ public void loadXMLConfiguration(String configurationFile) { try (StringWriter stringWriter = new StringWriter()) { currentConfigurationFile = configurationFile; this.configurationFile = KitodoConfigFile.getByName(configurationFile); XMLConfiguration currentConfiguration = new XMLConfiguration(this.configurationFile.getAbsolutePath()); currentConfiguration.save(stringWriter); this.xmlConfigurationString = stringWriter.toString(); } catch (ConfigurationException e) { String errorMessage = "ERROR: Unable to load configuration file '" + configurationFile + "'."; logger.error(errorMessage + " " + e.getMessage()); this.xmlConfigurationString = errorMessage; } catch (IOException e) { logger.error(e.getMessage()); } }
From source file:org.lockss.crawljax.DefLockssConfigurationBuilder.java
/** * Configure a CrawljaxConfiguration for a given url from a configuration * file with all output stored in a directory. * * @param urlValue the url we use for the CrawljaxConfiguration * @param outDir the output directory to use for content * @param configFile the properties file to use for the CrawljaxConfiguration * * @return the CrawljaxConfiguration//w w w . j av a 2 s. c o m */ @Override public CrawljaxConfigurationBuilder configure(final String urlValue, final String outDir, final String configFile) { m_urlValue = urlValue; m_outDir = outDir; m_configFile = configFile; /* get a new builder for the stating url*/ CrawljaxConfigurationBuilder builder = CrawljaxConfiguration.builderFor(m_urlValue); /* setup the output directory, creating it if necessary and store it in the configuration for later use. */ builder.setOutputDirectory(new File(m_outDir)); try { if (configFile != null) { m_config = new PropertiesConfiguration(configFile); } else { m_config = defaultConfig(); } configureBuilder(builder); } catch (ConfigurationException e) { System.out.println("Error configuring crawl: " + e.getMessage()); } return builder; }
From source file:org.manalith.ircbot.plugin.missedmessage.MissedMessageRunner.java
public String addMsg(String sender, String receiver, String msg) { StringBuilder result = new StringBuilder(); boolean savedMsg = false; int msglen = msg.length(); try {//from w ww. ja v a 2s . co m PropertiesConfiguration prop = new PropertiesConfiguration( getResourcePath() + MissedMessageRunner.filename); Iterator<String> userlist = prop.getKeys(); if (userlist != null) { while (userlist.hasNext()) { String key = userlist.next(); if (key.equals(receiver)) { if (prop.getString(receiver).length() != 0) { result.append(StringUtils.split(receiver, '.')[1]); String str = prop.getString(receiver); result.append("? ? ( "); int availableSpace = 3 - str.split("\\:\\:").length; if (availableSpace != 0) { if (msglen <= 150) { prop.setProperty(receiver, str + "::" + "[:" + sender + "] " + msg); result.append(availableSpace - 1); result.append(" / 3 )"); } else { result.delete(0, result.length()); result.append(" ? 150? ."); } } else { result.append(availableSpace); result.append(" / 3 ) : ??? "); } } else // if key has no value { if (msglen <= 150) { prop.setProperty(receiver, "[:" + sender + "] " + msg); result.append(StringUtils.split(receiver, '.')[1]); result.append("? ? ( 2 / 3 )"); } else { result.delete(0, result.length()); result.append(" ? 150? ."); } } savedMsg = true; prop.save(); break; } } if (!savedMsg) { result.append(receiver.split("\\.")[1] + "? ? ?? ?? ."); } } } catch (ConfigurationException ce) { return ce.getMessage(); } return result.toString(); }
From source file:org.manalith.ircbot.plugin.missedmessage.MissedMessageRunner.java
public String[] getMsg(String newRecv) { String[] msgs = null;/*from www .j ava 2 s. c om*/ try { // init! PropertiesConfiguration prop = new PropertiesConfiguration( getResourcePath() + MissedMessageRunner.filename); if (isMatchedNickinList(newRecv)) { if (prop.getString(newRecv).length() != 0) { msgs = prop.getString(newRecv).split("\\:\\:"); for (int i = 0; i < msgs.length; i++) msgs[i] = newRecv.split("\\.")[1] + ", " + msgs[i]; prop.setProperty(newRecv, ""); prop.save(); } } } catch (ConfigurationException ce) { msgs = new String[1]; msgs[0] = ce.getMessage(); } return msgs; }
From source file:org.manalith.ircbot.plugin.tweetreader.TweetReaderPlugin.java
@Override public void onMessage(MessageEvent event) { String[] command = event.getMessageSegments(); try {//ww w. ja va2s . co m reader = new TweetReader(getResourcePath(), consumerKey, consumerSecret); } catch (ConfigurationException e) { event.respond(e.getMessage()); return; } reader.setTwitterUsernameOrEmail(username); reader.setTwitterPassword(password); String result = reader.read(command); if (result != null) { event.respond(result); } }
From source file:org.n52.car.io.Preferences.java
private Preferences(InputStream stream) { XMLConfiguration xml = new XMLConfiguration(); try {//from w w w. j a v a2 s . c om xml.load(stream); } catch (ConfigurationException e) { logger.warn(e.getMessage(), e); } this.config = xml; initCommonParameters(); }
From source file:org.nekorp.workflow.desktop.control.imp.WorkflowAppPrototipo.java
@Override public void setPreferenciasUsuario(PreferenciasUsuario param) { try {//from w w w. ja v a 2 s . co m PropertiesConfiguration config = new PropertiesConfiguration("app.properties"); config.setProperty("app.service.busqueda.firstId", param.getFirstId()); config.setProperty("app.service.busqueda.filtro.ultimo", param.getUltimoFiltro()); config.save(); } catch (ConfigurationException ex) { WorkflowAppPrototipo.LOGGER.error("error al guardar las preferencias" + ex.getMessage()); } }
From source file:org.okinawaopenlabs.ofpm.utils.ConfigImpl.java
@Override public String getContents() { PropertiesConfiguration prop = new PropertiesConfiguration(); prop.append(this.config); StringWriter sw = new StringWriter(); try {//from w w w . j ava 2 s . c o m prop.save(sw); } catch (ConfigurationException e) { logger.error(e.getMessage()); throw new RuntimeException(e); } return sw.toString(); }