org.sakaiproject.profile2.logic
Interface ProfileMessagingLogic


public interface ProfileMessagingLogic

An interface for dealing with messaging in Profile2

Author:
Steve Swinsburg (steve.swinsburg@gmail.com)

Method Summary
 int getAllUnreadMessagesCount(String userId)
          Get the number of all unread messages for this user, across all all message threads.
 Message getMessage(String id)
          Gets a Message from the database
 MessageParticipant getMessageParticipant(String messageId, String userUuid)
          Get a MessageParticipant record
 List<Message> getMessagesInThread(String threadId)
          Gets a list of the messages contained in this thread, sorted by date posted.
 int getMessagesInThreadCount(String threadId)
          Gets the count of the messages in a thread
 MessageThread getMessageThread(String threadId)
          Gets a MessageThread, first gets the item, then injects the latest Message into it before returning TODO This needs to be optimised to get the latest message property in the same query.
 List<MessageThread> getMessageThreads(String userId)
          Gets a list of MessageThreads with messages to a given user, each containing the most recent messages in each thread TODO This needs to be optimised to get the latest message property in the same query.
 int getMessageThreadsCount(String userId)
          Gets the count of the message threads for a user
 int getSentMessagesCount(String userId)
          Get the number of all messages sent from this user
 List<String> getThreadParticipants(String threadId)
          Get a list of all participants in a thread
 String getThreadSubject(String threadId)
          Get the subject of a thread
 int getThreadsWithUnreadMessagesCount(String userId)
          Get the number of threads with unread messages.
 boolean isThreadParticipant(String threadId, String userId)
          Is the user a participant in this thread?
 Message replyToThread(String threadId, String reply, String userId)
          Sends a reply to a thread, returns the Message just sent
 boolean sendNewMessage(String uuidTo, String uuidFrom, String threadId, String subject, String messageStr)
          Send a message
 boolean toggleMessageRead(MessageParticipant participant, boolean status)
          Toggle a single message as read/unread
 

Method Detail

getAllUnreadMessagesCount

int getAllUnreadMessagesCount(String userId)
Get the number of all unread messages for this user, across all all message threads.

Parameters:
userId - uuid of the user to retrieve the count for

getThreadsWithUnreadMessagesCount

int getThreadsWithUnreadMessagesCount(String userId)
Get the number of threads with unread messages.

For instance, if a user has two message threads, each with one unread message in each thread, this will return 2, as expected.
However, if a user has two message threads, each with 5 unread messages in each thread, this will return 2, not 10.
This is because we are interested in the number of threads with unread messages not the total unread messages. See ProfileLogic#getAllUnreadMessagesCount(String) if you want that instead.

Parameters:
userId - uuid of the user to retrieve the count for
Returns:

getSentMessagesCount

int getSentMessagesCount(String userId)
Get the number of all messages sent from this user

Parameters:
userId - uuid of the user to retrieve the count for
Returns:

getMessageThread

MessageThread getMessageThread(String threadId)
Gets a MessageThread, first gets the item, then injects the latest Message into it before returning TODO This needs to be optimised to get the latest message property in the same query.

Parameters:
id - id of the thread
Returns:

getMessageThreads

List<MessageThread> getMessageThreads(String userId)
Gets a list of MessageThreads with messages to a given user, each containing the most recent messages in each thread TODO This needs to be optimised to get the latest message property in the same query.

Parameters:
userId - user to get the list of messages for
Returns:

getMessageThreadsCount

int getMessageThreadsCount(String userId)
Gets the count of the message threads for a user

Parameters:
userId - user to get the count of message threads for
Returns:

getMessagesInThread

List<Message> getMessagesInThread(String threadId)
Gets a list of the messages contained in this thread, sorted by date posted.

Parameters:
threadId - id of the thread to get the messages for
Returns:

getMessagesInThreadCount

int getMessagesInThreadCount(String threadId)
Gets the count of the messages in a thread

Parameters:
threadId - thread to get the count for
Returns:

getMessage

Message getMessage(String id)
Gets a Message from the database

Parameters:
id - id of the message
Returns:

sendNewMessage

boolean sendNewMessage(String uuidTo,
                       String uuidFrom,
                       String threadId,
                       String subject,
                       String messageStr)
Send a message

TODO this should be optimised for foreign key constraints

Parameters:
uuidTo - uuid of recipient
uuidFrom - uuid of sender
threadId - threadId, a uuid that should be generated via ProfileUtils.generateUuid()
subject - message subject
messageStr - message body
Returns:

replyToThread

Message replyToThread(String threadId,
                      String reply,
                      String userId)
Sends a reply to a thread, returns the Message just sent

Parameters:
threadId - id of the thread
reply - the message
userId - uuid of user who is sending the message
Returns:

toggleMessageRead

boolean toggleMessageRead(MessageParticipant participant,
                          boolean status)
Toggle a single message as read/unread

Parameters:
participant - the MessageParticipant record as this is the item that stores read/unread status
status - boolean if to be toggled as read/unread
Returns:

getMessageParticipant

MessageParticipant getMessageParticipant(String messageId,
                                         String userUuid)
Get a MessageParticipant record

Parameters:
messageId - message id to get the record for
userUuid - uuid to get the record for
Returns:

getThreadParticipants

List<String> getThreadParticipants(String threadId)
Get a list of all participants in a thread

Parameters:
threadId - id of the thread
Returns:

isThreadParticipant

boolean isThreadParticipant(String threadId,
                            String userId)
Is the user a participant in this thread?

Parameters:
threadId - id of the thread
userId - id of the user
Returns:

getThreadSubject

String getThreadSubject(String threadId)
Get the subject of a thread

Parameters:
threadId - id of the thread
Returns:


Copyright © 2008-2012 The Sakai Foundation. All Rights Reserved.