Event Stream Module

The Event Stream Module provides an API for manipulating activity events. An activity event is a recorded event of an action triggered in the wiki: page creation, modification or deletion, added or deleted objects and attachments etc. This API was created in order to replace the old Activity Stream Plugin.

The source code is available on GitHub.

Description

As shown in the Event interface, events are identified by: 

  • an unique identifier
  • a unique group identifier which is used for all the events triggered by the same action
  • the date and time when the event occurred
  • the importance allowing to order events in the same group or in the same stream which can be:
    • BACKGROUND - means the event is of very low importance in the current group. This is usually a side effect of another event
    • MINOR - means the event is of little importance, not relevant for most users.
    • MEDIUM - is the default event priority.
    • MAJOR - means that the event is important and it stands out in the event stream.
    • CRITICAL - means that the event signals a major change or problem in the wiki.

Every event contains a title, a body and a map of parameters.

Starting with XWiki Enterprise 3.5 the map of parameters was removed because of performance issues.

Events are categorized depending on:

  • the application that created them (The Blog Application, the User Status feature or the general wiki)
  • an eventual sub-stream inside the application, like a space for wiki events, or a certain group for user statuses
  • the particular type of event, like adding a comment, updating an attachment, setting a new user status

Events target:

  • the wiki, space and document affected by the event
  • an eventual entity inside the document, like an individual attachment for attachment events or an individual object for comment events

Events can store more information about the context in which they occur:

  • the user that caused the event
  • the version of the target document at the time the event occurred
  • the display title of the target document at the time the event occurred
  • the requested URL that caused the event

 

Examples

Add an Event to the Event Stream

import org.xwiki.eventstream.Event;
import org.xwiki.eventstream.EventFactory;
import org.xwiki.eventstream.EventStream;

@Inject
private EventFactory eventFactory;

@Inject
private EventStream eventStream;

Event event = this.eventFactory.createEvent();
event.setDocument(someDocument.getDocumentReference());

event.setApplication("myapp");
event.setType("myapptype");

Map<String, String> params = new HashMap<String, String>();
params.put("event alert", "entry created");

event.setParameters(params);
this.eventStream.addEvent(event);

Retrieve Events From the Stream

Query query = this.queryManager.createQuery("where event.application='myapp'", Query.HQL);
query.setLimit(15);

List<Event> myAppEvents = this.eventStream.searchEvents(query)

for(Event event : myAppEvents ) {
// Handle events
}

  

Related Pages

Search this space

 

Most popular tags

Failed to execute the [groovy] macro
  1. access rights
  2. activity stream
  3. annotation
  4. attachment
  5. comment
  6. Document Tree Macro
  7. export
  8. Extension Manager
  9. Flamingo skin
  10. global user
  11. Groovy event listener
  12. group
  13. nested page
  14. search
  15. skin
  16. syntax
  17. user
  18. user profile
  19. velocity macros
  20. wiki
  21. wysiwyg
  22. XWiki Applications
  23. xwikiattachment_archive table
  24. xwikiattachment table
  25. xwikiattrecyclebin table
  26. xwikiproperties table

[Display all tags from this space]