Search in sources :

Example 1 with AnnotationPrintRenderer

use of org.xwiki.annotation.renderer.AnnotationPrintRenderer in project xwiki-platform by xwiki.

the class DefaultAnnotationService method getAnnotatedRenderedContent.

@Override
public String getAnnotatedRenderedContent(String sourceReference, String sourceSyntax, String outputSyntax, Collection<Annotation> annotations) throws AnnotationServiceException {
    try {
        XDOM xdom = targetIoService.getXDOM(sourceReference, sourceSyntax);
        // build the annotations renderer hint for the specified output syntax
        String outputSyntaxId = "annotations-" + outputSyntax;
        AnnotationPrintRenderer annotationsRenderer = componentManager.getInstance(AnnotationPrintRenderer.class, outputSyntaxId);
        WikiPrinter printer = new DefaultWikiPrinter();
        annotationsRenderer.setPrinter(printer);
        // set the annotations for this renderer
        annotationsRenderer.setAnnotations(annotations);
        xdom.traverse(annotationsRenderer);
        return printer.toString();
    } catch (Exception exc) {
        throw new AnnotationServiceException(exc);
    }
}
Also used : XDOM(org.xwiki.rendering.block.XDOM) AnnotationPrintRenderer(org.xwiki.annotation.renderer.AnnotationPrintRenderer) DefaultWikiPrinter(org.xwiki.rendering.renderer.printer.DefaultWikiPrinter) AnnotationServiceException(org.xwiki.annotation.AnnotationServiceException) WikiPrinter(org.xwiki.rendering.renderer.printer.WikiPrinter) DefaultWikiPrinter(org.xwiki.rendering.renderer.printer.DefaultWikiPrinter) AnnotationServiceException(org.xwiki.annotation.AnnotationServiceException) IOServiceException(org.xwiki.annotation.io.IOServiceException)

Aggregations

AnnotationServiceException (org.xwiki.annotation.AnnotationServiceException)1 IOServiceException (org.xwiki.annotation.io.IOServiceException)1 AnnotationPrintRenderer (org.xwiki.annotation.renderer.AnnotationPrintRenderer)1 XDOM (org.xwiki.rendering.block.XDOM)1 DefaultWikiPrinter (org.xwiki.rendering.renderer.printer.DefaultWikiPrinter)1 WikiPrinter (org.xwiki.rendering.renderer.printer.WikiPrinter)1