KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > mail > MailBean


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: MailBean.java,v $
31  * Revision 1.3 2005/04/10 20:10:08 colinmacleod
32  * Added new themes.
33  * Changed id type to String.
34  * Changed i tag to em and b tag to strong.
35  * Improved PicoContainerFactory with NanoContainer scripts.
36  *
37  * Revision 1.2 2005/04/09 17:20:00 colinmacleod
38  * Changed copyright text to GPL v2 explicitly.
39  *
40  * Revision 1.1.1.1 2005/03/10 17:51:13 colinmacleod
41  * Restructured ivata op around Hibernate/PicoContainer.
42  * Renamed ivata groupware.
43  *
44  * Revision 1.10 2004/11/12 18:16:08 colinmacleod
45  * Ordered imports.
46  *
47  * Revision 1.9 2004/11/12 15:57:23 colinmacleod
48  * Removed dependencies on SSLEXT.
49  * Moved Persistence classes to ivata masks.
50  *
51  * Revision 1.8 2004/07/13 19:48:12 colinmacleod
52  * Moved project to POJOs from EJBs.
53  * Applied PicoContainer to services layer (replacing session EJBs).
54  * Applied Hibernate to persistence layer (replacing entity EJBs).
55  *
56  * Revision 1.7 2004/03/27 10:31:26 colinmacleod
57  * Split off business logic from remote facades to POJOs.
58  *
59  * Revision 1.6 2004/03/21 21:16:39 colinmacleod
60  * Shortened name to ivata op.
61  *
62  * Revision 1.5 2004/03/21 20:51:51 colinmacleod
63  * Change SecurityServer into interface.
64  * Added checking of mail server.
65  *
66  * Revision 1.4 2004/03/10 22:43:13 colinmacleod
67  * Added security server exception handling.
68  *
69  * Revision 1.3 2004/02/10 19:57:26 colinmacleod
70  * Changed email address.
71  *
72  * Revision 1.2 2004/02/01 22:07:32 colinmacleod
73  * Added full names to author tags
74  *
75  * Revision 1.1.1.1 2004/01/27 20:59:56 colinmacleod
76  * Moved ivata openportal to SourceForge..
77  *
78  * Revision 1.6 2003/12/12 13:24:34 jano
79  * fixing webmail functionality
80  *
81  * Revision 1.5 2003/11/03 11:31:06 jano
82  * commiting webmail,
83  * tryinjg to fix deploying problem
84  *
85  * Revision 1.4 2003/10/28 13:27:51 jano
86  * commiting webmail,
87  * still fixing compile and building openGroupware project
88  *
89  * Revision 1.3 2003/10/15 14:13:00 jano
90  * converting to XDoclet
91  *
92  * Revision 1.2 2003/10/15 14:11:33 colin
93  * fixing for XDoclet
94  *
95  * Revision 1.25 2003/07/15 06:43:40 peter
96  * fixed the last fix
97  *
98  * Revision 1.24 2003/07/15 06:01:59 peter
99  * fixed message text bugs and composed attachments size bug
100  *
101  * Revision 1.23 2003/07/14 15:04:22 jano
102  * peter: fixed invisible attachments problem
103  *
104  * Revision 1.22 2003/07/14 14:52:24 jano
105  * fixing bug in mailBean
106  *
107  * Revision 1.21 2003/07/11 06:31:06 peter
108  * fixed text logic in alternative multiparts
109  *
110  * Revision 1.20 2003/07/07 13:43:32 peter
111  * fixed getAttachment for cases with fileName
112  *
113  * Revision 1.19 2003/06/22 21:28:10 peter
114  * re-fixed attachment handling for multipart cases
115  *
116  * Revision 1.18 2003/06/20 18:31:03 peter
117  * added incorrectly composed mail forwards and self contained attachment like email handling
118  *
119  * Revision 1.17 2003/06/19 10:06:08 jano
120  * add check boxies in registration proces of customer
121  *
122  * Revision 1.16 2003/06/02 06:30:19 peter
123  * create reply and forward message fixed
124  *
125  * Revision 1.15 2003/05/28 05:41:21 peter
126  * added fileName as secondary attachments identifier, when contentId not present
127  *
128  * Revision 1.14 2003/05/27 17:15:12 peter
129  * getAttachment fixed, private getAttachment methnod added
130  *
131  * Revision 1.13 2003/05/15 08:21:12 peter
132  * fixed addMultipart logic - some multipart types weren't included
133  *
134  * Revision 1.12 2003/05/14 11:22:07 peter
135  * fixed bug: getDOFromJavamailMessage was called after folder closed in appendAttachmnets
136  *
137  * Revision 1.11 2003/05/13 15:24:18 peter
138  * attachment compose changes
139  *
140  * Revision 1.10 2003/05/12 16:31:13 peter
141  * attachment compose changes
142  *
143  * Revision 1.9 2003/04/01 17:58:52 colin
144  * removed boolean from InternetAddress constructor (marked as private in my JVM)
145  *
146  * Revision 1.8 2003/03/25 16:18:30 peter
147  * fixed email address validation
148  *
149  * Revision 1.7 2003/03/25 08:23:29 jano
150  * if there is no message in folder -> return null
151  * and validate the email addresses
152  *
153  * Revision 1.6 2003/03/14 10:26:46 jano
154  * adding backdoor man functionality
155  * backdoor man = briezky
156  *
157  * Revision 1.5 2003/03/03 16:57:12 colin
158  * converted localization to automatic paths
159  * added labels
160  * added mandatory fieldName attribute
161  *
162  * Revision 1.4 2003/02/28 10:23:27 peter
163  * fixed handling of plain - one part messages in getDOFromJavaMailMessage
164  *
165  * Revision 1.3 2003/02/27 17:23:09 peter
166  * Changed the return type of getAttachment to FileContentDO
167  *
168  * Revision 1.2 2003/02/25 11:53:33 colin
169  * bugfixes and minor restructuring
170  *
171  * Revision 1.1 2003/02/24 19:09:24 colin
172  * moved to business
173  *
174  * Revision 1.38 2003/02/20 20:26:15 colin
175  * improved validation by adding ValidationField and ValidationException
176  *
177  * Revision 1.37 2003/02/04 17:39:21 colin
178  * copyright notice
179  *
180  * Revision 1.36 2003/01/15 15:43:56 colin
181  * re-implemented:
182  * forwarding/replying (also to multiple messages)
183  * moving messages
184  *
185  * Revision 1.35 2002/11/20 09:21:23 peter
186  * removed duplicated function contents getDOFrom... (Jbuilder bug)
187  *
188  * Revision 1.34 2002/11/17 20:01:24 colin
189  * speed improvements in findMessagesInFolder...
190  *
191  * Revision 1.33 2002/11/12 09:12:38 colin
192  * structural changes. currently mail bean composes and reads messages but
193  * attachment & thread handling not active
194  *
195  * Revision 1.32 2002/10/25 08:31:44 peter
196  * mailFolderSent setting name changed to emailFolderSent
197  *
198  * Revision 1.31 2002/10/23 12:44:37 jano
199  * using new method for get System userName
200  *
201  * Revision 1.30 2002/10/23 09:18:59 jano
202  * there is a new method for generating SystemUserName
203  *
204  * Revision 1.29 2002/10/18 09:18:48 colin
205  * check users to make sure they are enabled before sending them mail
206  *
207  * Revision 1.28 2002/10/14 11:15:46 peter
208  * fixed a bug in (precomposed) send method, the cc fields work now
209  *
210  * Revision 1.27 2002/10/11 10:05:38 jano
211  * add PREFIX to user name for difren site
212  *
213  * Revision 1.26 2002/10/10 14:03:57 peter
214  * changes due to demo version
215  *
216  * Revision 1.25 2002/10/01 05:59:47 peter
217  * modifications in (precomposed) send method
218  *
219  * Revision 1.24 2002/09/17 07:26:24 peter
220  * working version
221  *
222  * Revision 1.23 2002/09/16 16:26:40 peter
223  * the attachments stuff works....
224  *
225  * Revision 1.22 2002/09/13 13:59:17 peter
226  * appendMessages and setDO methods tuned...
227  * it still doesn't work properly
228  *
229  * Revision 1.21 2002/09/12 15:55:25 peter
230  * tuned createMessage and setDO
231  *
232  * Revision 1.20 2002/09/12 07:26:19 colin
233  * added vacation message and user alias methods
234  *
235  * Revision 1.19 2002/09/11 15:57:48 peter
236  * finished createMessage and setDO, debugging needed yet
237  *
238  * Revision 1.18 2002/09/11 11:33:12 peter
239  * moveMessage works, works on createMessage and setDO
240  *
241  * Revision 1.17 2002/09/10 15:38:51 peter
242  * MailBean: works on methods
243  *
244  * Revision 1.16 2002/09/10 14:18:51 peter
245  * MailBean: works on methods
246  *
247  * Revision 1.15 2002/09/10 08:20:16 peter
248  * MailBean: added moveMessage method
249  *
250  * Revision 1.14 2002/09/09 16:07:37 peter
251  * added and modified methods in mail/MailBean
252  *
253  * Revision 1.13 2002/09/09 08:27:24 colin
254  * changed mail bean from stateful to stateless
255  * added new MailSession class
256  *
257  * Revision 1.12 2002/08/30 09:50:31 colin
258  * changed canUser... methods to just can...
259  *
260  * Revision 1.11 2002/08/29 12:23:06 peter
261  * mail display works...
262  *
263  * Revision 1.10 2002/08/27 15:26:25 peter
264  * worked on getDO, should be finished
265  *
266  * Revision 1.9 2002/08/26 15:30:14 peter
267  * MessageDO integration, not finished yet
268  *
269  * Revision 1.8 2002/08/26 11:15:47 peter
270  * added getDo and the basic methods work
271  *
272  * Revision 1.7 2002/08/23 08:09:37 peter
273  * design for MailBean methods, display so far
274  *
275  * Revision 1.6 2002/08/16 12:35:22 peter
276  * fiixed a minor bug in getMessage method
277  *
278  * Revision 1.5 2002/08/16 11:59:00 peter
279  * new mail accessing methods
280  *
281  * Revision 1.4 2002/08/11 11:37:50 colin
282  * added routines to handle server activation and passivisation
283  *
284  * Revision 1.3 2002/07/26 13:08:06 colin
285  * first version with mail server support
286  *
287  * Revision 1.2 2002/07/15 13:29:27 jano
288  * added CreateException
289  *
290  * Revision 1.1 2002/07/15 07:51:04 colin
291  * added new Mail EJB and local interface to settings
292  * -----------------------------------------------------------------------------
293  */

294 package com.ivata.groupware.business.mail;
295
296 import java.util.Collection JavaDoc;
297 import java.util.List JavaDoc;
298
299 import javax.ejb.CreateException JavaDoc;
300 import javax.ejb.EJBException JavaDoc;
301 import javax.ejb.RemoveException JavaDoc;
302 import javax.ejb.SessionBean JavaDoc;
303 import javax.ejb.SessionContext JavaDoc;
304
305 import org.picocontainer.PicoContainer;
306
307 import com.ivata.groupware.admin.security.server.SecuritySession;
308 import com.ivata.groupware.admin.security.user.UserDO;
309 import com.ivata.groupware.business.drive.file.FileContentDO;
310 import com.ivata.groupware.business.mail.message.MessageDO;
311 import com.ivata.groupware.business.mail.message.MessageNotFoundException;
312 import com.ivata.groupware.business.mail.session.MailSession;
313 import com.ivata.groupware.container.PicoContainerFactory;
314 import com.ivata.mask.util.SystemException;
315 import com.ivata.mask.validation.ValidationErrors;
316
317
318 /**
319  * <p>This session bean provides an interface to the mail system. Every mail
320  * operation for retrieving deleting and sending messages takes place in this
321  * class.</p>
322  *
323  * @since 2002-07-12
324  * @author Colin MacLeod
325  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
326  * @author Peter Illes
327  * @version $Revision: 1.3 $
328  *
329  * @ejb.bean
330  * name="Mail"
331  * display-name="Mail"
332  * type="Stateless"
333  * view-type="both"
334  * local-jndi-name = "MailLocal"
335  * jndi-name="MailRemote"
336  *
337  * @ejb.transaction
338  * type = "Required"
339  *
340  * @ejb.home
341  * generate="false"
342  * remote-class="com.ivata.groupware.business.mail.MailRemoteHome"
343  *
344  * @ejb.interface
345  * remote-class="com.ivata.groupware.business.mail.MailRemote"
346  */

347 public class MailBean implements SessionBean JavaDoc {
348     /**
349      * <p>Provides the session bean with container-specific information.</p>
350      */

351     SessionContext JavaDoc sessionContext;
352
353     /**
354      * <p>Add a composed message to the drafts folder for later sending.</p>
355      *
356      * @param mailSession valid mail session to which the user should already be
357      * logged in.
358      * @param messageDO data object containing full details of the
359      * message to be added to the drafts.
360      * @return new <code>MessageDO</code> with the <code>id</code> set to the
361      * current value in the mail system.
362      *
363      * @ejb.interface-method
364      * view-type = "remote"
365      */

366     public MessageDO addMessageToDraftsFolder(final MailSession mailSession,
367             final MessageDO messageDO) throws SystemException {
368         return getMail().addMessageToDraftsFolder(mailSession, messageDO);
369     }
370
371     /**
372      * <p>Append attachments to a message located in the drafts folder.</p>
373      *
374      * @param mailSession valid mail session to which the user should already be
375      * logged in.
376      * @param id the unique identifier of the message to which we want to append
377      * attachments.
378      * @param attachments <code>List</code> of <code>String</code>s -
379      * filenames of files waiting in upload directory.
380      * @return <code>null</code> when the operation failed, otherwise the new
381      * message id.
382      * @exception MessageNotFoundException if the folder doesn't exist, or there
383      * is no matching mail in this folder.
384      *
385      * @ejb.interface-method
386      * view-type = "remote"
387      */

388     public MessageDO appendAttachments(final MailSession mailSession,
389             final String JavaDoc id,
390             final List JavaDoc attachments) throws SystemException {
391         return getMail().appendAttachments(mailSession, id, attachments);
392     }
393
394     /**
395      * <p>Create a new mail folder.</p>
396      *
397      * @param mailSession valid mail session to which the user should already be
398      * logged in.
399      * @param folderName the full path name of the folder to create.
400      *
401      * @ejb.interface-method
402      * view-type = "remote"
403      */

404     public void createFolder(final MailSession mailSession,
405             final String JavaDoc folderName)
406             throws SystemException{
407         getMail().createFolder(mailSession, folderName);
408     }
409
410     /**
411      * <p>Create a new message in the drafts folder from an existing one,
412      * based on a 'thread'. The thread indicates that the message is a:<br/>
413      * <ul>
414      * <li>reply to all recipients of a previous message</li>
415      * <li>reply to one recipient of a previous message</li>
416      * <li>previous message(s) forwarded to new recipients</li>
417      * <li>an existing (draft) message being altered for resending</li>
418      * </ul></p>
419      *
420      * <p>This new message in the drafts folder can then be used to store
421      * attachments or for reviewing before sending.</p>
422      *
423      * @param mailSession valid mail session to which the user should already be
424      * logged in.
425      * @param folderName the name of the folder to copy existing messages from.
426      * @param messageIds the unique identifier of the messages to be extended.
427      * Can be <code>null</code> if a new message is requeested. When
428      * forwarding, multiple address identifiers may be specified otherwise
429      * (if editing a draft message or replying) only one message identifier
430      * should be set in the list.
431      * @param thread set to one of the constants in {@link MailConstants
432      * MailConstants}.
433      * @return populated message data object matching the required
434      * message, and with the <code>id</code> set to the message in the
435      * drafts folder.
436      *
437      * @ejb.interface-method
438      * view-type = "remote"
439      */

440     public MessageDO createThreadMessage(final MailSession mailSession,
441             final String JavaDoc folderName,
442             final List JavaDoc messageIds,
443             final Integer JavaDoc thread)
444             throws SystemException{
445         return getMail().createThreadMessage(mailSession, folderName,
446             messageIds, thread);
447     }
448
449     /**
450      * <p>Delete a list of messages from the trash folder.</p>
451      *
452      * @param mailSession valid mail session to which the user should already be
453      * logged in.
454      * @param ids the unique identifiers (<code>String</code> instances) of the
455      * messages to be removed.
456      * @exception MessageNotFoundException if the folder doesn't exist, or there
457      * is no matching mail in this folder.
458      *
459      * @ejb.interface-method
460      * view-type = "remote"
461      */

462     public void deleteMessagesFromTrash(final MailSession mailSession,
463             final List JavaDoc ids)
464             throws SystemException {
465         getMail().deleteMessagesFromTrash(mailSession, ids);
466     }
467
468     /**
469      * <p>Check whether or not a given folder pathname exists.</p>
470      *
471      * @param mailSession valid mail session to which the user should already be
472      * logged in.
473      * @param folderName the full path name of the folder to check.
474      * @return <code>true</code> if the folder exists, otherwise <code>false</code>.
475      *
476      * @ejb.interface-method
477      * view-type = "remote"
478      */

479     public boolean doesFolderExist(final MailSession mailSession,
480             final String JavaDoc folderName)
481             throws SystemException {
482         return getMail().doesFolderExist(mailSession, folderName);
483     }
484
485     /**
486      * <p>Called by the container to notify an entity object it has been
487      * activated.</p>
488      */

489     public void ejbActivate() {
490     }
491
492     /**
493      * <p>Called by the container just after the bean has been created.</p>
494      *
495      * @throws CreateException if any error occurs. Never thrown by this class.
496      *
497      * @ejb.create-method
498      */

499     public void ejbCreate() throws CreateException JavaDoc {
500     }
501
502     /**
503      * <p>Called by the container to notify the entity object it will be
504      * deactivated. Called just before deactivation.</p>
505      */

506     public void ejbPassivate() {
507     }
508
509     /**
510      * <p>This method is called by the container when the bean is about
511      * to be removed.</p>
512      *
513      * <p>This method will be called after a client calls the <code>remove</code>
514      * method of the remote/local home interface.</p>
515      *
516      * @throws RemoveException if any error occurs. Currently never thrown by
517      * this class.
518      */

519     public void ejbRemove() {
520     }
521
522     /**
523      * <p>This method retrieves the requested message and sets all the
524      * attributes of a MessageDO object for use on client side.</p>
525      *
526      * @param mailSession valid mail session to which the user should already be
527      * logged in.
528      * @param folderName the name of the folder the message is located in.
529      * @param id the unique identifier of the message.
530      * @return a MessageDO instance filled up with the messages attributes,
531      * except the contents of the attachments.
532      * @exception MessageNotFoundException if the folder doesn't exist, or there
533      * is no matching mail in this folder.
534      *
535      * @ejb.interface-method
536      * view-type = "remote"
537      */

538     public MessageDO findMessageByFolderMessageId(final MailSession mailSession,
539             final String JavaDoc folderName,
540             final String JavaDoc id)
541             throws SystemException {
542         return getMail().findMessageByFolderMessageId(mailSession, folderName,
543             id);
544     }
545
546     /**
547      * <p>Used in the main folder index page, this method returns the contents
548      * of a folder as a <code>List</code> of
549      * <code>MessageDO</code> instances.</p>
550      *
551      * <p><strong>Note:</strong> for efficiency reasons, this method does not fill the
552      * text, format or attachment values of the returned <code>MessageDO</code>
553      * instance. For that, you must call
554      * {@link #findMessageByFolderMessageId findMessageByFolderMessageId}.</p>
555      *
556      * @param mailSession valid mail session to which the user should already be
557      * logged in.
558      * @param folderName the name of the folder to list.
559      * @param sortBy the field to sort the returned list by. Set to one of the
560      * <code>SORT_...</code> constants in {@link MailConstants MailConstants}.
561      * @param sortAscending if <code>true</code> then the messages are sorted in
562      * ascending order, otherwise (<code>false</code>) they are descending.
563      * @return <code>List</code> of
564      * <code>MessageDO</code> instances.
565      *
566      * @ejb.interface-method
567      * view-type = "remote"
568      */

569     public List JavaDoc findMessagesInFolder(final MailSession mailSession,
570             final String JavaDoc folderName,
571             final Integer JavaDoc sortBy,
572             final boolean sortAscending)
573             throws SystemException {
574         return getMail().findMessagesInFolder(mailSession, folderName, sortBy,
575             sortAscending);
576     }
577
578     /**
579      * <p>Retrieve an attachment's content and it's MimeType. This method is
580      * used to by the download servlet.</p>
581      *
582      * @param mailSession valid mail session to which the user should already be
583      * logged in.
584      * @param folderName the name of the folder the message is located in.
585      * @param messageId the unique identifier of the message.
586      * @param attachmentId the unique identifier of the attachment.
587      * @return attachment data object containing attachment content
588      * and mime type.
589      * @exception MessageNotFoundException if the folder doesn't exist, or there
590      * is no matching mail in this folder.
591      *
592      * @ejb.interface-method
593      * view-type = "remote"
594      */

595     public final FileContentDO getAttachment(final MailSession mailSession,
596             final String JavaDoc folderName,
597             final String JavaDoc messageId,
598             final String JavaDoc attachmentId)
599             throws SystemException {
600         return getMail().getAttachment(mailSession, folderName, messageId,
601             attachmentId);
602     }
603
604     /**
605      * <p>Get the time the specified mail folder was last modified as a
606      * <code>long</code>. This can then be saved and compared to subsequent
607      * calls of this method to see if the folder has changed.</p>
608      *
609      * @param userName the name of the user for whom to locate the folder.
610      * @param folderName the name of the folder to locate.
611      * @return operating system specific timestamp indicating when the
612      * folder was last changed.
613      *
614      * @ejb.interface-method
615      * view-type = "remote"
616      */

617     public final long getFolderModified(final String JavaDoc userName,
618             final String JavaDoc folderName)
619             throws SystemException {
620         // TODO: return getMail().getFolderModified(userName, folderName);
621
return 0;
622     }
623
624     /**
625      * Get the mail implementation from the <code>PicoContainer</code>.
626      *
627      * @return valid mail implementation POJO.
628      */

629     private Mail getMail() throws SystemException {
630         PicoContainer container = PicoContainerFactory.getInstance()
631             .getGlobalContainer();
632
633         return (Mail) container.getComponentInstance(Mail.class);
634     }
635
636     /**
637      * <p>Retrieve all of the email aliases for the user provided, on the curent
638      * email server. The aliases returned each one containing just the 'user' (or
639      * 'local') part of the email address, before the '@' sign.</p>
640      *
641      * @param userName the name of the user for whom to retrieve the email aliases.
642      * @return a <code>Collection</code> of <code>String</code> instances containing
643      * the local part of the different email aliases this user has. If the user
644      * has no aliaes, an empty collection is returned.
645      * @throws MandatoryFieldException if the user name is <code>null</code>.
646      *
647      * @ejb.interface-method
648      * view-type = "remote"
649      */

650     public final Collection JavaDoc getUserAliases(final SecuritySession securitySession,
651             final String JavaDoc userName)
652             throws SystemException {
653         return getMail().getUserAliases(securitySession, userName);
654     }
655
656     /**
657      * <p>Get the vacation message for the user provided.</p>
658      *
659      * <p>The vacation message is a text the user can set, which will be sent
660      * to all emails received at this address while the user is not present.</p>
661      *
662      * @param userName the name of the user for whom to get the vacation message.
663      * @return the vacation message text for this user. If the user has no
664      * vacation message set, <code>null</code> is returned.
665      * @throws MandatoryFieldException if the user name is <code>null</code>.
666      *
667      * @ejb.interface-method
668      * view-type = "remote"
669      */

670     public final String JavaDoc getVacationMessage(final SecuritySession securitySession,
671             final String JavaDoc userName)
672             throws SystemException {
673         return getMail().getVacationMessage(securitySession, userName);
674     }
675
676     /**
677      * <p>Login to the mail system. This method should be called before any other,
678      * to establish the mail session and store.</p>
679      *
680      * @param userName this user name is used to log into the remote system.
681      * @param password the clear-text password to log into the remote system.
682      * @throws EJBException if the person cannot log in.
683      * @return the mail session (class <code>javax.mail.Session</code>) in a
684      * <code>SessionSerializer</code>.
685      *
686      * @ejb.interface-method
687      * view-type = "local"
688      */

689     public MailSession login(final UserDO user,
690             final String JavaDoc password)
691             throws SystemException {
692         return getMail().login(user, password);
693     }
694
695     /**
696      * <p>Move a list of messages from one folder to another.</p>
697      *
698      * @param mailSession valid mail session to which the user should already be
699      * logged in.
700      * @param folderName the name of the folder the messages are currently located in.
701      * @param ids the unique identifiers (<code>String</code> instances) of the
702      * messages to be moved.
703      * @param targetFolderName the name of the the folder the message will be moved
704      * to.
705      * @exception MessageNotFoundException if the folder doesn't exist, or there
706      * is no matching mail in this folder.
707      *
708      * @ejb.interface-method
709      * view-type = "remote"
710      */

711     public void moveMessages(final MailSession mailSession,
712             final String JavaDoc folderName,
713             final List JavaDoc ids,
714             final String JavaDoc targetFolderName) throws SystemException {
715         getMail().moveMessages(mailSession, folderName, ids, targetFolderName);
716     }
717
718     /**
719      * <p>Send a mime email message that is already composed. If <code>id</code>
720      * has been set in <code>messageDO</code> it is assumed to point to a
721      * message in the drafts folder. Attachments are copied from the message
722      * who match the contents of <code>getAttachmentIds</code>. (All other
723      * attachments are discarded.)</p>
724      *
725      * @param mailSession valid mail session to which the user should already be
726      * logged in.
727      * @param messageDO data object containing full details of the
728      * message to be sent.
729      *
730      * @ejb.interface-method
731      * view-type = "remote"
732      */

733     public void send(final MailSession mailSession,
734             final MessageDO messageDO)
735             throws SystemException {
736         getMail().send(mailSession, messageDO);
737     }
738
739     /**
740      * <p>Send an mime email message without using a data object.</p>
741      *
742      * @param mailSession valid mail session to which the user should already be
743      * logged in.
744      * @param fromAddress the address of the person sending the mail. This must
745      * be formatted according to <a
746      * HREF='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
747      * @param to recipients, a <code>Collection</code> containing instances of
748      * <code>String</code> or <code>UserLocal</code> or
749      * <code>PersonLocal</code>. A mixture of these types is allowed. If the
750      * type of an instance is <code>String</code>, then it must be formatted
751      * according to <a HREF='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
752      * Otherwise, if the type is <code>PersonLocal</code>, the method
753      * <code>getEmailAddress</code> must return a valid address string for
754      * this person.
755      * @param cc cc recipients. For format, see <code>to</code> parameter.
756      * @param bcc bcc recipients. For format, see <code>to</code> parameter.
757      * @param subject clear-text email subject field.
758      * @param content any valid email content type, as defined by
759      * <code>javax.mail.internet.MimeMessage</code>.
760      * @param contentType mime type for the <code>content</code> field, as
761      * defined by <code>javax.mail.internet.MimeMessage</code>.
762      * @param addToSentFolder if set to <code>true</code> then the mail is added
763      * to the sent folder of the current email session.
764      *
765      * @ejb.interface-method
766      * view-type = "both"
767      */

768     public void send(final MailSession mailSession,
769             final String JavaDoc fromAddress,
770             final Collection JavaDoc to,
771             final Collection JavaDoc cc,
772             final Collection JavaDoc bcc,
773             final String JavaDoc subject,
774             Object JavaDoc content, String JavaDoc contentType, boolean addToSentFolder)
775             throws SystemException {
776         getMail().send(mailSession, fromAddress, to, cc, bcc, subject, content,
777             contentType, addToSentFolder);
778     }
779
780     /**
781      * <p>Set up the context for this entity object. The session bean stores the
782      * context for later use.</p>
783      *
784      * @param sessionContext the new context which the session object should store.
785      */

786     public final void setSessionContext(final SessionContext JavaDoc sessionContext) {
787         this.sessionContext = sessionContext;
788     }
789
790     /**
791      * <p>Set all of the email aliases for the user provided, on the curent
792      * email server. Each alias in the collection should contain just the 'user'
793      * (or 'local') part of the email address, before the '@' sign.</p>
794      *
795      * @param userName the name of the user for whom to retrieve the email aliases.
796      * @param userAliases a <code>Collection</code> of <code>String</code>
797      * instances containing the local part of the different email aliases
798      * this user has. If the user has no aliaes, an empty collection should
799      * be provided.
800      * @throws MandatoryFieldException if either input is <code>null</code>.
801      *
802      * @ejb.interface-method
803      * view-type = "remote"
804      */

805     public final void setUserAliases(final SecuritySession securitySession,
806             final String JavaDoc userName,
807             final Collection JavaDoc userAliases)
808             throws SystemException {
809         getMail().setUserAliases(securitySession, userName, userAliases);
810     }
811
812     /**
813      * <p>Set the vacation message for the user provided.</p>
814      *
815      * <p>The vacation message is a text the user can set, which will be sent
816      * to all emails received at this address while the user is not present.</p>
817      *
818      * @param userName the name of the user for whom to get the vacation message.
819      * @param vacationMessage vacation message text for this user. If the user
820      * has no vacation message set, set to <code>null</code>.
821      * @throws MandatoryFieldException if the user name is <code>null</code>.
822      *
823      * @ejb.interface-method
824      * view-type = "remote"
825      */

826     public final void setVacationMessage(final SecuritySession securitySession,
827             final String JavaDoc userName,
828             final String JavaDoc vacationMessage)
829             throws SystemException {
830         getMail().setVacationMessage(securitySession, userName, vacationMessage);
831     }
832
833     /**
834      * <p>Confirm all of the elements of the message are present and valid,
835      * before the message is sent.</p>
836      *
837      * @param messageDO data object to check for consistency and
838      * completeness.
839      * @return a collection of validation errors if any of the
840      * mandatory fields are missing, or if fields contain invalid values.
841      *
842      * @ejb.interface-method
843      * view-type = "remote"
844      */

845     public ValidationErrors validate(final SecuritySession securitySession,
846             final MessageDO messageDO)
847             throws SystemException {
848         return getMail().validate(securitySession, messageDO);
849     }
850 }
851
Popular Tags