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();
}
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;
}
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);
}
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;
}
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);
}
}
Aggregations