|
Jive Forums API (5.5.20.2-oracle) Developer Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jivesoftware.forum.database.DbForumMessage
public class DbForumMessage
Database implementation of the ForumMessage interface. It stores messages in the jiveMessage database table, and message properties in the jiveMessageProp table.
Messages are not inserted into the database until they are added to a thread. Therefore, it is best to set all properties of the message before adding it to a thread in order to avoid extra database operations.
The maximum body size (in bytes) is defined using the Jive property message.maxBodySize and has a default value of 524288. Any body larger than the max size will be truncated before it's saved to the database.
Field Summary | |
---|---|
protected java.lang.String |
filteredBody
|
protected java.lang.String |
filteredPlainBody
|
protected java.lang.String |
filteredPlainSubject
|
protected java.util.Map |
filteredProperties
|
protected java.lang.String |
filteredSubject
|
protected long |
forumID
|
protected int |
moderationValue
|
static java.lang.String |
PROP_CONTENT_TYPE
|
static java.lang.String |
PROP_EMAIL
|
static java.lang.String |
PROP_IP
|
static java.lang.String |
PROP_NAME
|
static java.lang.String |
PROP_SOURCE
|
static java.lang.String |
PROP_USER
|
static java.lang.String |
TEXT_HTML
|
protected long |
threadID
|
static java.lang.String |
UPDATE_FORUM_INDEX
|
Fields inherited from interface com.jivesoftware.forum.JiveContentObject |
---|
PLAIN_STRATEGY |
Constructor Summary | |
---|---|
|
DbForumMessage()
Constructor for internal use only. |
protected |
DbForumMessage(long messageID)
Loads the specified message by its message id. |
protected |
DbForumMessage(long forumID,
int forumIndex)
Loads the specified message by forumID and forum index. |
protected |
DbForumMessage(User user,
Forum forum)
Creates a new DbForumMessage object. |
Method Summary | |
---|---|
Attachment |
createAttachment(java.lang.String name,
java.lang.String contentType,
java.io.InputStream data)
Creates a new attachment for this message. |
void |
deleteAttachment(Attachment attachment)
Deletes an attachment that belongs to this 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 message has. |
java.util.Iterator |
getAttachments()
Returns an Iterator for all the attachments of this message. |
java.util.Iterator |
getAttachments(java.sql.Connection con)
|
java.lang.String |
getBody()
Returns the message body. |
int |
getCachedSize()
Returns the approximate size of the Object in bytes. |
java.util.Date |
getCreationDate()
Returns the date this message was created. |
static long |
getFilterExpiration()
Returns the time (in milliseconds) that filtered output can be cached before being expired. |
Forum |
getForum()
Returns the forum this message belongs to. |
int |
getForumIndex()
Returns the index of this message in the forum. |
ForumThread |
getForumThread()
Returns the thread this message belongs to. |
long |
getID()
Retrieve the unique identifier for the jive object. |
int |
getModerationValue()
Returns the number of moderation points this message has. |
java.util.Date |
getModificationDate()
Returns the date this message was last modified. |
int |
getObjectType()
Return the object type of the jive object. |
ForumMessage |
getParentMessage()
Returns the parent message of this message or null if this message is the root message of a thread. |
long |
getParentMessageID()
Returns the parent message of the message, or -1 if there is no parent message (when the message is the root message of the thread). |
java.lang.String |
getPlainBody()
Returns the message body with no html markup applied. |
java.lang.String |
getPlainSubject()
Returns the message subject with no html markup applied. |
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 message. |
java.util.Iterator |
getPropertyNames()
Returns an Iterator of String values for all the names of the message properties. |
protected int |
getRewardPoints()
Returns the number of reward points for the thread. |
java.lang.String |
getSubject()
Returns the message subject. |
TagDelegator |
getTagDelegator()
Retrieve a tag delegator to manage message tags. |
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 message, bypassing any filters. |
java.lang.String |
getUnfilteredSubject()
Returns the message subject, bypassing any active filters. |
User |
getUser()
Returns the User that authored this message. |
int |
hashCode()
|
protected void |
insertIntoDb(DbForumThread thread,
long parentMessageID,
java.sql.Connection con)
Inserts a new message into the database. |
boolean |
isAnonymous()
Returns true if this message was posted anonymously. |
boolean |
isAuthorized(long type)
Returns true if the handle on this object has the permission specified. |
boolean |
isHtml()
Returns true if this body of this message contains HTML. |
protected static void |
loadBulkFromDb(long forumID,
int startForumIndex,
int endForumIndex)
Bulk loads messages within a range of of forumIndex values. |
protected void |
moveMessage(DbForumThread newThread,
long parentMessageID,
java.sql.Connection con)
Moves an existing message and all of its children from an existing thread to a new thread. |
protected void |
prepareInsertIntoDb(DbForumThread thread)
Prepares the message to be inserted into the database. |
void |
readExternal(java.io.DataInput in)
|
void |
setBody(java.lang.String body)
Sets the body of this message. |
void |
setCreationDate(java.util.Date creationDate)
Sets the creation date of this message. |
static void |
setFilterExpiration(long filterExpiration)
Sets the time (in milleseconds) that filtered output can be cached before being expired. |
void |
setModerationValue(int value,
AuthToken authToken)
Sets the number of moderation points this message has. |
void |
setModificationDate(java.util.Date modificationDate)
Sets the date this message was last modified. |
protected void |
setModValue(int value,
AuthToken authToken)
|
void |
setProperty(java.lang.String name,
java.lang.String value)
Sets an extended property of this message. |
protected void |
setRewardPoints(int rewardPoints,
java.sql.Connection con)
Sets the number of reward points for the thread. |
void |
setSubject(java.lang.String subject)
Sets the subject of this message. |
void |
setUser(User user)
|
java.lang.String |
toString()
Returns a String representation of the message object using the subject. |
protected void |
updateModifiedDate(long date,
java.sql.Connection con)
Updates the modified date. |
void |
writeExternal(java.io.DataOutput out)
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String UPDATE_FORUM_INDEX
public static final java.lang.String PROP_CONTENT_TYPE
public static final java.lang.String PROP_NAME
public static final java.lang.String PROP_EMAIL
public static final java.lang.String PROP_IP
public static final java.lang.String PROP_USER
public static final java.lang.String PROP_SOURCE
public static final java.lang.String TEXT_HTML
protected long threadID
protected long forumID
protected int moderationValue
protected java.lang.String filteredSubject
protected java.lang.String filteredPlainSubject
protected java.lang.String filteredBody
protected java.lang.String filteredPlainBody
protected java.util.Map filteredProperties
Constructor Detail |
---|
protected DbForumMessage(User user, Forum forum)
user
- the user creating the message, or null if it's anonymousforum
- the forum the message is being created in.protected DbForumMessage(long messageID) throws ForumMessageNotFoundException
messageID
- the message ID.
ForumMessageNotFoundException
protected DbForumMessage(long forumID, int forumIndex) throws ForumMessageNotFoundException
forumID
- the forumID.forumIndex
- the forum index.
ForumMessageNotFoundException
public DbForumMessage()
Method Detail |
---|
public static long getFilterExpiration()
public static void setFilterExpiration(long filterExpiration)
filterExpiration
- the time (in milliseconds) that filtered output can be
cached, or -1 if it can be cached indefinitely.public long getID()
JiveObject
getID
in interface JiveObject
getID
in interface ForumMessage
public int getForumIndex()
ForumMessage
Once a forum index is assigned to a message, that value is never re-used. Therefore, there will be gaps in the forum index values as messages are deleted, archived, or moved.
Forum index values are primarily provided to support an NNTP-centric view of forums, since the NNTP protocol requires article numbers (forum indexes) inside a newsgroup (forum).
getForumIndex
in interface ForumMessage
public java.util.Date getCreationDate()
ForumMessage
getCreationDate
in interface ForumMessage
getCreationDate
in interface JiveContentObject
public void setCreationDate(java.util.Date creationDate)
ForumMessage
setCreationDate
in interface ForumMessage
creationDate
- the date this message was created.public java.util.Date getModificationDate()
ForumMessage
getModificationDate
in interface ForumMessage
getModificationDate
in interface JiveContentObject
public void setModificationDate(java.util.Date modificationDate)
ForumMessage
setModificationDate
in interface ForumMessage
modificationDate
- the date this message was modified.public java.lang.String getSubject()
ForumMessage
getSubject
in interface ForumMessage
getSubject
in interface JiveContentObject
public java.lang.String getPlainSubject()
ForumMessage
getPlainSubject
in interface ForumMessage
getPlainSubject
in interface JiveContentObject
public java.lang.String getUnfilteredSubject()
ForumMessage
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.
getUnfilteredSubject
in interface ForumMessage
getUnfilteredSubject
in interface JiveContentObject
public void setSubject(java.lang.String subject) throws MessageRejectedException
ForumMessage
setSubject
in interface ForumMessage
subject
- the subject of this message.
MessageRejectedException
- if an interceptor rejected the message.public java.lang.String getBody()
ForumMessage
getBody
in interface ForumMessage
getBody
in interface JiveContentObject
public java.lang.String getPlainBody()
ForumMessage
getPlainBody
in interface ForumMessage
getPlainBody
in interface JiveContentObject
public java.lang.String getUnfilteredBody()
ForumMessage
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.
getUnfilteredBody
in interface ForumMessage
getUnfilteredBody
in interface JiveContentObject
public void setBody(java.lang.String body) throws MessageRejectedException
ForumMessage
setBody
in interface ForumMessage
body
- the body of this message.
MessageRejectedException
- if an interceptor rejected the message.public User getUser()
ForumMessage
getUser
in interface ForumMessage
getUser
in interface JiveContentObject
public void setUser(User user)
public ForumMessage getParentMessage()
ForumMessage
TreeWalker
for similiar functionality.
getParentMessage
in interface ForumMessage
public Attachment createAttachment(java.lang.String name, java.lang.String contentType, java.io.InputStream data) throws java.lang.IllegalStateException, AttachmentException
ForumMessage
createAttachment
in interface ForumMessage
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.
AttachmentException
- if an error occured while creating the
attachment. Errors can occur because the attachment is too large or
because the message already has too many attachments.
java.lang.IllegalStateException
Attachment
,
AttachmentManager
public int getAttachmentCount()
ForumMessage
getAttachmentCount
in interface ForumMessage
public void deleteAttachment(Attachment attachment) throws AttachmentException
ForumMessage
deleteAttachment
in interface ForumMessage
attachment
- the attachment to delete.
AttachmentException
- if there was an error deleting the attachment.public java.util.Iterator getAttachments()
ForumMessage
getAttachments
in interface ForumMessage
Attachment
public java.util.Iterator getAttachments(java.sql.Connection con)
public int getModerationValue()
ForumMessage
Forum.getModerationDefaultMessageValue()
If the moderation value is less than JiveConstants.FORUM_MODERATION_VISIBLE
then the message will not be displayed by default.
getModerationValue
in interface ForumMessage
public void setModerationValue(int value, AuthToken authToken)
ForumMessage
JiveConstants.FORUM_MODERATION_VISIBLE
, then
a number of things will happen:When calling this method results in a message to go from below the minimum visible threshold to above, then the actions listed above will all be executed. Any change of the moderation value also results in the modified date of the message being updated.
Only administrators and moderators can call this method.
The authToken token of the user must be passed into this method as a paramater for moderation auditing purposes.
setModerationValue
in interface ForumMessage
value
- the number of moderation points for the message.authToken
- the AuthToken token of the user that is making the
moderation decision.Gateway
,
WatchManager
public java.lang.String getProperty(java.lang.String name)
ForumMessage
For security reasons, you should enable an HTML filter in case properties contain malicious HTML code.
getProperty
in interface ForumMessage
name
- the name of the property to get.
public java.lang.String getUnfilteredProperty(java.lang.String name)
ForumMessage
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.
getUnfilteredProperty
in interface ForumMessage
name
- the name of the property to get.
public java.util.Collection getProperties(java.lang.String parentName)
ForumMessage
getProperties
in interface ForumMessage
parentName
- the name of the parent property to return the children for.
public void setProperty(java.lang.String name, java.lang.String value)
ForumMessage
setProperty
in interface ForumMessage
name
- the name of the property to set.value
- the new value for the property.public void deleteProperty(java.lang.String name)
ForumMessage
name
does not exist, this method will do nothing.
deleteProperty
in interface ForumMessage
name
- the name of the property to delete.public java.util.Iterator getPropertyNames()
ForumMessage
getPropertyNames
in interface ForumMessage
public boolean isAnonymous()
ForumMessage
isAnonymous
in interface ForumMessage
public long getParentMessageID()
Note: the need for this method is fairly specialized. Normally, a TreeWalker
can be used to determine the parent of a message. However, certain code paths
such as NNTP needs very fast access to parent information through this method
without the potential of additional database selects.
TreeWalker.getParent(ForumMessage)
public ForumThread getForumThread()
ForumMessage
getForumThread
in interface ForumMessage
public Forum getForum()
ForumMessage
getForum
in interface ForumMessage
public boolean isAuthorized(long type)
ForumMessage
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.
isAuthorized
in interface ForumMessage
type
- permissionType a permission type.
ForumPermissions
public boolean isHtml()
ForumMessage
PROP_CONTENT_TYPE
extended property being set to
TEXT_HTML
.
isHtml
in interface ForumMessage
public TagDelegator getTagDelegator()
ForumMessage
getTagDelegator
in interface ForumMessage
public int getCachedSize()
Cacheable
getCachedSize
in interface Cacheable
public void readExternal(java.io.DataInput in) throws java.io.IOException
readExternal
in interface com.tangosol.io.ExternalizableLite
java.io.IOException
public void writeExternal(java.io.DataOutput out) throws java.io.IOException
writeExternal
in interface com.tangosol.io.ExternalizableLite
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
protected int getRewardPoints()
protected void setRewardPoints(int rewardPoints, java.sql.Connection con) throws java.sql.SQLException
java.sql.SQLException
protected void setModValue(int value, AuthToken authToken)
protected void moveMessage(DbForumThread newThread, long parentMessageID, java.sql.Connection con) throws java.sql.SQLException
newThread
- the new thread the message and its children will belong to.parentMessageID
- the new parent message ID of this message.con
- a database connection to use for SQL operations.
java.sql.SQLException
- if an error occurs.protected void updateModifiedDate(long date, java.sql.Connection con) throws java.sql.SQLException
java.sql.SQLException
protected static void loadBulkFromDb(long forumID, int startForumIndex, int endForumIndex)
forumID
- the ID of the forum to load messages from.startForumIndex
- the starting forumIndex value in the range of messages to load.endForumIndex
- the ending forumIndex value in the range of messages to load.protected void prepareInsertIntoDb(DbForumThread thread) throws java.sql.SQLException, UnauthorizedException
insertIntoDb(com.jivesoftware.forum.database.DbForumThread, long, java.sql.Connection)
method would require more than one open database connection
otherwise, which can lead to deadlocks.
thread
- the thread the message is being inserted into.
java.sql.SQLException
- if an error occurs.
UnauthorizedException
- if not allowed to call this method.protected void insertIntoDb(DbForumThread thread, long parentMessageID, java.sql.Connection con) throws java.sql.SQLException, UnauthorizedException
con
- an open Connection used to insert the message to the db.thread
- the ForumThread the message is being added to.
java.sql.SQLException
UnauthorizedException
public int getObjectType()
JiveObject
getObjectType
in interface JiveObject
|
Jive Forums Project Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |