use of org.xwiki.eventstream.events.EventStreamAddedEvent in project xwiki-platform by xwiki.
the class ActivityStreamImpl method addActivityEvent.
/**
* @param event event to add to the stream
* @param doc which fired the event
* @param context the XWiki context
* @throws ActivityStreamException if the addition to the stream fails
*/
public void addActivityEvent(ActivityEvent event, XWikiDocument doc, XWikiContext context) throws ActivityStreamException {
prepareEvent(event, doc, context);
if (useLocalStore()) {
// store event in the local database
XWikiHibernateStore localHibernateStore = context.getWiki().getHibernateStore();
try {
localHibernateStore.beginTransaction(context);
Session session = localHibernateStore.getSession(context);
session.save(event);
localHibernateStore.endTransaction(context, true);
} catch (XWikiException e) {
localHibernateStore.endTransaction(context, false);
}
}
if (useMainStore()) {
// store event in the main database
String oriDatabase = context.getWikiId();
context.setWikiId(context.getMainXWiki());
XWikiHibernateStore mainHibernateStore = context.getWiki().getHibernateStore();
try {
mainHibernateStore.beginTransaction(context);
Session session = mainHibernateStore.getSession(context);
session.save(event);
mainHibernateStore.endTransaction(context, true);
} catch (XWikiException e) {
mainHibernateStore.endTransaction(context, false);
} finally {
context.setWikiId(oriDatabase);
}
}
this.sendEventStreamEvent(new EventStreamAddedEvent(), event);
}
use of org.xwiki.eventstream.events.EventStreamAddedEvent in project xwiki-platform by xwiki.
the class BridgeEventStream method addEvent.
@Override
public void addEvent(Event e) {
try {
XWikiContext context = getXWikiContext();
ActivityStreamPlugin plugin = getPlugin(context);
plugin.getActivityStream().addActivityEvent(eventConverter.convertEventToActivity(e), context);
this.observationManager.notify(new EventStreamAddedEvent(), e);
} catch (ActivityStreamException ex) {
// Unlikely; nothing we can do
}
}
use of org.xwiki.eventstream.events.EventStreamAddedEvent in project xwiki-platform by xwiki.
the class LiveNotificationEmailListenerTest method testOnEvent.
@Test
public void testOnEvent() throws Exception {
Event eventStreamEvent = mock(Event.class);
EventStreamAddedEvent event = mock(EventStreamAddedEvent.class);
RecordableEventDescriptor eventDescriptor = mock(RecordableEventDescriptor.class);
when(eventDescriptor.getEventType()).thenReturn("eventType");
when(this.recordableEventDescriptorManager.getRecordableEventDescriptors(true)).thenReturn(Arrays.asList(eventDescriptor));
when(eventStreamEvent.getType()).thenReturn("eventType");
when(this.notificationConfiguration.areEmailsEnabled()).thenReturn(true);
when(this.notificationConfiguration.isEnabled()).thenReturn(true);
this.mocker.getComponentUnderTest().onEvent(event, eventStreamEvent, null);
verify(this.liveNotificationEmailManager, times(1)).addEvent(eventStreamEvent);
}
Aggregations