List of usage examples for org.apache.commons.configuration ConfigurationException getMessage
public String getMessage()
From source file:eu.optimis.ics.core.util.PropertiesReader.java
/** * Gets the properties configuration/* w w w . j a v a 2 s . co m*/ * @param configFile the properties file * @return an object */ public static PropertiesConfiguration getPropertiesConfiguration(String configFile) { String filePath = null; PropertiesConfiguration config = null; try { filePath = getConfigFilePath(configFile); config = new PropertiesConfiguration(filePath); } catch (ConfigurationException ex) { log.error( "ics.core.util.PropertiesReader.getPropertiesConfiguration(): Error reading configuration file " + filePath + ex.getMessage()); //ex.printStackTrace(); } return config; }
From source file:net.orpiske.ssps.common.repository.utils.RepositoryUtils.java
private static void readPackageProperties(final File file, final PackageInfo packageInfo) { File settingsFile = new File(file.getPath() + File.separator + "package.properties"); if (logger.isDebugEnabled()) { logger.debug("Reading package properties for " + file.getPath()); logger.debug("Trying to open package.properties at " + settingsFile.getPath()); }//from ww w .ja va 2 s . com if (settingsFile.exists() && settingsFile.canRead()) { PropertiesConfiguration packageSettings; try { packageSettings = new PropertiesConfiguration(settingsFile); String slot = packageSettings.getString("package.default.slot", SlotComparatorFactory.DEFAULT_SLOT); packageInfo.setSlot(slot); } catch (ConfigurationException e) { logger.warn("Unable to read package configuration file at " + settingsFile.getPath()); if (logger.isDebugEnabled()) { logger.debug(e.getMessage(), e); } } } else { packageInfo.setSlot(SlotComparatorFactory.DEFAULT_SLOT); } }
From source file:at.ac.tuwien.ims.latex2mobiformulaconv.app.Main.java
private static void loadConfiguration() { Path defaultConfigPath = workingDirectory.resolve(CONFIGURATION_FILENAME); logger.debug("Searching for config in default filepath: " + defaultConfigPath.toAbsolutePath().toString()); try {/*from w w w. j a v a 2 s . c o m*/ logger.debug("Loading configuration."); config = new PropertiesConfiguration(defaultConfigPath.toFile()); } catch (ConfigurationException e) { logger.error(e.getMessage(), e); logger.error("Configuration could not be loaded. Exiting..."); System.exit(-1); } if (!(defaultConfigPath.toFile().exists() && defaultConfigPath.toFile().isFile())) { try { logger.info("Creating empty config file in working directory..."); config.save(); logger.debug("Saved empty configuration: " + defaultConfigPath.toAbsolutePath().toString()); } catch (ConfigurationException e) { logger.error("Default configuration file could not be saved!"); logger.error(e.getMessage(), e); } } }
From source file:com.servioticy.queueclient.QueueClient.java
private static QueueClient createInstance(String configPath) throws QueueClientException { QueueClient instance;//from w ww . jav a 2s . co m File f = new File(configPath); if (!f.exists()) { if (Thread.currentThread().getContextClassLoader().getResource(configPath) == null) { return createInstance(configPath, "kestrel", "localhost:22133", "services"); } } String type; HierarchicalConfiguration config; try { config = new XMLConfiguration(configPath); config.setExpressionEngine(new XPathExpressionEngine()); if (!config.containsKey("defaultQueue/queueType")) { String errMsg = "No default queue. Fix your configuration file."; logger.error(errMsg); throw new QueueClientException(errMsg); } type = config.getString("defaultQueue/queueType"); instance = createInstance(configPath, type, config.getString("defaultQueue/baseAddress", "localhost:22133"), config.getString("defaultQueue/relativeAddress", "services")); } catch (ConfigurationException e) { String errMsg = "'" + configPath + "' configuration file is malformed (" + e.getMessage() + ")."; logger.error(errMsg); throw new QueueClientException(errMsg); } return instance; }
From source file:com.termmed.statistics.runner.Runner.java
/** * Gets the params.// w ww .j a v a 2 s .c o m * * @param configFile the config file * @return the params * @throws Exception the exception */ private static void getParams(File configFile) throws Exception { XMLConfiguration xmlConfig; try { xmlConfig = new XMLConfiguration(configFile); } catch (ConfigurationException e) { logger.logError("ClassificationRunner - Error happened getting params configFile." + e.getMessage()); throw e; } releaseDate = xmlConfig.getString("releaseDate"); previousReleaseDate = xmlConfig.getString("previousReleaseDate"); if (releaseDate == null || releaseDate.length() != 8) { throw new Exception("Release date param is wrong."); } if (previousReleaseDate == null || previousReleaseDate.length() != 8) { throw new Exception("Release date param is wrong."); } }
From source file:com.termmed.statistics.runner.Runner.java
/** * Inits the file providers.//from ww w . ja v a 2 s .co m * * @param file the file * @throws Exception the exception */ private static void initFileProviders(File file) throws Exception { logger.logInfo("Initializing file providers"); XMLConfiguration xmlConfig; try { xmlConfig = new XMLConfiguration(file); } catch (ConfigurationException e) { logger.logInfo("ClassificationRunner - Error happened getting params configFile." + e.getMessage()); throw e; } String releaseFolder = xmlConfig.getString("releaseFullFolder"); if (releaseFolder == null || releaseFolder.trim().equals("") || !new File(releaseFolder).exists()) { throw new Exception("Release folder doesn't exist."); } File sourceFolder = new File(releaseFolder); Object prop = xmlConfig.getProperty("releaseDependencies.releaseFullFolder"); HashSet<String> releaseDependencies = null; if (prop != null) { if (prop instanceof Collection) { releaseDependencies = new HashSet<String>(); for (String loopProp : (Collection<String>) prop) { releaseDependencies.add(loopProp); } } else if (prop instanceof String) { releaseDependencies = new HashSet<String>(); releaseDependencies.add((String) prop); System.out.println(prop); } } String releaseDate = xmlConfig.getString("releaseDate"); String previousReleaseDate = xmlConfig.getString("previousReleaseDate"); CurrentFile.init(sourceFolder, new File("release" + releaseDate), releaseDependencies, releaseDate); PreviousFile.init(sourceFolder, new File("release" + previousReleaseDate), releaseDependencies, previousReleaseDate); String dependentRelease = xmlConfig.getString("dependentReleaseFullFolder"); if (dependentRelease != null && !dependentRelease.trim().equals("")) { String dependentReleaseDate = xmlConfig.getString("dependentReleaseDate"); if (dependentReleaseDate == null || dependentReleaseDate.trim().equals("")) { dependentReleaseDate = releaseDate; } DependentFile.init(new File(dependentRelease), new File("dependentrelease" + dependentReleaseDate), dependentReleaseDate); } }
From source file:eu.eco2clouds.accounting.monitoringcollector.ConfigurationValues.java
/** * Load properties from a file. Uses the hard-coded default if a value is not specified. * * @param filepath the location of the properties file to load from. *//* w w w .j a v a2 s. c o m*/ public static void loadProperties(String filepath) { MessageHandler.print("Loading configuration " + filepath); PropertiesConfiguration config = null; try { config = new PropertiesConfiguration(filepath); } catch (ConfigurationException e1) { MessageHandler.error("Error attempting to load properties file: " + filepath + ". Exception: " + e1.getMessage() + " . Using default values."); return; } fromProperties(config); }
From source file:com.heliosphere.athena.base.resource.bundle.ResourceBundleManager.java
/** * Initializes the resource bundle manager with a custom resource bundle * properties file and with a specific language. * <p>/* ww w . ja v a 2s. c om*/ * @param filename Path and name of the property file containing * configuration for the resource bundles. * @param locale {@link Locale} to use for the language. * @throws ResourceBundleException Thrown if a resource bundle file cannot * be found. */ @SuppressWarnings("unused") private static final void initialize(final String filename, final Locale locale) { if (filename == null || filename.length() == 0) { throw new InvalidArgumentException(BundleAthenaBase.ResourceBundleInvalidName); } if (locale == null) { throw new InvalidArgumentException(BundleAthenaBase.ResourceBundleInvalidLocale); } synchronized (BUNDLES) { try { setProperties(new PropertiesConfiguration(filename)); setLocale(locale); register(properties); } catch (final ConfigurationException e) { setInitialized(false); throw new ResourceBundleException(e.getMessage(), e); } } }
From source file:com.heliosphere.demeter.base.resource.bundle.ResourceBundleManager.java
/** * Initializes the resource bundle manager with a custom resource bundle * properties file and with a specific language. * <p>//from ww w . ja v a 2s .co m * @param filename Path and name of the property file containing * configuration for the resource bundles. * @param locale {@link Locale} to use for the language. * @throws ResourceBundleException Thrown if a resource bundle file cannot * be found. */ @SuppressWarnings("unused") private static final void initialize(final String filename, final Locale locale) { if (filename == null || filename.length() == 0) { throw new InvalidArgumentException(BundleDemeterBase.ResourceBundleInvalidName); } if (locale == null) { throw new InvalidArgumentException(BundleDemeterBase.ResourceBundleInvalidLocale); } synchronized (BUNDLES) { try { setProperties(new PropertiesConfiguration(filename)); setLocale(locale); register(properties); } catch (final ConfigurationException e) { setInitialized(false); throw new ResourceBundleException(e.getMessage(), e); } } }
From source file:gov.nih.nci.cacisweb.util.CaCISUtil.java
/** * /*from w w w .j a va2 s . c om*/ * @param propertyFileLocation * @param property * @return * @throws CaCISWebException */ public static String getPropertyFromPropertiesFile(String propertyFileLocation, String property) throws CaCISWebException { PropertiesConfiguration propertiesConfiguration; try { propertiesConfiguration = new PropertiesConfiguration(propertyFileLocation); String propertyValue = propertiesConfiguration.getString(property); if (propertyValue == null) { log.error(String.format("Property '%s' cannot be read from [%s]. Either the " + "property / properties file does not exist or the properties file is not readable.", property, propertyFileLocation)); throw new CaCISWebException(String.format("Property '%s' cannot be read from [%s]. Either the " + "property / properties file does not exist or the properties file is not readable.", property, propertyFileLocation)); } log.debug(property + " = " + propertyValue); return propertyValue; } catch (ConfigurationException e) { log.error(String.format( "Property '%s' cannot be read from [%s]. Either the " + "property / properties file does not exist or the properties file is not readable.", property, propertyFileLocation) + e.getMessage()); throw new CaCISWebException(String.format( "Property '%s' cannot be read from [%s]. Either the " + "property / properties file does not exist or the properties file is not readable.", property, propertyFileLocation) + e.getMessage()); } }