use of org.xwiki.eventstream.RecordableEvent in project xwiki-platform by xwiki.
the class DefaultUntypedRecordableEventConverter method convert.
@Override
public Event convert(RecordableEvent recordableEvent, String source, Object data) throws Exception {
Event convertedEvent = super.convert(recordableEvent, source, data);
convertedEvent.setType(((UntypedRecordableEvent) recordableEvent).getEventType());
return convertedEvent;
}
use of org.xwiki.eventstream.RecordableEvent in project xwiki-platform by xwiki.
the class RecordableEventListener method onEvent.
@Override
public void onEvent(Event event, Object source, Object data) {
if (!(event instanceof RecordableEvent) || remoteObservationManagerContext.isRemoteState()) {
return;
}
// Don't handle events that are already saved by the Activity Stream implementation.
for (Event ignoredEvent : ActivityStreamImpl.LISTENER_EVENTS) {
if (ignoredEvent.matches(event)) {
return;
}
}
try {
if (!this.execution.getContext().hasProperty(AbstractEventStreamEvent.EVENT_LOOP_CONTEXT_LOCK_PROPERTY)) {
this.execution.getContext().setProperty(AbstractEventStreamEvent.EVENT_LOOP_CONTEXT_LOCK_PROPERTY, true);
// Save the event in the event stream
eventStream.addEvent(convertEvent(event, source, data));
this.execution.getContext().removeProperty(AbstractEventStreamEvent.EVENT_LOOP_CONTEXT_LOCK_PROPERTY);
}
} catch (Exception e) {
logger.warn("Failed to save the event [{}].", event.getClass().getCanonicalName(), e);
}
}
Aggregations