Java Code Examples for org.apache.commons.configuration.XMLConfiguration#setDelimiterParsingDisabled()

The following examples show how to use org.apache.commons.configuration.XMLConfiguration#setDelimiterParsingDisabled() . 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: Configuration.java    From java-cme-mdp3-handler with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Loads and parse CME MDP Configuration.
 *
 * @param uri URI to CME MDP Configuration (config.xml, usually available on CME FTP)
 * @throws ConfigurationException if failed to parse configuration file
 * @throws MalformedURLException  if URI to Configuration is malformed
 */
private void load(final URI uri) throws ConfigurationException, MalformedURLException {
    // todo: if to implement the same via standard JAXB then dep to apache commons configuration will be not required
    final XMLConfiguration configuration = new XMLConfiguration();
    configuration.setDelimiterParsingDisabled(true);
    configuration.load(uri.toURL());
    for (final HierarchicalConfiguration channelCfg : configuration.configurationsAt("channel")) {
        final ChannelCfg channel = new ChannelCfg(channelCfg.getString("[@id]"), channelCfg.getString("[@label]"));

        for (final HierarchicalConfiguration connCfg : channelCfg.configurationsAt("connections.connection")) {
            final String id = connCfg.getString("[@id]");
            final FeedType type = FeedType.valueOf(connCfg.getString("type[@feed-type]"));
            final TransportProtocol protocol = TransportProtocol.valueOf(connCfg.getString("protocol").substring(0, 3));
            final Feed feed = Feed.valueOf(connCfg.getString("feed"));
            final String ip = connCfg.getString("ip");
            final int port = connCfg.getInt("port");
            final List<String> hostIPs = Arrays.asList(connCfg.getStringArray("host-ip"));

            final ConnectionCfg connection = new ConnectionCfg(feed, id, type, protocol, ip, hostIPs, port);
            channel.addConnection(connection);
            connCfgs.put(connection.getId(), connection);
        }
        channelCfgs.put(channel.getId(), channel);
    }
}
 
Example 2
Source File: SettingsLoader.java    From opensoc-streaming with Apache License 2.0 6 votes vote down vote up
public static Map<String, JSONObject> loadRegexAlerts(String config_path)
		throws ConfigurationException, ParseException {
	XMLConfiguration alert_rules = new XMLConfiguration();
	alert_rules.setDelimiterParsingDisabled(true);
	alert_rules.load(config_path);

	//int number_of_rules = alert_rules.getList("rule.pattern").size();

	String[] patterns = alert_rules.getStringArray("rule.pattern");
	String[] alerts = alert_rules.getStringArray("rule.alert");

	JSONParser pr = new JSONParser();
	Map<String, JSONObject> rules = new HashMap<String, JSONObject>();

	for (int i = 0; i < patterns.length; i++)
		rules.put(patterns[i], (JSONObject) pr.parse(alerts[i]));

	return rules;
}
 
Example 3
Source File: AbstractScriptRunner.java    From sailfish-core with Apache License 2.0 5 votes vote down vote up
protected GeneratedScript prepareScript(TestScriptDescription description) throws Exception {
    logger.info("Prepare script started [{}]", description.getMatrixFileName());

    GeneratedScript script = generateJavaSourcesFromMatrix(description);

    File binFolder = workspaceDispatcher.createFolder(FolderType.REPORT, description.getWorkFolder(), "bin");

    // parent class loader must be specified for new web-gui
    ILanguageFactory languageFactory = languageManager.getLanguageFactory(description.getLanguageURI());
    ClassLoader classLoader = languageFactory.createClassLoader(binFolder.toURI().toURL(), getClass().getClassLoader());

    // load Script Settings
    File scriptFile = workspaceDispatcher.getFile(FolderType.REPORT, description.getSettingsPath());
    XMLConfiguration scriptConfig = new XMLConfiguration();
    scriptConfig.setDelimiterParsingDisabled(true);
    scriptConfig.load(scriptFile);
    ScriptSettings scriptSettings = new ScriptSettings();
    scriptSettings.load(scriptConfig);
    scriptSettings.setScriptName(description.getMatrixFileName());

    // prepare script logger logger
    Logger scriptLogger = createScriptLogger(scriptSettings, description.getWorkFolder());

    description.setScriptConfiguration(AML.PACKAGE_NAME + "." + AML.CLASS_NAME, classLoader, scriptLogger, scriptSettings);
    description.setProgress(50);
    logger.info("Prepare script completed [{}]", description.getMatrixFileName());
    return script;
}
 
Example 4
Source File: XPathUtils.java    From qaf with MIT License 5 votes vote down vote up
/**
 * 
 * @param src
 * @return
 */
public static XMLConfiguration read(String src) {
	try {
		// remove all namespaces from xml
		src = removeNSAndPreamble(src);
		XMLConfiguration config = new XMLConfiguration();
		config.setDelimiterParsingDisabled(true);
		config.load(new ByteArrayInputStream(src.getBytes()));
		config.setExpressionEngine(new XPathExpressionEngine());
		return config;

	} catch (ConfigurationException e) {
		throw new RuntimeException(e);
	}
}
 
Example 5
Source File: ConfigurationEditor.java    From product-ei with Apache License 2.0 5 votes vote down vote up
public ConfigurationEditor(String originalConfigFilePath) throws ConfigurationException {
    this.originalConfigFilePath = originalConfigFilePath;

    configuration = new XMLConfiguration(this.originalConfigFilePath);

    // Support XPath queries.
    configuration.setExpressionEngine(new XPathExpressionEngine());

    configuration.setDelimiterParsingDisabled(true); // If we don't do this,
    // we can't add a new configuration to the compositeConfiguration by code.
}
 
Example 6
Source File: ApplicationArchive.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Loads the application descriptor from the specified application archive
 * stream and saves the stream in the appropriate application archive
 * directory.
 *
 * @param appName application name
 * @return application descriptor
 * @throws org.onosproject.app.ApplicationException if unable to read application description
 */
public ApplicationDescription getApplicationDescription(String appName) {
    try {
        XMLConfiguration cfg = new XMLConfiguration();
        cfg.setAttributeSplittingDisabled(true);
        cfg.setDelimiterParsingDisabled(true);
        cfg.load(appFile(appName, APP_XML));
        return loadAppDescription(cfg);
    } catch (Exception e) {
        throw new ApplicationException("Unable to get app description", e);
    }
}
 
Example 7
Source File: ApplicationArchive.java    From onos with Apache License 2.0 5 votes vote down vote up
private ApplicationDescription parsePlainAppDescription(InputStream stream)
        throws IOException {
    XMLConfiguration cfg = new XMLConfiguration();
    cfg.setAttributeSplittingDisabled(true);
    cfg.setDelimiterParsingDisabled(true);
    try {
        cfg.load(stream);
        return loadAppDescription(cfg);
    } catch (ConfigurationException e) {
        throw new IOException("Unable to parse " + APP_XML, e);
    }
}
 
Example 8
Source File: ApplicationArchive.java    From onos with Apache License 2.0 5 votes vote down vote up
private String getSelfContainedBundleCoordinates(ApplicationDescription desc) {
    try {
        XMLConfiguration cfg = new XMLConfiguration();
        cfg.setAttributeSplittingDisabled(true);
        cfg.setDelimiterParsingDisabled(true);
        cfg.load(appFile(desc.name(), FEATURES_XML));
        return cfg.getString("feature.bundle")
                .replaceFirst("wrap:", "")
                .replaceFirst("\\$Bundle-.*$", "");
    } catch (ConfigurationException e) {
        log.warn("Self-contained application {} has no features.xml", desc.name());
        return null;
    }
}