Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.database
Class DbPrivateMessage

java.lang.Object
  extended by com.jivesoftware.forum.database.DbPrivateMessage
All Implemented Interfaces:
PrivateMessage, Cacheable, com.tangosol.io.ExternalizableLite, java.io.Serializable

public class DbPrivateMessage
extends java.lang.Object
implements PrivateMessage, Cacheable, com.tangosol.io.ExternalizableLite

Database implementation of the PrivateMessage interface.

Since:
4.0
See Also:
Serialized Form

Field Summary
static java.lang.String DRAFTS_PROPERTY_KEY
           
protected  java.lang.String filteredBody
           
protected  java.util.Map filteredProperties
           
protected  java.lang.String filteredSubject
           
 
Constructor Summary
DbPrivateMessage()
          Constructor for internal use only.
DbPrivateMessage(DbPrivateMessage originalMessage)
          Creates a new private message by copying all the data from another private message.
DbPrivateMessage(long pMessageID)
          Loads an existing private message based on its ID.
DbPrivateMessage(User sender)
          Creates a new private message.
 
Method Summary
 Attachment createAttachment(java.lang.String name, java.lang.String contentType, java.io.InputStream data)
          Creates a new attachment for this private message.
 void deleteAttachment(Attachment attachment)
          Deletes an attachment that belongs to this private message.
 void deleteProperty(java.lang.String name)
          Deletes an extended property.
 boolean equals(java.lang.Object object)
           
 int getAttachmentCount()
          Returns the number of attachments this private message has.
 java.util.Iterator getAttachments()
          Returns an Iterator for all attachments of this private message.
 java.lang.String getBody()
          Returns the message body.
 int getCachedSize()
          Returns the approximate size of the Object in bytes.
 java.util.Date getDate()
          Returns the date the message was saved or sent, or null if the message hasn't been sent or saved yet.
 PrivateMessageFolder getFolder()
          Returns the folder the private message or null if the message does not yet belong to a folder.
 long getID()
          Returns the id of the message.
 long getOwnerID()
          Returns the userID of the owner of the private message.
 java.util.Collection getProperties(java.lang.String parentName)
          Return all immediate children property values of a parent property as an unmodifiable Collection of String values.
 java.lang.String getProperty(java.lang.String name)
          Returns an extended property of this private message.
 java.util.Iterator getPropertyNames()
          Returns an Iterator of String values for all the names of the message properties.
 User getRecipient()
          Returns the user the message was sent to.
 User getSender()
          Returns the user the message was sent by, or null if the message was sent by the system.
 java.lang.String getSubject()
          Returns the message subject.
 java.lang.String getUnfilteredBody()
          Returns the message body, bypassing any active filters.
 java.lang.String getUnfilteredProperty(java.lang.String name)
          Returns an extended property of this private message, bypassing any filters.
 java.lang.String getUnfilteredSubject()
          Returns the message subject, bypassing any active filters.
 int hashCode()
           
 void insertIntoDb()
          Inserts a new private message into the database.
 boolean isAuthorized(long permissionType)
          Returns true if the handle on this object has the permission specified.
 boolean isRead()
          Returns true if this message has been marked as read.
 void readExternal(java.io.DataInput in)
           
protected  void saveToDb()
          Saves private message data to the database.
 void setBody(java.lang.String body)
          Sets the body of the message.
 void setFolder(PrivateMessageFolder folder)
           
 void setProperty(java.lang.String name, java.lang.String value)
          Sets an extended property of this private message.
 void setRead(boolean read)
          Marks this message as read or unread.
 void setRecipient(User recipient)
           
 void setSubject(java.lang.String subject)
          Sets the subject of the message.
 java.lang.String toString()
           
 void writeExternal(java.io.DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DRAFTS_PROPERTY_KEY

public static final java.lang.String DRAFTS_PROPERTY_KEY
See Also:
Constant Field Values

filteredSubject

protected java.lang.String filteredSubject

filteredBody

protected java.lang.String filteredBody

filteredProperties

protected java.util.Map filteredProperties
Constructor Detail

DbPrivateMessage

public DbPrivateMessage(User sender)
Creates a new private message.

Parameters:
sender - the user sending the message.

DbPrivateMessage

public DbPrivateMessage(DbPrivateMessage originalMessage)
Creates a new private message by copying all the data from another private message.

Parameters:
originalMessage - the private message to copy.

DbPrivateMessage

public DbPrivateMessage(long pMessageID)
                 throws PrivateMessageNotFoundException
Loads an existing private message based on its ID.

Parameters:
pMessageID - the private message ID.
Throws:
PrivateMessageNotFoundException - if the specified private message could not be loaded.

DbPrivateMessage

public DbPrivateMessage()
Constructor for internal use only.

Method Detail

readExternal

public void readExternal(java.io.DataInput in)
                  throws java.io.IOException
Specified by:
readExternal in interface com.tangosol.io.ExternalizableLite
Throws:
java.io.IOException

writeExternal

public void writeExternal(java.io.DataOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface com.tangosol.io.ExternalizableLite
Throws:
java.io.IOException

getID

public long getID()
Description copied from interface: PrivateMessage
Returns the id of the message.

Specified by:
getID in interface PrivateMessage
Returns:
the unique id of the message.

getDate

public java.util.Date getDate()
Description copied from interface: PrivateMessage
Returns the date the message was saved or sent, or null if the message hasn't been sent or saved yet.

Specified by:
getDate in interface PrivateMessage
Returns:
the date the message was sent or saaved, or null if not yet sent.

getFolder

public PrivateMessageFolder getFolder()
Description copied from interface: PrivateMessage
Returns the folder the private message or null if the message does not yet belong to a folder.

Specified by:
getFolder in interface PrivateMessage
Returns:
the folder the message belongs to.

setFolder

public void setFolder(PrivateMessageFolder folder)

getSubject

public java.lang.String getSubject()
Description copied from interface: PrivateMessage
Returns the message subject. If message filters are active, the subject returned will be a filtered one. Because filters often provide security functionality, this method is the preferred way to get the subject of a message.

Specified by:
getSubject in interface PrivateMessage
Returns:
the subject of the message.

getUnfilteredSubject

public java.lang.String getUnfilteredSubject()
Description copied from interface: PrivateMessage
Returns the message subject, bypassing any active filters. Because filters often provide security, this method should be used with caution. In particular, you should avoid showing unfiltered data in an environment where embedded HTML might be interpreted.

Unfiltered content is necessary for a few reasons. One is when saving Jive content to another persistence mechanism such as an XML format. Another is when you need to skip filter formatting, such as when a user is responding to another user's message.

Specified by:
getUnfilteredSubject in interface PrivateMessage
Returns:
the subject of the message.

setSubject

public void setSubject(java.lang.String subject)
                throws UnauthorizedException
Description copied from interface: PrivateMessage
Sets the subject of the message.

Specified by:
setSubject in interface PrivateMessage
Parameters:
subject - the subject of the message.
Throws:
UnauthorizedException - if not allowed to edit the message.

getBody

public java.lang.String getBody()
Description copied from interface: PrivateMessage
Returns the message body. If message filters are active, the body returned will be a filtered one. Because filters often provide security functionality such as stripping out HTML and Javascript, this method is the preferred way to get the body of a message.

Specified by:
getBody in interface PrivateMessage
Returns:
the body of the message.

getUnfilteredBody

public java.lang.String getUnfilteredBody()
Description copied from interface: PrivateMessage
Returns the message body, bypassing any active filters. Because filters often provide security, this method should be used with caution. In particular, you should avoid showing unfiltered data in an environment where embedded HTML might be interpreted.

Unfiltered content is necessary for a few reasons. One is when saving Jive content to another persistence mechanism such as an XML format. Another is when you need to skip filter formatting, such as when a user is responding to another user's message.

Specified by:
getUnfilteredBody in interface PrivateMessage
Returns:
the body of the message.

setBody

public void setBody(java.lang.String body)
             throws UnauthorizedException
Description copied from interface: PrivateMessage
Sets the body of the message.

Specified by:
setBody in interface PrivateMessage
Parameters:
body - the body of the message.
Throws:
UnauthorizedException - if does not have ADMIN permissions.

getSender

public User getSender()
Description copied from interface: PrivateMessage
Returns the user the message was sent by, or null if the message was sent by the system.

Specified by:
getSender in interface PrivateMessage
Returns:
the user that sent the message.

getRecipient

public User getRecipient()
Description copied from interface: PrivateMessage
Returns the user the message was sent to.

Specified by:
getRecipient in interface PrivateMessage
Returns:
the user the message was sent to.

setRecipient

public void setRecipient(User recipient)

isRead

public boolean isRead()
Description copied from interface: PrivateMessage
Returns true if this message has been marked as read.

Specified by:
isRead in interface PrivateMessage
Returns:
true if the message is read.

setRead

public void setRead(boolean read)
Description copied from interface: PrivateMessage
Marks this message as read or unread.

Specified by:
setRead in interface PrivateMessage
Parameters:
read - true to mark the message as read.

createAttachment

public Attachment createAttachment(java.lang.String name,
                                   java.lang.String contentType,
                                   java.io.InputStream data)
                            throws java.lang.IllegalStateException,
                                   AttachmentException,
                                   UnauthorizedException
Description copied from interface: PrivateMessage
Creates a new attachment for this private message. Each attachment has a name, content type and binary data. Rules about who can create attachments and what kind attachments are allowed are controlled via an AttachmentManager.

Specified by:
createAttachment in interface PrivateMessage
Parameters:
name - the name of the new attachment, usually the file name.
contentType - the content type of the attachment.
data - an InputStream that contains the binary data of the attachment. The stream will never be closed so you must close it manually after calling this method.
Returns:
an Attachment object representing the new attachment created.
Throws:
AttachmentException - if an error occured while creating the attachment. Errors can occur because the attachment is too large or because the private message already has too many attachments.
UnauthorizedException - if not allowed to create attachments.
java.lang.IllegalStateException
See Also:
Attachment, AttachmentManager

getAttachmentCount

public int getAttachmentCount()
Description copied from interface: PrivateMessage
Returns the number of attachments this private message has.

Specified by:
getAttachmentCount in interface PrivateMessage
Returns:
the number of attachments this private message has.

deleteAttachment

public void deleteAttachment(Attachment attachment)
                      throws AttachmentException,
                             UnauthorizedException
Description copied from interface: PrivateMessage
Deletes an attachment that belongs to this private message. Only administrators or the creator of this message are allowed to call this method.

Specified by:
deleteAttachment in interface PrivateMessage
Parameters:
attachment - the attachment to delete.
Throws:
AttachmentException - if there was an error deleting the attachment.
UnauthorizedException - if not authorized to delete the attachment.

getAttachments

public java.util.Iterator getAttachments()
Description copied from interface: PrivateMessage
Returns an Iterator for all attachments of this private message.

Specified by:
getAttachments in interface PrivateMessage
Returns:
an Iterator for the message's attachments.
See Also:
Attachment

getProperty

public java.lang.String getProperty(java.lang.String name)
Description copied from interface: PrivateMessage
Returns an extended property of this private message. Each message can have an arbitrary number of extended properties. This lets particular skins or filters provide enhanced functionality that is not part of the base interface.

For security reasons, you should enable an HTML filter in case properties contain malicious HTML code.

Specified by:
getProperty in interface PrivateMessage
Parameters:
name - the name of the property to get.
Returns:
the value of the property.

getUnfilteredProperty

public java.lang.String getUnfilteredProperty(java.lang.String name)
Description copied from interface: PrivateMessage
Returns an extended property of this private message, bypassing any filters. Each message can have an arbitrary number of extended properties. This lets particular skins or filters provide enhanced functionality that is not part of the base interface.

Because properties are not filtered before being returned, this method should be used with caution. In particular, you should avoid showing unfiltered data in an environment where embedded HTML might be interpreted.

Specified by:
getUnfilteredProperty in interface PrivateMessage
Parameters:
name - the name of the property to get.
Returns:
the value of the property.

getProperties

public java.util.Collection getProperties(java.lang.String parentName)
Description copied from interface: PrivateMessage
Return all immediate children property values of a parent property as an unmodifiable Collection of String values. A parent/child relationship is denoted by the "." character. For example, given the properties X.Y.A, X.Y.B, X.Y.C and X.Y.C.D, then the immediate child properties of X.Y are X.Y.A, X.Y.B, and X.Y.C (the value of X.Y.C.D would not be returned using this method).

Specified by:
getProperties in interface PrivateMessage
Parameters:
parentName - the name of the parent property to return the children for.
Returns:
all Collection of all child property values for the given parent.

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
Description copied from interface: PrivateMessage
Sets an extended property of this private message. Each message can have an arbitrary number of extended properties. This lets particular skins or filters provide enhanced functionality that is not part of the base interface.

Specified by:
setProperty in interface PrivateMessage
Parameters:
name - the name of the property to set.
value - the new value for the property.

deleteProperty

public void deleteProperty(java.lang.String name)
Description copied from interface: PrivateMessage
Deletes an extended property. If the property specified by name does not exist, this method will do nothing.

Specified by:
deleteProperty in interface PrivateMessage
Parameters:
name - the name of the property to delete.

getPropertyNames

public java.util.Iterator getPropertyNames()
Description copied from interface: PrivateMessage
Returns an Iterator of String values for all the names of the message properties.

Specified by:
getPropertyNames in interface PrivateMessage
Returns:
an Iterator for the names of all message properties.

getOwnerID

public long getOwnerID()
Returns the userID of the owner of the private message.

Returns:
the ownerID.

isAuthorized

public boolean isAuthorized(long permissionType)
Description copied from interface: PrivateMessage
Returns true if the handle on this object has the permission specified. For example, if a forum administrator has a handle on this object, then calling isAuthorized(ForumPermissions.FORUM_ADMIN) would return true.

A list of possible permissions can be found in the ForumPermissions class. Certain methods of this class are restricted to certain permissions as specified in the method comments.

Specified by:
isAuthorized in interface PrivateMessage
Parameters:
permissionType - permissionType a permission type.
Returns:
true if the handle on the object has the specified permission.
See Also:
ForumPermissions

getCachedSize

public int getCachedSize()
Description copied from interface: Cacheable
Returns the approximate size of the Object in bytes. The size should be considered to be a best estimate of how much memory the Object occupies and may be based on empirical trials or dynamic calculations.

Specified by:
getCachedSize in interface Cacheable
Returns:
the size of the Object in bytes.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

insertIntoDb

public void insertIntoDb()
                  throws java.sql.SQLException,
                         UnauthorizedException
Inserts a new private message into the database.

Throws:
java.sql.SQLException
UnauthorizedException

saveToDb

protected void saveToDb()
Saves private message data to the database.


Jive Forums Project Page

Copyright © 1999-2006 Jive Software.