Search in sources :

Example 1 with MaintainerServiceException

use of org.xwiki.annotation.maintainer.MaintainerServiceException in project xwiki-platform by xwiki.

the class DocumentContentAnnotationUpdateListener method onEvent.

@Override
public void onEvent(Event event, Object source, Object data) {
    DocumentModelBridge currentDocument = (DocumentModelBridge) source;
    DocumentModelBridge previousDocument = currentDocument.getOriginalDocument();
    // maintainer, and the difference is in the content of the document
    if (!isUpdating && !previousDocument.getContent().equals(currentDocument.getContent())) {
        isUpdating = true;
        String content = currentDocument.getContent();
        String previousContent = previousDocument.getContent();
        // maintain the document annotations
        try {
            maintainer.updateAnnotations(this.serializer.serialize(currentDocument.getDocumentReference()), previousContent, content);
        } catch (MaintainerServiceException e) {
            this.logger.warn(e.getMessage(), e);
        // nothing else, just go further
        }
        isUpdating = false;
    }
}
Also used : DocumentModelBridge(org.xwiki.bridge.DocumentModelBridge) MaintainerServiceException(org.xwiki.annotation.maintainer.MaintainerServiceException)

Aggregations

MaintainerServiceException (org.xwiki.annotation.maintainer.MaintainerServiceException)1 DocumentModelBridge (org.xwiki.bridge.DocumentModelBridge)1