Search in sources :

Example 1 with FilterXMLInputProperties

use of org.xwiki.filter.filterxml.input.FilterXMLInputProperties in project xwiki-platform by xwiki.

the class AbstractInstanceFilterStreamTest method importFromXML.

protected void importFromXML(String resource, InstanceOutputProperties instanceProperties) throws FilterException {
    if (instanceProperties == null) {
        instanceProperties = new InstanceOutputProperties();
        instanceProperties.setVerbose(false);
    }
    OutputFilterStream outputFilterStream = this.outputFilterStreamFactory.createOutputFilterStream(instanceProperties);
    URL url = getClass().getResource("/filter/" + resource + ".xml");
    FilterXMLInputProperties properties = new FilterXMLInputProperties();
    properties.setSource(new DefaultURLInputSource(url));
    InputFilterStream inputFilterStream = this.xmlInputFilterStreamFactory.createInputFilterStream(properties);
    inputFilterStream.read(outputFilterStream.getFilter());
    try {
        inputFilterStream.close();
    } catch (IOException e) {
        throw new FilterException("Failed to close input wiki stream", e);
    }
    try {
        outputFilterStream.close();
    } catch (IOException e) {
        throw new FilterException("Failed to close output wiki stream", e);
    }
}
Also used : InstanceOutputProperties(org.xwiki.filter.instance.output.InstanceOutputProperties) OutputFilterStream(org.xwiki.filter.output.OutputFilterStream) DefaultURLInputSource(org.xwiki.filter.input.DefaultURLInputSource) FilterException(org.xwiki.filter.FilterException) FilterXMLInputProperties(org.xwiki.filter.filterxml.input.FilterXMLInputProperties) IOException(java.io.IOException) InputFilterStream(org.xwiki.filter.input.InputFilterStream) URL(java.net.URL)

Example 2 with FilterXMLInputProperties

use of org.xwiki.filter.filterxml.input.FilterXMLInputProperties in project xwiki-platform by xwiki.

the class ExtensionInstanceOutputFilterStreamTest method importFromXML.

protected void importFromXML(String resource, InstanceOutputProperties instanceProperties) throws FilterException {
    if (instanceProperties == null) {
        instanceProperties = new InstanceOutputProperties();
        instanceProperties.setVerbose(false);
    }
    OutputFilterStream outputFilterStream = this.outputFilterStreamFactory.createOutputFilterStream(instanceProperties);
    URL url = getClass().getResource("/" + resource + ".xml");
    FilterXMLInputProperties properties = new FilterXMLInputProperties();
    properties.setSource(new DefaultURLInputSource(url));
    InputFilterStream inputFilterStream = this.xmlInputFilterStreamFactory.createInputFilterStream(properties);
    inputFilterStream.read(outputFilterStream.getFilter());
    try {
        inputFilterStream.close();
    } catch (IOException e) {
        throw new FilterException("Failed to close input wiki stream", e);
    }
    try {
        outputFilterStream.close();
    } catch (IOException e) {
        throw new FilterException("Failed to close output wiki stream", e);
    }
}
Also used : ExtensionInstanceOutputProperties(org.xwiki.filter.instance.output.ExtensionInstanceOutputProperties) InstanceOutputProperties(org.xwiki.filter.instance.output.InstanceOutputProperties) OutputFilterStream(org.xwiki.filter.output.OutputFilterStream) DefaultURLInputSource(org.xwiki.filter.input.DefaultURLInputSource) FilterException(org.xwiki.filter.FilterException) FilterXMLInputProperties(org.xwiki.filter.filterxml.input.FilterXMLInputProperties) IOException(java.io.IOException) InputFilterStream(org.xwiki.filter.input.InputFilterStream) URL(java.net.URL)

Aggregations

IOException (java.io.IOException)2 URL (java.net.URL)2 FilterException (org.xwiki.filter.FilterException)2 FilterXMLInputProperties (org.xwiki.filter.filterxml.input.FilterXMLInputProperties)2 DefaultURLInputSource (org.xwiki.filter.input.DefaultURLInputSource)2 InputFilterStream (org.xwiki.filter.input.InputFilterStream)2 InstanceOutputProperties (org.xwiki.filter.instance.output.InstanceOutputProperties)2 OutputFilterStream (org.xwiki.filter.output.OutputFilterStream)2 ExtensionInstanceOutputProperties (org.xwiki.filter.instance.output.ExtensionInstanceOutputProperties)1