Example usage for org.apache.commons.configuration HierarchicalConfiguration getString

List of usage examples for org.apache.commons.configuration HierarchicalConfiguration getString

Introduction

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

Prototype

public String getString(String key) 

Source Link

Usage

From source file:net.datenwerke.sandbox.util.SandboxParser.java

protected void configurePermissions(SandboxContext set, HierarchicalConfiguration rs) {
    for (HierarchicalConfiguration perm : rs.configurationsAt("permission.whitelist.entry")) {
        String type = perm.getString("type");
        String pName = perm.getString("name");
        String actions = perm.getString("actions");

        Collection<StackEntry> entries = new HashSet<StackEntry>();

        for (HierarchicalConfiguration stack : perm.configurationsAt("stack.check")) {
            StackEntry entry = getStackEntry(stack);
            entries.add(entry);//from   w  w w .  ja v a  2s . c o  m
        }

        SecurityPermission wp = new SecurityPermission(type, pName, actions, entries);

        set.addSecurityPermission(AccessType.PERMIT, wp);
    }

    for (HierarchicalConfiguration perm : rs.configurationsAt("permission.blacklist.entry")) {
        String type = perm.getString("type");
        String pName = perm.getString("name", null);
        String actions = perm.getString("actions", null);

        Collection<StackEntry> entries = new HashSet<StackEntry>();

        for (HierarchicalConfiguration stack : perm.configurationsAt("stack.check")) {
            StackEntry entry = getStackEntry(stack);
            entries.add(entry);
        }

        SecurityPermission wp = new SecurityPermission(type,
                null != pName && "".equals(pName.trim()) ? null : pName,
                null != actions && "".equals(actions.trim()) ? null : actions, entries);

        set.addSecurityPermission(AccessType.DENY, wp);
    }
}

From source file:com.vmware.qe.framework.datadriven.impl.injector.DataInjectorUsingAnnotations.java

@Override
public void inject(Object test, HierarchicalConfiguration data, HierarchicalConfiguration context) {
    Class<? extends Object> testClass = test.getClass();
    for (Field field : testClass.getDeclaredFields()) {
        for (Annotation annotation : field.getAnnotations()) {
            if (annotation.annotationType().isAssignableFrom(Data.class)) {
            }/*from   w w  w . j  a v a2s . co m*/
            Data dataAnnotation = (Data) annotation;
            field.setAccessible(true);
            try {
                if (dataAnnotation.name().equals("")) {
                    field.set(test, data);
                } else {
                    String value = data.getString(dataAnnotation.name());
                    field.set(test, value);
                }
            } catch (IllegalArgumentException | IllegalAccessException e) {
                throw new DDException("Error in injecting data to field with name = " + field.getName(), e);
            }
        }
    }
}

From source file:com.webcohesion.enunciate.modules.docs.DocsModule.java

/**
 * The configured list of downloads to add to the documentation.
 *
 * @return The configured list of downloads to add to the documentation.
 *//*from  w ww  .  j  ava 2 s  .c om*/
public Collection<ExplicitDownloadConfig> getExplicitDownloads() {
    List<HierarchicalConfiguration> downloads = this.config.configurationsAt("download");
    ArrayList<ExplicitDownloadConfig> downloadConfigs = new ArrayList<ExplicitDownloadConfig>(downloads.size());
    for (HierarchicalConfiguration download : downloads) {
        ExplicitDownloadConfig downloadConfig = new ExplicitDownloadConfig();
        downloadConfig.setArtifact(download.getString("[@artifact]"));
        downloadConfig.setDescription(download.getString("[@description]"));
        downloadConfig.setFile(download.getString("[@file]"));
        downloadConfig.setName(download.getString("[@name]"));
        downloadConfig.setShowLink(download.getString("[@showLink]"));
        downloadConfigs.add(downloadConfig);
    }
    return downloadConfigs;
}

From source file:com.webcohesion.enunciate.modules.objc_client.ObjCXMLClientModule.java

/**
 * The package-to-module conversions./*  w ww.  jav a  2  s .com*/
 *
 * @return The package-to-module conversions.
 */
public Map<String, String> getPackageIdentifiers() {
    List<HierarchicalConfiguration> conversionElements = this.config.configurationsAt("package");
    HashMap<String, String> conversions = new HashMap<String, String>();
    for (HierarchicalConfiguration conversionElement : conversionElements) {
        conversions.put(conversionElement.getString("[@name]"), conversionElement.getString("[@identifier]"));
    }
    return conversions;
}

From source file:com.termmed.statistics.Processor.java

/**
 * Adds the header.//  w w w .ja v  a 2 s  . c o  m
 *
 * @param bw the bw
 * @param detail the detail
 * @param listDescriptors 
 * @throws IOException Signals that an I/O exception has occurred.
 */
private void addHeader(BufferedWriter bw, OutputDetailFile detail,
        List<HierarchicalConfiguration> listDescriptors) throws IOException {
    bw.append(detail.getReportHeader());
    if (listDescriptors != null) {
        for (HierarchicalConfiguration additionalList : listDescriptors) {
            bw.append(",");
            bw.append(additionalList.getString("listTitle"));
        }
    }
    bw.append("\r\n");

}

From source file:com.norconex.committer.idol.IdolCommitter.java

@Override
protected void loadFromXml(XMLConfiguration xml) {
    setHost(xml.getString("host"));
    setCfsPort(xml.getInt("cfsPort", -1));
    setIndexPort(xml.getInt("indexPort", -1));
    setDatabaseName(xml.getString("databaseName"));

    List<HierarchicalConfiguration> uparams = xml.configurationsAt("dreAddDataParams.param");
    for (HierarchicalConfiguration param : uparams) {
        addDreAddDataParam(param.getString("[@name]"), param.getString(""));
    }//from www.  j a  v a2 s  .  c o  m

    List<HierarchicalConfiguration> dparams = xml.configurationsAt("dreDeleteRefParams.param");
    for (HierarchicalConfiguration param : dparams) {
        addDreDeleteRefParam(param.getString("[@name]"), param.getString(""));
    }
}

From source file:com.termmed.statistics.Processor.java

/**
 * Execute.// w  w w .j a  v a2s  . c o  m
 *
 * @throws IOException Signals that an I/O exception has occurred.
 * @throws Exception the exception
 */
public void execute() throws IOException, Exception {
    logger.logInfo("Starting report execution");
    createFolders();
    XMLConfiguration xmlConfig;
    try {
        xmlConfig = new XMLConfiguration(configFile);
    } catch (ConfigurationException e) {
        logger.logInfo("ClassificationRunner - Error happened getting params configFile." + e.getMessage());
        throw e;
    }
    createDetails = xmlConfig.getString("createDetailReports");
    String dependentRelease = xmlConfig.getString("dependentReleaseFullFolder");
    enableListeners = true;
    if (dependentRelease == null || dependentRelease.trim().equals("")) {
        enableListeners = false;
    }
    List<HierarchicalConfiguration> listDescriptors = xmlConfig
            .configurationsAt("interestConceptLists.conceptListDescriptor");

    List<HierarchicalConfiguration> fields = xmlConfig.configurationsAt("reports.reportDescriptor");
    String excList = xmlConfig.getString("createExcluyentDetailLists");
    boolean createExcluyentDetailLists = false;
    if (excList != null && excList.equals("true")) {
        createExcluyentDetailLists = true;
    }
    mapExcluyentListFile = new TreeMap<Integer, IReportDetail>();

    for (HierarchicalConfiguration sub : fields) {

        String report = sub.getString("filename");
        String value = sub.getString("execute");

        if (value.toLowerCase().equals("true")) {
            logger.logInfo("Getting report config for " + report);
            ReportConfig reportCfg = ResourceUtils.getReportConfig(report);
            logger.logInfo("Executing report " + report);
            long start = logger.startTime();
            executeReport(reportCfg);

            logger.logInfo("Writing report " + report);
            writeReports(reportCfg, report, listDescriptors);

            String msg = logger.endTime(start);
            int posIni = msg.indexOf("ProcessingTime:") + 16;
            ReportInfo rInfo = new ReportInfo();
            rInfo.setName(reportCfg.getName());
            if (reportCfg.getOutputFile() != null) {
                for (OutputFileTableMap file : reportCfg.getOutputFile()) {
                    rInfo.getOutputFiles().add(file.getFile());
                }
            }
            if (reportCfg.getOutputDetailFile() != null) {
                for (OutputDetailFile file : reportCfg.getOutputDetailFile()) {
                    rInfo.getOutputDetailFiles().add(file.getFile());
                }
            }
            rInfo.setTimeTaken(msg.substring(posIni));
            OutputInfoFactory.get().getStatisticProcess().getReports().add(rInfo);

            if (createExcluyentDetailLists) {
                if (reportCfg.getOutputDetailFile() != null) {

                    for (OutputDetailFile file : reportCfg.getOutputDetailFile()) {
                        Integer priority = file.getExcluyentListPriority();
                        if (priority != null) {
                            mapExcluyentListFile.put(priority, file);
                        }
                    }
                }
            }
        }
        //            System.out.println(report + " " + value);
    }
    if (createExcluyentDetailLists) {
        File outputFold = createOutputExcluyentListFolder();
        createExcluyentList(outputFold, listDescriptors);
    }
}

From source file:ch.kostceco.tools.kostval.service.impl.ConfigurationServiceImpl.java

@SuppressWarnings("unchecked")
@Override/*w w  w  .j  a  v  a  2  s . com*/
public Map<String, String> getAllowedPuids() {
    Map<String, String> result = new HashMap<String, String>();
    List<HierarchicalConfiguration> fields = getConfig().configurationsAt("sip.allowedformats.allowedformat");
    for (Iterator<HierarchicalConfiguration> it = fields.iterator(); it.hasNext();) {
        HierarchicalConfiguration sub = it.next();
        // sub contains now all data about a single field
        String fieldPuid = sub.getString("puid");
        String fieldExt = sub.getString("extension");
        result.put(fieldPuid, fieldExt);
    }
    return result;
}

From source file:com.termmed.statistics.Processor.java

private AdditionalList[] getAdditionalList(List<HierarchicalConfiguration> listDescriptors) throws IOException {
    AdditionalList[] additionalList = new AdditionalList[listDescriptors.size()];
    int cont = 0;
    for (HierarchicalConfiguration additional : listDescriptors) {
        AdditionalList addList = new AdditionalList();
        String ix = additional.getString("conceptIdColumnIndex");
        int colIndex = 0;
        if (ix != null) {
            try {
                colIndex = Integer.parseInt(ix);
            } catch (Exception e) {
            }// ww  w . j  a va  2  s .c  o  m
        }
        String file = additional.getString("filePath");
        if (file == null || file.trim().equals("")) {
            continue;
        }
        addList.setFilePath(file);
        String listTitle = additional.getString("listTitle");
        if (listTitle == null || listTitle.trim().equals("")) {
            listTitle = "list " + cont;
        }
        addList.setListTitle(listTitle);
        addList.setConceptIdColumnIndex(String.valueOf(colIndex));
        HashSet<String> idList = getIdList(file, colIndex);
        addList.setIds(idList);
        additionalList[cont] = addList;
        cont++;
    }
    return additionalList;
}

From source file:net.datenwerke.sandbox.util.SandboxParser.java

protected SandboxContext loadSandbox(String name, HierarchicalConfiguration conf,
        HierarchicalConfiguration contextConf, HashSet<String> basedOnProcessed) {
    SandboxContext context = new SandboxContext();
    String basedOn = contextConf.getString("[@basedOn]");
    if (null != basedOn) {
        if (basedOnProcessed.contains(basedOn))
            throw new IllegalStateException(
                    "Loop detected: there seems to be a loop in the sandbox configuration at" + basedOn
                            + " and " + name);
        basedOnProcessed.add(basedOn);/*from w w  w  . ja v a2  s  . co m*/

        HierarchicalConfiguration baseConf = null;
        for (HierarchicalConfiguration c : conf.configurationsAt("security.sandbox")) {
            if (name.equals(contextConf.getString("[@name]"))) {
                baseConf = c;
                break;
            }
        }
        if (null == baseConf)
            throw new IllegalStateException("Could not find config for " + basedOn);

        SandboxContext basis = loadSandbox(name, conf, baseConf, basedOnProcessed);
        context = basis.clone();
    }

    Boolean allAccess = contextConf.getBoolean("[@allowAll]", false);
    if (allAccess)
        context.setPassAll(allAccess);

    boolean bypassClassAccesss = contextConf.getBoolean("[@bypassClassAccess]", false);
    context.setBypassClassAccessChecks(bypassClassAccesss);

    boolean bypassPackageAccesss = contextConf.getBoolean("[@bypassPackageAccess]", false);
    context.setBypassPackageAccessChecks(bypassPackageAccesss);

    Boolean debug = contextConf.getBoolean("[@debug]", false);
    if (debug)
        context.setDebug(debug);

    String codesource = contextConf.getString("[@codesource]", null);
    if (null != codesource && !"".equals(codesource.trim()))
        context.setCodesource(codesource);

    /* run in */
    Boolean runInThread = contextConf.getBoolean("[@runInThread]", false);
    if (runInThread)
        context.setRunInThread(runInThread);
    Boolean runRemote = contextConf.getBoolean("[@runRemote]", false);
    if (runRemote)
        context.setRunRemote(runRemote);

    /* finalizers */
    Boolean removeFinalizers = contextConf.getBoolean("[@removeFinalizers]", false);
    if (removeFinalizers)
        context.setRemoveFinalizers(removeFinalizers);

    /* thread */
    configureThreadRestrictions(context, contextConf);

    /* packages */
    configurePackages(context, contextConf);

    /* class access */
    try {
        configureClasses(context, contextConf);

        /* application loader */
        configureClassesForApplicationLoader(context, contextConf);
    } catch (MalformedURLException e) {
        throw new IllegalArgumentException("Could not generate URL", e);
    }

    /* permissions */
    configurePermissions(context, contextConf);

    /* file access */
    configureFileAccess(context, contextConf);

    return context;
}