Search in sources :

Example 6 with AnnotationServiceException

use of org.xwiki.annotation.AnnotationServiceException 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)6 XWikiException (com.xpn.xwiki.XWikiException)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 AnnotationResponse (org.xwiki.annotation.rest.model.jaxb.AnnotationResponse)4 DocumentReference (org.xwiki.model.reference.DocumentReference)4 Annotation (org.xwiki.annotation.Annotation)2 IOServiceException (org.xwiki.annotation.io.IOServiceException)2 AnnotationField (org.xwiki.annotation.rest.model.jaxb.AnnotationField)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Map (java.util.Map)1 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1 Request (org.restlet.Request)1 Form (org.restlet.data.Form)1 AnnotationPrintRenderer (org.xwiki.annotation.renderer.AnnotationPrintRenderer)1 AnnotationAddRequest (org.xwiki.annotation.rest.model.jaxb.AnnotationAddRequest)1 AnnotationFieldCollection (org.xwiki.annotation.rest.model.jaxb.AnnotationFieldCollection)1