Example usage for org.apache.commons.configuration SubnodeConfiguration getStringArray

List of usage examples for org.apache.commons.configuration SubnodeConfiguration getStringArray

Introduction

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

Prototype

public String[] getStringArray(String key) 

Source Link

Document

Get an array of strings associated with the given configuration key.

Usage

From source file:ee.ria.xroad.signer.tokenmanager.module.ModuleConf.java

private static String[] getStringArray(SubnodeConfiguration section, String key) {
    try {/*www  .ja v a  2 s  .  com*/
        return section.getStringArray(key);
    } catch (ConversionException e) {
        throw new ConversionException(String.format("Invalid value of '%s' for module (%s), skipping...", key,
                section.getSubnodeKey()), e);
    }
}

From source file:com.bist.elasticsearch.jetty.security.AuthorizationConfigurationLoader.java

protected QueryConstraints loadIni(HierarchicalINIConfiguration iniConfiguration,
        QueryConstraints queryConstraints) {
    for (String section : iniConfiguration.getSections()) {
        SubnodeConfiguration subnodeConfiguration = iniConfiguration.getSection(section);
        switch (section) {
        case "Public":
            for (String query : subnodeConfiguration.getStringArray("Queries")) {
                queryConstraints.addPublicQuery(query);
            }//from w w  w.  ja  va  2s.co  m
            break;
        case "Authenticated":
            for (String query : subnodeConfiguration.getStringArray("Queries")) {
                queryConstraints.addAuthenticatedQuery(query);
            }
            break;
        default:
            loadIndiceAuthZ(queryConstraints, section, subnodeConfiguration);
            break;
        }
    }
    { // make it atomic
        return queryConstraints;

    }
}

From source file:it.jnrpe.server.IniJNRPEConfiguration.java

@Override
public void load(final File confFile) throws ConfigurationException {
    // Parse an ini file
    ServerSection serverConf = getServerSection();
    CommandsSection commandSection = getCommandSection();
    try {// ww w  . ja va2  s .  c o  m
        HierarchicalINIConfiguration confParser = new HierarchicalINIConfiguration(confFile);

        List<Object> vBindAddresses = confParser.getList("server.bind-address");
        if (vBindAddresses != null) {
            for (Object address : vBindAddresses) {
                serverConf.addBindAddress((String) address);
            }
        }

        // Defaults accept params
        String sAcceptParams = confParser.getString("server.accept-params", "true");
        serverConf.setAcceptParams(
                "true".equalsIgnoreCase(sAcceptParams) || "yes".equalsIgnoreCase(sAcceptParams));
        serverConf.setPluginPath(confParser.getString("server.plugin-path", "."));

        serverConf.setBackLogSize(confParser.getInt("server.backlog-size", ServerSection.DEFAULT_BACKLOG));

        // TODO : move this to publicly accessible constants
        serverConf.setReadTimeout(confParser.getInteger("server.read-timeout", 10));
        // TODO : move this to publicly accessible constants
        serverConf.setWriteTimeout(confParser.getInteger("server.write-timeout", 60));

        List<Object> vAllowedAddresses = confParser.getList("server.allow-address");
        if (vAllowedAddresses != null) {
            for (Object address : vAllowedAddresses) {
                serverConf.addAllowedAddress((String) address);
            }
        }

        SubnodeConfiguration sc = confParser.getSection("commands");

        if (sc != null) {
            for (Iterator<String> it = sc.getKeys(); it.hasNext();) {
                String sCommandName = it.next();

                String sCommandLine = org.apache.commons.lang.StringUtils.join(sc.getStringArray(sCommandName),
                        ",");
                // first element of the command line is the plugin name

                String[] vElements = StringUtils.split(sCommandLine, false);
                String sPluginName = vElements[0];

                // Rebuilding the commandline
                StringBuilder cmdLine = new StringBuilder();

                for (int i = 1; i < vElements.length; i++) {
                    cmdLine.append(quoteAndEscape(vElements[i])).append(' ');
                }

                commandSection.addCommand(sCommandName, sPluginName, cmdLine.toString());
            }
        }
    } catch (org.apache.commons.configuration.ConfigurationException e) {
        throw new ConfigurationException(e);
    }

}

From source file:de.clusteval.program.ProgramParameter.java

/**
 * Parses a program parameter from a section of a configuration file.
 * //from  w  ww .ja va  2 s. co  m
 * <p>
 * This method only delegates depending on the type of the program parameter
 * to the methods
 * {@link DoubleProgramParameter#parseFromStrings(ProgramConfig, String, String, String, String, String)},
 * {@link IntegerProgramParameter#parseFromStrings(ProgramConfig, String, String, String, String, String)}
 * and
 * {@link StringProgramParameter#parseFromStrings(ProgramConfig, String, String, String, String, String)}.
 * 
 * @param programConfig
 *            The program configuration in which the program parameter has
 *            been defined.
 * @param name
 *            The name of the program parameter.
 * @param config
 *            The section of the configuration, which contains the
 *            information about this parameter.
 * @return The parsed program parameter.
 * @throws RegisterException
 * @throws UnknownParameterType
 */
public static ProgramParameter<?> parseFromConfiguration(final ProgramConfig programConfig, final String name,
        final SubnodeConfiguration config) throws RegisterException, UnknownParameterType {
    Map<String, String> paramValues = new HashMap<String, String>();
    paramValues.put("name", name);

    Iterator<String> itSubParams = config.getKeys();
    while (itSubParams.hasNext()) {
        final String subParam = itSubParams.next();
        final String value = config.getString(subParam);

        paramValues.put(subParam, value);
    }
    ParameterType type = ProgramParameter.parseTypeFromString(paramValues.get("type"));

    String na = paramValues.get("name");
    String description = paramValues.get("desc");
    String def = paramValues.get("def");

    // 23.05.2014: added support for options for float and integer
    // parameters. if options are given, we set minValue and maxValue to the
    // empty string.
    ProgramParameter<?> param = null;
    String[] options = config.getStringArray("options");
    String minValue = paramValues.get("minValue");
    String maxValue = paramValues.get("maxValue");
    if (config.containsKey("options")) {
        minValue = "";
        maxValue = "";
    }
    if (type.equals(ParameterType.FLOAT)) {
        param = DoubleProgramParameter.parseFromStrings(programConfig, na, description, minValue, maxValue,
                options, def);
    } else if (type.equals(ParameterType.INTEGER)) {
        param = IntegerProgramParameter.parseFromStrings(programConfig, na, description, minValue, maxValue,
                options, def);
    } else if (type.equals(ParameterType.STRING)) {
        param = StringProgramParameter.parseFromStrings(programConfig, na, description, options, def);
    }
    return param;
}

From source file:de.uni_rostock.goodod.evaluator.OntologyTest.java

public OntologyTest(HierarchicalConfiguration testDescription)
        throws FileNotFoundException, IOException, OWLOntologyCreationException, ConfigurationException {

    // Get a reference to the global configuration:
    globalConfig = Configuration.getConfiguration();
    threadCount = globalConfig.getInt("threadCount");
    compCtor = getComparatorConstructor(globalConfig.getString("similarity"));
    testConfig = testDescription;//w  w w. j a v  a 2s . c o m
    inProgressCount = new AtomicInteger();

    // Gather URIs for the raw, model and student ontologies.
    String repoRoot = globalConfig.getString("repositoryRoot");
    if (null == repoRoot) {
        repoRoot = "";
    }
    String testDir = repoRoot + File.separator + globalConfig.getString("testDir");
    String groupADir = "";
    String groupBDir = "";
    if (false == testConfig.getBoolean("notInRepository", false)) {
        groupADir = repoRoot + File.separator + globalConfig.configurationAt("groupDirs").getString("groupA")
                + File.separator;
        groupBDir = repoRoot + File.separator + globalConfig.configurationAt("groupDirs").getString("groupB")
                + File.separator;
    }
    File rawFile = null;
    if (testConfig.containsKey("rawOntology")) {
        rawFile = new File(testDir + File.separator + testConfig.getString("rawOntology"));
        rawOntology = rawFile.toURI();
    }
    File modelFile = null;
    if (testConfig.containsKey("modelOntology")) {
        modelFile = new File(testDir + File.separator + testConfig.getString("modelOntology"));
        modelOntology = modelFile.toURI();
    }
    groupAOntologies = new HashSet<URI>(12);
    groupBOntologies = new HashSet<URI>(12);
    failedComparisons = new HashMap<URI, Set<URI>>();
    SubnodeConfiguration studentOntConf = testConfig.configurationAt("studentOntologies");
    for (String fileName : studentOntConf.getStringArray("groupA")) {
        File studFile = new File(groupADir + fileName);
        groupAOntologies.add(studFile.toURI());
    }
    for (String fileName : studentOntConf.getStringArray("groupB")) {
        File studFile = new File(groupBDir + fileName);
        groupBOntologies.add(studFile.toURI());
    }

    // create the result map:
    resultMap = new HashMap<URI, Map<URI, ComparisonResult>>(25);

    // Get URIs for BioTopLite and the ignored imports.
    File biotopF = new File(globalConfig.getString("repositoryRoot") + File.separator
            + globalConfig.getString("bioTopLiteSource"));
    if (false == biotopF.canRead()) {
        logger.warn("Could not read BioTopLite.");
    } else {
        bioTopLiteURI = biotopF.toURI();
    }

    testIRIs = getIRIsToTest();

    considerImports = true;
}