List of usage examples for org.apache.commons.configuration ConfigurationException ConfigurationException
public ConfigurationException(String message, Throwable cause)
ConfigurationException
with specified detail message and nested Throwable
. From source file:org.wso2.andes.server.security.auth.manager.PrincipalDatabaseAuthenticationManager.java
private void configPrincipalDatabase(final PrincipalDatabase principalDatabase, final PrincipalDatabaseAuthenticationManagerConfiguration config) throws ConfigurationException { final Map<String, String> attributes = config.getPdClassAttributeMap(); for (Iterator<Entry<String, String>> iterator = attributes.entrySet().iterator(); iterator.hasNext();) { final Entry<String, String> nameValuePair = iterator.next(); final String methodName = generateSetterName(nameValuePair.getKey()); final Method method; try {// w w w.ja va 2s . c om method = principalDatabase.getClass().getMethod(methodName, String.class); } catch (Exception e) { throw new ConfigurationException( "No method " + methodName + " found in class " + principalDatabase.getClass() + " hence unable to configure principal database. The method must be public and " + "have a single String argument with a void return type", e); } try { method.invoke(principalDatabase, PropertyUtils.replaceProperties(nameValuePair.getValue())); } catch (IllegalArgumentException e) { throw new ConfigurationException(e.getMessage(), e); } catch (PropertyException e) { throw new ConfigurationException(e.getMessage(), e); } catch (IllegalAccessException e) { throw new ConfigurationException(e.getMessage(), e); } catch (InvocationTargetException e) { // QPID-1347.. InvocationTargetException wraps the checked exception thrown from the reflective // method call. Pull out the underlying message and cause to make these more apparent to the user. throw new ConfigurationException(e.getCause().getMessage(), e.getCause()); } } }
From source file:org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.config.AuthorizationConfiguration.java
/** * Given the data type and the value read from a config, this returns the parsed value * of the property.//from w w w . ja va 2s. c om * * @param key The Key to the property being read (n xpath format as contained in file.) * @param dataType Expected data type of the property * @param defaultValue This parameter should NEVER be null since we assign a default value to * every config property. * @param <T> Expected data type of the property * @return Value of config in the expected data type. * @throws ConfigurationException if there are any configuration issues */ private static <T> T deriveValidConfigurationValue(String key, Class<T> dataType, String defaultValue) throws ConfigurationException { if (log.isDebugEnabled()) { log.debug("Reading configuration value " + key); } String readValue = compositeConfiguration.getString(key); String validValue = defaultValue; if (StringUtils.isBlank(readValue)) { log.warn("Error when trying to read property : " + key + ". Switching to " + "default value : " + defaultValue); } else { validValue = overrideWithDecryptedValue(key, readValue); } if (log.isDebugEnabled()) { log.debug("Valid value read for andes configuration property " + key + " is : " + validValue); } try { return dataType.getConstructor(String.class).newInstance(validValue); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) { throw new ConfigurationException(MessageFormat.format(GENERIC_CONFIGURATION_PARSE_ERROR, key), e); } }