Search in sources :

Example 31 with FilterException

use of org.xwiki.filter.FilterException in project xwiki-platform by xwiki.

the class DefaultInstanceModel method getSpaceReferences.

@Override
public EntityReferenceTreeNode getSpaceReferences(WikiReference wikiReference) throws FilterException {
    // Get the spaces
    List<String> spaceReferenceStrings;
    try {
        spaceReferenceStrings = this.queryManager.getNamedQuery("getSpaces").setWiki(wikiReference.getName()).execute();
    } catch (QueryException e) {
        throw new FilterException(String.format("Failed to get the list of spaces in wiki [%s]", wikiReference), e);
    }
    // Get references
    List<SpaceReference> spaceReferences = new ArrayList<>(spaceReferenceStrings.size());
    for (String spaceReferenceString : spaceReferenceStrings) {
        spaceReferences.add(this.spaceResolver.resolve(spaceReferenceString, wikiReference));
    }
    // Create the tree
    EntityReferenceTree tree = new EntityReferenceTree(spaceReferences);
    return tree.getChildren().iterator().next();
}
Also used : QueryException(org.xwiki.query.QueryException) EntityReferenceTree(org.xwiki.model.reference.EntityReferenceTree) SpaceReference(org.xwiki.model.reference.SpaceReference) ArrayList(java.util.ArrayList) FilterException(org.xwiki.filter.FilterException)

Example 32 with FilterException

use of org.xwiki.filter.FilterException in project xwiki-platform by xwiki.

the class InstanceInputFilterStreamFactory method getFilterInterfaces.

@Override
public Collection<Class<?>> getFilterInterfaces() throws FilterException {
    List<InstanceInputEventGenerator> eventGenerators;
    try {
        eventGenerators = this.componentManagerProvider.get().getInstanceList(InstanceInputEventGenerator.class);
    } catch (ComponentLookupException e) {
        throw new FilterException("Failed to get registered instance of InstanceInputEventGenerator components", e);
    }
    Set<Class<?>> filters = new HashSet<Class<?>>();
    filters.addAll(super.getFilterInterfaces());
    for (InstanceInputEventGenerator generator : eventGenerators) {
        filters.addAll(generator.getFilterInterfaces());
    }
    return filters;
}
Also used : ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) FilterException(org.xwiki.filter.FilterException) InstanceInputEventGenerator(org.xwiki.filter.instance.input.InstanceInputEventGenerator) HashSet(java.util.HashSet)

Example 33 with FilterException

use of org.xwiki.filter.FilterException in project xwiki-platform by xwiki.

the class InstanceOutputFilterStream method setProperties.

@Override
public void setProperties(InstanceOutputProperties properties) throws FilterException {
    super.setProperties(properties);
    List<OutputInstanceFilterStreamFactory> factories;
    try {
        factories = this.componentManager.get().getInstanceList(OutputInstanceFilterStreamFactory.class);
    } catch (ComponentLookupException e) {
        throw new FilterException("Failed to get regsitered instance of OutputInstanceFilterStreamFactory components", e);
    }
    Object[] filters = new Object[factories.size()];
    int i = 0;
    for (OutputInstanceFilterStreamFactory factory : factories) {
        filters[i++] = factory.createOutputFilterStream(properties).getFilter();
    }
    this.filter = this.filterManager.createCompositeFilter(filters);
}
Also used : OutputInstanceFilterStreamFactory(org.xwiki.filter.instance.output.OutputInstanceFilterStreamFactory) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) FilterException(org.xwiki.filter.FilterException)

Example 34 with FilterException

use of org.xwiki.filter.FilterException in project xwiki-platform by xwiki.

the class InstanceOutputFilterStreamFactory method getFilterInterfaces.

@Override
public Collection<Class<?>> getFilterInterfaces() throws FilterException {
    List<OutputInstanceFilterStreamFactory> factories;
    try {
        factories = this.componentManagerProvider.get().getInstanceList(OutputInstanceFilterStreamFactory.class);
    } catch (ComponentLookupException e) {
        throw new FilterException("Failed to get regsitered instance of OutputInstanceFilterStreamFactory components", e);
    }
    Set<Class<?>> filters = new HashSet<Class<?>>();
    filters.addAll(super.getFilterInterfaces());
    for (OutputInstanceFilterStreamFactory factory : factories) {
        filters.addAll(factory.getFilterInterfaces());
    }
    return filters;
}
Also used : OutputInstanceFilterStreamFactory(org.xwiki.filter.instance.output.OutputInstanceFilterStreamFactory) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) FilterException(org.xwiki.filter.FilterException) HashSet(java.util.HashSet)

Example 35 with FilterException

use of org.xwiki.filter.FilterException 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

FilterException (org.xwiki.filter.FilterException)35 IOException (java.io.IOException)17 XWikiException (com.xpn.xwiki.XWikiException)10 XWikiContext (com.xpn.xwiki.XWikiContext)7 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)6 Date (java.util.Date)6 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)6 DocumentReference (org.xwiki.model.reference.DocumentReference)5 ArrayList (java.util.ArrayList)4 InputFilterStream (org.xwiki.filter.input.InputFilterStream)3 OutputFilterStream (org.xwiki.filter.output.OutputFilterStream)3 WikiReference (org.xwiki.model.reference.WikiReference)3 QueryException (org.xwiki.query.QueryException)3 XWikiAttachment (com.xpn.xwiki.doc.XWikiAttachment)2 BaseObject (com.xpn.xwiki.objects.BaseObject)2 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)2 InputStream (java.io.InputStream)2 URL (java.net.URL)2 HashSet (java.util.HashSet)2 ComponentManager (org.xwiki.component.manager.ComponentManager)2