org.sakaiproject.component.legacy.discussion
Class BaseDiscussionService.BaseDiscussionChannelEdit

java.lang.Object
  extended byjava.util.Observable
      extended byorg.sakaiproject.component.legacy.message.BaseMessageService.BaseMessageChannelEdit
          extended byorg.sakaiproject.component.legacy.discussion.BaseDiscussionService.BaseDiscussionChannelEdit
All Implemented Interfaces:
DiscussionChannel, DiscussionChannelEdit, Edit, Entity, EventListener, MessageChannel, MessageChannelEdit, SessionBindingListener
Enclosing class:
BaseDiscussionService

public class BaseDiscussionService.BaseDiscussionChannelEdit
extends BaseMessageService.BaseMessageChannelEdit
implements DiscussionChannelEdit

DiscussionChannel implementation


Field Summary
protected  List m_categories
          Store categories, each a string.
 
Fields inherited from class org.sakaiproject.component.legacy.message.BaseMessageService.BaseMessageChannelEdit
m_active, m_context, m_event, m_id, m_isRemoved, m_properties
 
Fields inherited from interface org.sakaiproject.service.legacy.entity.Entity
SEPARATOR
 
Constructor Summary
BaseDiscussionService.BaseDiscussionChannelEdit(Element el)
          Construct from a channel (and possibly messages) already defined in XML in a DOM tree.
BaseDiscussionService.BaseDiscussionChannelEdit(MessageChannel other)
          Construct as a copy of another message.
BaseDiscussionService.BaseDiscussionChannelEdit(String ref)
          Construct with a reference.
 
Method Summary
 boolean addCategory(String category)
          Add a new category for this channel.
 DiscussionMessageEdit addDiscussionMessage(String replyTo)
          A (DiscussionMessageEdit) cover for addMessage.
 DiscussionMessage addDiscussionMessage(String category, String subject, boolean draft, String replyTo, List attachments, String body)
          A (DiscussionMessage) cover for addMessage to add a new message to this channel.
 boolean allowAddTopicMessage()
          check permissions for addMessage() - if the message is a new Topic.
 boolean allowRemoveCategory()
          check permissions for removing category
 DiscussionMessageEdit editDiscussionMessage(String messageId)
          A (DiscussionMessageEdit) cover for editMessage.
 List getCategories(boolean scanMessages)
          Access the list of catagories defined in the channel.
 DiscussionMessage getDiscussionMessage(String messageId)
          Return a specific discussion channel message, as specified by message name.
 DiscussionMessage getDiscussionMessageNoException(String messageId)
          A (DiscussionMessage) cover for getMessage to return a specific discussion channel message, as specified by message id, and ignore exceptions if any
 List getMessages(Filter filter, boolean ascending)
          Return a list of all or filtered messages in the channel.
 Iterator getThread(DiscussionMessage message)
          Return an iterator on the DiscussionMessages that are in the response thread to the specified message.
 DiscussionMessage getThreadLatestReply(DiscussionMessage message)
          Access the most recent reply to the thread descending from this message, if any.
 int getThreadNumberOfReplies(DiscussionMessage message)
          Count the number of replies to this thread (i.e. the size of the getThread() iterator).
 Iterator getThreads(String category)
          Return an iterator on all messages in thread - depth first order.
 List getTopicMsgIds(String category)
          Access the message ids for the topics (i.e. messages that are not a response to any other message) in the category.
 Iterator getTopics(String category)
          Return an Iterator on the DiscussionMessages that are "topics", i.e.
 boolean removeCategory(String category)
          Remove a category and its related messages for this channel.
 void setCategories(List categories)
          Set categories for this channel.
protected  Iterator threadIterator(Iterator topLevel)
          Return an iterator on the DiscussionMessages that are in the response thread(s) to the specified iteration of messages.
 Element toXml(Document doc, Stack stack)
          Serialize the resource into XML, adding an element to the doc under the top of the stack element.
 
Methods inherited from class org.sakaiproject.component.legacy.message.BaseMessageService.BaseMessageChannelEdit
activate, addMessage, allowAddChannelMessage, allowAddMessage, allowEditMessage, allowEditMessage, allowGetMessages, allowRemoveMessage, cancelMessage, closeEdit, commitMessage, commitMessage, editMessage, finalize, findFilterMessages, findMessage, findMessages, getContext, getEvent, getGroupsAllowAddMessage, getGroupsAllowFunction, getGroupsAllowGetMessage, getId, getMessage, getProperties, getPropertiesEdit, getReference, getReference, getUrl, getUrl, isActiveEdit, isIntersectionGroupRefsToGroups, mergeMessage, notify, removeMessage, removeMessage, setEvent, setRemoved, valueBound, valueUnbound
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.sakaiproject.service.legacy.message.MessageChannel
addMessage, allowAddChannelMessage, allowAddMessage, allowEditMessage, allowGetMessages, allowRemoveMessage, cancelMessage, commitMessage, commitMessage, editMessage, getContext, getGroupsAllowAddMessage, getGroupsAllowGetMessage, getMessage, mergeMessage, removeMessage, removeMessage
 
Methods inherited from interface org.sakaiproject.service.legacy.entity.Entity
getId, getProperties, getReference, getReference, getUrl, getUrl
 
Methods inherited from interface org.sakaiproject.service.legacy.entity.Edit
getPropertiesEdit, isActiveEdit
 

Field Detail

m_categories

protected List m_categories
Store categories, each a string.

Constructor Detail

BaseDiscussionService.BaseDiscussionChannelEdit

public BaseDiscussionService.BaseDiscussionChannelEdit(String ref)
Construct with a reference.

Parameters:
ref - The channel reference.

BaseDiscussionService.BaseDiscussionChannelEdit

public BaseDiscussionService.BaseDiscussionChannelEdit(MessageChannel other)
Construct as a copy of another message.

Parameters:
other - The other message to copy.

BaseDiscussionService.BaseDiscussionChannelEdit

public BaseDiscussionService.BaseDiscussionChannelEdit(Element el)
Construct from a channel (and possibly messages) already defined in XML in a DOM tree. The Channel is added to storage.

Parameters:
el - The XML DOM element defining the channel.
Method Detail

toXml

public Element toXml(Document doc,
                     Stack stack)
Serialize the resource into XML, adding an element to the doc under the top of the stack element.

Specified by:
toXml in interface Entity
Overrides:
toXml in class BaseMessageService.BaseMessageChannelEdit
Parameters:
doc - The DOM doc to contain the XML (or null for a string return).
stack - The DOM elements, the top of which is the containing element of the new "resource" element.
Returns:
The newly added element.

getDiscussionMessage

public DiscussionMessage getDiscussionMessage(String messageId)
                                       throws IdUnusedException,
                                              PermissionException
Return a specific discussion channel message, as specified by message name.

Specified by:
getDiscussionMessage in interface DiscussionChannel
Parameters:
messageId - The id of the message to get.
Returns:
the DiscussionMessage that has the specified id.
Throws:
IdUnusedException - If this name is not a defined message in this discussion channel.
PermissionException - If the user does not have any permissions to read the message.

getDiscussionMessageNoException

public DiscussionMessage getDiscussionMessageNoException(String messageId)
Description copied from interface: DiscussionChannel
A (DiscussionMessage) cover for getMessage to return a specific discussion channel message, as specified by message id, and ignore exceptions if any

Specified by:
getDiscussionMessageNoException in interface DiscussionChannel
Parameters:
messageId - The id of the message to get.
Returns:
the DiscussionMessage that has the specified id.

getMessages

public List getMessages(Filter filter,
                        boolean ascending)
                 throws PermissionException
Return a list of all or filtered messages in the channel. The order in which the messages will be found in the iteration is by date, oldest first if ascending is true, newest first if ascending is false.

Specified by:
getMessages in interface MessageChannel
Overrides:
getMessages in class BaseMessageService.BaseMessageChannelEdit
Parameters:
filter - A filtering object to accept messages, or null if no filtering is desired.
ascending - Order of messages, ascending if true, descending if false
Returns:
a list on channel Message objects or specializations of Message objects (may be empty).
Throws:
PermissionException - if the user does not have read permission to the channel.

editDiscussionMessage

public DiscussionMessageEdit editDiscussionMessage(String messageId)
                                            throws IdUnusedException,
                                                   PermissionException,
                                                   InUseException
A (DiscussionMessageEdit) cover for editMessage. Return a specific channel message, as specified by message name, locked for update. Must commitEdit() to make official, or cancelEdit() when done!

Specified by:
editDiscussionMessage in interface DiscussionChannel
Parameters:
messageId - The id of the message to get.
Returns:
the Message that has the specified id.
Throws:
IdUnusedException - If this name is not a defined message in this channel.
PermissionException - If the user does not have any permissions to read the message.
InUseException - if the current user does not have permission to mess with this user.

allowAddTopicMessage

public boolean allowAddTopicMessage()
check permissions for addMessage() - if the message is a new Topic.

Specified by:
allowAddTopicMessage in interface DiscussionChannel
Returns:
true if the user is allowed to addMessage(...) for a new Topic, false if not.

allowRemoveCategory

public boolean allowRemoveCategory()
check permissions for removing category

Specified by:
allowRemoveCategory in interface DiscussionChannel
Returns:
true if the user is allowed to remove category, false if not.

addDiscussionMessage

public DiscussionMessageEdit addDiscussionMessage(String replyTo)
                                           throws PermissionException
A (DiscussionMessageEdit) cover for addMessage. Add a new message to this channel. Must commitEdit() to make official, or cancelEdit() when done!

Specified by:
addDiscussionMessage in interface DiscussionChannel
Parameters:
replyTo - The message id to which this message is a reply.
Returns:
The newly added message, locked for update.
Throws:
PermissionException - If the user does not have write permission to the channel.

addDiscussionMessage

public DiscussionMessage addDiscussionMessage(String category,
                                              String subject,
                                              boolean draft,
                                              String replyTo,
                                              List attachments,
                                              String body)
                                       throws PermissionException
A (DiscussionMessage) cover for addMessage to add a new message to this channel.

Specified by:
addDiscussionMessage in interface DiscussionChannel
Parameters:
category - The message header category.
subject - The message header subject.
draft - The message header draft setting.
replyTo - The message header message id to which this is a reply.
attachments - The message header attachments, a vector of Reference objects.
body - The message body.
Returns:
The newly added message.
Throws:
PermissionException - If the user does not have write permission to the channel.

setCategories

public void setCategories(List categories)
Set categories for this channel.

Specified by:
setCategories in interface DiscussionChannelEdit

getCategories

public List getCategories(boolean scanMessages)
Access the list of catagories defined in the channel.

Specified by:
getCategories in interface DiscussionChannel
Returns:
A List (String) of all the categories defined in the channel.

addCategory

public boolean addCategory(String category)
                    throws PermissionException,
                           InUseException
Add a new category for this channel.

Specified by:
addCategory in interface DiscussionChannel
Parameters:
category - The new category string to add.
Returns:
true if the category was new, false if it is already there.
Throws:
PermissionException - If the user does not have write permission to the channel.
InUseException

removeCategory

public boolean removeCategory(String category)
                       throws InUseException,
                              PermissionException
Remove a category and its related messages for this channel.

Specified by:
removeCategory in interface DiscussionChannel
Parameters:
category - The category string to be removed.
Returns:
true if the category can be removed, false if not.
Throws:
PermissionException - If the user does not have write permission to the channel.
InUseException

getTopics

public Iterator getTopics(String category)
Return an Iterator on the DiscussionMessages that are "topics", i.e. are not a response to any other message. Note: use DiscussionMessage.getReplies() to get the direct replies to any specific message.

Specified by:
getTopics in interface DiscussionChannel
Parameters:
category - Filter the responses to messages in just this category (optional, may be null).
Returns:
an Iterator on the DiscussionMessages that are "topics", i.e. are not a response to any other message.

getTopicMsgIds

public List getTopicMsgIds(String category)
Access the message ids for the topics (i.e. messages that are not a response to any other message) in the category.

Specified by:
getTopicMsgIds in interface DiscussionChannel
Parameters:
category - The category value.
Returns:
A List (Sting) of message id values for each message that is a topic in the category.

threadIterator

protected Iterator threadIterator(Iterator topLevel)
Return an iterator on the DiscussionMessages that are in the response thread(s) to the specified iteration of messages. They will be returned in depth first order.

Parameters:
topLevel - The iterator of messages to which those returned are some depth of response.
Returns:
an iterator on the DiscussionMessages that are in the response threads to the specified iteration of messages, in depth first order (may be empty).

getThread

public Iterator getThread(DiscussionMessage message)
Return an iterator on the DiscussionMessages that are in the response thread to the specified message. They will be returned in depth first order.

Specified by:
getThread in interface DiscussionChannel
Parameters:
message - The message to which those returned are some depth of response.
Returns:
an iterator on the DiscussionMessages that are in the response thread to the specified topic messages, in depth first order (may be empty).

getThreads

public Iterator getThreads(String category)
Return an iterator on all messages in thread - depth first order.

Specified by:
getThreads in interface DiscussionChannel
Parameters:
category - Filter the responses to messages in just this category (optional, may be null).
Returns:
an iterator on all messages in thread - depth first order (may be empty).

getThreadLatestReply

public DiscussionMessage getThreadLatestReply(DiscussionMessage message)
Access the most recent reply to the thread descending from this message, if any.

Specified by:
getThreadLatestReply in interface DiscussionChannel
Parameters:
message - The message that forms the top of a thread.
Returns:
the most recent DiscussionMessage reply to this thread, or null if there are no replies.

getThreadNumberOfReplies

public int getThreadNumberOfReplies(DiscussionMessage message)
Count the number of replies to this thread (i.e. the size of the getThread() iterator).

Specified by:
getThreadNumberOfReplies in interface DiscussionChannel
Parameters:
message - The message that forms the top of a thread.
Returns:
the number of replies to this thread.