Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.database
Class DbForumCategory

java.lang.Object
  extended by com.jivesoftware.forum.database.DbForumCategory
All Implemented Interfaces:
JiveObject, ContentRetrieval, ForumCategory, Cacheable, com.tangosol.io.ExternalizableLite, java.io.Serializable

public class DbForumCategory
extends java.lang.Object
implements ForumCategory, Cacheable, com.tangosol.io.ExternalizableLite

Database implementation of the ForumCategory interface. The SQL tree structure we use is Joe Celko's. For more information, see: http://searchdatabase.techtarget.com/tip/1,289483,sid13_gci537290,00.html.

The lft and rgt column values are responsible for defining the tree. An example tree with the lft and rgt column values (respectively) is as follows:

 

(1,12) / \ (2,3) (4,11) / | \ / | \ (5,6) (7,8) (9,10)

As you can see from the tree, the lft and rgt values of a child are always between the values of its parent. We can use this property to load the entire tree into memory using a single select. The simple way to determine the lft and rgt values of an arbitrary tree structure is to label lft then rgt by traversing the tree in depth-first order.

See Also:
Serialized Form

Field Summary
static boolean ENABLE_DATE_UPDATES
          When true, category modification dates will be updated when new messages are posted.
protected static java.lang.String FIND_FORUM_INDEX
           
protected static java.lang.String FORUM_IN_CATEGORY_COUNT
           
protected static java.lang.String SELECT_FORUMID_AND_INDEX_1
           
protected static java.lang.String SELECT_FORUMID_AND_INDEX_2
           
protected static java.lang.String SELECT_RECURSIVE_FORUMID
           
protected static java.lang.String SHIFT_CATEGORY_INDEX
           
 
Fields inherited from interface com.jivesoftware.forum.ContentRetrieval
ALL_TYPES, THREAD
 
Constructor Summary
  DbForumCategory()
          Constructor for internal use only.
  DbForumCategory(long id)
          Loads an existing category.
protected DbForumCategory(long id, java.sql.Connection con)
           
  DbForumCategory(java.lang.String name, java.lang.String description, DbForumCategory parentCategory)
          Creates a new category.
 
Method Summary
protected  void clearCache()
          Clears caches related to the object.
 ForumCategory createCategory(java.lang.String name, java.lang.String description)
          Creates a new ForumCategory as a sub-category of this category using the name and description.
 void deleteCategory(ForumCategory forumCategory)
          Deletes a sub-category.
 void deleteForum(Forum forum)
          Deletes a forum and all of its content.
 void deleteForum(Forum forum, boolean fireEvent)
           
protected  void deleteFromDb(java.sql.Connection con)
           
 void deleteProperty(java.lang.String name)
          Deletes an extended property.
 boolean equals(java.lang.Object object)
           
protected  void fireModificationEvent()
           
 int getCachedSize()
          Returns the approximate size of the Object in bytes.
 java.util.Iterator getCategories()
          Returns an Iterator for the child categories of this category.
 java.util.Iterator getCategories(int startIndex, int numResults)
          Returns an Iterator for the child categories of this category using a start index and the number of results to return.
 int getCategoryCount()
          Returns the number of sub-categories of this category.
 int getCategoryDepth()
          Returns the depth of a this category relative to the root.
 java.util.Iterator getCombinedContent(long[] types)
          Returns an Iterable for all threads, documents, and blog posts in the community, depending on which ContentTypes are supplied as an argument.
 java.util.Iterator getCombinedContent(ResultFilter filter, long[] types)
          Returns an Iterable for all threads, documents, and blog posts in the community, depending on which ContentTypes are supplied as an argument, and according the the supplied ResultFilter.
 int getCombinedContentCount(long[] contentTypes)
          Returns the combined number of threads, documents, and blog posts in the community, depending on which ContentTypes are supplied as an argument.
 int getCombinedContentCount(ResultFilter filter, long[] types)
          Returns the combined number of threads, documents, and blog posts in the community, depending on which ContentTypes are supplied as an argument, and restricted by the ResultFilter.
 java.util.Date getCreationDate()
          Returns the Date that the category was created.
 java.lang.String getDescription()
          Returns the description of the forum category.
 java.util.Locale getFinalLocale()
          Returns the locale for this category.
 int getForumCount()
          Returns the number of forums in the category.
 int getForumCount(ResultFilter resultFilter)
          Returns the number of forums in the category based on the specified ResultFilter.
protected  CachedPreparedStatement getForumListSQL(ResultFilter resultFilter, boolean countQuery, boolean recursiveQuery)
          Returns the SQL statement corresponding to a ResultFilter for threads.
 java.util.Iterator getForums()
          Returns an Iterator for all the forums in the category.
 java.util.Iterator getForums(ResultFilter resultFilter)
          Returns a Iterator for all the forums in the category that match the criteria specified by the ResultFilter.
 long getID()
          Retrieve the unique identifier for the jive object.
 InterceptorManager getInterceptorManager()
          Returns a message interceptor manager that can be used to manage interceptors for this category.
 ForumMessage getLatestMessage()
          Returns the most recently created or edited message in this category (including all sub-categories).
 java.util.Iterator getLatestMessages()
          Returns an Iterator for the most recently created or edited messages in this category (including all sub-categories).
static int[] getLftRgtValues(long categoryID)
          Returns the lft and rgt values for a category ID.
 java.util.Locale getLocale()
          Returns the locale for this category.
 int getMessageCount()
          Returns the number of messages in the community.
 int getMessageCount(ResultFilter resultFilter)
          Returns the number of messages in the community based on the specified ResultFilter.
protected  CachedPreparedStatement getMessageListSQL(ResultFilter resultFilter, boolean countQuery)
          Returns the SQL statement corresponding to a ResultFilter for messages.
 java.util.Iterator getMessages()
          Returns an Iterable for all the messages in the community.
 java.util.Iterator getMessages(ResultFilter resultFilter)
          Returns an Iterable for all the messages in the community that match the criteria specified by the ResultFilter.
 java.util.Date getModificationDate()
          Returns the Date this category was last modified.
 java.lang.String getName()
          Returns the name of the category.
 int getObjectType()
          Return the object type of the jive object.
 ForumCategory getParentCategory()
          Returns the parent category of this category.
protected  ForumCategory getParentCategory(java.sql.Connection con)
           
 Permissions getPermissions(AuthToken authToken)
          Returns the permissions for the category that correspond to the passed-in AuthToken.
 PermissionsManager getPermissionsManager()
          Returns a permissions manager that can be used to set permissions for this category.
 java.util.Iterator getPopularThreads()
          Returns an Iterator for the most popular threads in the category.
 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 the category.
 java.util.Iterator getPropertyNames()
          Returns an Iterator for the names of the forum category properties.
 java.util.Iterator getRecursiveCategories()
          Returns an Iterator for all sub-categories of this category, including sub-categories of sub-categories, etc.
 int getRecursiveCategoryCount()
          Returns the total count of all sub-categories of this category, including sub-categories of sub-categories, etc.
 int getRecursiveForumCount()
          Returns the number of forums in the category and all sub-categories.
 int getRecursiveForumCount(ResultFilter resultFilter)
          Returns the number of forums in the category and all sub-categories based on the specified ResultFilter.
 LongList getRecursiveForumIDs()
           
 java.util.Iterator getRecursiveForums()
          Returns an Iterator for all the forums in the category and all sub-categories.
 java.util.Iterator getRecursiveForums(ResultFilter resultFilter)
          Returns a Iterator for all the forums in the category and sub-categories that match the criteria specified by the ResultFilter.
 ForumRenderManager getRenderManager()
          Returns a render manager that can be used to manage render filters and macros for this category.
 java.util.Map getTags()
          Returns all tags for a given community in a Map where the key is the name of tag and the value is the number of times the tag has been used in this community.
 java.util.Map getTags(TagResultFilter resultFilter)
          Returns all tags for a given community in a Map where the key is the name of tag and the value is the number of times the tag has been used in this community filtered by the TagResultFilter.
 int getThreadCount()
          Returns the number of threads in the community.
 int getThreadCount(ResultFilter resultFilter)
          Returns the number of threads in the community based on the specified ResultFilter.
protected  CachedPreparedStatement getThreadListSQL(ResultFilter resultFilter, boolean countQuery)
          Returns the SQL statement corresponding to a ResultFilter for threads.
 java.util.Iterator getThreads()
          Returns an Iterable for all the threads in the community.
 java.util.Iterator getThreads(ResultFilter resultFilter)
          Returns an Iterable for all the threads in the community that match the criteria specified by the ResultFilter.
 int hashCode()
           
 boolean isAuthorized(long type)
          Returns true if the handle on the object has the permission specified.
 void moveCategory(ForumCategory category, ForumCategory destinationCategory)
          Moves a sub-category to another category.
 void moveForum(Forum forum, ForumCategory destinationCategory)
          Moves a forum from this category to another.
 void readExternal(java.io.DataInput in)
           
static void refreshCategoryTree(boolean startup)
          Loads the entire category tree into memory.
static void reset()
           
 void setCategoryIndex(ForumCategory category, int newIndex)
          Sets the display order of a sub-category.
 void setCreationDate(java.util.Date creationDate)
          Sets the creation date of the category.
 void setDescription(java.lang.String description)
          Sets the description of the forum category.
 void setForumIndex(Forum forum, int newIndex)
          Sets the index of the forum in the category.
 void setLocale(java.util.Locale locale)
          Sets the locale for this category.
 void setModificationDate(java.util.Date modificationDate)
          Sets the date the category was last modified.
 void setName(java.lang.String name)
          Sets the name of the forum category.
 void setProperties(java.util.Map propertyMap)
           
 void setProperty(java.lang.String name, java.lang.String value)
          Sets an extended property of the category.
 java.lang.String toString()
           
protected  void updateModifiedDate(long date, java.sql.Connection con)
          Updates the modified date of this category and all parent categories.
 void writeExternal(java.io.DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FIND_FORUM_INDEX

protected static final java.lang.String FIND_FORUM_INDEX
See Also:
Constant Field Values

FORUM_IN_CATEGORY_COUNT

protected static final java.lang.String FORUM_IN_CATEGORY_COUNT
See Also:
Constant Field Values

SELECT_RECURSIVE_FORUMID

protected static final java.lang.String SELECT_RECURSIVE_FORUMID
See Also:
Constant Field Values

SELECT_FORUMID_AND_INDEX_1

protected static final java.lang.String SELECT_FORUMID_AND_INDEX_1
See Also:
Constant Field Values

SELECT_FORUMID_AND_INDEX_2

protected static final java.lang.String SELECT_FORUMID_AND_INDEX_2
See Also:
Constant Field Values

SHIFT_CATEGORY_INDEX

protected static final java.lang.String SHIFT_CATEGORY_INDEX
See Also:
Constant Field Values

ENABLE_DATE_UPDATES

public static final boolean ENABLE_DATE_UPDATES
When true, category modification dates will be updated when new messages are posted. Updating the modification date can be a fairly expensive operation, especially when a cluster of servers is being used. The functionality may also not be important for some users. Therefore, this feature can be programatically enabled or disabled by setting category.enableDateUpdates to true or false.

Constructor Detail

DbForumCategory

public DbForumCategory(long id)
                throws ForumCategoryNotFoundException
Loads an existing category.

Parameters:
id - the ID of the category to load.
Throws:
ForumCategoryNotFoundException - if the category could not be loaded

DbForumCategory

protected DbForumCategory(long id,
                          java.sql.Connection con)
                   throws ForumCategoryNotFoundException
Throws:
ForumCategoryNotFoundException

DbForumCategory

public DbForumCategory(java.lang.String name,
                       java.lang.String description,
                       DbForumCategory parentCategory)
Creates a new category.

Parameters:
name - the name of the new category.
description - the description of the new category
parentCategory - the parent category of the new category

DbForumCategory

public DbForumCategory()
Constructor for internal use only.

Method Detail

reset

public static void reset()

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: JiveObject
Retrieve the unique identifier for the jive object.

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

getName

public java.lang.String getName()
Description copied from interface: ForumCategory
Returns the name of the category.

Specified by:
getName in interface ForumCategory
Returns:
the name of the category.

setName

public void setName(java.lang.String name)
Description copied from interface: ForumCategory
Sets the name of the forum category.

Specified by:
setName in interface ForumCategory
Parameters:
name - the name of the forum category.

getDescription

public java.lang.String getDescription()
Description copied from interface: ForumCategory
Returns the description of the forum category.

Specified by:
getDescription in interface ForumCategory
Returns:
the description of the forum category.

setDescription

public void setDescription(java.lang.String description)
Description copied from interface: ForumCategory
Sets the description of the forum category.

Specified by:
setDescription in interface ForumCategory
Parameters:
description - the description of the forum category.

getCreationDate

public java.util.Date getCreationDate()
Description copied from interface: ForumCategory
Returns the Date that the category was created.

Specified by:
getCreationDate in interface ForumCategory
Returns:
the Date the forum category was created.

setCreationDate

public void setCreationDate(java.util.Date creationDate)
Description copied from interface: ForumCategory
Sets the creation date of the category. In most cases, the creation date will default to when the category 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 ForumCategory
Parameters:
creationDate - the date the forum category was created.

getModificationDate

public java.util.Date getModificationDate()
Description copied from interface: ForumCategory
Returns the Date this category was last modified. In other words, the date of the most recent forum update in this category.

By default, this feature is

Specified by:
getModificationDate in interface ForumCategory
Returns:
the Date the forum was last modified.

setModificationDate

public void setModificationDate(java.util.Date modificationDate)
Description copied from interface: ForumCategory
Sets the date the category was last modified. In most cases, last modifed will default to when the category 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 ForumCategory
Parameters:
modificationDate - the date the forum was modified.

getLocale

public java.util.Locale getLocale()
Description copied from interface: ForumCategory
Returns the locale for this category. A locale specifies language and country codes, and is used for internationalization. If a locale has not been specified for this category, this method will return null. If you want to get the inherited locale for this category, you should call getFinalLocale().

Specified by:
getLocale in interface ForumCategory
Returns:
the locale for this category.

setLocale

public void setLocale(java.util.Locale locale)
               throws UnauthorizedException
Description copied from interface: ForumCategory
Sets the locale for this category. A locale specifies language and country codes, and is used for internationalization.

Specified by:
setLocale in interface ForumCategory
Parameters:
locale - the locale of this category.
Throws:
UnauthorizedException - if does not have admin permissions.

getFinalLocale

public java.util.Locale getFinalLocale()
Description copied from interface: ForumCategory
Returns the locale for this category. A locale specifies language and country codes, and is used for internationalization. If a locale has not been specified for this category, this method will return an inherited locale. A category will inherit the locale from it's chain of parent categories, if one exists. Otherwise it will inherit the default locale used by Jive. If you want to get the explicit locale for this category, you should call getLocale().

Specified by:
getFinalLocale in interface ForumCategory
Returns:
the final locale for this category.

getProperty

public java.lang.String getProperty(java.lang.String name)
Description copied from interface: ForumCategory
Returns an extended property of the category. Each category 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 ForumCategory
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: ForumCategory
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 ForumCategory
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: ForumCategory
Sets an extended property of the category. Each category can have an arbitrary number of extended properties. This allows for enhanced functionality that is not part of the base interface.

If the property referenced by name already exists, its value will be updated.

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

setProperties

public void setProperties(java.util.Map propertyMap)

deleteProperty

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

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

getPropertyNames

public java.util.Iterator getPropertyNames()
Description copied from interface: ForumCategory
Returns an Iterator for the names of the forum category properties.

Specified by:
getPropertyNames in interface ForumCategory
Returns:
an Iterator for the names of the forum category properties.

getForumCount

public int getForumCount()
Description copied from interface: ForumCategory
Returns the number of forums in the category. This number might not agree with the number of forums returned by ForumCategory.getForums() since that method only returns forums that a user has read permission for.

Specified by:
getForumCount in interface ForumCategory
Returns:
the number of forums in the category.

getForumCount

public int getForumCount(ResultFilter resultFilter)
Description copied from interface: ForumCategory
Returns the number of forums in the category based on the specified ResultFilter. This is useful for determining such things as the number of forums in a date range, etc. This number might not agree with the number of forums returned by ForumCategory.getForums() since that method only returns forums that a user has read permission for.

Specified by:
getForumCount in interface ForumCategory
Parameters:
resultFilter - a resultFilter to limit the query on.
Returns:
the number of forums in the category based on the filter.

getRecursiveForumCount

public int getRecursiveForumCount()
Description copied from interface: ForumCategory
Returns the number of forums in the category and all sub-categories. This number might not agree with the number of forums returned by ForumCategory.getRecursiveForums() since that method only returns forums that a user has read permission for.

Specified by:
getRecursiveForumCount in interface ForumCategory
Returns:
the number of forums in the category and sub-categories.

getRecursiveForumCount

public int getRecursiveForumCount(ResultFilter resultFilter)
Description copied from interface: ForumCategory
Returns the number of forums in the category and all sub-categories based on the specified ResultFilter. This is useful for determining such things as the number of forums in a date range, etc. This number might not agree with the number of forums returned by ForumCategory.getRecursiveForums() since that method only returns forums that a user has read permission for.

Specified by:
getRecursiveForumCount in interface ForumCategory
Parameters:
resultFilter - a resultFilter to limit the query on.
Returns:
the number of forums in the category and sub-categories based on the filter.

getForums

public java.util.Iterator getForums()
Description copied from interface: ForumCategory
Returns an Iterator for all the forums in the category. Forums will be sorted based on their category index.

Specified by:
getForums in interface ForumCategory
Returns:
an Iterator for all the forums in the category.

getForums

public java.util.Iterator getForums(ResultFilter resultFilter)
Description copied from interface: ForumCategory
Returns a Iterator for all the forums in the category that match the criteria specified by the ResultFilter.

Specified by:
getForums in interface ForumCategory
Parameters:
resultFilter - a ResultFilter object to perform filtering and sorting with.
Returns:
an Iterator for the forums in the category that match the ResultFilter.

getRecursiveForums

public java.util.Iterator getRecursiveForums()
Description copied from interface: ForumCategory
Returns an Iterator for all the forums in the category and all sub-categories. The ordering of forums in unspecified.

Specified by:
getRecursiveForums in interface ForumCategory
Returns:
an Iterator for all the forums in the category and sub-categories.

getRecursiveForums

public java.util.Iterator getRecursiveForums(ResultFilter resultFilter)
Description copied from interface: ForumCategory
Returns a Iterator for all the forums in the category and sub-categories that match the criteria specified by the ResultFilter. Note that attempting to sort the forums on their category index will have strange results.

Specified by:
getRecursiveForums in interface ForumCategory
Parameters:
resultFilter - a ResultFilter object to perform filtering and sorting with.
Returns:
an Iterator for the forums in the category and sub-categories that match the ResultFilter.

getRecursiveForumIDs

public LongList getRecursiveForumIDs()

setForumIndex

public void setForumIndex(Forum forum,
                          int newIndex)
Description copied from interface: ForumCategory
Sets the index of the forum in the category. The index value can be used to display the forums in a category in an arbitrary order. Index values are from 0 to getForumCount() - 1.

Specified by:
setForumIndex in interface ForumCategory
Parameters:
forum - the forum to adjust the index of.
newIndex - the new index value for the forum.

moveForum

public void moveForum(Forum forum,
                      ForumCategory destinationCategory)
Description copied from interface: ForumCategory
Moves a forum from this category to another.

Specified by:
moveForum in interface ForumCategory
Parameters:
forum - the forum to move.
destinationCategory - the category to move the forum to.

getParentCategory

public ForumCategory getParentCategory()
Description copied from interface: ForumCategory
Returns the parent category of this category. This method will return null if the current category is the root category.

Specified by:
getParentCategory in interface ForumCategory
Returns:
the parent category of this category.

getParentCategory

protected ForumCategory getParentCategory(java.sql.Connection con)

getCategoryCount

public int getCategoryCount()
Description copied from interface: ForumCategory
Returns the number of sub-categories of this category.

Specified by:
getCategoryCount in interface ForumCategory
Returns:
the number of sub-categories in this category.

getCategories

public java.util.Iterator getCategories()
Description copied from interface: ForumCategory
Returns an Iterator for the child categories of this category.

Specified by:
getCategories in interface ForumCategory
Returns:
the child categories of this category.

getCategories

public java.util.Iterator getCategories(int startIndex,
                                        int numResults)
Description copied from interface: ForumCategory
Returns an Iterator for the child categories of this category using a start index and the number of results to return. This method can be used to perform pagination of results. Note: the number of results returned may be less than numResults depending on the data that's actually available to return.

Specified by:
getCategories in interface ForumCategory
Parameters:
startIndex - the index of the first result to return.
numResults - the max number of results to return.
Returns:
an Iterator for the child categories of this category.

getRecursiveCategoryCount

public int getRecursiveCategoryCount()
Description copied from interface: ForumCategory
Returns the total count of all sub-categories of this category, including sub-categories of sub-categories, etc.

Specified by:
getRecursiveCategoryCount in interface ForumCategory
Returns:
the recursive sub-category count of this category.

getRecursiveCategories

public java.util.Iterator getRecursiveCategories()
Description copied from interface: ForumCategory
Returns an Iterator for all sub-categories of this category, including sub-categories of sub-categories, etc.

Specified by:
getRecursiveCategories in interface ForumCategory
Returns:
an Iterator for the recursive sub-categories of this category.

getCategoryDepth

public int getCategoryDepth()
Description copied from interface: ForumCategory
Returns the depth of a this category relative to the root. For example, consider the following tree (where 1 is the root category):
   1
   |-- 3
   |-- |-- 4
   |-- |-- |-- 7
 
The depth of message 4 is 2, the depth of category 7 is 3, etc. This method is useful in combination with the ForumCategory.getRecursiveCategories() Iterator to build a UI of hierarchical categories.

Specified by:
getCategoryDepth in interface ForumCategory
Returns:
the depth of the category in the category tree.

setCategoryIndex

public void setCategoryIndex(ForumCategory category,
                             int newIndex)
Description copied from interface: ForumCategory
Sets the display order of a sub-category. For example, if a sub-category has an index of 0, then it will returned first in the Iterator resulting from the categories method call.

Specified by:
setCategoryIndex in interface ForumCategory
Parameters:
category - the sub category to set the index for
newIndex - the new index of the sub category

moveCategory

public void moveCategory(ForumCategory category,
                         ForumCategory destinationCategory)
Description copied from interface: ForumCategory
Moves a sub-category to another category. You cannot move a category into a child category. For example, take the following category tree:
   1
   |-- 3
   |-- |-- 4
   |-- |-- |-- 7
 
Moving 3 to be a child of 7 is not allowed, since that breaks the tree structure.

Specified by:
moveCategory in interface ForumCategory
Parameters:
category - the ForumCategory to move.
destinationCategory - the category to move the sub-category to.

createCategory

public ForumCategory createCategory(java.lang.String name,
                                    java.lang.String description)
Description copied from interface: ForumCategory
Creates a new ForumCategory as a sub-category of this category using the name and description.

Specified by:
createCategory in interface ForumCategory
Parameters:
name - the name of the new category.
description - the description of the new category.
Returns:
a new ForumCategory.

deleteCategory

public void deleteCategory(ForumCategory forumCategory)
Description copied from interface: ForumCategory
Deletes a sub-category. Only direct children of this category can be deleted using this method. Attempting to delete a category that is not a direct child will throw an IllegalArgumentException.

Specified by:
deleteCategory in interface ForumCategory
Parameters:
forumCategory - the ForumCategory to delete.

deleteForum

public void deleteForum(Forum forum)
                 throws UnauthorizedException
Description copied from interface: ForumCategory
Deletes a forum and all of its content. The forum must belong to this category or to a sub-category.

This method is not always guaranteed to be safe to call. For example, if multiple clients have handles on a forum, and that forum is subsequently deleted, the behavior of the forum objects that the clients have handles on is unspecified and may result in errors.

Specified by:
deleteForum in interface ForumCategory
Parameters:
forum - the forum to delete.
Throws:
UnauthorizedException - if not allowed to delete a forum.

deleteForum

public void deleteForum(Forum forum,
                        boolean fireEvent)
                 throws UnauthorizedException
Throws:
UnauthorizedException

getPopularThreads

public java.util.Iterator getPopularThreads()
Description copied from interface: ForumCategory
Returns an Iterator for the most popular threads in the category. Popular threads are defined as those that have the most new messages over a period of time (e.g. the last 24 hours). When two threads have identical numbers of new messages, newer threads will be ordered first.

A number of configurable Jive properties control how the popular threads feature works:

Specified by:
getPopularThreads in interface ForumCategory
Returns:
an Iterator for the most popular threads in the category.

getThreads

public java.util.Iterator getThreads()
Description copied from interface: ContentRetrieval
Returns an Iterable for all the threads in the community. Threads will be sorted on their modified date.

Specified by:
getThreads in interface ContentRetrieval
Specified by:
getThreads in interface ForumCategory
Returns:
an Iterable for the threads in the community.

getThreads

public java.util.Iterator getThreads(ResultFilter resultFilter)
Description copied from interface: ContentRetrieval
Returns an Iterable for all the threads in the community that match the criteria specified by the ResultFilter.

Specified by:
getThreads in interface ContentRetrieval
Specified by:
getThreads in interface ForumCategory
Parameters:
resultFilter - a ResultFilter object to perform filtering and sorting with.
Returns:
an Iterable for the threads in the community that match the ResultFilter.

getMessages

public java.util.Iterator getMessages()
Description copied from interface: ContentRetrieval
Returns an Iterable for all the messages in the community.

Specified by:
getMessages in interface ContentRetrieval
Specified by:
getMessages in interface ForumCategory
Returns:
an Iterable for the messages in the community.

getMessages

public java.util.Iterator getMessages(ResultFilter resultFilter)
Description copied from interface: ContentRetrieval
Returns an Iterable for all the messages in the community that match the criteria specified by the ResultFilter.

Specified by:
getMessages in interface ContentRetrieval
Specified by:
getMessages in interface ForumCategory
Parameters:
resultFilter - a ResultFilter object to perform filtering and sorting with.
Returns:
an Iterable for the messages in the community that match the ResultFilter.

getThreadCount

public int getThreadCount()
Description copied from interface: ContentRetrieval
Returns the number of threads in the community. Note: this method ignores permissions because it's not possible to do a database query for the count that obeys permissions counts. Therefore, the count returned by this method may not be the same as the number of threads returned by the ContentRetrieval.getThreads() method.

Specified by:
getThreadCount in interface ContentRetrieval
Specified by:
getThreadCount in interface ForumCategory
Returns:
the number of threads in the community.

getThreadCount

public int getThreadCount(ResultFilter resultFilter)
Description copied from interface: ContentRetrieval
Returns the number of threads in the community based on the specified ResultFilter. This is useful for determining such things as the number of threads in a date range, etc. Note: this method ignores permissions because it's not possible to do a database query for the count that obeys permissions counts. Therefore, the count returned by this method may not be the same as the number of threads returned by the ContentRetrieval.getThreads(com.jivesoftware.forum.ResultFilter) method.

Specified by:
getThreadCount in interface ContentRetrieval
Specified by:
getThreadCount in interface ForumCategory
Parameters:
resultFilter - a resultFilter to limit the query on.
Returns:
the number of threads in the community based on the filter.

getMessageCount

public int getMessageCount()
Description copied from interface: ContentRetrieval
Returns the number of messages in the community. Note: this method ignores permissions because it's not possible to do a database query for the count that obeys permissions counts. Therefore, the count returned by this method may not be the same as the number of messages returned by the ContentRetrieval.getMessages() method.

Specified by:
getMessageCount in interface ContentRetrieval
Specified by:
getMessageCount in interface ForumCategory
Returns:
the number of messages in the community.

getMessageCount

public int getMessageCount(ResultFilter resultFilter)
Description copied from interface: ContentRetrieval
Returns the number of messages in the community based on the specified ResultFilter. This is useful for determining such things as the number of messages in a date range, etc. Note: this method ignores permissions because it's not possible to do a database query for the count that obeys permissions counts. Therefore, the count returned by this method may not be the same as the number of messages returned by the ContentRetrieval.getMessages(ResultFilter) method.

Specified by:
getMessageCount in interface ContentRetrieval
Specified by:
getMessageCount in interface ForumCategory
Parameters:
resultFilter - a resultFilter to limit the query on.
Returns:
the number of messages in the community based on the filter.

getLatestMessage

public ForumMessage getLatestMessage()
Description copied from interface: ForumCategory
Returns the most recently created or edited message in this category (including all sub-categories). If there are no messages in this category, this method will return null. 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 ForumCategory
Returns:
the most recently created or edited message in this category.

getLatestMessages

public java.util.Iterator getLatestMessages()
Description copied from interface: ForumCategory
Returns an Iterator for the most recently created or edited messages in this category (including all sub-categories). If there are no messages in this category, this method will return null.

Specified by:
getLatestMessages in interface ForumCategory
Returns:
the most recently created or edited messages in this category.

getPermissionsManager

public PermissionsManager getPermissionsManager()
Description copied from interface: ForumCategory
Returns a permissions manager that can be used to set permissions for this category. Only admins can perform this function.

Specified by:
getPermissionsManager in interface ForumCategory
Returns:
a PermissionsManager to manage the permissions on this forum.

getInterceptorManager

public InterceptorManager getInterceptorManager()
Description copied from interface: ForumCategory
Returns a message interceptor manager that can be used to manage interceptors for this category.

Specified by:
getInterceptorManager in interface ForumCategory
Returns:
a InterceptorManager to manage interceptors.

getRenderManager

public ForumRenderManager getRenderManager()
Description copied from interface: ForumCategory
Returns a render manager that can be used to manage render filters and macros for this category. Render filter management is only for administrators, excluding the RenderManager.render(Object, com.jivesoftware.forum.renderer.RenderType, String) and RenderManager.render(Object, com.jivesoftware.forum.renderer.RenderType, com.jivesoftware.forum.renderer.RenderStrategy, String) methods, which may be useful to skin writers.

Specified by:
getRenderManager in interface ForumCategory
Returns:
a RenderManager to manage render filters and macros for this category.
See Also:
RenderManager

getPermissions

public Permissions getPermissions(AuthToken authToken)
Description copied from interface: ForumCategory
Returns the permissions for the category that correspond to the passed-in AuthToken. This method is not generally useful to skin writers. Instead, the isAuthorized(int) method should be used for permission checking.

Specified by:
getPermissions in interface ForumCategory
Parameters:
authToken - the auth token to lookup permissions for.
Returns:
the permissions for the category that correspond to the passed-in AuthToken

isAuthorized

public boolean isAuthorized(long type)
Description copied from interface: ForumCategory
Returns true if the handle on the object has the permission specified. For example, if a category administrator has a handle on this object, then calling isAuthorized(ForumPermissions.FORUM_CATEGORY_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 ForumCategory
Parameters:
type - permissionType a permission type.
Returns:
true if the handle on the object has the specified permission.
See Also:
ForumPermissions

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.

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

clearCache

protected void clearCache()
Clears caches related to the object.


getThreadListSQL

protected CachedPreparedStatement getThreadListSQL(ResultFilter resultFilter,
                                                   boolean countQuery)
Returns the SQL statement corresponding to a ResultFilter for threads.


getMessageListSQL

protected CachedPreparedStatement getMessageListSQL(ResultFilter resultFilter,
                                                    boolean countQuery)
Returns the SQL statement corresponding to a ResultFilter for messages.


refreshCategoryTree

public static void refreshCategoryTree(boolean startup)
Loads the entire category tree into memory.

Parameters:
startup - true if the category refresh operation is being called when the instance is first being initialized. In that case, only database loads are performed and no cache clears are done since those might interfere with other cluster members.

updateModifiedDate

protected void updateModifiedDate(long date,
                                  java.sql.Connection con)
                           throws java.sql.SQLException
Updates the modified date of this category and all parent categories. It accepts a Connection so that it can participate in trasactions.

Throws:
java.sql.SQLException

getForumListSQL

protected CachedPreparedStatement getForumListSQL(ResultFilter resultFilter,
                                                  boolean countQuery,
                                                  boolean recursiveQuery)
Returns the SQL statement corresponding to a ResultFilter for threads.

Parameters:
resultFilter - the result filter to build the SQL from.
countQuery - true if this should be a count query.
recursiveQuery - if forums from all sub-categories should be in the results.

getLftRgtValues

public static int[] getLftRgtValues(long categoryID)
Returns the lft and rgt values for a category ID.

Parameters:
categoryID - the category ID.
Returns:
the lft and rgt values as an array of two int values.

deleteFromDb

protected void deleteFromDb(java.sql.Connection con)
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

getTags

public java.util.Map getTags()
Description copied from interface: ForumCategory
Returns all tags for a given community in a Map where the key is the name of tag and the value is the number of times the tag has been used in this community.

Specified by:
getTags in interface ForumCategory
Returns:
all tags for a given community in a Map where the key is the name of tag and the value is the number of times the tag has been used in this community.

getTags

public java.util.Map getTags(TagResultFilter resultFilter)
Description copied from interface: ForumCategory
Returns all tags for a given community in a Map where the key is the name of tag and the value is the number of times the tag has been used in this community filtered by the TagResultFilter.

Specified by:
getTags in interface ForumCategory
Parameters:
resultFilter - the filter to use to restrict tag results
Returns:
all tags for a given community in a Map where the key is the name of tag and the value is the number of times the tag has been used in this community filtered by the TagResultFilter.

getCombinedContentCount

public int getCombinedContentCount(long[] contentTypes)
Description copied from interface: ContentRetrieval
Returns the combined number of threads, documents, and blog posts in the community, depending on which ContentTypes are supplied as an argument. Note: this method ignores permissions because it's not possible to do a database query for the count that obeys permissions counts. Therefore, the count returned by this method may not be the same as the number of conten objects returned by the ContentRetrieval.getCombinedContent(long[]) method.

Specified by:
getCombinedContentCount in interface ContentRetrieval
Parameters:
contentTypes - the ContentTypes to include in the count.
Returns:
combined number of threads, documents, and blog posts in the community.

getCombinedContentCount

public int getCombinedContentCount(ResultFilter filter,
                                   long[] types)
Description copied from interface: ContentRetrieval
Returns the combined number of threads, documents, and blog posts in the community, depending on which ContentTypes are supplied as an argument, and restricted by the ResultFilter. Note: this method ignores permissions because it's not possible to do a database query for the count that obeys permissions counts. Therefore, the count returned by this method may not be the same as the number of conten objects returned by the ContentRetrieval.getCombinedContent(ResultFilter, long[]) method.

Specified by:
getCombinedContentCount in interface ContentRetrieval
Parameters:
filter - the ResultFilter to filter the results.
types - the ContentTypes to include in the count.
Returns:
combined number of threads, documents, and blog posts in the community.

getCombinedContent

public java.util.Iterator getCombinedContent(long[] types)
Description copied from interface: ContentRetrieval
Returns an Iterable for all threads, documents, and blog posts in the community, depending on which ContentTypes are supplied as an argument. The results will be sorted by descending modification date.

Specified by:
getCombinedContent in interface ContentRetrieval
Parameters:
types - the ContentTypes to include in the result.
Returns:
an Iterable for the threads, documents, and blog posts in the community.

getCombinedContent

public java.util.Iterator getCombinedContent(ResultFilter filter,
                                             long[] types)
Description copied from interface: ContentRetrieval
Returns an Iterable for all threads, documents, and blog posts in the community, depending on which ContentTypes are supplied as an argument, and according the the supplied ResultFilter.

Specified by:
getCombinedContent in interface ContentRetrieval
Parameters:
filter - the ResultFilter to filter and sort the results.
types - the ContentTypes to include in the result.
Returns:
an Iterable for the threads, documents, and blog posts in the community.

fireModificationEvent

protected void fireModificationEvent()

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.