org.xwiki.messagestream.internal
Class DefaultMessageStream

java.lang.Object
  extended by org.xwiki.messagestream.internal.DefaultMessageStream
All Implemented Interfaces:
MessageStream

@Component
@Singleton
public class DefaultMessageStream
extends Object
implements MessageStream

Implementation of the MessageStream that stores messages as events in the EventStream.

Since:
3.0M3

Constructor Summary
DefaultMessageStream()
           
 
Method Summary
protected  Event createMessageEvent(String message, String messageType)
          Creates an Event object with the common fields filled in: event ID, target document, application, user...
 void deleteMessage(String id)
          Delete an existing message, identified by its unique ID, if the current user is the author of that message.
 List<Event> getRecentDirectMessages()
          Get the 30 most recent direct messages sent to the current user.
 List<Event> getRecentDirectMessages(int limit, int offset)
          Get the most recent direct messages sent to the current user, at most limit, and skipping the first offset.
 List<Event> getRecentMessagesForGroup(DocumentReference group)
          Get the 30 most recent messages sent to the specified group.
 List<Event> getRecentMessagesForGroup(DocumentReference group, int limit, int offset)
          Get the most recent messages sent to the specified group, at most limit, and skipping the first offset.
 List<Event> getRecentPersonalMessages()
          Get the 30 most recent messages posted by the current user.
 List<Event> getRecentPersonalMessages(DocumentReference author)
          Get the 30 most recent personal messages posted by the specified user.
 List<Event> getRecentPersonalMessages(DocumentReference author, int limit, int offset)
          Get the most recent direct messages sent to the current user, at most limit, and skipping the first offset.
 List<Event> getRecentPersonalMessages(int limit, int offset)
          Get the most recent messages posted by the current user, at most limit, and skipping the first offset.
 void postDirectMessageToUser(String message, DocumentReference user)
          Post a private message to another user.
 void postMessageToGroup(String message, DocumentReference group)
          Post a message to a specific group of users.
 void postPersonalMessage(String message)
          Post a message to the current user's personal stream, displayed on his profile page and aggregated into their follower's streams.
 void postPublicMessage(String message)
          Post a message to the current user's stream, visible to everyone.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMessageStream

public DefaultMessageStream()
Method Detail

postPublicMessage

public void postPublicMessage(String message)
Description copied from interface: MessageStream
Post a message to the current user's stream, visible to everyone.

Specified by:
postPublicMessage in interface MessageStream
Parameters:
message - the message to store

postPersonalMessage

public void postPersonalMessage(String message)
Description copied from interface: MessageStream
Post a message to the current user's personal stream, displayed on his profile page and aggregated into their follower's streams.

Specified by:
postPersonalMessage in interface MessageStream
Parameters:
message - the message to store

postDirectMessageToUser

public void postDirectMessageToUser(String message,
                                    DocumentReference user)
Description copied from interface: MessageStream
Post a private message to another user.

Specified by:
postDirectMessageToUser in interface MessageStream
Parameters:
message - the message to send
user - the target user

postMessageToGroup

public void postMessageToGroup(String message,
                               DocumentReference group)
                        throws IllegalAccessError
Description copied from interface: MessageStream
Post a message to a specific group of users.

Specified by:
postMessageToGroup in interface MessageStream
Parameters:
message - the message to send
group - the target group
Throws:
IllegalAccessError

getRecentPersonalMessages

public List<Event> getRecentPersonalMessages()
Description copied from interface: MessageStream
Get the 30 most recent messages posted by the current user.

Specified by:
getRecentPersonalMessages in interface MessageStream
Returns:
a list of recent personal messages

getRecentPersonalMessages

public List<Event> getRecentPersonalMessages(int limit,
                                             int offset)
Description copied from interface: MessageStream
Get the most recent messages posted by the current user, at most limit, and skipping the first offset.

Specified by:
getRecentPersonalMessages in interface MessageStream
Parameters:
limit - the maximum number of messages to return
offset - how many messages to skip
Returns:
a list of recent personal messages, possibly empty

getRecentPersonalMessages

public List<Event> getRecentPersonalMessages(DocumentReference author)
Description copied from interface: MessageStream
Get the 30 most recent personal messages posted by the specified user.

Specified by:
getRecentPersonalMessages in interface MessageStream
Parameters:
author - the user that wrote the messages
Returns:
a list of recent personal messages, possibly empty

getRecentPersonalMessages

public List<Event> getRecentPersonalMessages(DocumentReference author,
                                             int limit,
                                             int offset)
Description copied from interface: MessageStream
Get the most recent direct messages sent to the current user, at most limit, and skipping the first offset.

Specified by:
getRecentPersonalMessages in interface MessageStream
Parameters:
author - the user that wrote the messages
limit - the maximum number of messages to return
offset - how many messages to skip
Returns:
a list of recent personal messages, possibly empty

getRecentDirectMessages

public List<Event> getRecentDirectMessages()
Description copied from interface: MessageStream
Get the 30 most recent direct messages sent to the current user.

Specified by:
getRecentDirectMessages in interface MessageStream
Returns:
a list of recent direct messages received

getRecentDirectMessages

public List<Event> getRecentDirectMessages(int limit,
                                           int offset)
Description copied from interface: MessageStream
Get the most recent direct messages sent to the current user, at most limit, and skipping the first offset.

Specified by:
getRecentDirectMessages in interface MessageStream
Parameters:
limit - the maximum number of messages to return
offset - how many messages to skip
Returns:
a list of recent direct messages received

getRecentMessagesForGroup

public List<Event> getRecentMessagesForGroup(DocumentReference group)
Description copied from interface: MessageStream
Get the 30 most recent messages sent to the specified group.

Specified by:
getRecentMessagesForGroup in interface MessageStream
Parameters:
group - the target group for which to retrieve messages
Returns:
a list of recent messages sent to the target group

getRecentMessagesForGroup

public List<Event> getRecentMessagesForGroup(DocumentReference group,
                                             int limit,
                                             int offset)
Description copied from interface: MessageStream
Get the most recent messages sent to the specified group, at most limit, and skipping the first offset.

Specified by:
getRecentMessagesForGroup in interface MessageStream
Parameters:
group - the target group for which to retrieve messages
limit - the maximum number of messages to return
offset - how many messages to skip
Returns:
a list of recent messages sent to the target group

deleteMessage

public void deleteMessage(String id)
Description copied from interface: MessageStream
Delete an existing message, identified by its unique ID, if the current user is the author of that message.

Specified by:
deleteMessage in interface MessageStream
Parameters:
id - the unique ID of the message

createMessageEvent

protected Event createMessageEvent(String message,
                                   String messageType)
Creates an Event object with the common fields filled in: event ID, target document, application, user... It also fills in the provided message body and type.

Parameters:
message - the message to store in the event; at most 2000 characters are stored, longer messages are automatically trimmed
messageType - the type of message
Returns:
the initialized event object