/** * Record in database the given {@link com.xpn.xwiki.plugin.activitystream.api.ActivityEvent} event. * * @param event the event to record in databases * @throws ActivityStreamException if the event addition fails */ public void addActivityEvent(com.xpn.xwiki.plugin.activitystream.api.ActivityEvent event) throws ActivityStreamException { if (hasProgrammingRights()) { getActivityStream().addActivityEvent(event, this.context); } }
/** * Delete the passed event form the database. * * @param event the event to delete from database * @throws ActivityStreamException if the event deletion fails */ public void deleteActivityEvent(ActivityEvent event) throws ActivityStreamException { if (hasProgrammingRights()) { getActivityStream().deleteActivityEvent(event.getEvent(), this.context); } }
/** * Get a feed from the given events. * * @param events events to create the feed from * @return the feed entry corresponding to the given events */ public SyndFeed getFeed(List<ActivityEvent> events) { return getActivityStream().getFeed(unwrapEvents(events), this.context); }
actStream.searchEvents( "act.date > ? and act.type in ('" + StringUtils.join(MATCHING_EVENT_TYPES, "','") + "')", false, true, 0, 0, parameters, context);
/** * {@inheritDoc} */ @Override protected void executeJob(JobExecutionContext jobContext) throws JobExecutionException { JobDataMap data = jobContext.getJobDetail().getJobDataMap(); // clone the context to make sure we have a new one per run XWikiContext context = (XWikiContext) ((XWikiContext) data.get("context")).clone(); // clean up the database connections context.getWiki().getStore().cleanUp(context); ActivityStreamPlugin plugin = (ActivityStreamPlugin) context.getWiki().getPlugin(ActivityStreamPlugin.PLUGIN_NAME, context); List<Object> parameters = new ArrayList<Object>(); int days = ActivityStreamCleaner.getNumberOfDaysToKeep(context); if (days > 0) { parameters.add(DateUtils.addDays(new Date(), days * -1)); try { List<ActivityEvent> events = plugin.getActivityStream().searchEvents("date < ?", false, true, 0, 0, parameters, context); for (ActivityEvent event : events) { plugin.getActivityStream().deleteActivityEvent(event, context); } } catch (ActivityStreamException e) { // TODO } } } }
/** * Records in database an event built upon the passed document and other parameters. The passed document is used to * retrieve document-related data for the event : date, page name, database. * * @param streamName the name of the stream to add the event to * @param doc the document from which to retrieve document data for the event * @param type the type of event. (see {@link #addActivityEvent(String, String, String)} * @param title the title of the event * @throws ActivityStreamException if the event addition fails */ public void addDocumentActivityEvent(String streamName, Document doc, String type, String title) throws ActivityStreamException { if (hasProgrammingRights()) { getActivityStream().addDocumentActivityEvent(streamName, doc.getDocument(), type, title, this.context); } }
/** * Get the string representation of a feed from the given feed. * * @param feed the feed to get the string representation from * @param type the feed type (syntax) to use, <b>null</b> if none. It can be any version of RSS or Atom. Some * possible values are "rss_1.0", "rss_2.0" and "atom_1.0" * @return the feed entry corresponding to the given events */ public String getFeedOutput(SyndFeed feed, String type) { return getActivityStream().getFeedOutput(feed, type); }
/** * Get the feed entry for the given event. * * @param event event to get the entry for * @param suffix suffix to add to entry title and body strings * @return the feed entry corresponding to the event */ public SyndEntry getFeedEntry(com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent event, String suffix) { return getActivityStream().getFeedEntry(event.getEvent(), suffix, this.context); }
/** * Return the latest recorded events for the given wiki space. * * @see #getEvents(boolean, int, int) * @param space the space to retrieve latest events for * @param filter if true, group the matched events by priority * @param nb the number of events to retrieve * @param start the offset to start retrieving event at * @return the latest recorded events * @throws ActivityStreamException if the search query fails */ public List<ActivityEvent> getEventsForSpace(String space, boolean filter, int nb, int start) throws ActivityStreamException { if (hasProgrammingRights()) { return wrapEvents(getActivityStream().getEventsForSpace(space, filter, nb, start, this.context)); } else { return null; } }
/** * Return the latest recorded events. * * @param filter if true, group the matched events by priority * @param nb the number of events to retrieve * @param start the offset to start retrieving event at * @return the latest recorded events * @throws ActivityStreamException if the search query fails */ public List<ActivityEvent> getEvents(boolean filter, int nb, int start) throws ActivityStreamException { if (hasProgrammingRights()) { return wrapEvents(getActivityStream().getEvents(filter, nb, start, this.context)); } else { return null; } }
/** * Return the latest events recorded for the given stream name and the given user. * * @param streamName the name of the stream to retrieve latest events for * @param user context user at the time the events were fired * @param filter if true, group the matched events by priority * @param nb the number of events to retrieve * @param start the offset to start retrieving event at * @return the latest events recorded for the given stream name * @throws ActivityStreamException if the search query fails */ public List<ActivityEvent> getEventsForUser(String streamName, String user, boolean filter, int nb, int start) throws ActivityStreamException { if (hasProgrammingRights()) { return wrapEvents(getActivityStream().getEventsForUser(streamName, user, filter, nb, start, this.context)); } else { return null; } }
/** * Search in database activity events matching the given hql query. Retrieved events are ordered by date descending. * * @param hql the "where" clause of the hql query to look events for * @param filter if true, group the matched events by priority * @param nb the number of events to retrieve * @param start the offset to start retrieving event at * @return a list of matching events, wrapped as {@link com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent} * objects. * @throws ActivityStreamException if the search query fails */ public List<ActivityEvent> searchEvents(String hql, boolean filter, int nb, int start) throws ActivityStreamException { if (hasProgrammingRights()) { return wrapEvents(getActivityStream().searchEvents(hql, filter, nb, start, this.context)); } else { return null; } }
/** * Records in database an event built upon the passed document and other parameters. The passed document is used to * retrieve document-related data for the event : date, page name, database. * * @param streamName name of the stream to use for the addition * @param doc which fired the event * @param type type of the event * @param priority priority of the event * @param title title of the event * @throws ActivityStreamException if the addition to the stream fails */ public void addDocumentActivityEvent(String streamName, Document doc, String type, int priority, String title) throws ActivityStreamException { if (hasProgrammingRights()) { getActivityStream().addDocumentActivityEvent(streamName, doc.getDocument(), type, priority, title, this.context); } }
/** * Get the string representation of a feed from the given events. * * @param events events to create the feed from * @param author author to set in the feed metadata * @param title title to set in the feed metadata * @param description description to set in the feed metadata * @param copyright copyright to set in the feed metadata * @param encoding encoding to set in the feed metadata * @param url URL to set in the feed metadata * @param type the feed type (syntax) to use, <b>null</b> if none. It can be any version of RSS or Atom. Some * possible values are "rss_1.0", "rss_2.0" and "atom_1.0" * @return the feed entry corresponding to the given events */ public String getFeedOutput(List<ActivityEvent> events, String author, String title, String description, String copyright, String encoding, String url, String type) { return getActivityStream().getFeedOutput(unwrapEvents(events), author, title, description, copyright, encoding, url, type, this.context); }
/** * Get the feed entry for the given event. * * @param event event to get the entry for * @return the feed entry corresponding to the event */ public SyndEntry getFeedEntry(com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent event) { return getActivityStream().getFeedEntry(event.getEvent(), this.context); }
/** * Return the latest events recorded for the given stream name in the given space. * * @param streamName the name of the stream to retrieve latest events for * @param space space in which the events have been fired * @param filter if true, group the matched events by priority * @param nb the number of events to retrieve * @param start the offset to start retrieving event at * @return the latest events recorded for the given stream name * @throws ActivityStreamException if the search query fails */ public List<ActivityEvent> getEventsForSpace(String streamName, String space, boolean filter, int nb, int start) throws ActivityStreamException { if (hasProgrammingRights()) { return wrapEvents(getActivityStream().getEventsForSpace(streamName, space, filter, nb, start, this.context)); } else { return null; } }
/** * Return the latest events recorded for the given stream name. * * @see #getEvents(boolean, int, int) * @param streamName the name of the stream to retrieve latest events for * @param filter if true, group the matched events by priority * @param nb the number of events to retrieve * @param start the offset to start retrieving event at * @return the latest events recorded for the given stream name * @throws ActivityStreamException if the search query fails */ public List<ActivityEvent> getEvents(String streamName, boolean filter, int nb, int start) throws ActivityStreamException { if (hasProgrammingRights()) { return wrapEvents(getActivityStream().getEvents(streamName, filter, nb, start, this.context)); } else { return null; } }
/** * Return the latest recorded events triggered by the given user. * * @see #getEvents(boolean, int, int) * @param user the user to retrieve latest events for * @param filter if true, group the matched events by priority * @param nb the number of events to retrieve * @param start the offset to start retrieving event at * @return the latest recorded events triggered by the given user. * @throws ActivityStreamException if the search query fails */ public List<ActivityEvent> getEventsForUser(String user, boolean filter, int nb, int start) throws ActivityStreamException { if (hasProgrammingRights()) { return wrapEvents(getActivityStream().getEventsForUser(user, filter, nb, start, this.context)); } else { return null; } }
/** * Search in database activity events matching the given hql query. Retrieved events are ordered by date descending. * * @param hql the "where" clause of the hql query to look events for * @param filter if true, group the matched events by priority * @param nb the number of events to retrieve * @param start the offset to start retrieving event at * @param parameterValues list of parameters to insert in the query * @return a list of matching events, wrapped as {@link com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent} * objects. * @throws ActivityStreamException if the search query fails */ public List<ActivityEvent> searchEvents(String hql, boolean filter, int nb, int start, List<Object> parameterValues) throws ActivityStreamException { if (hasProgrammingRights()) { return wrapEvents(getActivityStream().searchEvents("", hql, filter, nb, start, parameterValues, this.context)); } else { return null; } }
/** * Records in database the a event built upon the passed parameters. * * @param streamName the name of the stream to record the event for * @param type the type of event. The type can be a value picked from the list of values defined in * {@link com.xpn.xwiki.plugin.activitystream.api.ActivityEventType} or any other String * @param title the event title * @throws ActivityStreamException if the event addition fails */ public void addActivityEvent(String streamName, String type, String title) throws ActivityStreamException { if (hasProgrammingRights()) { getActivityStream().addActivityEvent(streamName, type, title, this.context); } }