1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.plugin.activitystream.api

File ActivityStream.java

 

Code metrics

0
0
0
1
531
74
0
-
-
0
-

Classes

Class Line # Actions
ActivityStream 35 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.plugin.activitystream.api;
21   
22    import java.util.List;
23   
24    import com.sun.syndication.feed.synd.SyndEntry;
25    import com.sun.syndication.feed.synd.SyndFeed;
26    import com.xpn.xwiki.XWikiContext;
27    import com.xpn.xwiki.XWikiException;
28    import com.xpn.xwiki.doc.XWikiDocument;
29   
30    /**
31    * Manages the activity stream.
32    *
33    * @version $Id: 8bbc42b7453bcc59c9e06923cbdd64b8f0dbc195 $
34    */
 
35    public interface ActivityStream
36    {
37    /**
38    * Init method, must be called on plugin init.
39    *
40    * @param context the XWiki context
41    * @throws XWikiException if the init of the activity stream failed
42    */
43    void init(XWikiContext context) throws XWikiException;
44   
45    /**
46    * Transforms space reference into stream name.
47    *
48    * @param space the space local serialized reference to transform
49    * @param context the XWiki context
50    * @return the name of the stream for the given space
51    */
52    String getStreamName(String space, XWikiContext context);
53   
54    /**
55    * Adding an activity event. The Id does not need to be filled as it will be created. Date and Wiki are optional.
56    *
57    * @param event event to add to the stream
58    * @param context the XWiki context
59    * @throws ActivityStreamException if the addition to the stream fails
60    */
61    void addActivityEvent(ActivityEvent event, XWikiContext context) throws ActivityStreamException;
62   
63    /**
64    * Adding an activity event. The Id does not need to be filled as it will be created. Date and Wiki are optional.
65    *
66    * @param streamName name of the stream to use for the addition
67    * @param type type of the event
68    * @param title title of the event
69    * @param context the XWiki context
70    * @throws ActivityStreamException if the addition to the stream fails
71    */
72    void addActivityEvent(String streamName, String type, String title, XWikiContext context)
73    throws ActivityStreamException;
74   
75    /**
76    * Adding an activity event. The Id does not need to be filled as it will be created. Date and Wiki are optional.
77    *
78    * @param streamName name of the stream to use for the addition
79    * @param type type of the event
80    * @param title title of the event
81    * @param params parameters of the event
82    * @param context the XWiki context
83    * @throws ActivityStreamException if the addition to the stream fails
84    */
85    void addActivityEvent(String streamName, String type, String title, List<String> params, XWikiContext context)
86    throws ActivityStreamException;
87   
88    /**
89    * Adding an activity event. The Id does not need to be filled as it will be created. Date and Wiki are optional.
90    *
91    * @param streamName name of the stream to use for the addition
92    * @param doc which fired the event
93    * @param type type of the event
94    * @param title title of the event
95    * @param context the XWiki context
96    * @throws ActivityStreamException if the addition to the stream fails
97    */
98    void addDocumentActivityEvent(String streamName, XWikiDocument doc, String type, String title, XWikiContext context)
99    throws ActivityStreamException;
100   
101    /**
102    * Adding an activity event. The Id does not need to be filled as it will be created. Date and Wiki are optional.
103    *
104    * @param streamName name of the stream to use for the addition
105    * @param doc which fired the event
106    * @param type type of the event
107    * @param priority priority of the event
108    * @param title title of the event
109    * @param context the XWiki context
110    * @throws ActivityStreamException if the addition to the stream fails
111    */
112    void addDocumentActivityEvent(String streamName, XWikiDocument doc, String type, int priority, String title,
113    XWikiContext context) throws ActivityStreamException;
114   
115    /**
116    * Adding an activity event. The Id does not need to be filled as it will be created. Date and Wiki are optional.
117    *
118    * @param streamName name of the stream to use for the addition
119    * @param doc which fired the event
120    * @param type type of the event
121    * @param title title of the event
122    * @param params parameters of the event
123    * @param context the XWiki context
124    * @throws ActivityStreamException if the addition to the stream fails
125    */
126    void addDocumentActivityEvent(String streamName, XWikiDocument doc, String type, String title, List<String> params,
127    XWikiContext context) throws ActivityStreamException;
128   
129    /**
130    * Adding an activity event. The Id does not need to be filled as it will be created. Date and Wiki are optional.
131    *
132    * @param streamName name of the stream to use for the addition
133    * @param doc which fired the event
134    * @param type type of the event
135    * @param priority priority of the event
136    * @param title title of the event
137    * @param params parameters of the event
138    * @param context the XWiki context
139    * @throws ActivityStreamException if the addition to the stream fails
140    */
141    void addDocumentActivityEvent(String streamName, XWikiDocument doc, String type, int priority, String title,
142    List<String> params, XWikiContext context) throws ActivityStreamException;
143   
144    /**
145    * Delete the given event from the database.
146    *
147    * @param event the event to delete
148    * @param context the XWiki context
149    * @throws ActivityStreamException if the delete of the event fails
150    */
151    void deleteActivityEvent(ActivityEvent event, XWikiContext context) throws ActivityStreamException;
152   
153    /**
154    * Search events.
155    *
156    * @param hql HQL where query statement
157    * @param filter true if the events should be filtered by priority
158    * @param nb number of events to retrieve
159    * @param start query offset
160    * @param context the XWiki context
161    * @return matching events
162    * @throws ActivityStreamException if the search query fails
163    */
164    List<ActivityEvent> searchEvents(String hql, boolean filter, int nb, int start, XWikiContext context)
165    throws ActivityStreamException;
166   
167    /**
168    * Search events.
169    *
170    * @param hql HQL where query statement
171    * @param filter true if the events should be filtered by priority
172    * @param globalSearch true if the request must be performed on the main database
173    * @param nb number of events to retrieve
174    * @param start query offset
175    * @param context the XWiki context
176    * @return matching events
177    * @throws ActivityStreamException if the search query fails
178    */
179    List<ActivityEvent> searchEvents(String hql, boolean filter, boolean globalSearch, int nb, int start,
180    XWikiContext context) throws ActivityStreamException;
181   
182    /**
183    * Search events.
184    *
185    * @param hql HQL where query statement
186    * @param filter true if the events should be filtered by priority
187    * @param globalSearch true if the request must be performed on the main database
188    * @param nb number of events to retrieve
189    * @param start query offset
190    * @param parameterValues values of the parametrized query
191    * @param context the XWiki context
192    * @return matching events
193    * @throws ActivityStreamException if the search query fails
194    */
195    List<ActivityEvent> searchEvents(String hql, boolean filter, boolean globalSearch, int nb, int start,
196    List<Object> parameterValues, XWikiContext context) throws ActivityStreamException;
197   
198    /**
199    * Search events.
200    *
201    * @param fromHql HQL from query statement
202    * @param hql HQL where query statement
203    * @param filter true if the events should be filtered by priority
204    * @param nb number of events to retrieve
205    * @param start query offset
206    * @param context the XWiki context
207    * @return matching events
208    * @throws ActivityStreamException if the search query fails
209    */
210    List<ActivityEvent> searchEvents(String fromHql, String hql, boolean filter, int nb, int start,
211    XWikiContext context) throws ActivityStreamException;
212   
213    /**
214    * Search events.
215    *
216    * @param fromHql HQL from query statement
217    * @param hql HQL where query statement
218    * @param filter true if the events should be filtered by priority
219    * @param globalSearch true if the request must be performed on the main database
220    * @param nb number of events to retrieve
221    * @param start query offset
222    * @param context the XWiki context
223    * @return matching events
224    * @throws ActivityStreamException if the search query fails
225    */
226    List<ActivityEvent> searchEvents(String fromHql, String hql, boolean filter, boolean globalSearch, int nb,
227    int start, XWikiContext context) throws ActivityStreamException;
228   
229    /**
230    * Search events.
231    *
232    * @param fromHql HQL from query statement
233    * @param hql HQL where query statement
234    * @param filter true if the events should be filtered by priority
235    * @param nb number of events to retrieve
236    * @param start query offset
237    * @param parameterValues values of the parametrized query
238    * @param context the XWiki context
239    * @return matching events
240    * @throws ActivityStreamException if the search query fails
241    */
242    List<ActivityEvent> searchEvents(String fromHql, String hql, boolean filter, int nb, int start,
243    List<Object> parameterValues, XWikiContext context) throws ActivityStreamException;
244   
245    /**
246    * Search events.
247    *
248    * @param fromHql HQL from query statement
249    * @param hql HQL where query statement
250    * @param filter true if the events should be filtered by priority
251    * @param globalSearch true if the request must be performed on the main database
252    * @param nb number of events to retrieve
253    * @param start query offset
254    * @param parameterValues values of the parametrized query
255    * @param context the XWiki context
256    * @return matching events
257    * @throws ActivityStreamException if the search query fails
258    */
259    List<ActivityEvent> searchEvents(String fromHql, String hql, boolean filter, boolean globalSearch, int nb,
260    int start, List<Object> parameterValues, XWikiContext context) throws ActivityStreamException;
261   
262    /**
263    * Get events from the activity stream.
264    *
265    * @param filter true if the events should be filtered by priority
266    * @param nb number of events to retrieve
267    * @param start query offset
268    * @param context the XWiki context
269    * @return a list of events
270    * @throws ActivityStreamException if the retrieval fails
271    */
272    List<ActivityEvent> getEvents(boolean filter, int nb, int start, XWikiContext context)
273    throws ActivityStreamException;
274   
275    /**
276    * Get events from the activity stream of a space.
277    *
278    * @param space local serialized reference of the space to retrieve the events from
279    * @param filter true if the events should be filtered by priority
280    * @param nb number of events to retrieve
281    * @param start query offset
282    * @param context the XWiki context
283    * @return a list of events
284    * @throws ActivityStreamException if the retrieval fails
285    */
286    List<ActivityEvent> getEventsForSpace(String space, boolean filter, int nb, int start, XWikiContext context)
287    throws ActivityStreamException;
288   
289    /**
290    * Get events from the activity stream of a user.
291    *
292    * @param user user to retrieve the events from
293    * @param filter true if the events should be filtered by priority
294    * @param nb number of events to retrieve
295    * @param start query offset
296    * @param context the XWiki context
297    * @return a list of events
298    * @throws ActivityStreamException if the retrieval fails
299    */
300    List<ActivityEvent> getEventsForUser(String user, boolean filter, int nb, int start, XWikiContext context)
301    throws ActivityStreamException;
302   
303    /**
304    * Get events from a particular activity stream.
305    *
306    * @param streamName name of the activity stream to retrieve the events from
307    * @param filter true if the events should be filtered by priority
308    * @param nb number of events to retrieve
309    * @param start query offset
310    * @param context the XWiki context
311    * @return a list of events
312    * @throws ActivityStreamException if the retrieval fails
313    */
314    List<ActivityEvent> getEvents(String streamName, boolean filter, int nb, int start, XWikiContext context)
315    throws ActivityStreamException;
316   
317    /**
318    * Get events from the given activity stream which happened in a particular space.
319    *
320    * @param streamName name of the activity stream to retrieve the events from
321    * @param space local serialized reference of the space to retrieve the events from
322    * @param filter true if the events should be filtered by priority
323    * @param nb number of events to retrieve
324    * @param start query offset
325    * @param context the XWiki context
326    * @return a list of events
327    * @throws ActivityStreamException if the retrieval fails
328    */
329    List<ActivityEvent> getEventsForSpace(String streamName, String space, boolean filter, int nb, int start,
330    XWikiContext context) throws ActivityStreamException;
331   
332    /**
333    * Get events from the given activity stream which have been fired by a particular user.
334    *
335    * @param streamName name of the activity stream to retrieve the events from
336    * @param user user to retrieve the events from
337    * @param filter true if the events should be filtered by priority
338    * @param nb number of events to retrieve
339    * @param start query offset
340    * @param context the XWiki context
341    * @return a list of events
342    * @throws ActivityStreamException if the retrieval fails
343    */
344    List<ActivityEvent> getEventsForUser(String streamName, String user, boolean filter, int nb, int start,
345    XWikiContext context) throws ActivityStreamException;
346   
347    /**
348    * Get the feed entry for the given event.
349    *
350    * @param event event to get the entry for
351    * @param context the XWiki context
352    * @return the feed entry corresponding to the event
353    */
354    SyndEntry getFeedEntry(ActivityEvent event, XWikiContext context);
355   
356    /**
357    * Get the feed entry for the given event.
358    *
359    * @param event event to get the entry for
360    * @param suffix suffix to add to entry title and body strings
361    * @param context the XWiki context
362    * @return the feed entry corresponding to the event
363    */
364    SyndEntry getFeedEntry(ActivityEvent event, String suffix, XWikiContext context);
365   
366    /**
367    * Get a feed from the given events.
368    *
369    * @param events events to create the feed from
370    * @param context the XWiki context
371    * @return the feed entry corresponding to the given events
372    */
373    SyndFeed getFeed(List<ActivityEvent> events, XWikiContext context);
374   
375    /**
376    * Get a feed from the given events.
377    *
378    * @param events events to create the feed from
379    * @param suffix suffix to add to entries title and body strings
380    * @param context the XWiki context
381    * @return the feed entry corresponding to the given events
382    */
383    SyndFeed getFeed(List<ActivityEvent> events, String suffix, XWikiContext context);
384   
385    /**
386    * Get a feed from the given events.
387    *
388    * @param events events to create the feed from
389    * @param author author to set in the feed metadata
390    * @param title title to set in the feed metadata
391    * @param description description to set in the feed metadata
392    * @param copyright copyright to set in the feed metadata
393    * @param encoding encoding to set in the feed metadata
394    * @param url URL to set in the feed metadata
395    * @param context the XWiki context
396    * @return the feed entry corresponding to the given events
397    */
398    SyndFeed getFeed(List<ActivityEvent> events, String author, String title, String description, String copyright,
399    String encoding, String url, XWikiContext context);
400   
401    /**
402    * Get a feed from the given events.
403    *
404    * @param events events to create the feed from
405    * @param author author to set in the feed metadata
406    * @param title title to set in the feed metadata
407    * @param description description to set in the feed metadata
408    * @param copyright copyright to set in the feed metadata
409    * @param encoding encoding to set in the feed metadata
410    * @param url URL to set in the feed metadata
411    * @param suffix suffix to add to entries title and body strings
412    * @param context the XWiki context
413    * @return the feed entry corresponding to the given events
414    */
415    SyndFeed getFeed(List<ActivityEvent> events, String author, String title, String description, String copyright,
416    String encoding, String url, String suffix, XWikiContext context);
417   
418    /**
419    * Get the string representation of a feed from the given events.
420    *
421    * @param events events to create the feed from
422    * @param author author to set in the feed metadata
423    * @param title title to set in the feed metadata
424    * @param description description to set in the feed metadata
425    * @param copyright copyright to set in the feed metadata
426    * @param encoding encoding to set in the feed metadata
427    * @param url URL to set in the feed metadata
428    * @param type the feed type (syntax) to use, <b>null</b> if none. It can be any version of RSS or Atom. Some
429    * possible values are "rss_1.0", "rss_2.0" and "atom_1.0"
430    * @param context the XWiki context
431    * @return the feed entry corresponding to the given events
432    */
433    String getFeedOutput(List<ActivityEvent> events, String author, String title, String description, String copyright,
434    String encoding, String url, String type, XWikiContext context);
435   
436    /**
437    * Get the string representation of a feed from the given events.
438    *
439    * @param events events to create the feed from
440    * @param author author to set in the feed metadata
441    * @param title title to set in the feed metadata
442    * @param description description to set in the feed metadata
443    * @param copyright copyright to set in the feed metadata
444    * @param encoding encoding to set in the feed metadata
445    * @param url URL to set in the feed metadata
446    * @param type the feed type (syntax) to use, <b>null</b> if none. It can be any version of RSS or Atom. Some
447    * possible values are "rss_1.0", "rss_2.0" and "atom_1.0"
448    * @param suffix suffix to add to entries title and body strings
449    * @param context the XWiki context
450    * @return the feed entry corresponding to the given events
451    */
452    String getFeedOutput(List<ActivityEvent> events, String author, String title, String description, String copyright,
453    String encoding, String url, String type, String suffix, XWikiContext context);
454   
455    /**
456    * @param feed the feed to get the string representation for
457    * @param type the feed type (syntax) to use, <b>null</b> if none. It can be any version of RSS or Atom. Some
458    * possible values are "rss_1.0", "rss_2.0" and "atom_1.0"
459    * @return the string representation of the given feed.
460    */
461    String getFeedOutput(SyndFeed feed, String type);
462   
463    /**
464    * Get events that have the same requestId as the event passed as parameter. The provided event is also included in
465    * the returned list.
466    *
467    * @param event the event for which to look for related events
468    * @param context the XWiki context
469    * @return a list of events
470    * @throws ActivityStreamException if the retrieval fails
471    */
472    List<ActivityEvent> getRelatedEvents(ActivityEvent event, XWikiContext context) throws ActivityStreamException;
473   
474    /**
475    * Get unique pages with events sorted by date. A document is returned at most once, regardless of the number of
476    * events.
477    *
478    * @param optionalWhereClause optional HQL where query statement
479    * @param maxItems maximum number of documents to retrieve
480    * @param startAt query offset
481    * @param context the XWiki context
482    * @return pairs of [document name, last event date], in descending order of the last event date
483    * @throws ActivityStreamException if the search fails
484    */
485    List<Object[]> searchUniquePages(String optionalWhereClause, int maxItems, int startAt, XWikiContext context)
486    throws ActivityStreamException;
487   
488    /**
489    * Get unique pages with events sorted by date. A document is returned at most once, regardless of the number of
490    * events.
491    *
492    * @param optionalWhereClause optional HQL where query statement
493    * @param parametersValues values for the query parameters
494    * @param maxItems maximum number of documents to retrieve
495    * @param startAt query offset
496    * @param context the XWiki context
497    * @return pairs of [document name, last event date], in descending order of the last event date
498    * @throws ActivityStreamException if the search fails
499    */
500    List<Object[]> searchUniquePages(String optionalWhereClause, List<Object> parametersValues, int maxItems,
501    int startAt, XWikiContext context) throws ActivityStreamException;
502   
503    /**
504    * Get unique pages with events sorted by date, grouped by days. A document is returned at most once per day, but
505    * might appear more than once if it has associated events in different days.
506    *
507    * @param optionalWhereClause optional HQL where query statement
508    * @param maxItems maximum number of documents to retrieve
509    * @param startAt query offset
510    * @param context the XWiki context
511    * @return pairs of [document name, event date], in descending order of the last event date
512    * @throws ActivityStreamException if the search fails
513    */
514    List<Object[]> searchDailyPages(String optionalWhereClause, int maxItems, int startAt, XWikiContext context)
515    throws ActivityStreamException;
516   
517    /**
518    * Get unique pages with events sorted by date, grouped by days. A document is returned at most once per day, but
519    * might appear more than once if it has associated events in different days.
520    *
521    * @param optionalWhereClause optional HQL where query statement
522    * @param parametersValues values for the query parameters
523    * @param maxItems maximum number of documents to retrieve
524    * @param startAt query offset
525    * @param context the XWiki context
526    * @return pairs of [document name, event date], in descending order of the last event date
527    * @throws ActivityStreamException if the search fails
528    */
529    List<Object[]> searchDailyPages(String optionalWhereClause, List<Object> parametersValues, int maxItems,
530    int startAt, XWikiContext context) throws ActivityStreamException;
531    }