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

File ActivityStreamPluginApi.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart1.png
82% of files have more coverage

Code metrics

50
103
42
1
814
337
71
0.69
2.45
42
1.69

Classes

Class Line # Actions
ActivityStreamPluginApi 43 103 0% 71 174
0.1076923110.8%
 

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.plugin;
21   
22    import java.util.ArrayList;
23    import java.util.Collections;
24    import java.util.List;
25   
26    import org.slf4j.Logger;
27    import org.slf4j.LoggerFactory;
28   
29    import com.sun.syndication.feed.synd.SyndEntry;
30    import com.sun.syndication.feed.synd.SyndFeed;
31    import com.xpn.xwiki.XWikiContext;
32    import com.xpn.xwiki.api.Document;
33    import com.xpn.xwiki.plugin.PluginApi;
34    import com.xpn.xwiki.plugin.XWikiPluginInterface;
35    import com.xpn.xwiki.plugin.activitystream.api.ActivityStream;
36    import com.xpn.xwiki.plugin.activitystream.api.ActivityStreamException;
37   
38    /**
39    * API for {@link ActivityStreamPlugin}.
40    *
41    * @version $Id: 0c89a357d8c09a37796e81c32c9e8de6398b7230 $
42    */
 
43    public class ActivityStreamPluginApi extends PluginApi<ActivityStreamPlugin>
44    {
45    /** Logging helper object. */
46    private static final Logger LOG = LoggerFactory.getLogger(ActivityStreamPlugin.class);
47   
48    /**
49    * Constructor.
50    *
51    * @see PluginApi#PluginApi(XWikiPluginInterface, XWikiContext)
52    * @param plugin plugin to wrap
53    * @param context the XWiki context
54    */
 
55  110 toggle public ActivityStreamPluginApi(ActivityStreamPlugin plugin, XWikiContext context)
56    {
57  110 super(plugin, context);
58    }
59   
60    /**
61    * @return The {@link ActivityStream} component to use inside the API
62    */
 
63  110 toggle protected ActivityStream getActivityStream()
64    {
65  110 return getProtectedPlugin().getActivityStream();
66    }
67   
68    /**
69    * Record in database the given {@link com.xpn.xwiki.plugin.activitystream.api.ActivityEvent} event.
70    *
71    * @param event the event to record in databases
72    * @throws ActivityStreamException if the event addition fails
73    */
 
74  0 toggle public void addActivityEvent(com.xpn.xwiki.plugin.activitystream.api.ActivityEvent event)
75    throws ActivityStreamException
76    {
77  0 if (hasProgrammingRights()) {
78  0 getActivityStream().addActivityEvent(event, this.context);
79    }
80    }
81   
82    /**
83    * Records in database the a event built upon the passed parameters.
84    *
85    * @param streamName the name of the stream to record the event for
86    * @param type the type of event. The type can be a value picked from the list of values defined in
87    * {@link com.xpn.xwiki.plugin.activitystream.api.ActivityEventType} or any other String
88    * @param title the event title
89    * @throws ActivityStreamException if the event addition fails
90    */
 
91  0 toggle public void addActivityEvent(String streamName, String type, String title) throws ActivityStreamException
92    {
93  0 if (hasProgrammingRights()) {
94  0 getActivityStream().addActivityEvent(streamName, type, title, this.context);
95    }
96    }
97   
98    /**
99    * Records in database an event built upon the passed document and other parameters. The passed document is used to
100    * retrieve document-related data for the event : date, page name, database.
101    *
102    * @param streamName name of the stream to use for the addition
103    * @param type type of the event
104    * @param title title of the event
105    * @param params parameters of the event
106    * @throws ActivityStreamException if the addition to the stream fails
107    */
 
108  0 toggle public void addActivityEvent(String streamName, String type, String title, List<String> params)
109    throws ActivityStreamException
110    {
111  0 if (hasProgrammingRights()) {
112  0 getActivityStream().addActivityEvent(streamName, type, title, params, this.context);
113    }
114    }
115   
116    /**
117    * Records in database an event built upon the passed document and other parameters. The passed document is used to
118    * retrieve document-related data for the event : date, page name, database.
119    *
120    * @param streamName the name of the stream to add the event to
121    * @param doc the document from which to retrieve document data for the event
122    * @param type the type of event. (see {@link #addActivityEvent(String, String, String)}
123    * @param title the title of the event
124    * @throws ActivityStreamException if the event addition fails
125    */
 
126  0 toggle public void addDocumentActivityEvent(String streamName, Document doc, String type, String title)
127    throws ActivityStreamException
128    {
129  0 if (hasProgrammingRights()) {
130  0 getActivityStream().addDocumentActivityEvent(streamName, doc.getDocument(), type, title, this.context);
131    }
132    }
133   
134    /**
135    * Records in database an event built upon the passed document and other parameters. The passed document is used to
136    * retrieve document-related data for the event : date, page name, database.
137    *
138    * @param streamName name of the stream to use for the addition
139    * @param doc which fired the event
140    * @param type type of the event
141    * @param priority priority of the event
142    * @param title title of the event
143    * @throws ActivityStreamException if the addition to the stream fails
144    */
 
145  0 toggle public void addDocumentActivityEvent(String streamName, Document doc, String type, int priority, String title)
146    throws ActivityStreamException
147    {
148  0 if (hasProgrammingRights()) {
149  0 getActivityStream().addDocumentActivityEvent(streamName, doc.getDocument(), type, priority, title,
150    this.context);
151    }
152    }
153   
154    /**
155    * Delete the passed events from the database.
156    *
157    * @param evs the events to be deleted
158    * @throws ActivityStreamException if the event deletion fails
159    */
 
160  0 toggle public void deleteActivityEvents(List<ActivityEvent> evs) throws ActivityStreamException
161    {
162  0 if (hasProgrammingRights()) {
163  0 List<com.xpn.xwiki.plugin.activitystream.api.ActivityEvent> events = unwrapEvents(evs);
164  0 for (com.xpn.xwiki.plugin.activitystream.api.ActivityEvent ev : events) {
165  0 getActivityStream().deleteActivityEvent(ev, this.context);
166    }
167    }
168    }
169   
170    /**
171    * Delete the passed event form the database.
172    *
173    * @param event the event to delete from database
174    * @throws ActivityStreamException if the event deletion fails
175    */
 
176  0 toggle public void deleteActivityEvent(ActivityEvent event) throws ActivityStreamException
177    {
178  0 if (hasProgrammingRights()) {
179  0 getActivityStream().deleteActivityEvent(event.getEvent(), this.context);
180    }
181    }
182   
183    /**
184    * Records in database an event built upon the passed document and other parameters. The passed document is used to
185    * retrieve document-related data for the event : date, page name, database.
186    *
187    * @param streamName name of the stream to use for the addition
188    * @param doc which fired the event
189    * @param type type of the event
190    * @param title title of the event
191    * @param params parameters of the event
192    * @throws ActivityStreamException if the addition to the stream fails
193    */
 
194  0 toggle public void addDocumentActivityEvent(String streamName, Document doc, String type, String title,
195    List<String> params) throws ActivityStreamException
196    {
197  0 if (hasProgrammingRights()) {
198  0 getActivityStream().addDocumentActivityEvent(streamName, doc.getDocument(), type, title, params,
199    this.context);
200    }
201    }
202   
203    /**
204    * Records in database an event built upon the passed document and other parameters. The passed document is used to
205    * retrieve document-related data for the event : date, page name, database.
206    *
207    * @param streamName name of the stream to use for the addition
208    * @param doc which fired the event
209    * @param type type of the event
210    * @param priority priority of the event
211    * @param title title of the event
212    * @param params parameters of the event
213    * @throws ActivityStreamException if the addition to the stream fails
214    */
 
215  0 toggle public void addDocumentActivityEvent(String streamName, Document doc, String type, int priority, String title,
216    List<String> params) throws ActivityStreamException
217    {
218  0 if (hasProgrammingRights()) {
219  0 getActivityStream().addDocumentActivityEvent(streamName, doc.getDocument(), type, priority, title, params,
220    this.context);
221    }
222    }
223   
224    /**
225    * Search in database activity events matching the given hql query. Retrieved events are ordered by date descending.
226    *
227    * @param hql the "where" clause of the hql query to look events for
228    * @param filter if true, group the matched events by priority
229    * @param nb the number of events to retrieve
230    * @param start the offset to start retrieving event at
231    * @return a list of matching events, wrapped as {@link com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent}
232    * objects.
233    * @throws ActivityStreamException if the search query fails
234    */
 
235  0 toggle public List<ActivityEvent> searchEvents(String hql, boolean filter, int nb, int start)
236    throws ActivityStreamException
237    {
238  0 if (hasProgrammingRights()) {
239  0 return wrapEvents(getActivityStream().searchEvents(hql, filter, nb, start, this.context));
240    } else {
241  0 return null;
242    }
243    }
244   
245    /**
246    * Search in database activity events matching the given hql query. Retrieved events are ordered by date descending.
247    *
248    * @param hql the "where" clause of the hql query to look events for
249    * @param filter if true, group the matched events by priority
250    * @param globalSearch true if the request must be performed on the main database
251    * @param nb the number of events to retrieve
252    * @param start the offset to start retrieving event at
253    * @return a list of matching events, wrapped as {@link com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent}
254    * objects.
255    * @throws ActivityStreamException if the search query fails
256    */
 
257  0 toggle public List<ActivityEvent> searchEvents(String hql, boolean filter, boolean globalSearch, int nb, int start)
258    throws ActivityStreamException
259    {
260  0 if (hasProgrammingRights()) {
261  0 return wrapEvents(getActivityStream().searchEvents(hql, filter, globalSearch, nb, start, this.context));
262    } else {
263  0 return null;
264    }
265    }
266   
267    /**
268    * Search in database activity events matching the given hql query. Retrieved events are ordered by date descending.
269    *
270    * @param hql the "where" clause of the hql query to look events for
271    * @param filter if true, group the matched events by priority
272    * @param nb the number of events to retrieve
273    * @param start the offset to start retrieving event at
274    * @param parameterValues list of parameters to insert in the query
275    * @return a list of matching events, wrapped as {@link com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent}
276    * objects.
277    * @throws ActivityStreamException if the search query fails
278    */
 
279  24 toggle public List<ActivityEvent> searchEvents(String hql, boolean filter, int nb, int start, List<Object> parameterValues)
280    throws ActivityStreamException
281    {
282  24 if (hasProgrammingRights()) {
283  24 return wrapEvents(getActivityStream().searchEvents("", hql, filter, nb, start, parameterValues,
284    this.context));
285    } else {
286  0 return null;
287    }
288    }
289   
290    /**
291    * Search in database activity events matching the given hql query. Retrieved events are ordered by date descending.
292    *
293    * @param hql the "where" clause of the hql query to look events for
294    * @param filter if true, group the matched events by priority
295    * @param globalSearch true if the request must be performed on the main database
296    * @param nb the number of events to retrieve
297    * @param start the offset to start retrieving event at
298    * @param parameterValues list of parameters to insert in the query
299    * @return a list of matching events, wrapped as {@link com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent}
300    * objects.
301    * @throws ActivityStreamException if the search query fails
302    */
 
303  0 toggle public List<ActivityEvent> searchEvents(String hql, boolean filter, boolean globalSearch, int nb, int start,
304    List<Object> parameterValues) throws ActivityStreamException
305    {
306  0 if (hasProgrammingRights()) {
307  0 return wrapEvents(getActivityStream().searchEvents("", hql, filter, globalSearch, nb, start,
308    parameterValues, this.context));
309    } else {
310  0 return null;
311    }
312    }
313   
314    /**
315    * Search in database activity events matching the given hql query. Retrieved events are ordered by date descending.
316    *
317    * @param fromHql the "from" clause of the hql query to look events for
318    * @param hql the "where" clause of the hql query to look events for
319    * @param filter if true, group the matched events by priority
320    * @param nb the number of events to retrieve
321    * @param start the offset to start retrieving event at
322    * @return a list of matching events, wrapped as {@link com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent}
323    * objects.
324    * @throws ActivityStreamException if the search query fails
325    */
 
326  0 toggle public List<ActivityEvent> searchEvents(String fromHql, String hql, boolean filter, int nb, int start)
327    throws ActivityStreamException
328    {
329  0 if (hasProgrammingRights()) {
330  0 return wrapEvents(getActivityStream().searchEvents(fromHql, hql, filter, nb, start, this.context));
331    } else {
332  0 return null;
333    }
334    }
335   
336    /**
337    * Search in database activity events matching the given hql query. Retrieved events are ordered by date descending.
338    *
339    * @param fromHql the "from" clause of the hql query to look events for
340    * @param hql the "where" clause of the hql query to look events for
341    * @param filter if true, group the matched events by priority
342    * @param globalSearch true if the request must be performed on the main database
343    * @param nb the number of events to retrieve
344    * @param start the offset to start retrieving event at
345    * @return a list of matching events, wrapped as {@link com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent}
346    * objects.
347    * @throws ActivityStreamException if the search query fails
348    */
 
349  0 toggle public List<ActivityEvent> searchEvents(String fromHql, String hql, boolean filter, boolean globalSearch, int nb,
350    int start) throws ActivityStreamException
351    {
352  0 if (hasProgrammingRights()) {
353  0 return wrapEvents(getActivityStream().searchEvents(fromHql, hql, filter, globalSearch, nb, start,
354    this.context));
355    } else {
356  0 return null;
357    }
358    }
359   
360    /**
361    * Search in database activity events matching the given hql query. Retrieved events are ordered by date descending.
362    *
363    * @param fromHql the "from" clause of the hql query to look events for
364    * @param hql the "where" clause of the hql query to look events for
365    * @param filter if true, group the matched events by priority
366    * @param nb the number of events to retrieve
367    * @param start the offset to start retrieving event at
368    * @param parameterValues list of parameters to insert in the query
369    * @return a list of matching events, wrapped as {@link com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent}
370    * objects.
371    * @throws ActivityStreamException if the search query fails
372    */
 
373  0 toggle public List<ActivityEvent> searchEvents(String fromHql, String hql, boolean filter, int nb, int start,
374    List<Object> parameterValues) throws ActivityStreamException
375    {
376  0 if (hasProgrammingRights()) {
377  0 return wrapEvents(getActivityStream().searchEvents(fromHql, hql, filter, nb, start, this.context));
378    } else {
379  0 return null;
380    }
381    }
382   
383    /**
384    * Search in database activity events matching the given hql query. Retrieved events are ordered by date descending.
385    *
386    * @param fromHql the "from" clause of the hql query to look events for
387    * @param hql the "where" clause of the hql query to look events for
388    * @param filter if true, group the matched events by priority
389    * @param globalSearch true if the request must be performed on the main database
390    * @param nb the number of events to retrieve
391    * @param start the offset to start retrieving event at
392    * @param parameterValues list of parameters to insert in the query
393    * @return a list of matching events, wrapped as {@link com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent}
394    * objects.
395    * @throws ActivityStreamException if the search query fails
396    */
 
397  0 toggle public List<ActivityEvent> searchEvents(String fromHql, String hql, boolean filter, boolean globalSearch, int nb,
398    int start, List<Object> parameterValues) throws ActivityStreamException
399    {
400  0 if (hasProgrammingRights()) {
401  0 return wrapEvents(getActivityStream().searchEvents(fromHql, hql, filter, globalSearch, nb, start,
402    this.context));
403    } else {
404  0 return null;
405    }
406    }
407   
408    /**
409    * Return the latest recorded events.
410    *
411    * @param filter if true, group the matched events by priority
412    * @param nb the number of events to retrieve
413    * @param start the offset to start retrieving event at
414    * @return the latest recorded events
415    * @throws ActivityStreamException if the search query fails
416    */
 
417  0 toggle public List<ActivityEvent> getEvents(boolean filter, int nb, int start) throws ActivityStreamException
418    {
419  0 if (hasProgrammingRights()) {
420  0 return wrapEvents(getActivityStream().getEvents(filter, nb, start, this.context));
421    } else {
422  0 return null;
423    }
424    }
425   
426    /**
427    * Return the latest recorded events for the given wiki space.
428    *
429    * @see #getEvents(boolean, int, int)
430    * @param space the local serialized reference of the space to retrieve latest events for
431    * @param filter if true, group the matched events by priority
432    * @param nb the number of events to retrieve
433    * @param start the offset to start retrieving event at
434    * @return the latest recorded events
435    * @throws ActivityStreamException if the search query fails
436    */
 
437  0 toggle public List<ActivityEvent> getEventsForSpace(String space, boolean filter, int nb, int start)
438    throws ActivityStreamException
439    {
440  0 if (hasProgrammingRights()) {
441  0 return wrapEvents(getActivityStream().getEventsForSpace(space, filter, nb, start, this.context));
442    } else {
443  0 return null;
444    }
445    }
446   
447    /**
448    * Return the latest recorded events triggered by the given user.
449    *
450    * @see #getEvents(boolean, int, int)
451    * @param user the user to retrieve latest events for
452    * @param filter if true, group the matched events by priority
453    * @param nb the number of events to retrieve
454    * @param start the offset to start retrieving event at
455    * @return the latest recorded events triggered by the given user.
456    * @throws ActivityStreamException if the search query fails
457    */
 
458  0 toggle public List<ActivityEvent> getEventsForUser(String user, boolean filter, int nb, int start)
459    throws ActivityStreamException
460    {
461  0 if (hasProgrammingRights()) {
462  0 return wrapEvents(getActivityStream().getEventsForUser(user, filter, nb, start, this.context));
463    } else {
464  0 return null;
465    }
466    }
467   
468    /**
469    * Return the latest events recorded for the given stream name.
470    *
471    * @see #getEvents(boolean, int, int)
472    * @param streamName the name of the stream to retrieve latest events for
473    * @param filter if true, group the matched events by priority
474    * @param nb the number of events to retrieve
475    * @param start the offset to start retrieving event at
476    * @return the latest events recorded for the given stream name
477    * @throws ActivityStreamException if the search query fails
478    */
 
479  0 toggle public List<ActivityEvent> getEvents(String streamName, boolean filter, int nb, int start)
480    throws ActivityStreamException
481    {
482  0 if (hasProgrammingRights()) {
483  0 return wrapEvents(getActivityStream().getEvents(streamName, filter, nb, start, this.context));
484    } else {
485  0 return null;
486    }
487    }
488   
489    /**
490    * Return the latest events recorded for the given stream name in the given space.
491    *
492    * @param streamName the name of the stream to retrieve latest events for
493    * @param space local serialized reference of the space in which the events have been fired
494    * @param filter if true, group the matched events by priority
495    * @param nb the number of events to retrieve
496    * @param start the offset to start retrieving event at
497    * @return the latest events recorded for the given stream name
498    * @throws ActivityStreamException if the search query fails
499    */
 
500  0 toggle public List<ActivityEvent> getEventsForSpace(String streamName, String space, boolean filter, int nb, int start)
501    throws ActivityStreamException
502    {
503  0 if (hasProgrammingRights()) {
504  0 return wrapEvents(getActivityStream().getEventsForSpace(streamName, space, filter, nb, start, this.context));
505    } else {
506  0 return null;
507    }
508    }
509   
510    /**
511    * Return the latest events recorded for the given stream name and the given user.
512    *
513    * @param streamName the name of the stream to retrieve latest events for
514    * @param user context user at the time the events were fired
515    * @param filter if true, group the matched events by priority
516    * @param nb the number of events to retrieve
517    * @param start the offset to start retrieving event at
518    * @return the latest events recorded for the given stream name
519    * @throws ActivityStreamException if the search query fails
520    */
 
521  0 toggle public List<ActivityEvent> getEventsForUser(String streamName, String user, boolean filter, int nb, int start)
522    throws ActivityStreamException
523    {
524  0 if (hasProgrammingRights()) {
525  0 return wrapEvents(getActivityStream().getEventsForUser(streamName, user, filter, nb, start, this.context));
526    } else {
527  0 return null;
528    }
529    }
530   
531    /**
532    * Wrap a list of events.
533    *
534    * @param events events to wrap
535    * @return list of wrapped events
536    */
 
537  96 toggle protected List<ActivityEvent> wrapEvents(List<com.xpn.xwiki.plugin.activitystream.api.ActivityEvent> events)
538    {
539  96 List<ActivityEvent> result = new ArrayList<ActivityEvent>();
540  96 if (events != null) {
541  96 for (com.xpn.xwiki.plugin.activitystream.api.ActivityEvent event : events) {
542  126 com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent wrappedEvent =
543    new com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent(event, getXWikiContext());
544  126 result.add(wrappedEvent);
545    }
546    }
547  96 return result;
548    }
549   
550    /**
551    * Unwrap a list of events.
552    *
553    * @param events events to unwrap
554    * @return list of unwrapped events
555    */
 
556  0 toggle protected List<com.xpn.xwiki.plugin.activitystream.api.ActivityEvent> unwrapEvents(List<ActivityEvent> events)
557    {
558  0 List<com.xpn.xwiki.plugin.activitystream.api.ActivityEvent> result =
559    new ArrayList<com.xpn.xwiki.plugin.activitystream.api.ActivityEvent>();
560  0 if (events != null) {
561  0 for (ActivityEvent event : events) {
562  0 com.xpn.xwiki.plugin.activitystream.api.ActivityEvent unwrappedEvent = event.getEvent();
563  0 result.add(unwrappedEvent);
564    }
565    }
566  0 return result;
567    }
568   
569    /**
570    * Get the feed entry for the given event.
571    *
572    * @param event event to get the entry for
573    * @return the feed entry corresponding to the event
574    */
 
575  0 toggle public SyndEntry getFeedEntry(com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent event)
576    {
577  0 return getActivityStream().getFeedEntry(event.getEvent(), this.context);
578    }
579   
580    /**
581    * Get the feed entry for the given event.
582    *
583    * @param event event to get the entry for
584    * @param suffix suffix to add to entry title and body strings
585    * @return the feed entry corresponding to the event
586    */
 
587  0 toggle public SyndEntry getFeedEntry(com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent event, String suffix)
588    {
589  0 return getActivityStream().getFeedEntry(event.getEvent(), suffix, this.context);
590    }
591   
592    /**
593    * Get a feed from the given events.
594    *
595    * @param events events to create the feed from
596    * @return the feed entry corresponding to the given events
597    */
 
598  0 toggle public SyndFeed getFeed(List<ActivityEvent> events)
599    {
600  0 return getActivityStream().getFeed(unwrapEvents(events), this.context);
601    }
602   
603    /**
604    * Get a feed from the given events.
605    *
606    * @param events events to create the feed from
607    * @param suffix suffix to add to entries title and body strings
608    * @return the feed entry corresponding to the given events
609    */
 
610  0 toggle public SyndFeed getFeed(List<ActivityEvent> events, String suffix)
611    {
612  0 return getActivityStream().getFeed(unwrapEvents(events), suffix, this.context);
613    }
614   
615    /**
616    * Get a feed from the given events.
617    *
618    * @param events events to create the feed from
619    * @param author author to set in the feed metadata
620    * @param title title to set in the feed metadata
621    * @param description description to set in the feed metadata
622    * @param copyright copyright to set in the feed metadata
623    * @param encoding encoding to set in the feed metadata
624    * @param url URL to set in the feed metadata
625    * @return the feed entry corresponding to the given events
626    */
 
627  0 toggle public SyndFeed getFeed(List<ActivityEvent> events, String author, String title, String description,
628    String copyright, String encoding, String url)
629    {
630  0 return getActivityStream().getFeed(unwrapEvents(events), author, title, description, copyright, encoding, url,
631    this.context);
632    }
633   
634    /**
635    * Get a feed from the given events.
636    *
637    * @param events events to create the feed from
638    * @param author author to set in the feed metadata
639    * @param title title to set in the feed metadata
640    * @param description description to set in the feed metadata
641    * @param copyright copyright to set in the feed metadata
642    * @param encoding encoding to set in the feed metadata
643    * @param url URL to set in the feed metadata
644    * @param suffix suffix to add to entries title and body strings
645    * @return the feed entry corresponding to the given events
646    */
 
647  0 toggle public SyndFeed getFeed(List<ActivityEvent> events, String author, String title, String description,
648    String copyright, String encoding, String url, String suffix)
649    {
650  0 return getActivityStream().getFeed(unwrapEvents(events), author, title, description, copyright, encoding, url,
651    suffix, this.context);
652    }
653   
654    /**
655    * Get the string representation of a feed from the given events.
656    *
657    * @param events events to create the feed from
658    * @param author author to set in the feed metadata
659    * @param title title to set in the feed metadata
660    * @param description description to set in the feed metadata
661    * @param copyright copyright to set in the feed metadata
662    * @param encoding encoding to set in the feed metadata
663    * @param url URL to set in the feed metadata
664    * @param type the feed type (syntax) to use, <b>null</b> if none. It can be any version of RSS or Atom. Some
665    * possible values are "rss_1.0", "rss_2.0" and "atom_1.0"
666    * @return the feed entry corresponding to the given events
667    */
 
668  0 toggle public String getFeedOutput(List<ActivityEvent> events, String author, String title, String description,
669    String copyright, String encoding, String url, String type)
670    {
671  0 return getActivityStream().getFeedOutput(unwrapEvents(events), author, title, description, copyright, encoding,
672    url, type, this.context);
673    }
674   
675    /**
676    * Get the string representation of a feed from the given events.
677    *
678    * @param events events to create the feed from
679    * @param author author to set in the feed metadata
680    * @param title title to set in the feed metadata
681    * @param description description to set in the feed metadata
682    * @param copyright copyright to set in the feed metadata
683    * @param encoding encoding to set in the feed metadata
684    * @param url URL to set in the feed metadata
685    * @param type the feed type (syntax) to use, <b>null</b> if none. It can be any version of RSS or Atom. Some
686    * possible values are "rss_1.0", "rss_2.0" and "atom_1.0"
687    * @param suffix suffix to add to entries title and body strings
688    * @return the feed entry corresponding to the given events
689    */
 
690  0 toggle public String getFeedOutput(List<ActivityEvent> events, String author, String title, String description,
691    String copyright, String encoding, String url, String type, String suffix)
692    {
693  0 return getActivityStream().getFeedOutput(unwrapEvents(events), author, title, description, copyright, encoding,
694    url, type, suffix, this.context);
695    }
696   
697    /**
698    * Get the string representation of a feed from the given feed.
699    *
700    * @param feed the feed to get the string representation from
701    * @param type the feed type (syntax) to use, <b>null</b> if none. It can be any version of RSS or Atom. Some
702    * possible values are "rss_1.0", "rss_2.0" and "atom_1.0"
703    * @return the feed entry corresponding to the given events
704    */
 
705  0 toggle public String getFeedOutput(SyndFeed feed, String type)
706    {
707  0 return getActivityStream().getFeedOutput(feed, type);
708    }
709   
710    /**
711    * @param space the space local serialized reference to transform
712    * @return the name of the event stream associated with the given space
713    */
 
714  0 toggle public String getStreamName(String space)
715    {
716  0 return getActivityStream().getStreamName(space, this.context);
717    }
718   
719    /**
720    * Get events that have the same requestId as the event passed as parameter. The provided event is also included in
721    * the returned list.
722    *
723    * @param event the event for which to look for related events
724    * @return a list of events
725    * @throws ActivityStreamException if the retrieval fails
726    * @see ActivityStream#getRelatedEvents(com.xpn.xwiki.plugin.activitystream.api.ActivityEvent, XWikiContext)
727    */
 
728  72 toggle public List<ActivityEvent> getRelatedEvents(ActivityEvent event) throws ActivityStreamException
729    {
730  72 return wrapEvents(getActivityStream().getRelatedEvents(event.getEvent(), this.context));
731    }
732   
733    /**
734    * Get unique pages with events sorted by date. A document is returned at most once, regardless of the number of
735    * events.
736    *
737    * @param optionalWhereClause HQL where query statement
738    * @param maxItems number of events to retrieve
739    * @param startAt query offset
740    * @return matching pages with events
741    */
 
742  0 toggle public List<Object[]> searchUniquePages(String optionalWhereClause, int maxItems, int startAt)
743    {
744  0 try {
745  0 return getActivityStream().searchUniquePages(optionalWhereClause, maxItems, startAt, this.context);
746    } catch (ActivityStreamException ex) {
747  0 LOG.error("Failed to query events: " + ex.getMessage(), ex);
748  0 return Collections.emptyList();
749    }
750    }
751   
752    /**
753    * Get unique pages with events sorted by date. A document is returned at most once, regardless of the number of
754    * events.
755    *
756    * @param optionalWhereClause HQL where query statement
757    * @param parametersValues values for the query parameters
758    * @param maxItems number of events to retrieve
759    * @param startAt query offset
760    * @return matching pages with events
761    */
 
762  0 toggle public List<Object[]> searchUniquePages(String optionalWhereClause, List<Object> parametersValues, int maxItems,
763    int startAt)
764    {
765  0 try {
766  0 return getActivityStream().searchUniquePages(optionalWhereClause, parametersValues, maxItems, startAt,
767    this.context);
768    } catch (ActivityStreamException ex) {
769  0 LOG.error("Failed to query events: " + ex.getMessage(), ex);
770  0 return Collections.emptyList();
771    }
772    }
773   
774    /**
775    * Get unique pages with events sorted by date, grouped by days. A document is returned at most once per day, but
776    * might appear more than once if it has associated events in different days.
777    *
778    * @param optionalWhereClause HQL where query statement
779    * @param maxItems number of events to retrieve
780    * @param startAt query offset
781    * @return matching pages with events
782    */
 
783  0 toggle public List<Object[]> searchDailyPages(String optionalWhereClause, int maxItems, int startAt)
784    {
785  0 try {
786  0 return getActivityStream().searchDailyPages(optionalWhereClause, maxItems, startAt, this.context);
787    } catch (ActivityStreamException ex) {
788  0 LOG.error("Failed to query events: " + ex.getMessage(), ex);
789  0 return Collections.emptyList();
790    }
791    }
792   
793    /**
794    * Get unique pages with events sorted by date, grouped by days. A document is returned at most once per day, but
795    * might appear more than once if it has associated events in different days.
796    *
797    * @param optionalWhereClause HQL where query statement
798    * @param parametersValues values for the query parameters
799    * @param maxItems number of events to retrieve
800    * @param startAt query offset
801    * @return matching pages with events
802    */
 
803  14 toggle public List<Object[]> searchDailyPages(String optionalWhereClause, List<Object> parametersValues, int maxItems,
804    int startAt)
805    {
806  14 try {
807  14 return getActivityStream().searchDailyPages(optionalWhereClause, parametersValues, maxItems, startAt,
808    this.context);
809    } catch (ActivityStreamException ex) {
810  0 LOG.error("Failed to query events: " + ex.getMessage(), ex);
811  0 return Collections.emptyList();
812    }
813    }
814    }