use of com.xpn.xwiki.plugin.activitystream.api.ActivityStream in project xwiki-platform by xwiki.
the class DefaultWatchListEventMatcher method getEventsSince.
@Override
public List<WatchListEvent> getEventsSince(Date start) {
List<WatchListEvent> events = new ArrayList<>();
XWikiContext context = getXWikiContext();
ActivityStream actStream = ((ActivityStreamPlugin) context.getWiki().getPlugin(ActivityStreamPlugin.PLUGIN_NAME, context)).getActivityStream();
List<Object> parameters = new ArrayList<Object>();
parameters.add(start);
try {
// FIXME: Watch out for memory usage here, since the list of events could be huge in some cases.
List<ActivityEvent> rawEvents = actStream.searchEvents("act.date > ? and act.type in ('" + StringUtils.join(MATCHING_EVENT_TYPES, "','") + "')", false, true, 0, 0, parameters, context);
// WatchListEvent#equals(WatchListEvent).
for (ActivityEvent rawEvent : rawEvents) {
WatchListEvent event = this.eventConverter.convert(rawEvent);
int existingIndex = events.indexOf(event);
if (existingIndex == -1) {
// An event on a new document, add the new event.
events.add(event);
} else {
// An event on an existing document, add to the events of that document.
WatchListEvent existingCompositeEvent = events.get(existingIndex);
existingCompositeEvent.addEvent(event);
}
}
} catch (Exception e) {
logger.error("Failed to retrieve updated documents from activity stream since [{}]", start, e);
}
return events;
}
Aggregations