Example usage for org.apache.commons.configuration ConfigurationException ConfigurationException

List of usage examples for org.apache.commons.configuration ConfigurationException ConfigurationException

Introduction

In this page you can find the example usage for org.apache.commons.configuration ConfigurationException ConfigurationException.

Prototype

public ConfigurationException(Throwable cause) 

Source Link

Document

Constructs a new ConfigurationException with specified nested Throwable.

Usage

From source file:ch.admin.suis.msghandler.config.ClientConfigurationFactory.java

/**
 * berprft dass es keine doppelten SedexId mit gleichen MsgTypes gibt.
 *
 * @param inbox The Inbox//from ww  w. j  av  a  2 s.com
 * @throws ConfigurationException Config problems
 */
private void checkSedexIdMsgTypes(Inbox inbox) throws ConfigurationException {
    String sedexId = inbox.getSedexId();
    List<MessageType> msgTypes = inbox.getMessageTypes();

    for (MessageType mt : msgTypes) {
        LOG.debug("checkSedexIdMsgTypes: " + sedexId + ", " + mt.getType());
        if (checkSedexIdMsgType.containsKey(sedexId)) {
            Set<Integer> msgTypesSet = checkSedexIdMsgType.get(sedexId);
            if (msgTypesSet.contains(mt.getType())) {
                throw new ConfigurationException("There's already a participantId with msgType defined. "
                        + sedexId + ", " + mt.getType());
            } else {
                checkSedexIdMsgType.get(sedexId).add(mt.getType());
            }
        } else {
            Set<Integer> mySet = new HashSet<>();
            mySet.add(mt.getType());
            checkSedexIdMsgType.put(sedexId, mySet);
        }
    }
}

From source file:nl.isaac.dotcms.plugin.configuration.dotcms.DotCMSFileConfiguration.java

@Override
public void load() throws ConfigurationException {
    // And here we must read out dotCMS.
    final String fileName = getFileName();
    Host host;//w  w  w .j  a v a  2 s.c  o  m
    User systemUser;
    try {
        systemUser = APILocator.getUserAPI().getSystemUser();
        host = APILocator.getHostAPI().findByName(hostName, systemUser, false);
        if (host == null) {
            host = APILocator.getHostAPI().findByAlias(hostName, systemUser, false);
        }
    } catch (DotDataException e) {
        throw new ConfigurationException(e);
    } catch (DotSecurityException e) {
        throw new ConfigurationException(e);
    }
    FileAsset file = FileTools.getFileAssetByURI(fileName, host, true);
    java.io.File ioFile = file.getFileAsset();
    load(ioFile);
}

From source file:org.ambraproject.configuration.ConfigurationStore.java

/**
 * Use the default commons configuration specified by this library.
 *
 * @throws ConfigurationException when the configuration can't be found.
 *//* www .  j  a  va  2 s  .c  o  m*/
public void loadDefaultConfiguration() throws ConfigurationException {
    // Allow JVM level property to override everything else
    String name = System.getProperty(CONFIG_URL);
    if (name == null)
        name = DEFAULT_CONFIG_URL;

    try {
        loadConfiguration(new URL(name));
    } catch (MalformedURLException e) {
        throw new ConfigurationException(
                "Invalid value of '" + name + "' for '" + CONFIG_URL + "'. Must be a valid URL.");
    }
}

From source file:org.apache.bookkeeper.common.util.ReflectionUtils.java

/**
 * Get the value of the <code>name</code> property as a <code>Class</code>.
 * If no such property is specified, then <code>defaultCls</code> is returned.
 *
 * @param conf// w ww  .j a  va2s.c  om
 *          Configuration Object.
 * @param name
 *          Class Property Name.
 * @param defaultCls
 *          Default Class to be returned.
 * @param classLoader
 *          Class Loader to load class.
 * @return property value as a <code>Class</code>, or <code>defaultCls</code>.
 * @throws ConfigurationException
 */
public static Class<?> getClass(Configuration conf, String name, Class<?> defaultCls, ClassLoader classLoader)
        throws ConfigurationException {
    String valueStr = conf.getString(name);
    if (null == valueStr) {
        return defaultCls;
    }
    try {
        return Class.forName(valueStr, true, classLoader);
    } catch (ClassNotFoundException cnfe) {
        throw new ConfigurationException(cnfe);
    }
}

From source file:org.apache.bookkeeper.common.util.ReflectionUtils.java

/**
 * Get the value of the <code>name</code> property as a <code>Class</code> implementing
 * the interface specified by <code>xface</code>.
 *
 * <p>If no such property is specified, then <code>defaultValue</code> is returned.
 *
 * <p>An exception is thrown if the returned class does not implement the named interface.
 *
 * @param conf//  ww  w  .  j  a va 2 s.  c  o m
 *          Configuration Object.
 * @param name
 *          Class Property Name.
 * @param defaultValue
 *          Default Class to be returned.
 * @param xface
 *          The interface implemented by the named class.
 * @param classLoader
 *          Class Loader to load class.
 * @return property value as a <code>Class</code>, or <code>defaultValue</code>.
 * @throws ConfigurationException
 */
public static <T> Class<? extends T> getClass(Configuration conf, String name, Class<? extends T> defaultValue,
        Class<T> xface, ClassLoader classLoader) throws ConfigurationException {
    try {
        Class<?> theCls = getClass(conf, name, defaultValue, classLoader);
        if (null != theCls && !xface.isAssignableFrom(theCls)) {
            throw new ConfigurationException(theCls + " not " + xface.getName());
        } else if (null != theCls) {
            return theCls.asSubclass(xface);
        } else {
            return null;
        }
    } catch (Exception e) {
        throw new ConfigurationException(e);
    }
}

From source file:org.apache.bookkeeper.conf.ServerConfiguration.java

/**
 * Validate the configuration./*from  w  w w.  j a  v  a2s.c  o  m*/
 * @throws ConfigurationException
 */
public void validate() throws ConfigurationException {
    if (getSkipListArenaChunkSize() < getSkipListArenaMaxAllocSize()) {
        throw new ConfigurationException("Arena max allocation size should be smaller than the chunk size.");
    }
    if (getJournalAlignmentSize() < 512 || getJournalAlignmentSize() % 512 != 0) {
        throw new ConfigurationException("Invalid journal alignment size : " + getJournalAlignmentSize());
    }
    if (getJournalAlignmentSize() > getJournalPreAllocSizeMB() * 1024 * 1024) {
        throw new ConfigurationException("Invalid preallocation size : " + getJournalPreAllocSizeMB() + " MB");
    }
    if (getEntryLogSizeLimit() > BookKeeperConstants.MAX_LOG_SIZE_LIMIT) {
        throw new ConfigurationException(
                "Entry log file size should not be larger than " + BookKeeperConstants.MAX_LOG_SIZE_LIMIT);
    }
}

From source file:org.apache.bookkeeper.stream.conf.StreamConfiguration.java

/**
 * Validate if current configuration is valid.
 *
 * @throws ConfigurationException/* w w w.j a  v a  2  s  .  c  o  m*/
 */
public void validate() throws ConfigurationException {
    if (getSegmentWriterEntryBufferSize() > MB) {
        throw new ConfigurationException(
                "Too large write entry buffer size " + getSegmentWriterEntryBufferSize());
    }
}

From source file:org.apache.bookkeeper.util.ReflectionUtils.java

/**
 * Get the value of the <code>name</code> property as a <code>Class</code> implementing
 * the interface specified by <code>xface</code>.
 *
 * If no such property is specified, then <code>defaultValue</code> is returned.
 *
 * An exception is thrown if the returned class does not implement the named interface.
 *
 * @param conf//from   w  w w  . j  a v a2 s. c  o m
 *          Configuration Object.
 * @param name
 *          Class Property Name.
 * @param defaultValue
 *          Default Class to be returned.
 * @param xface
 *          The interface implemented by the named class.
 * @param classLoader
 *          Class Loader to load class.
 * @return property value as a <code>Class</code>, or <code>defaultValue</code>.
 * @throws ConfigurationException
 */
public static <U> Class<? extends U> getClass(Configuration conf, String name, Class<? extends U> defaultValue,
        Class<U> xface, ClassLoader classLoader) throws ConfigurationException {
    try {
        Class<?> theCls = getClass(conf, name, defaultValue, classLoader);
        if (null != theCls && !xface.isAssignableFrom(theCls)) {
            throw new ConfigurationException(theCls + " not " + xface.getName());
        } else if (null != theCls) {
            return theCls.asSubclass(xface);
        } else {
            return null;
        }
    } catch (Exception e) {
        throw new ConfigurationException(e);
    }
}

From source file:org.apache.distributedlog.config.DynamicConfigurationFactory.java

public synchronized Optional<DynamicDistributedLogConfiguration> getDynamicConfiguration(String configPath,
        ConcurrentBaseConfiguration defaultConf) throws ConfigurationException {
    checkNotNull(configPath);/*w  w  w .  j  a  va  2  s.co m*/
    try {
        if (!dynamicConfigs.containsKey(configPath)) {
            File configFile = new File(configPath);
            FileConfigurationBuilder properties = new PropertiesConfigurationBuilder(
                    configFile.toURI().toURL());
            DynamicDistributedLogConfiguration dynConf = new DynamicDistributedLogConfiguration(defaultConf);
            List<FileConfigurationBuilder> fileConfigBuilders = Lists.newArrayList(properties);
            ConfigurationSubscription subscription = new ConfigurationSubscription(dynConf, fileConfigBuilders,
                    executorService, reloadPeriod, reloadUnit);
            subscriptions.add(subscription);
            dynamicConfigs.put(configPath, dynConf);
            LOG.info("Loaded dynamic configuration at {}", configPath);
        }
        return Optional.of(dynamicConfigs.get(configPath));
    } catch (MalformedURLException ex) {
        throw new ConfigurationException(ex);
    }
}

From source file:org.apache.hedwig.client.conf.ClientConfiguration.java

public void validate() throws ConfigurationException {
    if (isSSLEnabled() && getDefaultServerHedwigSocketAddress().getSSLSocketAddress() == null) {
        throw new ConfigurationException("SSL is enabled but a default server SSL port not given!");
    }//from w  w  w  . ja  v  a2  s .c o m
    // Add other validation checks here
}