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

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

Introduction

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

Prototype

String[] getStringArray(String key);

Source Link

Document

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

Usage

From source file:com.qmetry.qaf.automation.testng.pro.DataProviderUtil.java

public static List<Object[]> getDataSetAsMap(String key) {
    Configuration config = ConfigurationManager.getBundle().subset(key);
    ArrayList<Object[]> dataset = new ArrayList<Object[]>();
    if (config.isEmpty()) {
        logger.error("Missing data with key [" + key + "]. ");
        throw new DataProviderException("Not test data found with key:" + key);
    }/*from   w w w  .  java 2 s .  com*/
    int size = config.getList(config.getKeys().next().toString()).size();
    for (int i = 0; i < size; i++) {
        Map<String, String> map = new LinkedHashMap<String, String>();
        Iterator<?> iter = config.getKeys();
        while (iter.hasNext()) {
            String dataKey = String.valueOf(iter.next());
            try {
                map.put(dataKey, config.getStringArray(dataKey)[i]);
            } catch (ArrayIndexOutOfBoundsException e) {
                logger.error(
                        "Missing entry for property " + dataKey
                                + ". Provide value for each property (or blank) in each data set in data file.",
                        e);
                throw e;
            }
        }
        dataset.add(new Object[] { map });
    }
    return dataset;
}

From source file:com.evolveum.midpoint.wf.impl.processors.primary.PcpConfigurationHelper.java

private void setPrimaryChangeProcessorAspects(PrimaryChangeProcessor primaryChangeProcessor) {

    List<PrimaryChangeAspect> aspects = new ArrayList<>();

    Configuration c = primaryChangeProcessor.getProcessorConfiguration();
    if (c != null) {
        String[] aspectNames = c.getStringArray(KEY_ASPECT);
        if (aspectNames == null || aspectNames.length == 0) {
            LOGGER.warn(/*from ww  w .  ja v  a  2 s  . c  o m*/
                    "No aspects defined for primary change processor " + primaryChangeProcessor.getBeanName());
        } else {
            for (String aspectName : aspectNames) {
                LOGGER.trace("Searching for aspect " + aspectName);
                try {
                    PrimaryChangeAspect aspect = (PrimaryChangeAspect) primaryChangeProcessor.getBeanFactory()
                            .getBean(aspectName);
                    aspects.add(aspect);
                } catch (BeansException e) {
                    throw new SystemException("Change aspect " + aspectName + " could not be found.", e);
                }
            }
            LOGGER.debug("Resolved " + aspects.size() + " process aspects for primary change processor "
                    + primaryChangeProcessor.getBeanName());
        }
    }
    primaryChangeProcessor.setChangeAspects(aspects);
}

From source file:dk.itst.oiosaml.sp.service.LoginHandler.java

private boolean isForceAuthnEnabled(HttpServletRequest servletRequest, Configuration conf) {
    String[] urls = conf.getStringArray(Constants.PROP_FORCE_AUTHN_URLS);
    if (urls == null)
        return false;

    String path = servletRequest.getPathInfo();
    if (path == null) {
        path = "/";
    }/*from ww  w.  j a  v a2 s .  c o m*/
    if (log.isDebugEnabled())
        log.debug("ForceAuthn urls: " + Arrays.toString(urls) + "; path: " + path);

    for (String url : urls) {
        if (path.matches(url.trim())) {
            if (log.isDebugEnabled())
                log.debug("Requested url " + path + " is in forceauthn list " + Arrays.toString(urls));
            return true;
        }
    }
    return false;
}

From source file:fi.kela.kanta.cda.MaarittelyKonfiguraatio.java

private void kasitteleTyyppi(Configuration config, String templateId) {
    MaarittelyLuokka luokka = MaarittelyLuokka.VANHA;
    for (String token : config.getStringArray(templateId)) {
        if ((token == null) || "".equals(token)) {
            continue;
        }/*from   w ww  .j ava2s . c  o  m*/
        token = token.trim().toUpperCase();
        if ("NYKYINEN".equals(token)) {
            luokka = MaarittelyLuokka.NYKYINEN;
        } else if ("TULEVA".equals(token)) {
            luokka = MaarittelyLuokka.TULEVA;
        } else if ("VANHA".equals(token)) {
            luokka = MaarittelyLuokka.VANHA;
        } else if ("EI_TUETTU".equals(token)) {
            luokka = MaarittelyLuokka.EI_TUETTU;
        } else if ("*".equals(token)) {
            kasitteleKoodi(templateId, luokka);
        } else {
            kasitteleKoodi(templateId + "..." + token, luokka);
        }
    }
}

From source file:cross.io.InputDataFactory.java

@Override
public void configure(final Configuration cfg) {
    if (cfg.containsKey("input.dataInfo")) {
        this.input = cfg.getStringArray("input.dataInfo");
    }/*from w w w  .ja v a  2  s .  c o  m*/
    this.basedir = cfg.getString("input.basedir", "");
    if (this.basedir.isEmpty() || this.basedir.equals(".")) {
        log.debug("Configuration has no value for input.basedir! {}", this.basedir);
        this.basedir = System.getProperty("user.dir");
    }
    this.recurse = cfg.getBoolean("input.basedir.recurse", false);
}

From source file:edu.berkeley.sparrow.daemon.SparrowDaemon.java

public void initialize(Configuration conf) throws Exception {
    Level logLevel = Level.toLevel(conf.getString(SparrowConf.LOG_LEVEL, ""), DEFAULT_LOG_LEVEL);
    Logger.getRootLogger().setLevel(logLevel);

    // Start as many node monitors as specified in config
    String[] nmPorts = conf.getStringArray(SparrowConf.NM_THRIFT_PORTS);
    String[] inPorts = conf.getStringArray(SparrowConf.INTERNAL_THRIFT_PORTS);

    if (nmPorts.length != inPorts.length) {
        throw new ConfigurationException(SparrowConf.NM_THRIFT_PORTS + " and "
                + SparrowConf.INTERNAL_THRIFT_PORTS + " not of equal length");
    }/*from w w  w. j  av a 2 s .  c o  m*/
    if (nmPorts.length > 1 && (!conf.getString(SparrowConf.DEPLYOMENT_MODE, "").equals("standalone"))) {
        throw new ConfigurationException("Mutliple NodeMonitors only allowed " + "in standalone deployment");
    }
    if (nmPorts.length == 0) {
        (new NodeMonitorThrift()).initialize(conf, NodeMonitorThrift.DEFAULT_NM_THRIFT_PORT,
                NodeMonitorThrift.DEFAULT_INTERNAL_THRIFT_PORT);
    } else {
        for (int i = 0; i < nmPorts.length; i++) {
            (new NodeMonitorThrift()).initialize(conf, Integer.parseInt(nmPorts[i]),
                    Integer.parseInt(inPorts[i]));
        }
    }

    SchedulerThrift scheduler = new SchedulerThrift();
    scheduler.initialize(conf);
}

From source file:ch.epfl.eagle.daemon.EagleDaemon.java

public void initialize(Configuration conf) throws Exception {
    Level logLevel = Level.toLevel(conf.getString(EagleConf.LOG_LEVEL, ""), DEFAULT_LOG_LEVEL);
    Logger.getRootLogger().setLevel(logLevel);

    // Start as many node monitors as specified in config
    String[] nmPorts = conf.getStringArray(EagleConf.NM_THRIFT_PORTS);
    String[] inPorts = conf.getStringArray(EagleConf.INTERNAL_THRIFT_PORTS);

    if (nmPorts.length != inPorts.length) {
        throw new ConfigurationException(
                EagleConf.NM_THRIFT_PORTS + " and " + EagleConf.INTERNAL_THRIFT_PORTS + " not of equal length");
    }/*  ww w . j av a 2s.  c  om*/
    if (nmPorts.length > 1 && (!conf.getString(EagleConf.DEPLOYMENT_MODE, "").equals("standalone"))) {
        throw new ConfigurationException("Mutliple NodeMonitors only allowed " + "in standalone deployment");
    }
    if (nmPorts.length == 0) {
        (new NodeMonitorThrift()).initialize(conf, NodeMonitorThrift.DEFAULT_NM_THRIFT_PORT,
                NodeMonitorThrift.DEFAULT_INTERNAL_THRIFT_PORT);
    } else {
        for (int i = 0; i < nmPorts.length; i++) {
            (new NodeMonitorThrift()).initialize(conf, Integer.parseInt(nmPorts[i]),
                    Integer.parseInt(inPorts[i]));
        }
    }

    SchedulerThrift scheduler = new SchedulerThrift();
    scheduler.initialize(conf);
}

From source file:cz.cas.lib.proarc.common.process.ExternalProcess.java

protected List<String> buildCmdLine(Configuration conf) {
    String exec = conf.getString(PROP_EXEC);
    if (exec == null) {
        throw new IllegalStateException("Missing 'exec'!");
    }//from   www .ja  v a  2s .  c  o m
    String[] args = conf.getStringArray(PROP_ARG);
    List<String> cmdLine = new ArrayList<String>();
    cmdLine.add(exec);
    cmdLine.addAll(Arrays.asList(args));
    return cmdLine;
}

From source file:com.github.rwhogg.git_vcr.review.ReviewResults.java

/**
 * Retrieve the tests that will be run according to the configuration
 * @return a Map of MIMEtypes to a list of review tools
 * @throws ParseException if there is an invalid MIMEtype
 * @throws ClassNotFoundException if a review tool class is not found
 * @throws IllegalAccessException if we could not access the review tool class
 * @throws InstantiationException if we could not instantiate a review tool class
 *//*from  w w  w  .j a  v  a  2s  . c  om*/
private Map<String, List<ReviewTool>> getTests()
        throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    Map<String, List<ReviewTool>> tests = new HashMap<>();

    // get the types of files this configuration can handle
    Configuration typesSection = config.getSection("MIMEtypes");
    Iterator<String> typesHandled = typesSection.getKeys();
    while (typesHandled.hasNext()) {
        String mimeType = typesHandled.next();
        String[] toolNames = typesSection.getStringArray(mimeType);
        List<ReviewTool> tools = new LinkedList<>();
        for (String tool : toolNames) {
            tool = tool.trim();

            // construct the class
            ReviewTool reviewTool = (ReviewTool) Class.forName(tool).newInstance();
            reviewTool.setConfiguration(config.getSection(tool));
            tools.add(reviewTool);
        }
        tests.put(mimeType, tools);
    }

    return tests;
}

From source file:net.przemkovv.sphinx.compiler.MSVCCompiler.java

public MSVCCompiler() throws InvalidCompilerException, CompilerNonAvailableException {
    Configuration config;
    try {//  ww w. ja v a  2s  .  com
        config = new PropertiesConfiguration("net/przemkovv/sphinx/compiler/msvc_compiler.properties");
        String cmds[] = config.getStringArray("net.przemkovv.sphinx.compiler.msvc.cmd");
        String prepare_envs[] = config.getStringArray("net.przemkovv.sphinx.compiler.msvc.prepare_env");
        msvc = null;
        prepare_env = null;
        for (int i = 0; i < cmds.length; i++) {
            File temp_cmd = new File(cmds[i]);
            File temp_prepare_env = new File(prepare_envs[i]);
            if (temp_cmd.exists() && temp_cmd.canExecute()) {
                msvc = temp_cmd;
                prepare_env = temp_prepare_env;
                break;
            }

        }
        if (msvc == null) {
            throw new CompilerNonAvailableException("Compiler MS VC++ is not available.");
        }
        CompilerInfo info = getCompilerInfo();
        if (info != null) {
            logger.debug("Found MS VC++ Compiler. Version: {}, Arch: {}", info.version, info.architecture);
        }
        tmp_dir = System.getProperty("java.io.tmpdir");
        logger.debug("Temporary directory: {}", tmp_dir);
    } catch (ConfigurationException ex) {
        throw new CompilerNonAvailableException("Couldn't find configuration for compiler MS VC++.", ex);
    }

}