Java Code Examples for org.apache.commons.configuration2.HierarchicalConfiguration#getInt()

The following examples show how to use org.apache.commons.configuration2.HierarchicalConfiguration#getInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IMAPServer.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Override
public void doConfigure(HierarchicalConfiguration<ImmutableNode> configuration) throws ConfigurationException {
    
    super.doConfigure(configuration);
    
    hello = softwaretype + " Server " + getHelloName() + " is ready.";
    compress = configuration.getBoolean("compress", false);
    maxLineLength = configuration.getInt("maxLineLength", DEFAULT_MAX_LINE_LENGTH);
    inMemorySizeLimit = configuration.getInt("inMemorySizeLimit", DEFAULT_IN_MEMORY_SIZE_LIMIT);
    literalSizeLimit = configuration.getInt("literalSizeLimit", DEFAULT_LITERAL_SIZE_LIMIT);

    plainAuthDisallowed = configuration.getBoolean("plainAuthDisallowed", false);
    timeout = configuration.getInt("timeout", DEFAULT_TIMEOUT);
    if (timeout < DEFAULT_TIMEOUT) {
        throw new ConfigurationException("Minimum timeout of 30 minutes required. See rfc2060 5.4 for details");
    }
    
    if (timeout < 0) {
        timeout = 0;
    }

    processor.configure(getImapConfiguration(configuration));
}
 
Example 2
Source File: JamesMailSpooler.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(HierarchicalConfiguration<ImmutableNode> config) {
    concurrencyLevel = config.getInt("threads", 100);
    errorRepositoryURL = Optional.ofNullable(config.getString("errorRepository", null))
        .map(MailRepositoryUrl::from)
        .orElseGet(() -> MailRepositoryUrl.fromPathAndProtocol(
            mailRepositoryStore.defaultProtocol()
                .orElseThrow(() -> new IllegalStateException("Cannot retrieve mailRepository URL, you need to configure an `errorRepository` property for the spooler.0")),
            ERROR_REPOSITORY_PATH));
}
 
Example 3
Source File: RecipientRewriteTableConfiguration.java    From james-project with Apache License 2.0 5 votes vote down vote up
public static RecipientRewriteTableConfiguration fromConfiguration(HierarchicalConfiguration<ImmutableNode> config) throws ConfigurationException {
    boolean recursive = config.getBoolean("recursiveMapping", RECURSIVE_MAPPING_ENABLED);
    int mappingLimit;
    if (recursive) {
        mappingLimit = config.getInt("mappingLimit", DEFAULT_ENABLED_MAPPING_LIMIT);
        checkMappingLimit(mappingLimit);
    } else {
        mappingLimit = DISABLED_MAPPING_LIMIT;
    }
    return new RecipientRewriteTableConfiguration(recursive, mappingLimit);
}
 
Example 4
Source File: MailPriorityHandler.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
public void init(Configuration config) throws ConfigurationException {
    List<HierarchicalConfiguration<ImmutableNode>> entries = ((HierarchicalConfiguration<ImmutableNode>)config).configurationsAt("priorityEntries.priorityEntry");
    for (HierarchicalConfiguration<ImmutableNode> prioConf : entries) {
        Domain domain = Domain.of(prioConf.getString("domain"));
        int prio = prioConf.getInt("priority", MailPrioritySupport.NORMAL_PRIORITY);
        if (prio > MailPrioritySupport.HIGH_PRIORITY || prio < MailPrioritySupport.LOW_PRIORITY) {
            throw new ConfigurationException("configured priority must be >= " + MailPrioritySupport.LOW_PRIORITY + " and <= " + MailPrioritySupport.HIGH_PRIORITY);
        }
        prioMap.put(domain, prio);
    }        
}
 
Example 5
Source File: AbstractContentTypeUpgradeOperation.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void doInit(final HierarchicalConfiguration<ImmutableNode> config) {
    super.doInit(config);
    includedContentTypes = config.getList(String.class, CONFIG_KEY_CONTENT_TYPES);
    formDefinitionXpath = config.getString(CONFIG_KEY_FORM_DEFINITION);
    int maxCacheItems = config.getInt(CONFIG_KEY_MAX_ITEMS, DEFAULT_MAX_ITEMS);
    cache = CacheBuilder
        .newBuilder()
        .maximumSize(maxCacheItems)
        .build();
}
 
Example 6
Source File: JDBCMailRepository.java    From james-project with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(HierarchicalConfiguration<ImmutableNode> configuration) throws ConfigurationException {
    LOGGER.debug("{}.configure()", getClass().getName());
    destination = configuration.getString("[@destinationURL]");

    // normalize the destination, to simplify processing.
    if (!destination.endsWith("/")) {
        destination += "/";
    }
    // Parse the DestinationURL for the name of the datasource,
    // the table to use, and the (optional) repository Key.
    // Split on "/", starting after "db://"
    List<String> urlParams = new ArrayList<>();
    int start = 5;
    if (destination.startsWith("dbfile")) {
        // this is dbfile:// instead of db://
        start += 4;
    }
    int end = destination.indexOf('/', start);
    while (end > -1) {
        urlParams.add(destination.substring(start, end));
        start = end + 1;
        end = destination.indexOf('/', start);
    }

    // Build SqlParameters and get datasource name from URL parameters
    if (urlParams.size() == 0) {
        String exceptionBuffer = "Malformed destinationURL - Must be of the format '" + "db://<data-source>[/<table>[/<repositoryName>]]'.  Was passed " + configuration.getString("[@destinationURL]");
        throw new ConfigurationException(exceptionBuffer);
    }
    if (urlParams.size() >= 1) {
        datasourceName = urlParams.get(0);
    }
    if (urlParams.size() >= 2) {
        tableName = urlParams.get(1);
    }
    if (urlParams.size() >= 3) {
        repositoryName = "";
        for (int i = 2; i < urlParams.size(); i++) {
            if (i >= 3) {
                repositoryName += '/';
            }
            repositoryName += urlParams.get(i);
        }
    }

    LOGGER.debug("Parsed URL: table = '{}', repositoryName = '{}'", tableName, repositoryName);

    inMemorySizeLimit = configuration.getInt("inMemorySizeLimit", 409600000);

    filestore = configuration.getString("filestore", null);
    sqlFileName = configuration.getString("sqlFile");

}
 
Example 7
Source File: LdapRepositoryConfiguration.java    From james-project with Apache License 2.0 4 votes vote down vote up
public static LdapRepositoryConfiguration from(HierarchicalConfiguration<ImmutableNode> configuration) throws ConfigurationException {
    String ldapHost = configuration.getString("[@ldapHost]", "");
    String principal = configuration.getString("[@principal]", "");
    String credentials = configuration.getString("[@credentials]", "");
    String userBase = configuration.getString("[@userBase]");
    String userIdAttribute = configuration.getString("[@userIdAttribute]");
    String userObjectClass = configuration.getString("[@userObjectClass]");
    // Default is to use connection pooling
    boolean useConnectionPool = configuration.getBoolean("[@useConnectionPool]", USE_CONNECTION_POOL);
    int connectionTimeout = configuration.getInt("[@connectionTimeout]", NO_CONNECTION_TIMEOUT);
    int readTimeout = configuration.getInt("[@readTimeout]", NO_READ_TIME_OUT);
    // Default maximum retries is 1, which allows an alternate connection to
    // be found in a multi-homed environment
    int maxRetries = configuration.getInt("[@maxRetries]", 1);
    boolean supportsVirtualHosting = configuration.getBoolean(SUPPORTS_VIRTUAL_HOSTING, !ENABLE_VIRTUAL_HOSTING);
    // Default retry start interval is 0 second
    long retryStartInterval = configuration.getLong("[@retryStartInterval]", 0);
    // Default maximum retry interval is 60 seconds
    long retryMaxInterval = configuration.getLong("[@retryMaxInterval]", 60);
    int scale = configuration.getInt("[@retryIntervalScale]", 1000); // seconds

    HierarchicalConfiguration<ImmutableNode> restrictionConfig = null;
    // Check if we have a restriction we can use
    // See JAMES-1204
    if (configuration.containsKey("restriction[@memberAttribute]")) {
        restrictionConfig = configuration.configurationAt("restriction");
    }
    ReadOnlyLDAPGroupRestriction restriction = new ReadOnlyLDAPGroupRestriction(restrictionConfig);

    //see if there is a filter argument
    String filter = configuration.getString("[@filter]");

    Optional<String> administratorId = Optional.ofNullable(configuration.getString("[@administratorId]"));

    return new LdapRepositoryConfiguration(
        ldapHost,
        principal,
        credentials,
        userBase,
        userIdAttribute,
        userObjectClass,
        useConnectionPool,
        connectionTimeout,
        readTimeout,
        maxRetries,
        supportsVirtualHosting,
        retryStartInterval,
        retryMaxInterval,
        scale,
        restriction,
        filter,
        administratorId);
}