Search in sources :

Example 1 with Filters

use of org.jdom2.filter.Filters in project jspwiki by apache.

the class DefaultFilterManager method parseConfigFile.

/**
 *  Parses the XML filters configuration file.
 *
 * @param xmlStream stream to parse
 */
private void parseConfigFile(InputStream xmlStream) {
    List<Element> pageFilters = XmlUtil.parse(xmlStream, "/pagefilters/filter");
    for (Iterator<Element> i = pageFilters.iterator(); i.hasNext(); ) {
        Element f = i.next();
        String filterClass = f.getChildText("class");
        Properties props = new Properties();
        List<Element> params = f.getChildren("param");
        for (Iterator<Element> par = params.iterator(); par.hasNext(); ) {
            Element p = par.next();
            props.setProperty(p.getChildText("name"), p.getChildText("value"));
        }
        initPageFilter(filterClass, props);
    }
}
Also used : Element(org.jdom2.Element) Properties(java.util.Properties)

Example 2 with Filters

use of org.jdom2.filter.Filters in project stdlib by petergeneric.

the class CarbonSource method setFilterGUIDs.

/**
 * Set the filter GUID, replacing any filter that is currently defined
 *
 * @param filterGUIDs
 */
public void setFilterGUIDs(List<String> filterGUIDs) {
    int i = 0;
    for (String filterGUID : filterGUIDs) {
        // Remove filters (we're replacing them)
        removeFilter("Filter_" + i);
        // Build a new Filter_0 element
        Element filter = buildFilterElement("Filter_" + i, filterGUID);
        element.addContent(filter);
        i++;
    }
}
Also used : Element(org.jdom2.Element)

Example 3 with Filters

use of org.jdom2.filter.Filters in project stdlib by petergeneric.

the class CarbonDestination method getVideoFilters.

public List<CarbonModule> getVideoFilters() {
    List<CarbonModule> filters = new ArrayList<CarbonModule>();
    final Element filterContainer = getVideoFilterElement();
    if (filterContainer != null) {
        for (Element element : filterContainer.getChildren()) {
            filters.add(new CarbonModule(element));
        }
    }
    return filters;
}
Also used : Element(org.jdom2.Element) ArrayList(java.util.ArrayList)

Example 4 with Filters

use of org.jdom2.filter.Filters in project stdlib by petergeneric.

the class CarbonDestination method addVideoFilter.

// 
// Video filters
// 
public void addVideoFilter(CarbonModule module) {
    final Element filterContainer = getOrCreateVideoFilterElement();
    // We should use lastModule number + 1 as the number for the new module
    final int moduleNumber = filterContainer.getChildren().size();
    final Element moduleElement = module.getElement();
    moduleElement.detach();
    moduleElement.setName("Module_" + moduleNumber);
    filterContainer.addContent(moduleElement);
}
Also used : Element(org.jdom2.Element)

Example 5 with Filters

use of org.jdom2.filter.Filters in project jspwiki by apache.

the class DefaultFilterManager method registerFilters.

private void registerFilters() {
    log.info("Registering filters");
    List<Element> filters = XmlUtil.parse(PLUGIN_RESOURCE_LOCATION, "/modules/filter");
    // 
    for (Iterator<Element> i = filters.iterator(); i.hasNext(); ) {
        Element pluginEl = i.next();
        String className = pluginEl.getAttributeValue("class");
        PageFilterInfo filterInfo = PageFilterInfo.newInstance(className, pluginEl);
        if (filterInfo != null) {
            registerFilter(filterInfo);
        }
    }
}
Also used : Element(org.jdom2.Element)

Aggregations

Element (org.jdom2.Element)8 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Document (org.jdom2.Document)2 JDOMException (org.jdom2.JDOMException)2 SAXBuilder (org.jdom2.input.SAXBuilder)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 Collections (java.util.Collections)1 EnumSet (java.util.EnumSet)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Properties (java.util.Properties)1 JarFile (java.util.jar.JarFile)1 Collectors (java.util.stream.Collectors)1 DispatcherType (javax.servlet.DispatcherType)1 ServletContext (javax.servlet.ServletContext)1