List of usage examples for org.apache.commons.configuration ConfigurationException ConfigurationException
public ConfigurationException(Throwable cause)
ConfigurationException
with specified nested Throwable
. From source file:com.facebook.presto.accumulo.tools.Main.java
public static AccumuloConfig fromFile(File f) throws ConfigurationException { if (!f.exists() || f.isDirectory()) { throw new ConfigurationException(format("File %s does not exist or is a directory", f)); }//ww w .j ava 2 s . c om PropertiesConfiguration props = new PropertiesConfiguration(f); props.setThrowExceptionOnMissing(true); AccumuloConfig config = new AccumuloConfig(); config.setCardinalityCacheExpiration( Duration.valueOf(props.getString(CARDINALITY_CACHE_EXPIRE_DURATION, "5m"))); config.setCardinalityCacheSize(props.getInt(CARDINALITY_CACHE_SIZE, 100_000)); config.setInstance(props.getString(INSTANCE)); config.setPassword(props.getString(PASSWORD)); config.setUsername(props.getString(USERNAME)); config.setZkMetadataRoot(props.getString(ZOOKEEPER_METADATA_ROOT, "/presto-accumulo")); config.setZooKeepers(props.getString(ZOOKEEPERS)); return config; }
From source file:ch.admin.suis.msghandler.config.ClientConfiguration.java
/** * Adds a new transparent sender configuration. This method does check, if a configuration with the same name has been * already added.//from w w w.ja v a 2s . c o m * * @param senderConfiguration the senderConfiguration to add; cannot be <code>null</code> */ public void addTransparentSenderConfiguration(SenderConfiguration senderConfiguration) throws ConfigurationException { Validate.notNull(senderConfiguration); // check if we already have a configuration with the same name! for (SenderConfiguration existing : transparentSenderConfigurations) { if (StringUtils.equals(existing.getName(), senderConfiguration.getName())) { throw new ConfigurationException("transparent sender configuration with the name " + senderConfiguration.getName() + " already exists; this transparent sender will not be started: " + senderConfiguration); } } transparentSenderConfigurations.add(senderConfiguration); }
From source file:jdbc.pool.CXMLManager.java
protected boolean update(CPoolAttribute pattribute) throws ConfigurationException { CPoolAttribute attribute = null;/*from w w w . j av a 2s . c o m*/ try { attribute = (CPoolAttribute) pattribute.clone(); } catch (CloneNotSupportedException e) { logger_.error("Unable to store the atrributes."); // CPoolAttribute supports clone. } boolean bThrowException = true; int iSize = xmlPoolConfig.getMaxIndex("pool[@name]"); for (int i = 0; i <= iSize; i++) { if (xmlPoolConfig.getString("pool(" + i + ")[@name]").equals(attribute.getPoolName())) { xmlPoolConfig.setProperty("pool(" + i + ")[@driver]", attribute.getDriver()); xmlPoolConfig.setProperty("pool(" + i + ")[@vendor]", attribute.getVendor()); xmlPoolConfig.setProperty("pool(" + i + ")[@url]", attribute.getURL()); xmlPoolConfig.setProperty("pool(" + i + ")[@user]", attribute.getUser()); xmlPoolConfig.setProperty("pool(" + i + ")[@password]", attribute.getPassword()); xmlPoolConfig.setProperty("pool(" + i + ")[@initial-connections]", attribute.getInitialPoolSize() + ""); xmlPoolConfig.setProperty("pool(" + i + ")[@capacity-increament]", attribute.getCapacityIncreament() + ""); xmlPoolConfig.setProperty("pool(" + i + ")[@maximum-capacity]", attribute.getMaximumCapacity() + ""); xmlPoolConfig.setProperty("pool(" + i + ")[@inactive-time-out]", attribute.getConnectionIdleTimeout() + ""); xmlPoolConfig.setProperty("pool(" + i + ")[@shrink-pool-interval]", attribute.getShrinkPoolInterval() + ""); xmlPoolConfig.setProperty("pool(" + i + ")[@critical-operation-time-limit]", attribute.getCriticalOperationTimeLimit() + ""); xmlPoolConfig.setProperty("pool(" + i + ").in-use-wait-time", attribute.getInUseWaitTime() + ""); xmlPoolConfig.setProperty("pool(" + i + ").load-on-startup", (attribute.isLoadOnStartup() ? "true" : "false")); xmlPoolConfig.setProperty("pool(" + i + ").max-usage-per-jdbc-connection", attribute.getMaxUsagePerJDBCConnection() + ""); xmlPoolConfig.setProperty("pool(" + i + ").pool-algorithm", attribute.getPoolAlgorithm()); xmlPoolConfig.setProperty("pool(" + i + ").inmemory-statistics-history-size", attribute.getStatisticalHistoryRecordCount() + ""); xmlPoolConfig.setProperty("pool(" + i + ").sql-query", attribute.getSqlQuery() + ""); bThrowException = false; break; } } if (bThrowException) { throw new ConfigurationException( "Unable to find such a configuration. Pool Name #" + attribute.getPoolName()); } return true; }
From source file:ch.admin.suis.msghandler.config.SedexCertConfigFactory.java
/** * Gets the best certificate in the list * * @param sedexCfgs The list of sedex certs. * @param configFile The config file to match * @throws ConfigurationException Badly written config file *///ww w .j a v a 2 s . c o m private void handleMultipleCerts(List<SedexCertConfig> sedexCfgs, String configFile) throws ConfigurationException { for (SedexCertConfig sedexConfig : sedexCfgs) { if (sedexConfig.getExpireDate() == null) { throw new ConfigurationException( "multiple privateCertificate elements found, but no privateCertificate/optionalInfo/expirydate. " + "Can't determine expiry date of certificate. File: " + configFile); } if (sedexCertConfig == null) { sedexCertConfig = sedexConfig; } else { if (sedexCertConfig.getExpireDate().before(sedexConfig.getExpireDate())) { sedexCertConfig = sedexConfig; } } } }
From source file:de.sub.goobi.metadaten.RenderablePersonMetadataGroup.java
/** * Checks whether the configuration is consistent, throws a * ConfigurationException otherwise.//from ww w . jav a 2s . c o m * * @throws ConfigurationException * if one of the sub-fields was configured to display a * multi-select metadata */ private final void checkConfiguration() throws ConfigurationException { for (Entry<String, RenderableGroupableMetadatum> entry : members.entrySet()) { if (!(entry.getValue() instanceof SingleValueRenderableMetadatum)) { throw new ConfigurationException( entry.getKey() + " is configured to display a multi-select input element," + " but the field cannot take multiple values."); } } }
From source file:gda.util.persistence.LocalParameters.java
/** * @param configDir/* w w w . j a v a 2s . co m*/ * @param configName * @param createIfMissing * @param createAlways true if existing config in the cache is to be thrown away - re-reads the underlying file * @return XMLConfiguration * @throws ConfigurationException * @throws IOException */ public synchronized static XMLConfiguration getXMLConfiguration(String configDir, String configName, Boolean createIfMissing, boolean createAlways) throws ConfigurationException, IOException { // Instantiate the Configuration if it has not been instantiated if (configDir == null || configDir.isEmpty()) throw new IllegalArgumentException("configDir is null or empty"); if (!configDir.endsWith(File.separator)) configDir += File.separator; final String fullName = getFullName(configDir, configName); if (createAlways && configList.containsKey(fullName)) { configList.remove(fullName); } if (configList.containsKey(fullName) == false) { XMLConfiguration config; // Try to open the file try { config = loadConfigurationFromFile(fullName); } catch (ConfigurationException e) // catch (NoClassDefFoundError e) { // Assume the error occured because the file does not exist // Throw exception if createIfMissing is false if (createIfMissing == false) { logger.error("Could not load " + configDir + configName + ".xml which will not be created"); throw new ConfigurationException(e); } // else try to make it... try { File dir = new File(configDir); if (!dir.exists()) if (!dir.mkdirs()) { throw new FileNotFoundException("Couldn't create directory: " + dir); } File file = new File(fullName); PrintWriter out = new PrintWriter(new FileWriter(file)); out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"no\"?>"); out.println("<" + configName + ">"); out.println("</" + configName + ">"); out.close(); } catch (IOException ee) { logger.error("Failed trying to create non-existent file " + fullName); throw new IOException(ee); } // ... and read it again try { config = loadConfigurationFromFile(fullName); } catch (ConfigurationException ee) { logger.error("Failed trying to read newly-created file " + fullName); throw new ConfigurationException(e); } logger.debug("Created configuration file: " + fullName); } // endif - create a missing file config.setReloadingStrategy(new FileChangedReloadingStrategy()); configList.put(fullName, config); logger.debug("Loaded the configuration file: " + fullName); } // endif - instantiate a new configuration // return the configuration object return configList.get(fullName); }
From source file:dk.dbc.opensearch.datadock.DatadockMain.java
/** * * /*w w w.j a v a2 s . c om*/ * @param args * @throws ConfigurationException */ public DatadockMain(String[] args) throws ConfigurationException { /** Try obtaining home path of datadock. If property 'datadock.home' is not set, * current working directory is assumed to be home. */ String datadockHome = System.getProperty("datadock.home"); if (datadockHome == null) { datadockHome = new File(".").getAbsolutePath(); } else { datadockHome = new File(datadockHome).getAbsolutePath(); } log.info(String.format("Using datadock.home: %s", datadockHome)); System.out.println(String.format("Using datadock.home: %s", datadockHome)); Configuration config = null; // Try reading properties file from -Dproperties.file String localPropFileName = System.getProperty("properties.file"); // If -Dpropfile is not set try reading from either ../config/datadock.properties or ./config/datadock.properties if (localPropFileName != null) { config = new PropertiesConfiguration(localPropFileName); } else { localPropFileName = "../config/" + propFileName; if (new File(localPropFileName).exists()) { config = new PropertiesConfiguration(localPropFileName); } localPropFileName = "./config/" + propFileName; if (new File(localPropFileName).exists()) { config = new PropertiesConfiguration(localPropFileName); } } // Throw new ConfigurationException if properties file could not be located. if (config == null) { throw new ConfigurationException( String.format("Could not load configuration from configuration file: %s; CWD: %s", localPropFileName, new File(".").getAbsoluteFile())); } log.info(String.format("Using properties file: %s", localPropFileName)); try { String configFile = config.getString("Log4j"); if (new File(configFile).exists()) { Log4jConfiguration.configure(configFile); } else { if (configFile.startsWith("../")) { configFile = configFile.replaceFirst("../", ""); if (new File(configFile).exists()) { Log4jConfiguration.configure(configFile); } else { throw new ConfigurationException( String.format("Could not locate config file at: %s", config.getString("Log4j"))); } } else { throw new ConfigurationException( String.format("Could not locate config file at: %s", config.getString("Log4j"))); } } log.info(String.format("Using config file: %s", configFile)); } catch (ConfigurationException ex) { String errMsg = String.format("Logger could not be configured, will continue without logging: %s", ex.getMessage()); log.error(errMsg); System.out.println(errMsg); } pollTime = config.getInt("MainPollTime"); queueSize = config.getInt("QueueSize"); corePoolSize = config.getInt("CorePoolSize"); maxPoolSize = config.getInt("MaxPoolSize"); keepAliveTime = config.getInt("KeepAliveTime"); log.debug(String.format("Starting Datadock with pollTime = %s", pollTime)); log.debug(String.format("Starting Datadock with queueSize = %s", queueSize)); log.debug(String.format("Starting Datadock with corePoolSize = %s", corePoolSize)); log.debug(String.format("Starting Datadock with maxPoolSize = %s", maxPoolSize)); log.debug(String.format("Starting Datadock with keepAliveTime = %s", keepAliveTime)); pluginFlowXmlPath = new File(config.getString("PluginFlowXmlPath")); pluginFlowXsdPath = new File(config.getString("PluginFlowXsdPath")); if (null == pluginFlowXmlPath || null == pluginFlowXsdPath) { throw new ConfigurationException( "Failed to initialize configuration values for File objects properly (pluginFlowXmlPath or pluginFlowXsdPath)"); } log.debug(String.format("Starting Datadock with pluginFlowXmlPath = %s", pluginFlowXmlPath)); log.debug(String.format("Starting Datadock with pluginFlowXsdPath = %s", pluginFlowXsdPath)); maxToHarvest = config.getInt("MaxToHarvest"); dataBaseNames = config.getList("OracleDataBaseNames"); oracleCacheName = config.getString("OracleCacheName"); oracleUrl = config.getString("OracleUrl"); oracleUser = config.getString("OracleUserID"); oraclePassWd = config.getString("OraclePassWd"); minLimit = config.getString("OracleMinLimit"); maxLimit = config.getString("OracleMaxLimit"); initialLimit = config.getString("OracleInitialLimit"); connectionWaitTimeout = config.getString("OracleConnectionWaitTimeout"); usePriorityFlag = config.getBoolean("UsePriorityField"); host = config.getString("Host"); port = config.getString("Port"); user = config.getString("User"); pass = config.getString("PassPhrase"); javascriptPath = config.getString("ScriptPath"); fileHarvestLightDir = config.getString("ToHarvest"); fileHarvestLightSuccessDir = config.getString("HarvestDone"); fileHarvestLightFailureDir = config.getString("HarvestFailure"); }
From source file:edu.kit.dama.ui.admin.AdminUIMainView.java
private void doBasicSetup() { //configure SiMon try {/*from w w w . j a v a2s .c o m*/ String path = DataManagerSettings.getSingleton() .getStringProperty(DataManagerSettings.SIMON_CONFIG_LOCATION_ID, null); if (path == null || !new File(path).exists()) { throw new ConfigurationException("Configuration element '" + DataManagerSettings.SIMON_CONFIG_LOCATION_ID + "' is not set or not a valid directory."); } File configLocation = new File(path); SimonConfigurator.getSingleton().setConfigLocation(configLocation); } catch (ConfigurationException ex) { LOGGER.error("Failed to initialize SimpleMonitoring", ex); } //set error handler in order to catch unhandled exceptions UI.getCurrent().setErrorHandler(new DefaultErrorHandler() { @Override public void error(com.vaadin.server.ErrorEvent event) { String cause = "<h3>An unexpected error has occured. Please reload the page.<br/>" + "If the error persists, please contact an administrator.</h3>"; Label errorLabel = new Label(cause, ContentMode.HTML); errorLabel.setDescription(StackTraceUtil.getCustomStackTrace(event.getThrowable(), false)); LOGGER.error("An unhandled exception has occured!", event.getThrowable()); // Display the error message in a custom fashion mainLayout.addComponent(errorLabel, 0); // Do the default error handling (optional) doDefault(event); } }); }
From source file:ch.admin.suis.msghandler.config.ClientConfiguration.java
/** * @param localRecipient The recipient to be added to the local list. *///from w w w . j a v a 2s . c o m public void addLocalRecipient(LocalRecipient localRecipient) throws ConfigurationException { Validate.notNull(localRecipient, "LocalRecipient cannot be null"); if (localRecipients.containsKey(localRecipient.getRecipientId())) { throw new ConfigurationException( "Already a localRecipient added with recipientId: " + localRecipient.getRecipientId()); } localRecipients.put(localRecipient.getRecipientId(), localRecipient); }
From source file:jdbc.pool.CPropertyManager.java
/** * Constructs the Configuration Manager around a supplied properties file. * /*from ww w . j av a 2 s . co m*/ * @param file Properties file * @throws ConfigurationException * */ protected CPropertyManager(File file) throws ConfigurationException { super(file); properties_ = new Properties(); logger_ = Logger.getLogger(this.getClass().getName()); FileInputStream fis = null; try { fis = new FileInputStream(file); properties_.load(fis); } catch (FileNotFoundException e) { logger_.error("FileNotFoundException", e); throw new ConfigurationException("File not found"); } catch (IOException e) { logger_.error("IOException", e); throw new ConfigurationException("IO exception"); } finally { if (fis != null) { try { fis.close(); } catch (IOException e) { //dummy. } } } }