use of org.xwiki.filter.instance.input.InstanceInputEventGenerator in project xwiki-platform by xwiki.
the class InstanceInputFilterStream method writeSpace.
private void writeSpace(EntityReferenceTreeNode node, Object filter, InstanceFilter proxyFilter) throws FilterException {
SpaceReference spaceReference = (SpaceReference) node.getReference();
FilterEventParameters parameters = new FilterEventParameters();
// Get begin/end space parameters
for (InstanceInputEventGenerator generator : this.eventGenerators) {
generator.setWikiSpaceParameters(spaceReference.getName(), parameters);
}
// Begin space
proxyFilter.beginWikiSpace(spaceReference.getName(), parameters);
// Extend begin space
for (InstanceInputEventGenerator generator : this.eventGenerators) {
generator.beginWikiSpace(spaceReference.getName(), parameters);
}
// Write documents
for (DocumentReference documentReference : this.instanceModel.getDocumentReferences(spaceReference)) {
if (isDocumentEnabled(documentReference)) {
writeDocument(documentReference, filter, proxyFilter);
} else {
if (this.properties.isVerbose()) {
this.logger.info(LOG_DOCUMENT_SKIPPED, "Skipped document [{}]", documentReference);
}
}
}
// Write nested spaces
for (EntityReferenceTreeNode child : node.getChildren()) {
writeSpace(child, filter, proxyFilter);
}
// Extend end space
for (InstanceInputEventGenerator generator : this.eventGenerators) {
generator.endWikiSpace(spaceReference.getName(), parameters);
}
// End space
proxyFilter.endWikiSpace(spaceReference.getName(), parameters);
}
use of org.xwiki.filter.instance.input.InstanceInputEventGenerator in project xwiki-platform by xwiki.
the class InstanceInputFilterStream method read.
@Override
protected void read(Object filter, InstanceFilter proxyFilter) throws FilterException {
FilterEventParameters parameters = new FilterEventParameters();
for (InstanceInputEventGenerator generator : this.eventGenerators) {
generator.setWikiFarmParameters(parameters);
}
proxyFilter.beginWikiFarm(parameters);
for (InstanceInputEventGenerator generator : this.eventGenerators) {
generator.setFilter(filter);
generator.beginWikiFarm(parameters);
}
for (WikiReference wikiReference : this.instanceModel.getWikiReferences()) {
if (isWikiEnabled(wikiReference)) {
writeWiki(wikiReference, filter, proxyFilter);
}
}
for (InstanceInputEventGenerator generator : this.eventGenerators) {
generator.endWikiFarm(parameters);
}
proxyFilter.endWikiFarm(parameters);
}
use of org.xwiki.filter.instance.input.InstanceInputEventGenerator in project xwiki-platform by xwiki.
the class InstanceInputFilterStreamFactory method initialize.
@Override
public void initialize() throws InitializationException {
super.initialize();
List<InstanceInputEventGenerator> eventGenerators;
try {
eventGenerators = this.componentManagerProvider.get().getInstanceList(InstanceInputEventGenerator.class);
} catch (ComponentLookupException e) {
throw new InitializationException("Failed to get registered instance of InstanceInputEventGenerator components", e);
}
FilterStreamDescriptor[] descriptors = new FilterStreamDescriptor[eventGenerators.size() + 1];
descriptors[0] = this.descriptor;
for (int i = 0; i < eventGenerators.size(); ++i) {
descriptors[i + 1] = eventGenerators.get(i).getDescriptor();
}
setDescriptor(new CompositeFilterStreamDescriptor(this.descriptor.getName(), this.descriptor.getDescription(), descriptors));
}
use of org.xwiki.filter.instance.input.InstanceInputEventGenerator in project xwiki-platform by xwiki.
the class InstanceInputFilterStream method writeDocument.
private void writeDocument(DocumentReference documentReference, Object filter, InstanceFilter proxyFilter) throws FilterException {
FilterEventParameters parameters = new FilterEventParameters();
for (InstanceInputEventGenerator generator : this.eventGenerators) {
generator.setWikiDocumentParameters(documentReference.getName(), parameters);
}
proxyFilter.beginWikiDocument(documentReference.getName(), parameters);
for (InstanceInputEventGenerator generator : this.eventGenerators) {
generator.beginWikiDocument(documentReference.getName(), parameters);
}
for (InstanceInputEventGenerator generator : this.eventGenerators) {
generator.endWikiDocument(documentReference.getName(), parameters);
}
proxyFilter.endWikiDocument(documentReference.getName(), parameters);
}
use of org.xwiki.filter.instance.input.InstanceInputEventGenerator in project xwiki-platform by xwiki.
the class InstanceInputFilterStream method writeWiki.
private void writeWiki(WikiReference wikiReference, Object filter, InstanceFilter proxyFilter) throws FilterException {
FilterEventParameters parameters = new FilterEventParameters();
for (InstanceInputEventGenerator generator : this.eventGenerators) {
generator.setWikiParameters(wikiReference.getName(), parameters);
}
proxyFilter.beginWiki(wikiReference.getName(), parameters);
for (InstanceInputEventGenerator generator : this.eventGenerators) {
generator.beginWiki(wikiReference.getName(), parameters);
}
// TODO: improve with a new space related API to get space level by space level instead of all of them at the
// same time
EntityReferenceTreeNode spaces = this.instanceModel.getSpaceReferences(wikiReference);
for (EntityReferenceTreeNode node : spaces.getChildren()) {
if (isSpaceEnabled((SpaceReference) node.getReference())) {
writeSpace(node, filter, proxyFilter);
}
}
for (InstanceInputEventGenerator generator : this.eventGenerators) {
generator.endWiki(wikiReference.getName(), parameters);
}
proxyFilter.endWiki(wikiReference.getName(), parameters);
}
Aggregations