use of com.xpn.xwiki.plugin.activitystream.plugin.ActivityStreamPlugin in project xwiki-platform by xwiki.
the class ActivityStreamCleaner method getNumberOfDaysToKeep.
/**
* @param context the XWiki context
* @return the number of days activitystream events should be kept (default: infinite duration).
*/
public static int getNumberOfDaysToKeep(XWikiContext context) {
ActivityStreamPlugin plugin = (ActivityStreamPlugin) context.getWiki().getPlugin(ActivityStreamPlugin.PLUGIN_NAME, context);
String pref = plugin.getActivityStreamPreference("daystokeepevents", "0", context);
return Integer.parseInt(pref);
}
use of com.xpn.xwiki.plugin.activitystream.plugin.ActivityStreamPlugin 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;
}
use of com.xpn.xwiki.plugin.activitystream.plugin.ActivityStreamPlugin in project xwiki-platform by xwiki.
the class BridgeEventStream method getRelatedEvents.
@Override
public EventGroup getRelatedEvents(Event e) {
XWikiContext context = getXWikiContext();
ActivityStreamPlugin plugin = getPlugin(context);
EventGroup result = new EventGroup();
try {
result.addEvents(convertActivitiesToEvents(plugin.getActivityStream().getRelatedEvents(eventConverter.convertEventToActivity(e), context)).toArray(new Event[0]));
} catch (ActivityStreamException ex) {
// Should not happen, and the eventual error was already reported downstream
}
return result;
}
use of com.xpn.xwiki.plugin.activitystream.plugin.ActivityStreamPlugin 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 com.xpn.xwiki.plugin.activitystream.plugin.ActivityStreamPlugin in project xwiki-platform by xwiki.
the class BridgeEventStream method deleteEvent.
@Override
public void deleteEvent(Event e) {
try {
XWikiContext context = getXWikiContext();
ActivityStreamPlugin plugin = getPlugin(context);
plugin.getActivityStream().deleteActivityEvent(eventConverter.convertEventToActivity(e), context);
this.observationManager.notify(new EventStreamDeletedEvent(), e);
} catch (ActivityStreamException ex) {
// Unlikely; nothing we can do
}
}
Aggregations