Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.database
Class DbPrivateMessageManager

java.lang.Object
  extended by com.jivesoftware.forum.database.DbPrivateMessageManager
All Implemented Interfaces:
JiveManager, PrivateMessageManager

public class DbPrivateMessageManager
extends java.lang.Object
implements PrivateMessageManager, JiveManager

Database implementation of PrivateMessageManager.

Since:
4.0

Constructor Summary
DbPrivateMessageManager()
          Creates a new DbPrivateMessageManager instance.
 
Method Summary
 PrivateMessageFolder createFolder(User user, java.lang.String name)
          Creates a new folder.
 PrivateMessage createMessage(User sender)
          Creates a new private message.
 void deleteFolder(PrivateMessageFolder folder)
          Deletes a folder.
 void destroy()
          Notifies the manager to release any resources that may be holding on too.
 PrivateMessageFolder getFolder(User user, int folderID)
          Returns the specified folder for a user.
 int getFolderCount(User user)
          Returns the total number of folders the user has.
 java.util.Iterator getFolders(User user)
          Returns an Iterator of PrivateMessageFolder objects for the folders the user has.
static DbPrivateMessageManager getInstance()
          Returns a singleton instance of DbPrivateMessageManager.
 int getMaxMessagesPerUser()
          Returns the max number of messages each user is allowed to store in their mailbox, or -1 if there is no limit.
 PrivateMessage getMessage(long pMessageID)
          Returns the specified private message.
 int getMessageCount(User user)
          Returns the total number of private messages a user has in their mailbox.
 RenderManager getRenderManager()
          Returns a render manager for private messages in the system.
 int getUnreadMessageCount(User user)
          Returns the total number of unread private messages a user has in their mailbox.
 void initialize()
          Initialize the manager.
 boolean isPrivateMessagesEnabled()
          Returns true if the feature is enabled, false otherwise.
 void saveMessageAsDraft(PrivateMessage privateMessage)
          Saves a message as a draft by storing it in the sender's Drafts folder.
 PrivateMessage sendMessage(PrivateMessage privateMessage, User recipient, boolean copyToSentFolder)
          Sends a private message to another user.
 void setMaxMessagesPerUser(int maxMessagesPerUser)
          Sets the max number of message is allowed to store in their mailbox.
 void setPrivateMessagesEnabled(boolean enabled)
          Enables or disables the private message feature.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbPrivateMessageManager

public DbPrivateMessageManager()
Creates a new DbPrivateMessageManager instance.

Method Detail

getInstance

public static DbPrivateMessageManager getInstance()
Returns a singleton instance of DbPrivateMessageManager.

Returns:
a singleton instance.

initialize

public void initialize()
Description copied from interface: JiveManager
Initialize the manager. It is within this method that it is ok to create, access and/or otherwise use external classes (including caches). Until this method is called implementation should not access any external classes that could possibly either access one of the main Factory classes or any caches since doing so can cause deadlocks and possible clustering issues during startup.

This method is used internally by Jive during application startup and should not be called during normal usage of the class.

Specified by:
initialize in interface JiveManager

destroy

public void destroy()
Description copied from interface: JiveManager
Notifies the manager to release any resources that may be holding on too. This could also be used to clear out the managers caches, etc.

This method is used internally by Jive during application startup and should not be called during normal usage of the class.

Specified by:
destroy in interface JiveManager

isPrivateMessagesEnabled

public boolean isPrivateMessagesEnabled()
Description copied from interface: PrivateMessageManager
Returns true if the feature is enabled, false otherwise.

Specified by:
isPrivateMessagesEnabled in interface PrivateMessageManager
Returns:
true if the feature is enabled, false otherwise.

setPrivateMessagesEnabled

public void setPrivateMessagesEnabled(boolean enabled)
                               throws UnauthorizedException
Description copied from interface: PrivateMessageManager
Enables or disables the private message feature. You must have admin privileges to call this method.

Specified by:
setPrivateMessagesEnabled in interface PrivateMessageManager
Parameters:
enabled - true to enable PM's, false otherwise.
Throws:
UnauthorizedException

getRenderManager

public RenderManager getRenderManager()
Description copied from interface: PrivateMessageManager
Returns a render manager for private messages in the system.

Specified by:
getRenderManager in interface PrivateMessageManager
Returns:
the private message render manager.

getMaxMessagesPerUser

public int getMaxMessagesPerUser()
Description copied from interface: PrivateMessageManager
Returns the max number of messages each user is allowed to store in their mailbox, or -1 if there is no limit. All messages in folders other than the Trash count towards the message total. Once the total is reached, other users will not be able to send messages to the user. However, additional system messages can continue to be sent to the user ast the total.

Specified by:
getMaxMessagesPerUser in interface PrivateMessageManager
Returns:
the max number of messages a user is allowed to store in their mailbox, or -1 if there is no limit.

setMaxMessagesPerUser

public void setMaxMessagesPerUser(int maxMessagesPerUser)
Description copied from interface: PrivateMessageManager
Sets the max number of message is allowed to store in their mailbox. All messages in folders other than the Trash count towards the message total. Once the total is reached, other users will not be able to send messages to the user. However, additional system messages can continue to be sent to the user ast the total.

Specified by:
setMaxMessagesPerUser in interface PrivateMessageManager
Parameters:
maxMessagesPerUser - the max number of messages a user is allowed to store in their mailbox, or -1 for no limit.

getMessageCount

public int getMessageCount(User user)
Description copied from interface: PrivateMessageManager
Returns the total number of private messages a user has in their mailbox. This calculation does not count any messages in the user's Trash folder.

Specified by:
getMessageCount in interface PrivateMessageManager
Parameters:
user - the user.
Returns:
the total number of private messages the user has.

getUnreadMessageCount

public int getUnreadMessageCount(User user)
Description copied from interface: PrivateMessageManager
Returns the total number of unread private messages a user has in their mailbox. This calculation does not count any messages in the user's Trash folder.

Specified by:
getUnreadMessageCount in interface PrivateMessageManager
Parameters:
user - the user.
Returns:
the total number of unread private messages the user has.

getFolderCount

public int getFolderCount(User user)
Description copied from interface: PrivateMessageManager
Returns the total number of folders the user has. Every user always has at least the four built-in folders, plus any additional custom folders.

Specified by:
getFolderCount in interface PrivateMessageManager
Parameters:
user - the user.
Returns:
the total number of folders the user has.

getFolders

public java.util.Iterator getFolders(User user)
Description copied from interface: PrivateMessageManager
Returns an Iterator of PrivateMessageFolder objects for the folders the user has. The four built-in folders (Inbox, Sent, Drafts, Trash) are returned first, followed by custom folders in alphabetical order.

Specified by:
getFolders in interface PrivateMessageManager
Parameters:
user - the user.
Returns:
the an Iterator for the user's folders.

getFolder

public PrivateMessageFolder getFolder(User user,
                                      int folderID)
                               throws PrivateMessageFolderNotFoundException
Description copied from interface: PrivateMessageManager
Returns the specified folder for a user.

Specified by:
getFolder in interface PrivateMessageManager
Parameters:
user - the user.
folderID - the folder ID.
Returns:
the user's folder.
Throws:
PrivateMessageFolderNotFoundException - if the folder could not be loaded.

createFolder

public PrivateMessageFolder createFolder(User user,
                                         java.lang.String name)
                                  throws UnauthorizedException
Description copied from interface: PrivateMessageManager
Creates a new folder.

Specified by:
createFolder in interface PrivateMessageManager
Parameters:
user - the user to create the folder for.
name - the name of the folder.
Returns:
the new folder.
Throws:
UnauthorizedException - if not an administrator or the user.

deleteFolder

public void deleteFolder(PrivateMessageFolder folder)
                  throws UnauthorizedException
Description copied from interface: PrivateMessageManager
Deletes a folder. All messages in the folder will be moved to the user's Trash folder. Attempting to delete one of the four default folders will move all messages in the folder to Trash but won't delete the folder itself. If the folder is the Trash folder, all messages in the folder will be permanently deleted.

Specified by:
deleteFolder in interface PrivateMessageManager
Parameters:
folder - the folder to delete.
Throws:
UnauthorizedException - if not an administrator or the user.

getMessage

public PrivateMessage getMessage(long pMessageID)
                          throws PrivateMessageNotFoundException
Description copied from interface: PrivateMessageManager
Returns the specified private message.

Specified by:
getMessage in interface PrivateMessageManager
Parameters:
pMessageID - the ID of the private message.
Throws:
PrivateMessageNotFoundException - if the message could not be loaded.

createMessage

public PrivateMessage createMessage(User sender)
                             throws UnauthorizedException
Description copied from interface: PrivateMessageManager
Creates a new private message. The message must be either saved as a draft or sent to another user in order to be stored permanently.

Specified by:
createMessage in interface PrivateMessageManager
Parameters:
sender - the user sending the message.
Returns:
a new message.
Throws:
UnauthorizedException - if not an administrator or the user.

saveMessageAsDraft

public void saveMessageAsDraft(PrivateMessage privateMessage)
                        throws PrivateMessageRejectedException
Description copied from interface: PrivateMessageManager
Saves a message as a draft by storing it in the sender's Drafts folder.

Specified by:
saveMessageAsDraft in interface PrivateMessageManager
Parameters:
privateMessage - the message to save.
Throws:
PrivateMessageRejectedException - if the message could not be saved as a draft.

sendMessage

public PrivateMessage sendMessage(PrivateMessage privateMessage,
                                  User recipient,
                                  boolean copyToSentFolder)
                           throws PrivateMessageRejectedException
Description copied from interface: PrivateMessageManager
Sends a private message to another user. The message will be delivered to the recipient's Inbox. Optionally, a copy of the message will be put in the sender's Sent folder.

If the recipient's mailbox is full, a PrivateMessageRejectedException will be thrown. The exception will also be thrown if the recipient is not allowed to receive private messages or if the user has elected to save a copy of the message in their Sent folder, but doesn't have room to do so.

Specified by:
sendMessage in interface PrivateMessageManager
Parameters:
privateMessage - the message to send.
recipient - the user to send the message to.
copyToSentFolder - true if the message should be copied to the Sent folder.
Throws:
PrivateMessageRejectedException - if the message could not be delivered.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.