Package lumis.collaboration.chat
Class ChatManager
- java.lang.Object
-
- lumis.collaboration.chat.ChatManager
-
- All Implemented Interfaces:
IChatManager
public class ChatManager extends java.lang.Object implements IChatManager
Responsible for managing all chat conversations- Since:
- 4.0.5
- Version:
- $Revision: 7300 $ $Date: 2007-06-08 16:09:55 -0300 (Fri, 08 Jun 2007) $
-
-
Constructor Summary
Constructors Constructor Description ChatManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addConversation(SessionConfig sessionConfig, ChatConversationConfig conversationConfig, ITransaction transaction)
Adds a chat conversation.void
addMessage(SessionConfig sessionConfig, ChatMessageConfig messageConfig, ITransaction transaction)
Adds a chat message to a conversation.void
addUser(SessionConfig sessionConfig, ChatUserConfig userConfig, ITransaction transaction)
Adds a chat uservoid
closeExpiredConversations(SessionConfig sessionConfig, ITransaction transaction)
closes expired conversations.void
deleteConversation(SessionConfig sessionConfig, java.lang.String conversationId, ITransaction transaction)
Deletes the given chat conversation.void
deleteMessage(SessionConfig sessionConfig, java.lang.String messageId, ITransaction transaction)
Deletes the given message Id from its conversation.void
deleteUser(SessionConfig sessionConfig, java.lang.String userId, ITransaction transaction)
Deletes the given user.java.util.Collection<ChatUserConfig>
getActiveUsers(SessionConfig sessionConfig, java.lang.String conversationId, ITransaction transaction)
Returns all the active chat users given the conversation idjava.util.Collection<ChatUserConfig>
getActiveUsersWithExpiredLastAccess(SessionConfig sessionConfig, ITransaction transaction)
ChatConversationConfig
getConversation(SessionConfig sessionConfig, java.lang.String conversationId, ITransaction transaction)
Returns a chat conversation config object.java.util.List<ChatMessageConfig>
getLatestMessages(SessionConfig sessionConfig, java.lang.String conversationId, java.lang.String chatUserId, int maxMessages, boolean getMessagesToModerate, java.util.Date greaterThanDate, ITransaction transaction)
Deprecated.java.util.List<ChatMessageConfig>
getLatestMessages(SessionConfig sessionConfig, java.lang.String conversationId, java.lang.String chatUserId, int firstMessageIndex, int maxMessages, boolean getMessagesToModerate, java.util.Date greaterThanDate, ITransaction transaction)
Returns up to maxMessages messageConfigs for a given conversationId.int
getLatestMessagesCount(SessionConfig sessionConfig, java.lang.String conversationId, java.lang.String chatUserId, boolean getMessagesToModerate, java.util.Date greaterThanDate, ITransaction transaction)
Returns the number of messages that exists and would be available for the#getLatestMessages(String, String, int, int, boolean, Date, ITransaction)
method.ChatMessageConfig
getMessage(SessionConfig sessionConfig, java.lang.String messageId, ITransaction transaction)
Returns a message config object.java.util.Collection<ChatMessageConfig>
getMessages(SessionConfig sessionConfig, java.lang.String conversationId, ITransaction transaction)
Returns all the messages for a given conversationId.java.lang.String
getMessagesXml(SessionConfig sessionConfig, java.util.Collection<ChatMessageConfig> chatMessageConfigs, boolean getMessagesToModerate, java.util.List<IResource> resources, ITransaction transaction)
Returns the xml for the given messages.ChatUserConfig
getUser(SessionConfig sessionConfig, java.lang.String userId, java.lang.String conversationId, java.lang.String userSessionId, ITransaction transaction)
Returns a chat user given the portal user id, conversation id and optionally the user sessionIdChatUserConfig
getUser(SessionConfig sessionConfig, java.lang.String id, ITransaction transaction)
Returns a chat user given the chat user idjava.util.Collection<ChatUserConfig>
getUsers(SessionConfig sessionConfig, java.lang.String conversationId, ITransaction transaction)
Returns all the chat users given the conversation idvoid
openStartedConversations(SessionConfig sessionConfig, ITransaction transaction)
Opens the conversations whose startTime has already been reached.boolean
reachedUserLimit(SessionConfig sessionConfig, java.lang.String conversationId, ITransaction transaction)
Returns true if the conversation has reached its user limitvoid
updateActiveUserState(SessionConfig sessionConfig, ITransaction transaction)
Checks if any of the active users have not updated their last acces date.void
updateLastAccess(SessionConfig sessionConfig, java.lang.String chatUserId, ITransaction transaction)
Updates the last access date for the given chat user.void
userLeftConversation(SessionConfig sessionConfig, ChatUserConfig chatUserConfig, ITransaction transaction)
Method to indicate that a user left the conversationvoid
validateActiveConversation(java.lang.String conversationId, ITransaction transaction)
-
-
-
Field Detail
-
resource
protected IResource resource
-
-
Method Detail
-
addUser
public void addUser(SessionConfig sessionConfig, ChatUserConfig userConfig, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Adds a chat user- Specified by:
addUser
in interfaceIChatManager
- Throws:
PortalException
-
getUser
public ChatUserConfig getUser(SessionConfig sessionConfig, java.lang.String id, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Returns a chat user given the chat user id- Specified by:
getUser
in interfaceIChatManager
- Throws:
PortalException
-
getUser
public ChatUserConfig getUser(SessionConfig sessionConfig, java.lang.String userId, java.lang.String conversationId, java.lang.String userSessionId, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Returns a chat user given the portal user id, conversation id and optionally the user sessionId- Specified by:
getUser
in interfaceIChatManager
- Returns:
- Throws:
PortalException
-
getUsers
public java.util.Collection<ChatUserConfig> getUsers(SessionConfig sessionConfig, java.lang.String conversationId, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Returns all the chat users given the conversation id- Specified by:
getUsers
in interfaceIChatManager
- Returns:
- Throws:
PortalException
-
getActiveUsers
public java.util.Collection<ChatUserConfig> getActiveUsers(SessionConfig sessionConfig, java.lang.String conversationId, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Returns all the active chat users given the conversation id- Specified by:
getActiveUsers
in interfaceIChatManager
- Returns:
- Throws:
PortalException
-
reachedUserLimit
public boolean reachedUserLimit(SessionConfig sessionConfig, java.lang.String conversationId, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Returns true if the conversation has reached its user limit- Specified by:
reachedUserLimit
in interfaceIChatManager
- Returns:
- Throws:
PortalException
-
getActiveUsersWithExpiredLastAccess
public java.util.Collection<ChatUserConfig> getActiveUsersWithExpiredLastAccess(SessionConfig sessionConfig, ITransaction transaction) throws PortalException
- Throws:
PortalException
-
deleteUser
public void deleteUser(SessionConfig sessionConfig, java.lang.String userId, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Deletes the given user.- Specified by:
deleteUser
in interfaceIChatManager
- Throws:
PortalException
-
addConversation
public void addConversation(SessionConfig sessionConfig, ChatConversationConfig conversationConfig, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Adds a chat conversation.- Specified by:
addConversation
in interfaceIChatManager
- Throws:
PortalException
-
getConversation
public ChatConversationConfig getConversation(SessionConfig sessionConfig, java.lang.String conversationId, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Returns a chat conversation config object.- Specified by:
getConversation
in interfaceIChatManager
- Throws:
PortalException
-
deleteConversation
public void deleteConversation(SessionConfig sessionConfig, java.lang.String conversationId, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Deletes the given chat conversation.- Specified by:
deleteConversation
in interfaceIChatManager
- Throws:
PortalException
-
openStartedConversations
public void openStartedConversations(SessionConfig sessionConfig, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Opens the conversations whose startTime has already been reached.- Specified by:
openStartedConversations
in interfaceIChatManager
- Parameters:
sessionConfig
- the user session information.transaction
- the transaction for persistence access.- Throws:
PortalException
-
closeExpiredConversations
public void closeExpiredConversations(SessionConfig sessionConfig, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
closes expired conversations.- Specified by:
closeExpiredConversations
in interfaceIChatManager
- Throws:
PortalException
-
updateActiveUserState
public void updateActiveUserState(SessionConfig sessionConfig, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Checks if any of the active users have not updated their last acces date. If not, change their state to inactive- Specified by:
updateActiveUserState
in interfaceIChatManager
- Throws:
PortalException
-
userLeftConversation
public void userLeftConversation(SessionConfig sessionConfig, ChatUserConfig chatUserConfig, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Method to indicate that a user left the conversation- Specified by:
userLeftConversation
in interfaceIChatManager
- Throws:
PortalException
-
addMessage
public void addMessage(SessionConfig sessionConfig, ChatMessageConfig messageConfig, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Adds a chat message to a conversation.- Specified by:
addMessage
in interfaceIChatManager
- Throws:
PortalException
-
validateActiveConversation
public void validateActiveConversation(java.lang.String conversationId, ITransaction transaction) throws PortalException
- Throws:
PortalException
-
getMessage
public ChatMessageConfig getMessage(SessionConfig sessionConfig, java.lang.String messageId, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Returns a message config object.- Specified by:
getMessage
in interfaceIChatManager
- Throws:
PortalException
-
getMessages
public java.util.Collection<ChatMessageConfig> getMessages(SessionConfig sessionConfig, java.lang.String conversationId, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Returns all the messages for a given conversationId. The messages are returned ordered by creation date.- Specified by:
getMessages
in interfaceIChatManager
- Returns:
- Throws:
PortalException
-
getLatestMessages
@Deprecated public java.util.List<ChatMessageConfig> getLatestMessages(SessionConfig sessionConfig, java.lang.String conversationId, java.lang.String chatUserId, int maxMessages, boolean getMessagesToModerate, java.util.Date greaterThanDate, ITransaction transaction) throws PortalException
Deprecated.Description copied from interface:IChatManager
Returns up to maxMessages messageConfigs for a given conversationId. If more than maxMessages exist, the most recent messages are returned. The messages are returned ordered by creation date.- Specified by:
getLatestMessages
in interfaceIChatManager
- Parameters:
sessionConfig
- the user session information.conversationId
- the conversation identifier.chatUserId
- the chat user identifier. If null no private messages are returned. If specified the private messages for that user are returned.maxMessages
- the maximum number of messages to be returned.getMessagesToModerate
- if true the messages to moderate are also returned.greaterThanDate
- if not null, only the message with sent date-time greater than this argument are returned.transaction
- the transaction for persistence access.- Returns:
- the messages.
- Throws:
PortalException
-
getLatestMessages
public java.util.List<ChatMessageConfig> getLatestMessages(SessionConfig sessionConfig, java.lang.String conversationId, java.lang.String chatUserId, int firstMessageIndex, int maxMessages, boolean getMessagesToModerate, java.util.Date greaterThanDate, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Returns up to maxMessages messageConfigs for a given conversationId. If more than maxMessages exist, the most recent messages are returned. The messages returned start at thefirstMessage
zero-based index. The messages are returned ordered by descending sent date-time.- Specified by:
getLatestMessages
in interfaceIChatManager
- Parameters:
sessionConfig
- the user session information.conversationId
- the conversation identifier.chatUserId
- the chat user identifier. If null no private messages are returned. If specified the private messages for that user are returned.firstMessageIndex
- the index of the first message to be returned. This index is zero based. May be used for pagination.maxMessages
- the maximum number of messages to be returned.getMessagesToModerate
- if true the messages to moderate are also returned.greaterThanDate
- if not null, only the message with sent date-time greater than this argument are returned.transaction
- the transaction for persistence access.- Returns:
- the list of messages.
- Throws:
PortalException
-
getMessagesXml
public java.lang.String getMessagesXml(SessionConfig sessionConfig, java.util.Collection<ChatMessageConfig> chatMessageConfigs, boolean getMessagesToModerate, java.util.List<IResource> resources, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Returns the xml for the given messages. The collection's iterator ordering will be used.- Specified by:
getMessagesXml
in interfaceIChatManager
- Parameters:
sessionConfig
- the user session information.chatMessageConfigs
- the messages collection.getMessagesToModerate
- if true the messages to moderate are also returned.resources
- resources used for localization.transaction
- the transaction for persistence access.- Returns:
- the xml.
- Throws:
PortalException
-
getLatestMessagesCount
public int getLatestMessagesCount(SessionConfig sessionConfig, java.lang.String conversationId, java.lang.String chatUserId, boolean getMessagesToModerate, java.util.Date greaterThanDate, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Returns the number of messages that exists and would be available for the#getLatestMessages(String, String, int, int, boolean, Date, ITransaction)
method.- Specified by:
getLatestMessagesCount
in interfaceIChatManager
- Parameters:
sessionConfig
- the user session information.conversationId
- the conversation identifier.chatUserId
- the chat user identifier. If null no private messages are returned. If specified the private messages for that user are returned.getMessagesToModerate
- if true the messages to moderate are also returned.greaterThanDate
- if not null, only the message with sent date-time greater than this argument are returned.transaction
- the transaction for persistence access.- Returns:
- the number of messages.
- Throws:
PortalException
-
deleteMessage
public void deleteMessage(SessionConfig sessionConfig, java.lang.String messageId, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Deletes the given message Id from its conversation.- Specified by:
deleteMessage
in interfaceIChatManager
- Throws:
PortalException
-
updateLastAccess
public void updateLastAccess(SessionConfig sessionConfig, java.lang.String chatUserId, ITransaction transaction) throws PortalException
Description copied from interface:IChatManager
Updates the last access date for the given chat user.- Specified by:
updateLastAccess
in interfaceIChatManager
- Throws:
PortalException
-
-