Class 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 the MessageStream functionality, allowing to post messages from the current user.
    Version:
    $Id: 54536fb82c5b50951189471dfb98c6be10ca6369 $
    • Field Detail

      • execution

        @Inject
        protected org.xwiki.context.Execution execution
        Provides access to the current context.
    • Constructor Detail

      • MessageStreamScriptService

        public MessageStreamScriptService()
    • 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 send
        user - 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 send
        group - 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 using getLastError().
        Parameters:
        e - the exception to store, can be null to clear the previously stored exception
        See Also:
        getLastError()