org.sakaiproject.component.legacy.discussion
Class BaseDiscussionService

java.lang.Object
  extended byorg.sakaiproject.component.legacy.message.BaseMessageService
      extended byorg.sakaiproject.component.legacy.discussion.BaseDiscussionService
All Implemented Interfaces:
CacheRefresher, DiscussionService, EntityProducer, MessageService, StorageUser
Direct Known Subclasses:
DbDiscussionService

public abstract class BaseDiscussionService
extends BaseMessageService
implements DiscussionService

BaseDiscussionService extends the BaseMessageService for the specifics of Discussion.

Version:
$Revision: 6016 $ Note: when a message is posted to a channel, it may have a new category. This category is NOT automatically added to the categories of a channel, which may exist without a message. To get the full list of categories, you must get the channel's categories, and add any that the set of messages for the channel has.
Author:
University of Michigan, CHEF Software Development Team

Nested Class Summary
 class BaseDiscussionService.BaseDiscussionChannelEdit
          DiscussionChannel implementation
 class BaseDiscussionService.BaseDiscussionMessageEdit
          DiscussionMessage implementation
 class BaseDiscussionService.BaseDiscussionMessageHeaderEdit
          DiscussionMessageHeaderEdit implementation
protected  class BaseDiscussionService.PrivacyFilter
          A filter that will reject discussion message drafts not from the current user, and otherwise use another filter, if defined, for acceptance.
 
Nested classes inherited from class org.sakaiproject.component.legacy.message.BaseMessageService
BaseMessageService.BaseMessageChannelEdit, BaseMessageService.BaseMessageEdit, BaseMessageService.BaseMessageHeaderEdit, BaseMessageService.MessagePermissionFilter, BaseMessageService.MessageSelectionFilter, BaseMessageService.Storage
 
Nested classes inherited from class org.sakaiproject.service.legacy.entity.EntityProducer
EntityProducer.ChangeType
 
Field Summary
 
Fields inherited from class org.sakaiproject.component.legacy.message.BaseMessageService
m_caching, m_channelCache, m_entityManager, m_logger, m_memoryService, m_messageCaches, m_serverConfigurationService, m_storage
 
Fields inherited from interface org.sakaiproject.service.legacy.discussion.DiscussionService
REFERENCE_ROOT, SECURE_ADD_TOPIC, SERVICE_NAME
 
Fields inherited from interface org.sakaiproject.service.legacy.message.MessageService
REF_TYPE_CHANNEL, REF_TYPE_CHANNEL_GROUPS, REF_TYPE_MESSAGE, SECURE_ADD, SECURE_ALL_GROUPS, SECURE_READ, SECURE_READ_DRAFT, SECURE_REMOVE_ANY, SECURE_REMOVE_OWN, SECURE_UPDATE_ANY, SECURE_UPDATE_OWN
 
Constructor Summary
BaseDiscussionService()
           
 
Method Summary
 DiscussionChannelEdit addDiscussionChannel(String ref)
          Add a new discussion channel.
 String archive(String siteId, Document doc, Stack stack, String archivePath, List attachments)
          Archive the resources for the given site.
protected  String eventId(String secure)
          Form a tracking event string based on a security function string.
 Time getDate(Entity r)
          Access the resource date.
 DiscussionChannel getDiscussionChannel(String ref)
          Return a specific discussion channel.
 String getLabel()
          
 String getOwnerId(Entity r)
          Access the resource owner user id.
protected  String getReferenceRoot()
          Return the reference rooot for use in resource references and urls.
 void importEntities(String fromContext, String toContext, List resourceIds)
          import tool(s) contents from the source context into the destination context
 void init()
          Final initialization, once all dependencies are set.
 boolean isDraft(Entity r)
          Check if this resource is in draft mode.
 Entity newContainer(Element element)
          Construct a new container resource, from an XML element.
 Entity newContainer(Entity other)
          Construct a new container resource, as a copy of another
 Entity newContainer(String ref)
          Construct a new continer given just ids.
 Edit newContainerEdit(Element element)
          Construct a new container resource, from an XML element.
 Edit newContainerEdit(Entity other)
          Construct a new container resource, as a copy of another
 Edit newContainerEdit(String ref)
          Construct a new continer given just ids.
protected  MessageHeaderEdit newMessageHeader(Message msg, Element el)
          Construct a new message header from XML in a DOM element.
protected  MessageHeaderEdit newMessageHeader(Message msg, MessageHeader other)
          Construct a new message header as a copy of another.
protected  MessageHeaderEdit newMessageHeader(Message msg, String id)
          Construct a new message header from XML in a DOM element.
 Entity newResource(Entity container, Element element)
          Construct a new resource, from an XML element.
 Entity newResource(Entity container, Entity other)
          Construct a new resource from another resource of the same type.
 Entity newResource(Entity container, String id, Object[] others)
          Construct a new rsource given just an id.
 Edit newResourceEdit(Entity container, Element element)
          Construct a new resource, from an XML element.
 Edit newResourceEdit(Entity container, Entity other)
          Construct a new resource from another resource of the same type.
 Edit newResourceEdit(Entity container, String id, Object[] others)
          Construct a new rsource given just an id.
 boolean parseEntityReference(String reference, Reference ref)
          If the service recognizes the reference as its own, parse it and fill in the Reference
protected  String serviceName()
          Report the Service API name being implemented.
 Object[] storageFields(Entity r)
          Collect the fields that need to be stored outside the XML (for the resource).
 void syncWithSiteChange(Site site, EntityProducer.ChangeType change)
          Synchronize any entities related to the Site given this change in the Site, possibly a structural change where a tool is added or removed, or the site is new, or being deleted.
 
Methods inherited from class org.sakaiproject.component.legacy.message.BaseMessageService
addChannel, allowAddChannel, allowEditChannel, allowGetChannel, allowGetMessage, allowRemoveChannel, cancelChannel, cancelMessage, channelReference, commitChannel, destroy, disableMessageChannel, editChannel, enableMessageChannel, findChannel, getAccessPoint, getChannel, getChannelIds, getChannels, getEntity, getEntityAuthzGroups, getEntityDescription, getEntityResourceProperties, getEntityUrl, getHttpAccess, getMessage, getMessages, merge, messageReference, messageReference, newStorage, refresh, removeChannel, service, setCaching, setEntityManager, setLogger, setMemoryService, setServerConfigurationService, unlock, unlock2, unlock3, unlockCheck, unlockCheck2, unlockCheck3, willArchiveMerge, willImport
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.sakaiproject.service.legacy.message.MessageService
addChannel, allowAddChannel, allowEditChannel, allowGetChannel, allowRemoveChannel, cancelChannel, cancelMessage, channelReference, commitChannel, editChannel, getChannel, getChannelIds, getChannels, getMessage, getMessages, messageReference, messageReference, removeChannel
 
Methods inherited from interface org.sakaiproject.service.legacy.entity.EntityProducer
getEntity, getEntityAuthzGroups, getEntityDescription, getEntityResourceProperties, getEntityUrl, getHttpAccess, merge, willArchiveMerge, willImport
 

Constructor Detail

BaseDiscussionService

public BaseDiscussionService()
Method Detail

init

public void init()
Final initialization, once all dependencies are set.

Overrides:
init in class BaseMessageService

newContainer

public Entity newContainer(String ref)
Construct a new continer given just ids.

Specified by:
newContainer in interface StorageUser
Parameters:
ref - The channel reference.
Returns:
The new containe Resource.

newContainer

public Entity newContainer(Element element)
Construct a new container resource, from an XML element.

Specified by:
newContainer in interface StorageUser
Parameters:
element - The XML.
Returns:
The new container resource.

newContainer

public Entity newContainer(Entity other)
Construct a new container resource, as a copy of another

Specified by:
newContainer in interface StorageUser
Parameters:
other - The other contianer to copy.
Returns:
The new container resource.

newResource

public Entity newResource(Entity container,
                          String id,
                          Object[] others)
Construct a new rsource given just an id.

Specified by:
newResource in interface StorageUser
Parameters:
container - The Resource that is the container for the new resource (may be null).
id - The id for the new object.
others - (options) array of objects to load into the Resource's fields.
Returns:
The new resource.

newResource

public Entity newResource(Entity container,
                          Element element)
Construct a new resource, from an XML element.

Specified by:
newResource in interface StorageUser
Parameters:
container - The Resource that is the container for the new resource (may be null).
element - The XML.
Returns:
The new resource from the XML.

newResource

public Entity newResource(Entity container,
                          Entity other)
Construct a new resource from another resource of the same type.

Specified by:
newResource in interface StorageUser
Parameters:
container - The Resource that is the container for the new resource (may be null).
other - The other resource.
Returns:
The new resource as a copy of the other.

newContainerEdit

public Edit newContainerEdit(String ref)
Construct a new continer given just ids.

Specified by:
newContainerEdit in interface StorageUser
Parameters:
ref - The channel reference.
Returns:
The new containe Resource.

newContainerEdit

public Edit newContainerEdit(Element element)
Construct a new container resource, from an XML element.

Specified by:
newContainerEdit in interface StorageUser
Parameters:
element - The XML.
Returns:
The new container resource.

newContainerEdit

public Edit newContainerEdit(Entity other)
Construct a new container resource, as a copy of another

Specified by:
newContainerEdit in interface StorageUser
Parameters:
other - The other contianer to copy.
Returns:
The new container resource.

newResourceEdit

public Edit newResourceEdit(Entity container,
                            String id,
                            Object[] others)
Construct a new rsource given just an id.

Specified by:
newResourceEdit in interface StorageUser
Parameters:
container - The Resource that is the container for the new resource (may be null).
id - The id for the new object.
others - (options) array of objects to load into the Resource's fields.
Returns:
The new resource.

newResourceEdit

public Edit newResourceEdit(Entity container,
                            Element element)
Construct a new resource, from an XML element.

Specified by:
newResourceEdit in interface StorageUser
Parameters:
container - The Resource that is the container for the new resource (may be null).
element - The XML.
Returns:
The new resource from the XML.

newResourceEdit

public Edit newResourceEdit(Entity container,
                            Entity other)
Construct a new resource from another resource of the same type.

Specified by:
newResourceEdit in interface StorageUser
Parameters:
container - The Resource that is the container for the new resource (may be null).
other - The other resource.
Returns:
The new resource as a copy of the other.

storageFields

public Object[] storageFields(Entity r)
Collect the fields that need to be stored outside the XML (for the resource).

Specified by:
storageFields in interface StorageUser
Returns:
An array of field values to store in the record outside the XML (for the resource).

isDraft

public boolean isDraft(Entity r)
Check if this resource is in draft mode.

Specified by:
isDraft in interface StorageUser
Parameters:
r - The resource.
Returns:
true if the resource is in draft mode, false if not.

getOwnerId

public String getOwnerId(Entity r)
Access the resource owner user id.

Specified by:
getOwnerId in interface StorageUser
Parameters:
r - The resource.
Returns:
The resource owner user id.

getDate

public Time getDate(Entity r)
Access the resource date.

Specified by:
getDate in interface StorageUser
Parameters:
r - The resource.
Returns:
The resource date.

serviceName

protected String serviceName()
Report the Service API name being implemented.

Specified by:
serviceName in class BaseMessageService

newMessageHeader

protected MessageHeaderEdit newMessageHeader(Message msg,
                                             String id)
Construct a new message header from XML in a DOM element.

Specified by:
newMessageHeader in class BaseMessageService
Parameters:
id - The message Id.
msg - The message to own this header.
Returns:
The new message header.

newMessageHeader

protected MessageHeaderEdit newMessageHeader(Message msg,
                                             Element el)
Construct a new message header from XML in a DOM element.

Specified by:
newMessageHeader in class BaseMessageService
Parameters:
el - The XML DOM element that has the header information.
msg - The message to own this header.
Returns:
The new message header.

newMessageHeader

protected MessageHeaderEdit newMessageHeader(Message msg,
                                             MessageHeader other)
Construct a new message header as a copy of another.

Specified by:
newMessageHeader in class BaseMessageService
Parameters:
other - The other header to copy.
msg - The message to own this header.
Returns:
The new message header.

eventId

protected String eventId(String secure)
Form a tracking event string based on a security function string.

Specified by:
eventId in class BaseMessageService
Parameters:
secure - The security function string.
Returns:
The event tracking string.

getReferenceRoot

protected String getReferenceRoot()
Return the reference rooot for use in resource references and urls.

Specified by:
getReferenceRoot in class BaseMessageService
Returns:
The reference rooot for use in resource references and urls.

parseEntityReference

public boolean parseEntityReference(String reference,
                                    Reference ref)
If the service recognizes the reference as its own, parse it and fill in the Reference

Specified by:
parseEntityReference in interface EntityProducer
Parameters:
reference - The reference string to examine.
ref - The Reference object to set with the results of the parse from a recognized reference.
Returns:
true if the reference belonged to the service, false if not.

syncWithSiteChange

public void syncWithSiteChange(Site site,
                               EntityProducer.ChangeType change)
Synchronize any entities related to the Site given this change in the Site, possibly a structural change where a tool is added or removed, or the site is new, or being deleted.

Specified by:
syncWithSiteChange in interface EntityProducer
Overrides:
syncWithSiteChange in class BaseMessageService

getDiscussionChannel

public DiscussionChannel getDiscussionChannel(String ref)
                                       throws IdUnusedException,
                                              PermissionException
Return a specific discussion channel.

Specified by:
getDiscussionChannel in interface DiscussionService
Parameters:
ref - The channel reference.
Returns:
the DiscussionChannel that has the specified name.
Throws:
IdUnusedException - If this name is not defined for a discussion channel.
PermissionException - If the user does not have any permissions to the channel.

addDiscussionChannel

public DiscussionChannelEdit addDiscussionChannel(String ref)
                                           throws IdUsedException,
                                                  IdInvalidException,
                                                  PermissionException
Add a new discussion channel.

Specified by:
addDiscussionChannel in interface DiscussionService
Parameters:
ref - The channel reference.
Returns:
The newly created channel.
Throws:
IdUsedException - if the id is not unique.
IdInvalidException - if the id is not made up of valid characters.
PermissionException - if the user does not have permission to add a channel.

archive

public String archive(String siteId,
                      Document doc,
                      Stack stack,
                      String archivePath,
                      List attachments)
Archive the resources for the given site.

Specified by:
archive in interface EntityProducer
Overrides:
archive in class BaseMessageService

getLabel

public String getLabel()

Specified by:
getLabel in interface EntityProducer
Returns:
a short string identifying the resources kept here, good for a file name or label.

importEntities

public void importEntities(String fromContext,
                           String toContext,
                           List resourceIds)
import tool(s) contents from the source context into the destination context

Specified by:
importEntities in interface EntityProducer
Overrides:
importEntities in class BaseMessageService
Parameters:
fromContext - The source context
toContext - The destination context
resourceIds - when null, all resources will be imported; otherwise, only resources with those ids will be imported