use of com.xpn.xwiki.plugin.activitystream.plugin.ActivityStreamPlugin in project xwiki-platform by xwiki.
the class ActivityStreamCleanerJob method executeJob.
@Override
protected void executeJob(JobExecutionContext jobContext) throws JobExecutionException {
ActivityStreamPlugin plugin = (ActivityStreamPlugin) getXWikiContext().getWiki().getPlugin(ActivityStreamPlugin.PLUGIN_NAME, getXWikiContext());
List<Object> parameters = new ArrayList<Object>();
int days = ActivityStreamCleaner.getNumberOfDaysToKeep(getXWikiContext());
if (days > 0) {
parameters.add(DateUtils.addDays(new Date(), days * -1));
try {
List<ActivityEvent> events = plugin.getActivityStream().searchEvents("date < ?", false, true, 0, 0, parameters, getXWikiContext());
for (ActivityEvent event : events) {
plugin.getActivityStream().deleteActivityEvent(event, getXWikiContext());
}
} catch (ActivityStreamException e) {
// TODO
}
}
}
use of com.xpn.xwiki.plugin.activitystream.plugin.ActivityStreamPlugin in project xwiki-platform by xwiki.
the class ActivityStreamConfiguration method useLocalStore.
/**
* This method determine if events must be store in the local wiki. If the activitystream is set not to store events
* in the main wiki, the method will return true. If events are stored in the main wiki, the method retrieves the
* 'platform.plugin.activitystream.uselocalstore' configuration option. If the option is not found the method
* returns true (default behavior).
*
* @return true if the activity stream is configured to store events in the main wiki, false otherwise
*/
public boolean useLocalStore() {
if (!useMainStore()) {
// If the main store is disabled, force local store.
return true;
}
XWikiContext context = contextProvider.get();
ActivityStreamPlugin plugin = (ActivityStreamPlugin) context.getWiki().getPlugin(ActivityStreamPlugin.PLUGIN_NAME, context);
return Integer.parseInt(plugin.getActivityStreamPreference("uselocalstore", "1", context)) == 1;
}
use of com.xpn.xwiki.plugin.activitystream.plugin.ActivityStreamPlugin in project xwiki-platform by xwiki.
the class ActivityStreamConfiguration method useMainStore.
/**
* This method determine if events must be store in the main wiki. If the current wiki is the main wiki, this method
* returns false, otherwise if retrieves the 'platform.plugin.activitystream.usemainstore' configuration option. If
* the option is not found the method returns true (default behavior).
*
* @return true if the activity stream is configured to store events in the main wiki, false otherwise
*/
public boolean useMainStore() {
XWikiContext context = contextProvider.get();
if (context.isMainWiki()) {
// We're in the main database, we don't have to store the data twice.
return false;
}
ActivityStreamPlugin plugin = (ActivityStreamPlugin) context.getWiki().getPlugin(ActivityStreamPlugin.PLUGIN_NAME, context);
return Integer.parseInt(plugin.getActivityStreamPreference("usemainstore", "1", context)) == 1;
}
Aggregations