List of usage examples for org.apache.commons.configuration ConfigurationException getMessage
public String getMessage()
From source file:com.termmed.idcreation.IdCreation.java
/** * Gets the params./* w w w. ja v a2 s . co m*/ * * @return the params * @throws ConfigurationException the configuration exception */ private void getParams() throws ConfigurationException { try { xmlConfig = new XMLConfiguration(config); } catch (ConfigurationException e) { log.info("IdCreation - Error happened getting params file." + e.getMessage()); throw e; } componentFile = xmlConfig.getString(I_Constants.RELATIONSHIP_FILE); String nSpace = xmlConfig.getString(I_Constants.NAMESPACE); if (nSpace != null) { namespaceId = Integer.parseInt(nSpace); } String partId = xmlConfig.getString(I_Constants.PARTITION); if (partId != null) { partitionId = Long.parseLong(partId); } endPointURL = xmlConfig.getString(I_Constants.ENDPOINTURL); username = xmlConfig.getString(I_Constants.USERNAME); pass = xmlConfig.getString(I_Constants.PASSWORD); releaseDate = xmlConfig.getString(I_Constants.RELEASEDATE); log.info("Id Creation - Parameters:"); log.info("Input file : " + componentFile); log.info("NamespaceId : " + namespaceId); log.info("PartitionId : " + partitionId); log.info("End point url : " + endPointURL); log.info("Username : " + username); log.info("Release date : " + releaseDate); }
From source file:it.geosolutions.opensdi2.configurations.dao.PropertiesDAO.java
@Override public boolean merge(OSDIConfiguration updatedConfig) throws OSDIConfigurationNotFoundException, OSDIConfigurationInternalErrorException { boolean outcome = false; File configFile = searchConfigurationFile(updatedConfig.getScopeID(), updatedConfig.getInstanceID()); PropertiesConfiguration oldConfig = loadConfigurationInstance(configFile); OSDIConfigurationKVP updatedConfigKVP = (OSDIConfigurationKVP) updatedConfig; Iterator<String> iter = updatedConfigKVP.getAllKeys().iterator(); String tmpKey = ""; while (iter.hasNext()) { tmpKey = iter.next();/*from w w w . java2s.c o m*/ Object newValue = updatedConfigKVP.getValue(tmpKey); Object oldValue = oldConfig.getProperty(tmpKey); if (newValue != null && !newValue.equals(oldValue)) { oldConfig.setProperty(tmpKey, newValue); outcome = true; } } try { oldConfig.save(); } catch (ConfigurationException e) { throw new OSDIConfigurationInternalErrorException( "Error occurred while saving the updated configuration, exception msg is: '" + e.getMessage() + "'"); } return outcome; }
From source file:com.termmed.control.executor.PatternExecutor.java
/** * Execute.//from w w w . ja v a 2 s .c o m * * @throws IOException Signals that an I/O exception has occurred. * @throws Exception the exception */ public void execute() throws IOException, Exception { logger.logInfo("Starting patterns execution"); XMLConfiguration xmlConfig; try { xmlConfig = new XMLConfiguration(configFile); } catch (ConfigurationException e) { logger.logInfo("ClassificationRunner - Error happened getting params configFile." + e.getMessage()); throw e; } String runControls = xmlConfig.getString("patternExecutions.runControlPatterns"); if (runControls == null || !runControls.toLowerCase().equals("true")) { return; } resultOutputFolder = I_Constants.PATTERN_OUTPUT_FOLDER; File resultTmpFolder = new File(resultOutputFolder); if (!resultTmpFolder.exists()) { resultTmpFolder.mkdirs(); } else { FileHelper.emptyFolder(resultTmpFolder); } this.releaseDate = xmlConfig.getString("releaseDate"); this.previousReleaseDate = xmlConfig.getString("previousReleaseDate"); getNewConcepts(); getChangedConcepts(); excludes = new HashSet<String>(); Object prop = xmlConfig.getProperty("patternExecutions.exclusions.patternId"); if (prop != null) { if (prop instanceof Collection) { for (String loopProp : (Collection<String>) prop) { excludes.add(loopProp); } } else if (prop instanceof String) { excludes.add((String) prop); } } String relativePath = "src/main/resources/"; String path = "org/ihtsdo/control/patterns"; if (new File(relativePath).isDirectory()) { path = relativePath + path; logger.logInfo("Getting patterns from file system: " + path); executeFromFileSystem(path); } else { logger.logInfo("Getting patterns from resources: " + path); executeFromResources(path); } }
From source file:com.nridge.connector.common.con_com.transform.TFieldMapper.java
/** * Applies a transformation against the source document to produce * the returned destination document. If the document has a field * containing content, then this method may update it as part of its * processing logic./* w ww. j av a 2s .co m*/ * * @param aSrcDoc Source document instance. * * @return New destination DataBag instance. * * @throws NSException Indicates a data validation error condition. */ public Document process(Document aSrcDoc) throws NSException { Document dstDoc; Logger appLogger = mAppMgr.getLogger(this, "process"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); if (aSrcDoc == null) throw new NSException("Source document is null."); if (mCfgProperties == null) { String fieldMappingFileName = getCfgString("field_mapper_file"); if (StringUtils.isNotEmpty(fieldMappingFileName)) { String fieldMappingPathFileName = String.format("%s%c%s", mAppMgr.getString(mAppMgr.APP_PROPERTY_CFG_PATH), File.separatorChar, fieldMappingFileName); File mappingFile = new File(fieldMappingPathFileName); if (mappingFile.exists()) { try { mCfgProperties = new PropertiesConfiguration(fieldMappingPathFileName); } catch (ConfigurationException e) { mCfgProperties = null; String msgStr = String.format("%s: %s", fieldMappingPathFileName, e.getMessage()); throw new NSException(msgStr); } } } } dstDoc = new Document(aSrcDoc); if (mCfgProperties != null) transform(dstDoc); appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); return dstDoc; }
From source file:de.sub.goobi.export.download.ExportMets.java
/** * DMS-Export an eine gewnschte Stelle.//from w w w . j a va2 s. co m * * @param myProcess * Process object * @param inZielVerzeichnis * String */ public boolean startExport(Process myProcess, URI inZielVerzeichnis) throws IOException, PreferencesException, WriteException, DocStructHasNoTypeException, MetadataTypeNotAllowedException, ExportFileException, ReadException, TypeNotAllowedForParentException { /* * Read Document */ this.myPrefs = serviceManager.getRulesetService().getPreferences(myProcess.getRuleset()); String atsPpnBand = myProcess.getTitle(); Fileformat gdzfile = serviceManager.getProcessService().readMetadataFile(myProcess); String rules = ConfigCore.getParameter("copyData.onExport"); if (rules != null && !rules.equals("- keine Konfiguration gefunden -")) { try { new DataCopier(rules).process(new CopierData(gdzfile, myProcess)); } catch (ConfigurationException e) { Helper.setFehlerMeldung("dataCopier.syntaxError", e.getMessage()); return false; } catch (RuntimeException exception) { Helper.setFehlerMeldung("dataCopier.runtimeException", exception.getMessage()); return false; } } /* nur beim Rusdml-Projekt die Metadaten aufbereiten */ ConfigProjects cp = new ConfigProjects(myProcess.getProject().getTitle()); if (cp.getParamList("dmsImport.check").contains("rusdml")) { ExportDms_CorrectRusdml expcorr = new ExportDms_CorrectRusdml(myProcess, this.myPrefs, gdzfile); atsPpnBand = expcorr.correctionStart(); } URI zielVerzeichnis = prepareUserDirectory(inZielVerzeichnis); String targetFileName = zielVerzeichnis + atsPpnBand + "_mets.xml"; URI metaFile = fileService.getProcessSubTypeURI(myProcess, ProcessSubType.META_XML, targetFileName); return writeMetsFile(myProcess, metaFile, gdzfile, false); }
From source file:it.imtech.configuration.StartWizard.java
/** * Sets the version and default locale//from www.j a v a 2s . c o m * @return */ private XMLConfiguration setConfiguration() { XMLConfiguration config = null; try { config = new XMLConfiguration(Globals.INTERNAL_CONFIG); Globals.CURRENT_VERSION = config.getString("version[@current]"); mainFrame.setTitle("Phaidra Importer v." + config.getString("version[@current]")); String locale = config.getString("locale.current[@value]"); Globals.CURRENT_LOCALE = new Locale(locale); } catch (ConfigurationException ex) { logger.error(ex.getMessage()); Globals.CURRENT_LOCALE = new Locale("en"); } return config; }
From source file:ee.ria.xroad.confproxy.ConfProxyProperties.java
/** * Constructs the configuration for the given * configuration proxy instance id./*w w w. j a va 2 s . com*/ * @param name the if of the configuration proxy instance * @throws ConfigurationException if the configuration could not be loaded */ public ConfProxyProperties(final String name) throws ConfigurationException { this.instance = name; String confDir = SystemProperties.getConfigurationProxyConfPath(); File configFile = Paths.get(confDir, instance, CONF_INI).toFile(); if (!configFile.exists()) { throw new ConfigurationException("'" + CONF_INI + "' does not exist."); } try { config = new HierarchicalINIConfiguration(configFile); } catch (ConfigurationException e) { log.error("Failed to load '{}': {}", configFile, e.getMessage()); throw e; } }
From source file:com.bibisco.manager.ConfigManager.java
private ConfigManager(String pStrConfigurationFilePath) { mXMLConfiguration = new XMLConfiguration(); mXMLConfiguration.setFileName(pStrConfigurationFilePath); mXMLConfiguration.setExpressionEngine(new XPathExpressionEngine()); try {/* ww w . j a va2s . com*/ mXMLConfiguration.load(); } catch (ConfigurationException e) { mLog.error(e, "Error while reading configuration from file ", CONFIG_FILENAME); throw new BibiscoException(e, "bibiscoException.configManager.errorWhileReadingConfiguration", e.getMessage()); } mBlnCache = true; mLog.debug("ConfigManager initialized using file ", pStrConfigurationFilePath); }
From source file:eu.matejkormuth.ts3bot.Bot.java
/** * Boots up Bot./*from www. j a va 2s .c o m*/ */ public void boot() { if (this.configuration != null) { throw new RuntimeException("Bot is already booted up!"); } this.logger.info("Booting up..."); this.logger.info("Reading configuration..."); try { this.configuration = new PropertiesConfiguration("bot.properties"); } catch (ConfigurationException e) { this.logger.error("Error while loading configuration from bot.properties: {}", e.getMessage()); try { this.configuration = new PropertiesConfiguration( this.getClass().getClassLoader().getResource("bot.properties")); } catch (ConfigurationException e2) { this.logger.error("Error while loading configuration from jar: {}", e2.getMessage()); this.configuration = new PropertiesConfiguration(); this.configuration.setHeader("TS3 Bot configuration."); this.configuration.setFileName("bot.properties"); } } // Connect to teamspeak server. String name = this.configuration.getString("query.login"); String pass = this.configuration.getString("query.password"); String ip = this.configuration.getString("server.ip"); if (name == null || pass == null || ip == null) { // Can't continue without these values. throw new RuntimeException( "Can't get query login, query password or server ip address from config! Can't continue!"); } boolean flood = this.configuration.getBoolean("server.preventflood", false); boolean autoRegister = this.configuration.getBoolean("server.autoRegisterChannelEvents", true); String nickname = this.configuration.getString("bot.name", "TS3Bot"); this.logger.info("Connecting to teamspeak server {}...", ip); QueryCreditnals creds = new QueryCreditnals(name, pass); this.queryConnection = new QueryConnection(creds, ip, nickname, flood, autoRegister); // nickname will never be null... // Connect to server. this.queryConnection.connect(); // Some default services. List<Object> services = this.configuration.getList("bot.services"); // In case we have only one service. if (services.size() == 0) { if (this.configuration.getString("bot.service") != null) { services.add(this.configuration.getString("bot.service")); } } // Create all services. this.logger.info("Loading services..."); for (Object o : services) { try { Class<?> clazz = Class.forName(o.toString()); if (Service.class.isAssignableFrom(clazz)) { Service service = (Service) clazz.getConstructor().newInstance(); this.services.add(service); } else { this.logger.error( "Specified service " + o.toString() + " does not extend Service class! Can't load it."); } } catch (Exception e) { this.logger.error("Can't load service {}! Problem: {}", o.toString(), e.getMessage()); this.logger.error(e.toString()); } } this.logger.info("Starting services..."); // Start services. for (Service service : this.services) { if (service.isAsynchronous()) { this.logger.info("Enabling service asynchronously " + service.getClass().getSimpleName() + "..."); final Service s = service; // Start thread for service. new Thread(new Runnable() { public void run() { s.setBot(Bot.this); Bot.this.eventBus.register(s); s.enable(); } }, "service/" + service.getClass().getSimpleName()).run(); } else { try { this.logger .info("Enabling service synchronously " + service.getClass().getSimpleName() + "..."); service.setBot(this); this.eventBus.register(service); service.enable(); } catch (Exception e) { this.logger.error("Can't enable service! Problem: {}", e.getMessage()); this.logger.error(e.toString()); } } } this.logger.info("Finished loading!"); // Start reading commands from console. this.consoleReader = new ConsoleReader(); this.consoleReader.setBot(this); this.consoleReader.enable(); }
From source file:com.evolveum.midpoint.init.StartupConfiguration.java
/** * Loading logic/*from ww w .j a v a2s. c o m*/ */ private void loadConfiguration(File midpointHome) { if (config != null) { config.clear(); } else { config = new CompositeConfiguration(); } DocumentBuilder documentBuilder = DOMUtil.createDocumentBuilder(); // we need namespace-aware document builder (see GeneralChangeProcessor.java) if (midpointHome != null) { /* configuration logic */ File f = new File(midpointHome, this.getConfigFilename()); System.out.println("Loading midPoint configuration from file " + f); LOGGER.info("Loading midPoint configuration from file {}", f); try { if (!f.exists()) { LOGGER.warn("Configuration file {} does not exists. Need to do extraction ...", f); ApplicationHomeSetup ah = new ApplicationHomeSetup(); ah.init(MIDPOINT_HOME); ClassPathUtil.extractFileFromClassPath(this.getConfigFilename(), f.getPath()); } //Load and parse properties config.addProperty(MIDPOINT_HOME, System.getProperty(MIDPOINT_HOME)); createXmlConfiguration(documentBuilder, f.getPath()); } catch (ConfigurationException e) { String message = "Unable to read configuration file [" + f + "]: " + e.getMessage(); LOGGER.error(message); System.out.println(message); throw new SystemException(message, e); // there's no point in continuing with midpoint initialization } } else { // Load from current directory try { createXmlConfiguration(documentBuilder, this.getConfigFilename()); } catch (ConfigurationException e) { String message = "Unable to read configuration file [" + this.getConfigFilename() + "]: " + e.getMessage(); LOGGER.error(message); System.out.println(message); throw new SystemException(message, e); } } }