org.sakaiproject.component.legacy.email
Class BaseMailArchiveService

java.lang.Object
  extended byorg.sakaiproject.component.legacy.message.BaseMessageService
      extended byorg.sakaiproject.component.legacy.email.BaseMailArchiveService
All Implemented Interfaces:
CacheRefresher, EntityProducer, MailArchiveService, MessageService, StorageUser
Direct Known Subclasses:
DbMailArchiveService

public abstract class BaseMailArchiveService
extends BaseMessageService
implements MailArchiveService

BaseMailArchiveService extends the BaseMessageService for the specifics of MailArchive.

Version:
$Revision: 6016 $
Author:
University of Michigan, CHEF Software Development Team

Nested Class Summary
 class BaseMailArchiveService.BaseMailArchiveChannelEdit
          MailArchiveChannel implementation
 class BaseMailArchiveService.BaseMailArchiveMessageEdit
          MailArchiveMessage implementation
 class BaseMailArchiveService.BaseMailArchiveMessageHeaderEdit
          MailArchiveMessageHeaderEdit implementation
 
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
protected  NotificationService m_notificationService
          Dependency: NotificationService.
 
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.email.MailArchiveService
HEADER_INNER_CONTENT_TYPE, HEADER_OUTER_CONTENT_TYPE, REFERENCE_ROOT, SECURE_MAIL_ADD, SECURE_MAIL_READ, SECURE_MAIL_READ_DRAFT, SECURE_MAIL_REMOVE_ANY, SECURE_MAIL_REMOVE_OWN, SECURE_MAIL_ROOT, SECURE_MAIL_UPDATE_ANY, SECURE_MAIL_UPDATE_OWN, 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
BaseMailArchiveService()
           
 
Method Summary
 MailArchiveChannelEdit addMailArchiveChannel(String ref)
          Add a new mail message channel.
protected  void disableMailbox(Site site)
          Set a site's mailbox to inactive - it remains in existance, just disabled
protected  void enableMailbox(Site site)
          Setup the mailbox for an active 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.
 String getLabel()
          
 MailArchiveChannel getMailArchiveChannel(String ref)
          Return a specific mail message channel.
 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 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.
 void setNotificationService(NotificationService service)
          Dependency: NotificationService.
 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, archive, cancelChannel, cancelMessage, channelReference, commitChannel, destroy, disableMessageChannel, editChannel, enableMessageChannel, findChannel, getAccessPoint, getChannel, getChannelIds, getChannels, getEntity, getEntityAuthzGroups, getEntityDescription, getEntityResourceProperties, getEntityUrl, getHttpAccess, getMessage, getMessages, importEntities, 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
archive, getEntity, getEntityAuthzGroups, getEntityDescription, getEntityResourceProperties, getEntityUrl, getHttpAccess, importEntities, merge, willArchiveMerge, willImport
 

Field Detail

m_notificationService

protected NotificationService m_notificationService
Dependency: NotificationService.

Constructor Detail

BaseMailArchiveService

public BaseMailArchiveService()
Method Detail

setNotificationService

public void setNotificationService(NotificationService service)
Dependency: NotificationService.

Parameters:
service - The NotificationService.

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

enableMailbox

protected void enableMailbox(Site site)
Setup the mailbox for an active site.

Parameters:
site - The site.

disableMailbox

protected void disableMailbox(Site site)
Set a site's mailbox to inactive - it remains in existance, just disabled

Parameters:
site - The site.

getMailArchiveChannel

public MailArchiveChannel getMailArchiveChannel(String ref)
                                         throws IdUnusedException,
                                                PermissionException
Return a specific mail message channel.

Specified by:
getMailArchiveChannel in interface MailArchiveService
Parameters:
ref - The channel reference.
Returns:
the MailArchiveChannel that has the specified name.
Throws:
IdUnusedException - If this name is not defined for a mail message channel.
PermissionException - If the user does not have any permissions to the channel.

addMailArchiveChannel

public MailArchiveChannelEdit addMailArchiveChannel(String ref)
                                             throws IdUsedException,
                                                    IdInvalidException,
                                                    PermissionException
Add a new mail message channel.

Specified by:
addMailArchiveChannel in interface MailArchiveService
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.

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.