Compoze Software, Inc.

com.compoze.discussion
Class Topic

java.lang.Object
  |
  +--com.compoze.discussion.Topic
All Implemented Interfaces:
java.io.Serializable

public class Topic
extends java.lang.Object
implements java.io.Serializable

This class represents a topic. Topics are grouped under a forum.

To add and search for topic, see the Topics collection class available from a Forum. Once the topic is obtained, its accessor methods may be called to set and get properties. The update() method must be called to store any changes to the server.

The following table contains the mappings from Topic properties to their corresponding Java methods:

Topic Property Java Methods
TopicProperty.APPROVAL_STATUS getApprovalStatus()
TopicProperty.AUTHOR getAuthor()
TopicProperty.CONTENT_TYPE getContentType()
TopicProperty.DATE_CREATED getDateCreated()
TopicProperty.DATE_LAST_MODIFIED getDateLastModified()
TopicProperty.DESCRIPTION getDescription()
TopicProperty.EXPIRATION_DATE getExpiration()
hasExpiration()
clearExpiration()
TopicProperty.FILE_ATTACHMENT_COUNT getFileAttachmentCount()
TopicProperty.KEYWORDS getKeywords()
TopicProperty.MASK_AUTHOR getMaskAuthor()
TopicProperty.MESSAGE_COUNT getMessageCount()
TopicProperty.SUBJECT getSubject()
TopicProperty.CUSTOM_NUM1 getCustomNum1()
TopicProperty.CUSTOM_NUM2 getCustomNum2()
TopicProperty.CUSTOM_NUM3 getCustomNum3()
TopicProperty.CUSTOM_NUM4 getCustomNum4()
TopicProperty.CUSTOM_STR1 getCustomStr1()
TopicProperty.CUSTOM_STR2 getCustomStr2()
TopicProperty.CUSTOM_STR3 getCustomStr3()
TopicProperty.CUSTOM_STR4 getCustomStr4()

See Also:
Serialized Form

Field Summary
protected  int m_iMessageCount
           
 
Constructor Summary
Topic()
          Constructor.
 
Method Summary
 FileAttachment addFileAttachment(java.lang.String sFilename, java.io.InputStream io)
          Adds the file attachment to this topic.
 void clearExpiration()
          Clears the expiration date for this topic.
 void delete()
          Deletes the topic.
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this one.
 ApprovalStatus getApprovalStatus()
          Gets the approval status of the topic.
 java.lang.String getAuthor()
          Gets the name of the author.
 java.lang.String getContentType()
          Gets the content type of the topic description.
 long getCustomNum1()
          Gets the custom number1 field of the topic.
 long getCustomNum2()
          Gets the custom number2 field of the topic.
 long getCustomNum3()
          Gets the custom number3 field of the topic.
 long getCustomNum4()
          Gets the custom number4 field of the topic.
 java.lang.String getCustomStr1()
          Gets the custom string1 field of the topic.
 java.lang.String getCustomStr2()
          Gets the custom string2 field of the topic.
 java.lang.String getCustomStr3()
          Gets the custom string3 field of the topic.
 java.lang.String getCustomStr4()
          Gets the custom string4 field of the topic.
 java.util.Date getDateCreated()
          Gets the date the topic was created.
 java.util.Date getDateLastModified()
          Gets the date the topic was last modified.
 java.lang.String getDescription()
          Gets the description of the topic.
 java.lang.String getDescription(int iLength)
          Gets the description of the topic.
 java.util.Date getExpiration()
          Gets the expiration date of this topic, if on exists.
 FileAttachment getFileAttachment(long lAttachmentID)
          Gets the file attachment by the specified id.
 int getFileAttachmentCount()
          Gets the number of files associated with this topic.
 java.util.List getFileAttachments()
          Gets a list of file attachments for this topic.
 Forum getForum()
          Gets the forum this topic is associated with.
 long getForumID()
          Gets the forum id this topic is associated with.
 long getID()
          Gets the unique identifier (id) of the topic.
 java.lang.String getKeywords()
          Gets the keywords associated with this topic.
 boolean getMaskAuthor()
          Gets the mask author setting.
 int getMessageCount()
          Gets the number of messages associated with the topics under this topic.
 Messages getMessages()
          Gets the messages associated with this topic.
 java.lang.String getSubject()
          Gets the subject of the topic.
 java.lang.String getSubject(int iLength)
          Gets the subject of the topic.
 java.lang.String getUnmaskedAuthor()
          Gets the name of the author without a mask.
 boolean hasExpiration()
          Checks if this topic has an expiration.
 boolean hasFileAttachment()
          Checks if the topic has any file attachments.
 boolean isAuthor()
          Checks if this user is the author of the topic.
 boolean isExpired()
          Checks if this topic is expired.
 boolean isModified()
          Checks if this topic has been modified since the user's last login.
 boolean isSubscriber()
          Checks if the authenticated user is a subscriber to the topic.
 boolean isSubscriber(User user)
          Checks if the specified user is a subscriber to the topic.
 void removeFileAttachment(long lAttachmentID)
          Removes the file attachment by the specified id.
 void setApprovalStatus(ApprovalStatus status)
          Sets the approval status of the topic.
 void setContentType(java.lang.String sContentType)
          Sets the content type of the topic description.
 void setCustomNum1(long lCustomNum1)
          Sets the custom number1 field of the topic.
 void setCustomNum2(long lCustomNum2)
          Sets the custom number2 field of the topic.
 void setCustomNum3(long lCustomNum3)
          Sets the custom number3 field of the topic.
 void setCustomNum4(long lCustomNum4)
          Sets the custom number4 field of the topic.
 void setCustomStr1(java.lang.String sCustomStr1)
          Sets the custom string1 field of the topic.
 void setCustomStr2(java.lang.String sCustomStr2)
          Sets the custom string2 field of the topic.
 void setCustomStr3(java.lang.String sCustomStr3)
          Sets the custom string3 field of the topic.
 void setCustomStr4(java.lang.String sCustomStr4)
          Sets the custom string4 field of the topic.
 void setDescription(java.lang.String sDescription)
          Sets the description of the topic.
 void setExpiration(java.util.Date expirationDate)
          Sets the expiration date for this topic.
 void setKeywords(java.lang.String sKeywords)
          Sets the keywords associated with this topic.
 void setKeywords(java.lang.String[] keywords)
          Sets the keywords associated with this topic.
 void setMaskAuthor(boolean bMaskAuthor)
          Sets the mask author setting.
 void setSubject(java.lang.String sSubject)
          Sets the subject of the topic.
 boolean subscribe()
          Subscribes the user to this topic.
 java.util.List subscribers()
          Gets a list subscribers for this topic.
 java.lang.String toString()
          Returns a string representation of the object.
 boolean unsubscribe()
          Unsubscribes the user to this topic.
 boolean update()
          Updates the topic (saves the topic entry).
 boolean update(boolean bForce)
          Updates the topic (saves the topic entry).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_iMessageCount

protected int m_iMessageCount
Constructor Detail

Topic

public Topic()
Constructor.
Method Detail

getID

public long getID()
Gets the unique identifier (id) of the topic. This is non-zero number that uniquely identifies the topic.
Returns:
the id of the topic

getForumID

public long getForumID()
Gets the forum id this topic is associated with.
Returns:
the forum id

getForum

public Forum getForum()
Gets the forum this topic is associated with.
Returns:
the forum

getMessages

public Messages getMessages()
Gets the messages associated with this topic.
Returns:
the messages

getAuthor

public java.lang.String getAuthor()
Gets the name of the author. The author is the name of the user who originally created this forum. If the mask author setting is true, the author name will be masked as '*' characters.
Returns:
the author name
See Also:
getMaskAuthor()

getUnmaskedAuthor

public java.lang.String getUnmaskedAuthor()
                                   throws java.security.AccessControlException
Gets the name of the author without a mask. This method returns the author name without a mask if the mask author flag is set. This method will thrown an exception if the caller is not a moderator.
Returns:
the unmasked author name
Throws:
java.security.AccessControlException - occurs if the caller does not have MODERATOR permission
See Also:
getMaskAuthor()

getMaskAuthor

public boolean getMaskAuthor()
Gets the mask author setting.
Returns:
true to mask the author; false otherwise

setMaskAuthor

public void setMaskAuthor(boolean bMaskAuthor)
                   throws java.security.AccessControlException
Sets the mask author setting.
Parameters:
bMaskAuthor - true to mask the author; false otherwise
Throws:
java.security.AccessControlException - occurs if an attempt is made to set the mask author by a user without MODERATOR permission

isAuthor

public boolean isAuthor()
Checks if this user is the author of the topic.
Returns:
true if this user is the author; false otherwise

getApprovalStatus

public ApprovalStatus getApprovalStatus()
Gets the approval status of the topic.
Returns:
the approval status

setApprovalStatus

public void setApprovalStatus(ApprovalStatus status)
                       throws java.security.AccessControlException
Sets the approval status of the topic.
Parameters:
status - the approval status (may not be null)
Throws:
java.security.AccessControlException - occurs if an attempt is made to set the approval status by a user without MODERATOR permission

getSubject

public java.lang.String getSubject()
Gets the subject of the topic.
Returns:
the subject of the topic or null if no subject is set

getSubject

public java.lang.String getSubject(int iLength)
Gets the subject of the topic. The subject is truncated after the specified number of characters and "..." is appended to it.
Parameters:
iLength - the maximum length of the result (string plus "...")
Returns:
the truncated subject of the topic

setSubject

public void setSubject(java.lang.String sSubject)
Sets the subject of the topic.
Parameters:
sSubject - the subject of the topic or null for no subject

hasExpiration

public boolean hasExpiration()
Checks if this topic has an expiration. After the expiration date, no more topics can be added to this topic.
Returns:
true if this topic has an expiration: false otherwise

getExpiration

public java.util.Date getExpiration()
Gets the expiration date of this topic, if on exists.
Returns:
the expiration date or null for none

setExpiration

public void setExpiration(java.util.Date expirationDate)
Sets the expiration date for this topic. After the expiration date, no more topics can be added to this topic.
Parameters:
expirationDate - the date the topic expires or null for no expiration date

clearExpiration

public void clearExpiration()
Clears the expiration date for this topic.

isExpired

public boolean isExpired()
Checks if this topic is expired. This would be the case if the topic had an expiration date which was passed.
Returns:
true if the forum is expired; false if forum has not expired or not expiration is set
See Also:
hasExpiration()

getDateCreated

public java.util.Date getDateCreated()
Gets the date the topic was created.
Returns:
the date created

getContentType

public java.lang.String getContentType()
Gets the content type of the topic description. The content type can be used to determine how to display the topic description. For example, text/plain can be displayed as plain text.
Returns:
the MIME content type of the description
See Also:
getDescription()

setContentType

public void setContentType(java.lang.String sContentType)
Sets the content type of the topic description.
Parameters:
sContentType - the MIME content type of the description (may not be null or empty)
See Also:
getDescription()

getDescription

public java.lang.String getDescription()
Gets the description of the topic. The description should explain what types of topics are contained.
Returns:
the description of the topic or null for no description

getDescription

public java.lang.String getDescription(int iLength)
Gets the description of the topic. The description should explain what types of topics are contained. The description is truncated after the specified number of characters and "..." is appended to it.
Parameters:
iLength - the maximum length of the result (string plus "...")
Returns:
the description of the topic or null for no description

setDescription

public void setDescription(java.lang.String sDescription)
Sets the description of the topic. The description should explain what types of topics are contained.
Parameters:
sDescription - the description of the topic or null for no description

getMessageCount

public int getMessageCount()
Gets the number of messages associated with the topics under this topic. The number of messages includes all messages directly under the associated topics and the sub-messages of those messages.
Returns:
the number of messages (0 for none)

getKeywords

public java.lang.String getKeywords()
Gets the keywords associated with this topic.
Returns:
the keywords associated with this topic or null for none
See Also:
setKeywords(String)

setKeywords

public void setKeywords(java.lang.String[] keywords)
Sets the keywords associated with this topic. Keywords represent meta-data to describe the topic which are not part of the topic subject. When searching for topics by keywords, this field is checked.

The specified array of keywords are converted into a space delimited String of keywords. Existing keywords (if any) are over-written by the specified keywords.

Parameters:
keywords - an array of keywords to associate with this topic (may not be null)
See Also:
setKeywords(String)

setKeywords

public void setKeywords(java.lang.String sKeywords)
Sets the keywords associated with this topic. Keywords represent meta-data to describe the topic which are not part of the topic subject. When searching for topics by keywords, this field is checked.

Existing keywords (if any) are over-written by the specified keywords.

Parameters:
sKeywords - the keywords to associate with this topic or null for none

getDateLastModified

public java.util.Date getDateLastModified()
Gets the date the topic was last modified.
Returns:
the date last modified

isModified

public boolean isModified()
Checks if this topic has been modified since the user's last login.
Returns:
true if topic has been modified; false otherwise

getCustomNum1

public long getCustomNum1()
Gets the custom number1 field of the topic.
Returns:
the custom number1 field of the topic or null if the custom number1 field is not set

setCustomNum1

public void setCustomNum1(long lCustomNum1)
Sets the custom number1 field of the topic.
Parameters:
lCustomNum1 - the custom number1 field of the topic

getCustomNum2

public long getCustomNum2()
Gets the custom number2 field of the topic.
Returns:
the custom number2 field of the topic or null if the custom number2 field is not set

setCustomNum2

public void setCustomNum2(long lCustomNum2)
Sets the custom number2 field of the topic.
Parameters:
lCustomNum2 - the custom number2 field of the topic

getCustomNum3

public long getCustomNum3()
Gets the custom number3 field of the topic.
Returns:
the custom number3 field of the topic or null if the custom number3 field is not set

setCustomNum3

public void setCustomNum3(long lCustomNum3)
Sets the custom number3 field of the topic.
Parameters:
lCustomNum3 - the custom number3 field of the topic

getCustomNum4

public long getCustomNum4()
Gets the custom number4 field of the topic.
Returns:
the custom number4 field of the topic or null if the custom number4 field is not set

setCustomNum4

public void setCustomNum4(long lCustomNum4)
Sets the custom number4 field of the topic.
Parameters:
lCustomNum4 - the custom number4 field of the topic

getCustomStr1

public java.lang.String getCustomStr1()
Gets the custom string1 field of the topic.
Returns:
the custom string1 field of the topic or null if the custom string1 field is not set

setCustomStr1

public void setCustomStr1(java.lang.String sCustomStr1)
Sets the custom string1 field of the topic.
Parameters:
sCustomStr1 - the custom string1 field of the topic

getCustomStr2

public java.lang.String getCustomStr2()
Gets the custom string2 field of the topic.
Returns:
the custom string2 field of the topic or null if the custom string2 field is not set

setCustomStr2

public void setCustomStr2(java.lang.String sCustomStr2)
Sets the custom string2 field of the topic.
Parameters:
sCustomStr2 - the custom string2 field of the topic

getCustomStr3

public java.lang.String getCustomStr3()
Gets the custom string3 field of the topic.
Returns:
the custom string3 field of the topic or null if the custom string3 field is not set

setCustomStr3

public void setCustomStr3(java.lang.String sCustomStr3)
Sets the custom string3 field of the topic.
Parameters:
sCustomStr3 - the custom string3 field of the topic

getCustomStr4

public java.lang.String getCustomStr4()
Gets the custom string4 field of the topic.
Returns:
the custom string4 field of the topic or null if the custom string4 field is not set

setCustomStr4

public void setCustomStr4(java.lang.String sCustomStr4)
Sets the custom string4 field of the topic.
Parameters:
sCustomStr4 - the custom string4 field of the topic

subscribe

public boolean subscribe()
Subscribes the user to this topic. The user will receive email alerts when the topic is updated (i.e. new messages are added).

This operation does not subscribe if the discussion authentication is anonymous or the email address of the user is not set.

Returns:
true if the subscribe is successful; false is the user is already a subscriber

unsubscribe

public boolean unsubscribe()
Unsubscribes the user to this topic. This change is automatically saved to the database; therefore, update() is not required.
Returns:
true if the unsubscribe is successful; false otherwise

isSubscriber

public boolean isSubscriber()
Checks if the authenticated user is a subscriber to the topic.
Returns:
true if the user is subscribed; false otherwise

isSubscriber

public boolean isSubscriber(User user)
Checks if the specified user is a subscriber to the topic.
Parameters:
user - the user to check
Returns:
true if the user is subscriber; false otherwise

subscribers

public java.util.List subscribers()
Gets a list subscribers for this topic. Subscribers receive email alerts when the topic is updated (i.e. new messages are added).
Returns:
an unmodifiable list of subscriber email addresses (java.lang.String)

update

public boolean update()
               throws java.security.AccessControlException
Updates the topic (saves the topic entry). This method must be called to commit changes to the topic.
Throws:
java.security.AccessControlException - occurs if the user does not have permission to edit the topic

update

public boolean update(boolean bForce)
               throws java.security.AccessControlException
Updates the topic (saves the topic entry). This method must be called to commit changes to the topic.
Parameters:
bForce - true to force the update; false otherwise (currently ignored)
Returns:
true if the update is successful; false otherwise
Throws:
java.security.AccessControlException - occurs if the user does not have permission to edit the topic

delete

public void delete()
            throws java.security.AccessControlException
Deletes the topic.
Throws:
java.security.AccessControlException - occurs if the user does not have permission to delete the topic

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one. The message id is used to determine equality.
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare for eqaulity
Returns:
true if the objects are equals; falseotherwise

hasFileAttachment

public boolean hasFileAttachment()
Checks if the topic has any file attachments.
Returns:
true if the topic has file attachments; false otherwise

getFileAttachmentCount

public int getFileAttachmentCount()
Gets the number of files associated with this topic.
Returns:
the number of files

removeFileAttachment

public void removeFileAttachment(long lAttachmentID)
Removes the file attachment by the specified id.
Returns:
lAttachmentID the file attachment id

getFileAttachment

public FileAttachment getFileAttachment(long lAttachmentID)
Gets the file attachment by the specified id.
Returns:
lAttachmentID the file attachment id

getFileAttachments

public java.util.List getFileAttachments()
Gets a list of file attachments for this topic.
Returns:
an unmodifiable list of FileAttachment objects

addFileAttachment

public FileAttachment addFileAttachment(java.lang.String sFilename,
                                        java.io.InputStream io)
                                 throws java.io.IOException
Adds the file attachment to this topic. The input stream will be fully read and closed. The attachment is added and commited to the topic. A call to update() is not required.
Parameters:
sFilename - the file attachment name (may not be null)
io - the input stream to the file attachment data
Returns:
the newly added file attachment

toString

public java.lang.String toString()
Returns a string representation of the object.
Overrides:
toString in class java.lang.Object
Returns:
the string representation of the object

Compoze Software, Inc.

Copyright ©1999-2003 Compoze Software, Inc. All rights reserved.