use of org.xwiki.eventstream.TargetableEvent in project xwiki-platform by xwiki.
the class DefaultRecordableEventConverter method convert.
@Override
public Event convert(RecordableEvent recordableEvent, String source, Object data) throws Exception {
XWikiContext context = contextProvider.get();
org.xwiki.eventstream.Event convertedEvent = new DefaultEvent();
convertedEvent.setType(recordableEvent.getClass().getCanonicalName());
convertedEvent.setApplication(source);
convertedEvent.setDate(new Date());
convertedEvent.setUser(context.getUserReference());
convertedEvent.setWiki(context.getWikiReference());
if (recordableEvent instanceof TargetableEvent) {
convertedEvent.setTarget(((TargetableEvent) recordableEvent).getTarget());
}
if (data instanceof String) {
convertedEvent.setBody((String) data);
} else if (data instanceof XWikiDocument) {
XWikiDocument document = (XWikiDocument) data;
convertedEvent.setDocument(document.getDocumentReference());
convertedEvent.setDocumentVersion(document.getVersion());
convertedEvent.setDocumentTitle(document.getRenderedTitle(context));
}
return convertedEvent;
}
Aggregations