Search in sources :

Example 1 with InstanceInputEventGenerator

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);
}
Also used : FilterEventParameters(org.xwiki.filter.FilterEventParameters) SpaceReference(org.xwiki.model.reference.SpaceReference) EntityReferenceTreeNode(org.xwiki.model.reference.EntityReferenceTreeNode) InstanceInputEventGenerator(org.xwiki.filter.instance.input.InstanceInputEventGenerator) DocumentReference(org.xwiki.model.reference.DocumentReference)

Example 2 with InstanceInputEventGenerator

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);
}
Also used : FilterEventParameters(org.xwiki.filter.FilterEventParameters) WikiReference(org.xwiki.model.reference.WikiReference) InstanceInputEventGenerator(org.xwiki.filter.instance.input.InstanceInputEventGenerator)

Example 3 with InstanceInputEventGenerator

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));
}
Also used : CompositeFilterStreamDescriptor(org.xwiki.filter.descriptor.CompositeFilterStreamDescriptor) CompositeFilterStreamDescriptor(org.xwiki.filter.descriptor.CompositeFilterStreamDescriptor) FilterStreamDescriptor(org.xwiki.filter.descriptor.FilterStreamDescriptor) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) InitializationException(org.xwiki.component.phase.InitializationException) InstanceInputEventGenerator(org.xwiki.filter.instance.input.InstanceInputEventGenerator)

Example 4 with InstanceInputEventGenerator

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);
}
Also used : FilterEventParameters(org.xwiki.filter.FilterEventParameters) InstanceInputEventGenerator(org.xwiki.filter.instance.input.InstanceInputEventGenerator)

Example 5 with InstanceInputEventGenerator

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);
}
Also used : FilterEventParameters(org.xwiki.filter.FilterEventParameters) EntityReferenceTreeNode(org.xwiki.model.reference.EntityReferenceTreeNode) InstanceInputEventGenerator(org.xwiki.filter.instance.input.InstanceInputEventGenerator)

Aggregations

InstanceInputEventGenerator (org.xwiki.filter.instance.input.InstanceInputEventGenerator)6 FilterEventParameters (org.xwiki.filter.FilterEventParameters)4 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)2 EntityReferenceTreeNode (org.xwiki.model.reference.EntityReferenceTreeNode)2 HashSet (java.util.HashSet)1 InitializationException (org.xwiki.component.phase.InitializationException)1 FilterException (org.xwiki.filter.FilterException)1 CompositeFilterStreamDescriptor (org.xwiki.filter.descriptor.CompositeFilterStreamDescriptor)1 FilterStreamDescriptor (org.xwiki.filter.descriptor.FilterStreamDescriptor)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 SpaceReference (org.xwiki.model.reference.SpaceReference)1 WikiReference (org.xwiki.model.reference.WikiReference)1