Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.proxy
Class ForumThreadProxy

java.lang.Object
  extended by com.jivesoftware.forum.proxy.ForumThreadProxy
All Implemented Interfaces:
JiveObject, Watchable, ForumThread, JiveContentObject, Taggable

public class ForumThreadProxy
extends java.lang.Object
implements ForumThread

Protection proxy for ForumThread objects. It restricts access to protected methods by throwing UnauthorizedExceptions if the user does not have permission to access the class.


Field Summary
protected  Permissions permissions
           
 
Fields inherited from interface com.jivesoftware.forum.JiveContentObject
PLAIN_STRATEGY
 
Constructor Summary
ForumThreadProxy(ForumThread thread, AuthToken authToken, Permissions permissions)
          Creates a new proxy.
 
Method Summary
 void addMessage(ForumMessage parentMessage, ForumMessage newMessage)
          Adds a new message to this thread.
 void deleteMessage(ForumMessage message)
          Deletes a message in this thread.
 void deleteMessage(ForumMessage message, boolean deleteChildren)
          Deletes a message in this thread, optionally recusively deleting child messages.
 void deleteProperty(java.lang.String name)
          Deletes an extended property.
 boolean equals(java.lang.Object object)
           
 java.lang.String getBody()
          Return a summary of the jive object content.
 java.util.Date getCreationDate()
          Returns the date that this thread was created.
 Forum getForum()
          Returns the forum this thread belongs to.
 long getID()
          Retrieve the unique identifier for the jive object.
 ForumMessage getLatestMessage()
          Returns the most recently created messages in this thread.
 ForumMessage getMessage(long messageID)
          Returns a message from this thread based on its id.
 int getMessageCount()
          Returns the number of messages in the thread.
 int getMessageCount(ResultFilter resultFilter)
          Returns the number of messages in this thread based on the specified result filter.
 java.util.Iterator getMessages()
          Return an Iterator for all the messages in this thread.
 java.util.Iterator getMessages(ResultFilter resultFilter)
          Returns a Iterator for all the messages in the thread that match the criteria specified by the ResultFilter.
 int getModerationValue()
          Returns the number of moderation points this thread has.
 java.util.Date getModificationDate()
          Returns the date that this thread was last modified.
 java.lang.String getName()
          Returns the subject of the root message of this thread.
 int getObjectType()
          Return the object type of the jive object.
 java.lang.String getPlainBody()
          Returns the body of the jive object content with no markup applied.
 java.lang.String getPlainSubject()
          Returns the title of the jive object content with no 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 thread.
 java.util.Iterator getPropertyNames()
          Returns an Iterator for the names of this thread's properties.
 ForumThread getProxiedForumThread()
          Provides access to the underlying thread object.
 ForumMessage getRootMessage()
          Returns the root message this thread.
 java.lang.String getSubject()
          Return the title of the jive object content
 TagDelegator getTagDelegator()
          Retrieve a tag delegator to manage thread tags.
 TreeWalker getTreeWalker()
          Returns the TreeWalker for this thread.
 java.lang.String getUnfilteredBody()
          Returns the body, bypassing any active filters.
 java.lang.String getUnfilteredSubject()
          Returns the subject, bypassing any active filters.
 User getUser()
          Returns the user who authored of the jive object.
 int hashCode()
           
 boolean isAuthorized(long type)
          Returns true if the handle on the object has the permission specified.
 void setCreationDate(java.util.Date creationDate)
          Sets the creation date of this thread.
 void setModerationValue(int value, AuthToken authToken)
          Sets the number of moderation points this thread has.
 void setModificationDate(java.util.Date modificationDate)
          Sets the date this thread was last modified.
 void setProperty(java.lang.String name, java.lang.String value)
          Sets an extended property of this thread.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

permissions

protected Permissions permissions
Constructor Detail

ForumThreadProxy

public ForumThreadProxy(ForumThread thread,
                        AuthToken authToken,
                        Permissions permissions)
Creates a new proxy.

Method Detail

getID

public long getID()
Description copied from interface: JiveObject
Retrieve the unique identifier for the jive object.

Specified by:
getID in interface JiveObject
Specified by:
getID in interface ForumThread
Returns:
the unique identifier for the jive object.

getName

public java.lang.String getName()
Description copied from interface: ForumThread
Returns the subject of the root message of this thread. This is a convenience method equivalent to getRootMessage().getSubject().

Specified by:
getName in interface ForumThread
Returns:
the name of this thread, which is the subject of the root message.

getSubject

public java.lang.String getSubject()
Description copied from interface: JiveContentObject
Return the title of the jive object content

Specified by:
getSubject in interface JiveContentObject
Returns:
the title of the jive object content

getPlainSubject

public java.lang.String getPlainSubject()
Description copied from interface: JiveContentObject
Returns the title of the jive object content with no markup applied

Specified by:
getPlainSubject in interface JiveContentObject
Returns:
the title of the jive object content with no markup applied

getBody

public java.lang.String getBody()
Description copied from interface: JiveContentObject
Return a summary of the jive object content.

Specified by:
getBody in interface JiveContentObject
Returns:
a summary of the jive object content.

getPlainBody

public java.lang.String getPlainBody()
Description copied from interface: JiveContentObject
Returns the body of the jive object content with no markup applied. In the case of a document with a binary body the text returned will be the document summary.

Specified by:
getPlainBody in interface JiveContentObject
Returns:
the body of the jive object content with no markup applied

getUser

public User getUser()
Description copied from interface: JiveContentObject
Returns the user who authored of the jive object.

Specified by:
getUser in interface JiveContentObject
Returns:
the author of the jive object.

getUnfilteredSubject

public java.lang.String getUnfilteredSubject()
Description copied from interface: JiveContentObject
Returns the 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.

Specified by:
getUnfilteredSubject in interface JiveContentObject
Returns:
the unfiltered subject of the object.

getUnfilteredBody

public java.lang.String getUnfilteredBody()
Description copied from interface: JiveContentObject
Returns the 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.

Specified by:
getUnfilteredBody in interface JiveContentObject
Returns:
the unfiltered body of this object.

getCreationDate

public java.util.Date getCreationDate()
Description copied from interface: ForumThread
Returns the date that this thread was created.

Specified by:
getCreationDate in interface ForumThread
Specified by:
getCreationDate in interface JiveContentObject
Returns:
the date this thread was created.

getObjectType

public int getObjectType()
Description copied from interface: JiveObject
Return the object type of the jive object.

Specified by:
getObjectType in interface JiveObject
Returns:
the object type of the jive object.

setCreationDate

public void setCreationDate(java.util.Date creationDate)
                     throws UnauthorizedException
Description copied from interface: ForumThread
Sets the creation date of this thread. In most cases, the creation date will default to when the thread was entered into the system. However, the creation date needs to be set manually when importing data. In other words, skin authors should ignore this method since it only intended for system maintenance.

Specified by:
setCreationDate in interface ForumThread
Parameters:
creationDate - the date this thread was created.
Throws:
UnauthorizedException - if not an administrator.

getModificationDate

public java.util.Date getModificationDate()
Description copied from interface: ForumThread
Returns the date that this thread was last modified. In other words, the date of the most recent message in the thread.

Specified by:
getModificationDate in interface ForumThread
Specified by:
getModificationDate in interface JiveContentObject
Returns:
the date this thread was last modified.

setModificationDate

public void setModificationDate(java.util.Date modificationDate)
                         throws UnauthorizedException
Description copied from interface: ForumThread
Sets the date this thread was last modified. In most cases, last modifed will default to when the thread data was last changed. However, the last modified date needs to be set manually when importing data. In other words, skin authors should ignore this method since it only intended for system maintenance.

Specified by:
setModificationDate in interface ForumThread
Parameters:
modificationDate - the date this thread was modified.
Throws:
UnauthorizedException - if not an administrator.

getModerationValue

public int getModerationValue()
Description copied from interface: ForumThread
Returns the number of moderation points this thread has. The default moderation value is determined by the forum this thread belongs to: Forum.getModerationDefaultThreadValue()

If the moderation value is less than JiveConstants.FORUM_MODERATION_VISIBLE then the thread will not be displayed by default. Because a thread and its root message are intrinsically bound together, their moderation values are linked and are always the same. This means that setting the moderation value on the thread or setting the moderation value of a root message will always affect both objects.

Specified by:
getModerationValue in interface ForumThread
Returns:
the number of moderation points the thread has.

setModerationValue

public void setModerationValue(int value,
                               AuthToken authToken)
                        throws UnauthorizedException
Description copied from interface: ForumThread
Sets the number of moderation points this thread has. If the moderation value is less than JiveConstants.FORUM_MODERATION_VISIBLE then the thread will not be displayed by default. Because a thread and its root message must always go together, their moderation values are linked and are always the same. This means that setting the moderation value on the thread or setting the moderation value of a root message will always affect both objects.

The authToken token of the user must be passed into this method as a paramater for auditing purposes.

Specified by:
setModerationValue in interface ForumThread
Parameters:
value - the number of moderation points for this thread.
authToken - the AuthToken token of the user that is making the moderation decision.
Throws:
UnauthorizedException - if not a moderator or administrator.

getProperty

public java.lang.String getProperty(java.lang.String name)
Description copied from interface: ForumThread
Returns an extended property of this thread. Each thread can have an arbitrary number of extended properties. This allows for enhanced functionality that is not part of the base interface.

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

getProperties

public java.util.Collection getProperties(java.lang.String parentName)
Description copied from interface: ForumThread
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 ForumThread
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)
                 throws UnauthorizedException
Description copied from interface: ForumThread
Sets an extended property of this thread. Each thread can have an arbitrary number of extended properties. This allows for enhanced functionality that is not part of the base interface.

The user that created the thread (author of rootMessage), or system or forum admins can always call this method. Additionally, anyone (including anonymous users) can call this method before the thread has been added to a Forum.

Specified by:
setProperty in interface ForumThread
Parameters:
name - the name of the property to set.
value - the new value for the property.
Throws:
UnauthorizedException - if not allowed to set extended properties.

deleteProperty

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

The user that created the thread (author of rootMessage), or system or forum admins can always call this method. Additionally, anyone (including anonymous users) can call this method before the thread has been added to a Forum.

Specified by:
deleteProperty in interface ForumThread
Parameters:
name - the name of the property to delete.
Throws:
UnauthorizedException - if not allowed to delete extended properties.

getPropertyNames

public java.util.Iterator getPropertyNames()
Description copied from interface: ForumThread
Returns an Iterator for the names of this thread's properties.

Specified by:
getPropertyNames in interface ForumThread
Returns:
an Iterator for the names of this thread's properties.

getForum

public Forum getForum()
Description copied from interface: ForumThread
Returns the forum this thread belongs to.

Specified by:
getForum in interface ForumThread
Returns:
the forum this thread belongs to.

getMessageCount

public int getMessageCount()
Description copied from interface: ForumThread
Returns the number of messages in the thread. This includes the root message. So, to find the number of replies to the root message, subtract one from the answer of this method.

Specified by:
getMessageCount in interface ForumThread
Returns:
the number of messages in this thread.

getMessageCount

public int getMessageCount(ResultFilter resultFilter)
Description copied from interface: ForumThread
Returns the number of messages in this thread based on the specified result filter. This includes the root message. So, to find the number of replies to the root message, subtract one from the answer of this method.

Specified by:
getMessageCount in interface ForumThread
Parameters:
resultFilter - a filter to limit the message count query, such as date or moderation value range.
Returns:
the number of messages in this thread based on a ResultFilter.

getRootMessage

public ForumMessage getRootMessage()
Description copied from interface: ForumThread
Returns the root message this thread. The root message is a special first message that is intimately tied to the thread for most forumViews. All other messages in the thread are children of the root message.

Specified by:
getRootMessage in interface ForumThread
Returns:
the root message of this thread.

addMessage

public void addMessage(ForumMessage parentMessage,
                       ForumMessage newMessage)
                throws MessageRejectedException,
                       UnauthorizedException
Description copied from interface: ForumThread
Adds a new message to this thread. It is not legal to add a message to a thread before the thread has been added to a forum.

When a message is being added, it is first run through all message interceptors that are installed. Each interceptor has the option to reject the message by throwing a MessageRejectedException. For example, an interceptor might reject all messages coming from a certain IP.

Specified by:
addMessage in interface ForumThread
Parameters:
parentMessage - some message in this thread that will be parent.
newMessage - message to add to this thread under the parent.
Throws:
MessageRejectedException - if one of the installed interceptors prevents the message from being posted.
UnauthorizedException - if does not have CREATE_MESSAGE permissions.
See Also:
MessageInterceptor

deleteMessage

public void deleteMessage(ForumMessage message)
                   throws UnauthorizedException
Description copied from interface: ForumThread
Deletes a message in this thread. Deleting a message also deletes all of its children messages. The search index and other resources that referenced the message and its children will also be updated appropriately.

Specified by:
deleteMessage in interface ForumThread
Parameters:
message - the message to delete.
Throws:
UnauthorizedException - if does not have permission to delete messages.

deleteMessage

public void deleteMessage(ForumMessage message,
                          boolean deleteChildren)
                   throws UnauthorizedException
Description copied from interface: ForumThread
Deletes a message in this thread, optionally recusively deleting child messages. Passing in true to this method is equivalent to calling the ForumThread.deleteMessage(ForumMessage) method since it will recursively delete all child messages of the message. If deleteChildren is false, then child messages will not be deleted. Instead, they will be made children of the message's parent message. As an example, consider the following thread:
 A
 |-- B
     |-- C
     |-- D
         |-- E
 
If message B is deleted with deleteChildren set to true, then messages C, D, and E will also be deleted. If deleteChildren is set to false, then the new message structure will be:
 A
 |-- C
 |-- D
     |-- E
 
Note: because the root message has no parent messages, an IllegalArgumentException will thrown if message is the root message and deleteChildren is true.

Specified by:
deleteMessage in interface ForumThread
Parameters:
message - the message to delete.
deleteChildren - true if child messages should be deleted, false if child messages should be moved to be children of the message's parent.
Throws:
UnauthorizedException - if does not have permission to delete messages.

getMessage

public ForumMessage getMessage(long messageID)
                        throws ForumMessageNotFoundException
Description copied from interface: ForumThread
Returns a message from this thread based on its id.

Specified by:
getMessage in interface ForumThread
Parameters:
messageID - the ID of the message to get from this thread.
Throws:
ForumMessageNotFoundException

getLatestMessage

public ForumMessage getLatestMessage()
Description copied from interface: ForumThread
Returns the most recently created messages in this thread. This information could also be determined using a ResultFilter, but this method offers a simpler, more optimized way to access the data.

Specified by:
getLatestMessage in interface ForumThread
Returns:
the most recently created message in this thread.

getTreeWalker

public TreeWalker getTreeWalker()
Description copied from interface: ForumThread
Returns the TreeWalker for this thread. A TreeWalker is used to navigate through the tree of messages in a hierarchical manner.

Specified by:
getTreeWalker in interface ForumThread
Returns:
the tree walker for this thread.

getMessages

public java.util.Iterator getMessages()
Description copied from interface: ForumThread
Return an Iterator for all the messages in this thread.

Specified by:
getMessages in interface ForumThread
Returns:
an Iterator for all messages in this thread.

getMessages

public java.util.Iterator getMessages(ResultFilter resultFilter)
Description copied from interface: ForumThread
Returns a Iterator for all the messages in the thread that match the criteria specified by the ResultFilter.

Specified by:
getMessages in interface ForumThread
Parameters:
resultFilter - a ResultFilter object to perform filtering and sorting with.
Returns:
an Iterator for the messages in the thread that match the ResultFilter.

isAuthorized

public boolean isAuthorized(long type)
Description copied from interface: ForumThread
Returns true if the handle on the 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 ForumThread
Parameters:
type - a permission type.
Returns:
true if the handle on the object has the specified permission.
See Also:
ForumPermissions

getTagDelegator

public TagDelegator getTagDelegator()
Description copied from interface: ForumThread
Retrieve a tag delegator to manage thread tags. Attempting to retrieve a tag delegator prior to the thread being created will result in an IllegalStateArgument being thrown.

Specified by:
getTagDelegator in interface ForumThread
Returns:
a tag delegator to manage thread tags.

toString

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

equals

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

hashCode

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

getProxiedForumThread

public ForumThread getProxiedForumThread()
                                  throws UnauthorizedException
Provides access to the underlying thread object.

Throws:
UnauthorizedException

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.