| java.lang.Object com.ivata.groupware.business.mail.MailImpl
MailImpl | public class MailImpl implements Mail,Serializable(Code) | | This session bean provides an interface to the mail system. Every mail
operation for retrieving deleting and sending messages takes place in this
class.
since: 2002-07-12 author: Colin MacLeod author: colin.macleod@ivata.com author: Peter Illes version: $Revision: 1.12 $ |
Constructor Summary | |
public | MailImpl(SecurityServer securityServer, AddressBook addressBook, Settings settings, MaskFactory maskFactory)
Initialize the mail implementation.
Parameters: securityServer - A valid security server for the current site. |
Method Summary | |
public MessageDO | addMessageToDraftsFolder(MailSession mailSession, MessageDO messageDO) Add a composed message to the drafts folder for later sending.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: messageDO - data object containing full details of themessage to be added to the drafts. | public void | addUserAliasEmailAddresses(SecuritySession securitySession, String userName, Collection userAliases, Collection telecomAddresses, String emailAddressHost)
Add appropriate user addresses given a list of user aliases.
Parameters: securitySession - valid security session. Parameters: userName - name of the user who owns teh aliases. Parameters: userAliases - a Collection of String instances containing the local part of the different email aliasesthis user has. | public MessageDO | appendAttachments(MailSession mailSession, String id, List attachments) Append attachments to a message located in the drafts folder.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: id - the unique identifier of the message to which we want to appendattachments. Parameters: attachments - List of String s -filenames of files waiting in upload directory. | public void | createFolder(MailSession mailSession, String folderName) | public MessageDO | createThreadMessage(MailSession mailSession, String folderName, List messageIds, Integer thread) Create a new message in the drafts folder from an existing one,
based on a 'thread'. | public void | deleteMessagesFromTrash(MailSession mailSession, List ids) | public boolean | doesFolderExist(MailSession mailSession, String folderName) Check whether or not a given folder pathname exists.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: folderName - the full path name of the folder to check. | public MessageDO | findMessageByFolderMessageId(MailSession mailSession, String folderName, String id) This method retrieves the requested message and sets all the
attributes of a MessageDO object for use on client side.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: folderName - the name of the folder the message is located in. Parameters: id - the unique identifier of the message. | public List | findMessagesInFolder(MailSession mailSession, String folderName, Integer sortBy, boolean sortAscending) Used in the main folder index page, this method returns the contents
of a folder as a List of
MessageDO instances.
Note: for efficiency reasons, this method does not fill the
text, format or attachment values of the returned MessageDO
instance. | final public FileContentDO | getAttachment(MailSession mailSession, String folderName, String messageId, String attachmentId) Retrieve an attachment's content and it's MimeType. | public List | getUserAliases(SecuritySession securitySession, String userName) Retrieve all of the email aliases for the user provided, on the curent
email server. | final public String | getVacationMessage(SecuritySession securitySession, String userName) Get the vacation message for the user provided.
The vacation message is a text the user can set, which will be sent
to all emails received at this address while the user is not present.
Parameters: userName - the name of the user for whom to get the vacation message. | final public boolean | hasNewMessages(SecuritySession securitySession, String userName, String folderName) Get the time the specified mail folder was last modified as a
long . | public MailSession | login(UserDO user, String password) Login to the mail system. | public void | moveMessages(MailSession mailSession, String folderName, List ids, String targetFolderName) | public void | send(MailSession mailSession, MessageDO messageDO) Send a mime email message that is already composed. | public void | send(MailSession mailSession, String fromAddress, Collection to, String subject, Object content, String contentType, boolean addToSentFolder) Send an mime email message without using a data object.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: fromAddress - the address of the person sending the mail. | final public void | setUserAliases(SecuritySession securitySession, String userName, Collection userAliases) Set all of the email aliases for the user provided, on the curent
email server. | final public void | setVacationMessage(SecuritySession securitySession, String userName, String vacationMessage) Set the vacation message for the user provided.
The vacation message is a text the user can set, which will be sent
to all emails received at this address while the user is not present.
Parameters: userName - the name of the user for whom to get the vacation message. Parameters: vacationMessage - vacation message text for this user. | public ValidationErrors | validate(SecuritySession securitySession, MessageDO messageDO) Confirm all of the elements of the message are present and valid,
before the message is sent.
Parameters: messageDO - data object to check for consistency andcompleteness. |
maskFactory | MaskFactory maskFactory(Code) | | |
MailImpl | public MailImpl(SecurityServer securityServer, AddressBook addressBook, Settings settings, MaskFactory maskFactory)(Code) | |
Initialize the mail implementation.
Parameters: securityServer - A valid security server for the current site. Ifthis is not an instance of com.ivata.groupware.business.mail.server.MailServerthe mail implementation will not be usable. Parameters: persistenceManager - This is used to save/access data from thepersistence store. Parameters: addressBook - This is used to read contacts email details. Parameters: settings - Contains user defined settings and preferences. Parameters: dateFormatter - Used to format mail dates and times. Parameters: idDispenser - |
addMessageToDraftsFolder | public MessageDO addMessageToDraftsFolder(MailSession mailSession, MessageDO messageDO) throws SystemException(Code) | | Add a composed message to the drafts folder for later sending.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: messageDO - data object containing full details of themessage to be added to the drafts. new MessageDO with the id set to thecurrent value in the mail system. |
addUserAliasEmailAddresses | public void addUserAliasEmailAddresses(SecuritySession securitySession, String userName, Collection userAliases, Collection telecomAddresses, String emailAddressHost) throws SystemException(Code) | |
Add appropriate user addresses given a list of user aliases.
Parameters: securitySession - valid security session. Parameters: userName - name of the user who owns teh aliases. Parameters: userAliases - a Collection of String instances containing the local part of the different email aliasesthis user has. If the user has no aliaes, an empty collection shouldbe provided. Parameters: telecomAddresess - a Collection containing all theuser's existing email addresses, as TelecomAddressDO instances. |
appendAttachments | public MessageDO appendAttachments(MailSession mailSession, String id, List attachments) throws SystemException(Code) | | Append attachments to a message located in the drafts folder.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: id - the unique identifier of the message to which we want to appendattachments. Parameters: attachments - List of String s -filenames of files waiting in upload directory. null when the operation failed, otherwise the newmessage id. exception: MessageNotFoundException - if the folder doesn't exist, or thereis no matching mail in this folder. |
createFolder | public void createFolder(MailSession mailSession, String folderName) throws SystemException(Code) | | Create a new mail folder.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: folderName - the full path name of the folder to create. |
createThreadMessage | public MessageDO createThreadMessage(MailSession mailSession, String folderName, List messageIds, Integer thread) throws SystemException(Code) | | Create a new message in the drafts folder from an existing one,
based on a 'thread'. The thread indicates that the message is a:
- reply to all recipients of a previous message
- reply to one recipient of a previous message
- previous message(s) forwarded to new recipients
- an existing (draft) message being altered for resending
This new message in the drafts folder can then be used to store
attachments or for reviewing before sending.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: folderName - the name of the folder to copy existing messages from. Parameters: messageIds - the unique identifier of the messages to be extended.Can be null if a new message is requeested. Whenforwarding, multiple address identifiers may be specified otherwise(if editing a draft message or replying) only one message identifiershould be set in the list. Parameters: thread - set to one of the constants in MailConstantsMailConstants. populated message data object matching the requiredmessage, and with the id set to the message in thedrafts folder. |
deleteMessagesFromTrash | public void deleteMessagesFromTrash(MailSession mailSession, List ids) throws SystemException(Code) | | Delete a list of messages from the trash folder.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: ids - the unique identifiers (String instances) of themessages to be removed. exception: MessageNotFoundException - if the folder doesn't exist, or thereis no matching mail in this folder. |
doesFolderExist | public boolean doesFolderExist(MailSession mailSession, String folderName) throws SystemException(Code) | | Check whether or not a given folder pathname exists.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: folderName - the full path name of the folder to check. true if the folder exists, otherwise false . |
findMessageByFolderMessageId | public MessageDO findMessageByFolderMessageId(MailSession mailSession, String folderName, String id) throws SystemException(Code) | | This method retrieves the requested message and sets all the
attributes of a MessageDO object for use on client side.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: folderName - the name of the folder the message is located in. Parameters: id - the unique identifier of the message. a MessageDO instance filled up with the messages attributes,except the contents of the attachments. exception: MessageNotFoundException - if the folder doesn't exist, or thereis no matching mail in this folder. |
findMessagesInFolder | public List findMessagesInFolder(MailSession mailSession, String folderName, Integer sortBy, boolean sortAscending) throws SystemException(Code) | | Used in the main folder index page, this method returns the contents
of a folder as a List of
MessageDO instances.
Note: for efficiency reasons, this method does not fill the
text, format or attachment values of the returned MessageDO
instance. For that, you must call
MailImpl.findMessageByFolderMessageId findMessageByFolderMessageId .
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: folderName - the name of the folder to list. Parameters: sortBy - the field to sort the returned list by. Set to one of theSORT_... constants in MailConstants MailConstants. Parameters: sortAscending - if true then the messages are sorted inascending order, otherwise (false ) they are descending. List ofMessageDO instances. |
getAttachment | final public FileContentDO getAttachment(MailSession mailSession, String folderName, String messageId, String attachmentId) throws SystemException(Code) | | Retrieve an attachment's content and it's MimeType. This method is
used to by the download servlet.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: folderName - the name of the folder the message is located in. Parameters: messageId - the unique identifier of the message. Parameters: attachmentId - the unique identifier of the attachment. attachment data object containing attachment contentand mime type. exception: MessageNotFoundException - if the folder doesn't exist, or thereis no matching mail in this folder. |
getUserAliases | public List getUserAliases(SecuritySession securitySession, String userName) throws SystemException(Code) | | Retrieve all of the email aliases for the user provided, on the curent
email server. The aliases returned each one containing just the 'user' (or
'local') part of the email address, before the '@' sign.
Parameters: userName - the name of the user for whom to retrieve the email aliases. a Collection of String instances containingthe local part of the different email aliases this user has. If the userhas no aliaes, an empty collection is returned. |
getVacationMessage | final public String getVacationMessage(SecuritySession securitySession, String userName) throws SystemException(Code) | | Get the vacation message for the user provided.
The vacation message is a text the user can set, which will be sent
to all emails received at this address while the user is not present.
Parameters: userName - the name of the user for whom to get the vacation message. the vacation message text for this user. If the user has novacation message set, null is returned. |
hasNewMessages | final public boolean hasNewMessages(SecuritySession securitySession, String userName, String folderName) throws SystemException(Code) | | Get the time the specified mail folder was last modified as a
long . This can then be saved and compared to subsequent
calls of this method to see if the folder has changed.
Parameters: userName - the name of the user for whom to locate the folder. Parameters: folderName - the name of the folder to locate. operating system specific timestamp indicating when thefolder was last changed. |
login | public MailSession login(UserDO user, String password) throws SystemException(Code) | | Login to the mail system. This method should be called before any other,
to establish the mail session and store.
Parameters: userName - this user name is used to log into the remote system. Parameters: password - the clear-text password to log into the remote system. throws: GroupwareException - if the person cannot log in. the mail session (class Session ) in aSessionSerializer . |
moveMessages | public void moveMessages(MailSession mailSession, String folderName, List ids, String targetFolderName) throws SystemException(Code) | | Move a list of messages from one folder to another.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: folderName - the name of the folder the messages are currently located in. Parameters: ids - the unique identifiers (String instances) of themessages to be moved. Parameters: targetFolderName - the name of the the folder the message will be movedto. exception: MessageNotFoundException - if the folder doesn't exist, or thereis no matching mail in this folder. |
send | public void send(MailSession mailSession, MessageDO messageDO) throws SystemException(Code) | | Send a mime email message that is already composed. If id
has been set in messageDO it is assumed to point to a
message in the drafts folder. Attachments are copied from the message
who match the contents of getAttachmentIds . (All other
attachments are discarded.)
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: messageDO - data object containing full details of themessage to be sent. |
send | public void send(MailSession mailSession, String fromAddress, Collection to, String subject, Object content, String contentType, boolean addToSentFolder) throws SystemException(Code) | | Send an mime email message without using a data object.
Parameters: mailSession - valid mail session to which the user should already belogged in. Parameters: fromAddress - the address of the person sending the mail. This mustbe formatted according to RFC822. Parameters: to - recipients, a Collection containing instances ofString or UserDO orPersonDO . A mixture of these types is allowed. If thetype of an instance is String , then it must be formattedaccording to RFC822.Otherwise, if the type is PersonDO , the methodgetEmailAddress must return a valid address string forthis person. Parameters: subject - clear-text email subject field. Parameters: content - any valid email content type, as defined byMimeMessage . Parameters: contentType - mime type for the content field, asdefined by MimeMessage . Parameters: addToSentFolder - if set to true then the mail is addedto the sent folder of the current email session. |
setUserAliases | final public void setUserAliases(SecuritySession securitySession, String userName, Collection userAliases) throws SystemException(Code) | | Set all of the email aliases for the user provided, on the curent
email server. Each alias in the collection should contain just the 'user'
(or 'local') part of the email address, before the '@' sign.
Parameters: userName - the name of the user for whom to retrieve the email aliases. Parameters: userAliases - a Collection of String instances containing the local part of the different email aliasesthis user has. If the user has no aliaes, an empty collection shouldbe provided. |
setVacationMessage | final public void setVacationMessage(SecuritySession securitySession, String userName, String vacationMessage) throws SystemException(Code) | | Set the vacation message for the user provided.
The vacation message is a text the user can set, which will be sent
to all emails received at this address while the user is not present.
Parameters: userName - the name of the user for whom to get the vacation message. Parameters: vacationMessage - vacation message text for this user. If the userhas no vacation message set, set to null . |
validate | public ValidationErrors validate(SecuritySession securitySession, MessageDO messageDO)(Code) | | Confirm all of the elements of the message are present and valid,
before the message is sent.
Parameters: messageDO - data object to check for consistency andcompleteness. a collection of validation errors if any of themandatory fields are missing, or if fields contain invalid values. |
|
|