Package org.xwiki.messagestream.script
Class MessageStreamScriptService
- java.lang.Object
-
- org.xwiki.messagestream.script.MessageStreamScriptService
-
- All Implemented Interfaces:
org.xwiki.script.service.ScriptService
@Component @Named("messageStream") @Singleton public class MessageStreamScriptService extends Object implements org.xwiki.script.service.ScriptService
Service exposing theMessageStream
functionality, allowing to post messages from the current user.- Version:
- $Id: 54536fb82c5b50951189471dfb98c6be10ca6369 $
-
-
Field Summary
Fields Modifier and Type Field Description protected org.xwiki.context.Execution
execution
Provides access to the current context.
-
Constructor Summary
Constructors Constructor Description MessageStreamScriptService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
deleteMessage(String id)
Delete an existing message, identified by its unique ID, if the current user is the author of that message.Exception
getLastError()
Get the error generated while performing the previously called action.boolean
isActive()
boolean
postDirectMessageToUser(String message, DocumentReference user)
Post a private message to another user.boolean
postMessageToGroup(String message, DocumentReference group)
Post a message to a specific group of users.boolean
postPersonalMessage(String message)
Post a message to the user's personal stream, displayed on his profile page and aggregated into their follower's streams.boolean
postPublicMessage(String message)
Post a message to the user's stream, visible to everyone.protected void
setError(Exception e)
Store a caught exception in the context, so that it can be later retrieved usinggetLastError()
.
-
-
-
Method Detail
-
postPublicMessage
public boolean postPublicMessage(String message)
Post a message to the user's stream, visible to everyone.- Parameters:
message
- the message to store- Returns:
true
if the message was successfully posted,false
otherwise
-
postPersonalMessage
public boolean postPersonalMessage(String message)
Post a message to the user's personal stream, displayed on his profile page and aggregated into their follower's streams.- Parameters:
message
- the message to store- Returns:
true
if the message was successfully posted,false
otherwise
-
postDirectMessageToUser
public boolean postDirectMessageToUser(String message, DocumentReference user)
Post a private message to another user.- Parameters:
message
- the message to senduser
- the target user- Returns:
true
if the message was successfully posted,false
otherwise
-
postMessageToGroup
public boolean postMessageToGroup(String message, DocumentReference group)
Post a message to a specific group of users.- Parameters:
message
- the message to sendgroup
- the target group- Returns:
true
if the message was successfully posted,false
otherwise
-
deleteMessage
public boolean deleteMessage(String id)
Delete an existing message, identified by its unique ID, if the current user is the author of that message.- Parameters:
id
- the unique ID of the message- Returns:
true
if the message was successfully deleted,false
otherwise
-
isActive
public boolean isActive()
- Returns:
- true if the Message Stream feature is active or false otherwise
- Since:
- 8.4RC1
-
getLastError
public Exception getLastError()
Get the error generated while performing the previously called action.- Returns:
- the exception or
null
if no exception was thrown
-
setError
protected void setError(Exception e)
Store a caught exception in the context, so that it can be later retrieved usinggetLastError()
.- Parameters:
e
- the exception to store, can benull
to clear the previously stored exception- See Also:
getLastError()
-
-