Source Code Cross Referenced for MailBean.java in  » Groupware » ivatagroupware » com » ivata » groupware » business » mail » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » ivatagroupware » com.ivata.groupware.business.mail 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2001 - 2005 ivata limited.
003:         * All rights reserved.
004:         * -----------------------------------------------------------------------------
005:         * ivata groupware may be redistributed under the GNU General Public
006:         * License as published by the Free Software Foundation;
007:         * version 2 of the License.
008:         *
009:         * These programs are free software; you can redistribute them and/or
010:         * modify them under the terms of the GNU General Public License
011:         * as published by the Free Software Foundation; version 2 of the License.
012:         *
013:         * These programs are distributed in the hope that they will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016:         *
017:         * See the GNU General Public License in the file LICENSE.txt for more
018:         * details.
019:         *
020:         * If you would like a copy of the GNU General Public License write to
021:         *
022:         * Free Software Foundation, Inc.
023:         * 59 Temple Place - Suite 330
024:         * Boston, MA 02111-1307, USA.
025:         *
026:         *
027:         * To arrange commercial support and licensing, contact ivata at
028:         *                  http://www.ivata.com/contact.jsp
029:         * -----------------------------------------------------------------------------
030:         * $Log: MailBean.java,v $
031:         * Revision 1.3  2005/04/10 20:10:08  colinmacleod
032:         * Added new themes.
033:         * Changed id type to String.
034:         * Changed i tag to em and b tag to strong.
035:         * Improved PicoContainerFactory with NanoContainer scripts.
036:         *
037:         * Revision 1.2  2005/04/09 17:20:00  colinmacleod
038:         * Changed copyright text to GPL v2 explicitly.
039:         *
040:         * Revision 1.1.1.1  2005/03/10 17:51:13  colinmacleod
041:         * Restructured ivata op around Hibernate/PicoContainer.
042:         * Renamed ivata groupware.
043:         *
044:         * Revision 1.10  2004/11/12 18:16:08  colinmacleod
045:         * Ordered imports.
046:         *
047:         * Revision 1.9  2004/11/12 15:57:23  colinmacleod
048:         * Removed dependencies on SSLEXT.
049:         * Moved Persistence classes to ivata masks.
050:         *
051:         * Revision 1.8  2004/07/13 19:48:12  colinmacleod
052:         * Moved project to POJOs from EJBs.
053:         * Applied PicoContainer to services layer (replacing session EJBs).
054:         * Applied Hibernate to persistence layer (replacing entity EJBs).
055:         *
056:         * Revision 1.7  2004/03/27 10:31:26  colinmacleod
057:         * Split off business logic from remote facades to POJOs.
058:         *
059:         * Revision 1.6  2004/03/21 21:16:39  colinmacleod
060:         * Shortened name to ivata op.
061:         *
062:         * Revision 1.5  2004/03/21 20:51:51  colinmacleod
063:         * Change SecurityServer into interface.
064:         * Added checking of mail server.
065:         *
066:         * Revision 1.4  2004/03/10 22:43:13  colinmacleod
067:         * Added security server exception handling.
068:         *
069:         * Revision 1.3  2004/02/10 19:57:26  colinmacleod
070:         * Changed email address.
071:         *
072:         * Revision 1.2  2004/02/01 22:07:32  colinmacleod
073:         * Added full names to author tags
074:         *
075:         * Revision 1.1.1.1  2004/01/27 20:59:56  colinmacleod
076:         * Moved ivata openportal to SourceForge..
077:         *
078:         * Revision 1.6  2003/12/12 13:24:34  jano
079:         * fixing webmail functionality
080:         *
081:         * Revision 1.5  2003/11/03 11:31:06  jano
082:         * commiting webmail,
083:         * tryinjg to fix deploying problem
084:         *
085:         * Revision 1.4  2003/10/28 13:27:51  jano
086:         * commiting webmail,
087:         * still fixing compile and building openGroupware project
088:         *
089:         * Revision 1.3  2003/10/15 14:13:00  jano
090:         * converting to XDoclet
091:         *
092:         * Revision 1.2  2003/10/15 14:11:33  colin
093:         * fixing for XDoclet
094:         *
095:         * Revision 1.25  2003/07/15 06:43:40  peter
096:         * fixed the last fix
097:         *
098:         * Revision 1.24  2003/07/15 06:01:59  peter
099:         * 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;
297:        import java.util.List;
298:
299:        import javax.ejb.CreateException;
300:        import javax.ejb.EJBException;
301:        import javax.ejb.RemoveException;
302:        import javax.ejb.SessionBean;
303:        import javax.ejb.SessionContext;
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:         * <p>This session bean provides an interface to the mail system. Every mail
319:         * operation for retrieving deleting and sending messages takes place in this
320:         * class.</p>
321:         *
322:         * @since 2002-07-12
323:         * @author Colin MacLeod
324:         * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
325:         * @author Peter Illes
326:         * @version $Revision: 1.3 $
327:         *
328:         * @ejb.bean
329:         *      name="Mail"
330:         *      display-name="Mail"
331:         *      type="Stateless"
332:         *      view-type="both"
333:         *      local-jndi-name = "MailLocal"
334:         *      jndi-name="MailRemote"
335:         *
336:         * @ejb.transaction
337:         *      type = "Required"
338:         *
339:         *  @ejb.home
340:         *      generate="false"
341:         *      remote-class="com.ivata.groupware.business.mail.MailRemoteHome"
342:         *
343:         *  @ejb.interface
344:         *      remote-class="com.ivata.groupware.business.mail.MailRemote"
345:         */
346:        public class MailBean implements  SessionBean {
347:            /**
348:             * <p>Provides the session bean with container-specific information.</p>
349:             */
350:            SessionContext sessionContext;
351:
352:            /**
353:             * <p>Add a composed message to the drafts folder for later sending.</p>
354:             *
355:             * @param mailSession valid mail session to which the user should already be
356:             *     logged in.
357:             * @param messageDO data object containing full details of the
358:             *     message to be added to the drafts.
359:             * @return new <code>MessageDO</code> with the <code>id</code> set to the
360:             *     current value in the mail system.
361:             *
362:             * @ejb.interface-method
363:             *      view-type = "remote"
364:             */
365:            public MessageDO addMessageToDraftsFolder(
366:                    final MailSession mailSession, final MessageDO messageDO)
367:                    throws SystemException {
368:                return getMail().addMessageToDraftsFolder(mailSession,
369:                        messageDO);
370:            }
371:
372:            /**
373:             * <p>Append attachments to a message located in the drafts folder.</p>
374:             *
375:             * @param mailSession valid mail session to which the user should already be
376:             *     logged in.
377:             * @param id the unique identifier of the message to which we want to append
378:             *     attachments.
379:             * @param attachments <code>List</code> of <code>String</code>s -
380:             *     filenames of files waiting in upload directory.
381:             * @return <code>null</code> when the operation failed, otherwise the new
382:             *     message id.
383:             * @exception MessageNotFoundException if the folder doesn't exist, or there
384:             *     is no matching mail in this folder.
385:             *
386:             * @ejb.interface-method
387:             *      view-type = "remote"
388:             */
389:            public MessageDO appendAttachments(final MailSession mailSession,
390:                    final String id, final List attachments)
391:                    throws SystemException {
392:                return getMail()
393:                        .appendAttachments(mailSession, id, attachments);
394:            }
395:
396:            /**
397:             * <p>Create a new mail folder.</p>
398:             *
399:             * @param mailSession valid mail session to which the user should already be
400:             *     logged in.
401:             * @param folderName the full path name of the folder to create.
402:             *
403:             * @ejb.interface-method
404:             *      view-type = "remote"
405:             */
406:            public void createFolder(final MailSession mailSession,
407:                    final String folderName) throws SystemException {
408:                getMail().createFolder(mailSession, folderName);
409:            }
410:
411:            /**
412:             * <p>Create a new message in the drafts folder from an existing one,
413:             * based on a 'thread'. The thread indicates that the message is a:<br/>
414:             * <ul>
415:             *   <li>reply to all recipients of a previous message</li>
416:             *   <li>reply to one recipient of a previous message</li>
417:             *   <li>previous message(s) forwarded to new recipients</li>
418:             *   <li>an existing (draft) message being altered for resending</li>
419:             * </ul></p>
420:             *
421:             * <p>This new message in the drafts folder can then be used to store
422:             * attachments or for reviewing before sending.</p>
423:             *
424:             * @param mailSession valid mail session to which the user should already be
425:             *     logged in.
426:             * @param folderName the name of the folder to copy existing messages from.
427:             * @param messageIds the unique identifier of the messages to be extended.
428:             *     Can be <code>null</code> if a new message is requeested. When
429:             *     forwarding, multiple address identifiers may be specified otherwise
430:             *     (if editing a draft message or replying) only one message identifier
431:             *     should be set in the list.
432:             * @param thread set to one of the constants in {@link MailConstants
433:             *     MailConstants}.
434:             * @return populated message data object matching the required
435:             *     message, and with the <code>id</code> set to the message in the
436:             *     drafts folder.
437:             *
438:             * @ejb.interface-method
439:             *      view-type = "remote"
440:             */
441:            public MessageDO createThreadMessage(final MailSession mailSession,
442:                    final String folderName, final List messageIds,
443:                    final Integer thread) throws SystemException {
444:                return getMail().createThreadMessage(mailSession, folderName,
445:                        messageIds, thread);
446:            }
447:
448:            /**
449:             * <p>Delete a list of messages from the trash folder.</p>
450:             *
451:             * @param mailSession valid mail session to which the user should already be
452:             *     logged in.
453:             * @param ids the unique identifiers (<code>String</code> instances) of the
454:             *     messages to be removed.
455:             * @exception MessageNotFoundException if the folder doesn't exist, or there
456:             *     is no matching mail in this folder.
457:             *
458:             * @ejb.interface-method
459:             *      view-type = "remote"
460:             */
461:            public void deleteMessagesFromTrash(final MailSession mailSession,
462:                    final List ids) throws SystemException {
463:                getMail().deleteMessagesFromTrash(mailSession, ids);
464:            }
465:
466:            /**
467:             * <p>Check whether or not a given folder pathname exists.</p>
468:             *
469:             * @param mailSession valid mail session to which the user should already be
470:             *     logged in.
471:             * @param folderName the full path name of the folder to check.
472:             * @return <code>true</code> if the folder exists, otherwise <code>false</code>.
473:             *
474:             * @ejb.interface-method
475:             *      view-type = "remote"
476:             */
477:            public boolean doesFolderExist(final MailSession mailSession,
478:                    final String folderName) throws SystemException {
479:                return getMail().doesFolderExist(mailSession, folderName);
480:            }
481:
482:            /**
483:             * <p>Called by the container to notify an entity object it has been
484:             * activated.</p>
485:             */
486:            public void ejbActivate() {
487:            }
488:
489:            /**
490:             * <p>Called by the container just after the bean has been created.</p>
491:             *
492:             * @throws CreateException if any error occurs. Never thrown by this class.
493:             *
494:             * @ejb.create-method
495:             */
496:            public void ejbCreate() throws CreateException {
497:            }
498:
499:            /**
500:             * <p>Called by the container to notify the entity object it will be
501:             * deactivated. Called just before deactivation.</p>
502:             */
503:            public void ejbPassivate() {
504:            }
505:
506:            /**
507:             * <p>This method is called by the container when the bean is about
508:             * to be removed.</p>
509:             *
510:             * <p>This method will be called after a client calls the <code>remove</code>
511:             * method of the remote/local home interface.</p>
512:             *
513:             * @throws RemoveException if any error occurs. Currently never thrown by
514:             *     this class.
515:             */
516:            public void ejbRemove() {
517:            }
518:
519:            /**
520:             * <p>This method retrieves the requested message and sets all the
521:             * attributes of a MessageDO object for use on client side.</p>
522:             *
523:             * @param mailSession valid mail session to which the user should already be
524:             *     logged in.
525:             * @param folderName the name of the folder the message is located in.
526:             * @param id the unique identifier of the message.
527:             * @return a MessageDO instance filled up with the messages attributes,
528:             *     except the contents of the attachments.
529:             * @exception MessageNotFoundException if the folder doesn't exist, or there
530:             *     is no matching mail in this folder.
531:             *
532:             * @ejb.interface-method
533:             *      view-type = "remote"
534:             */
535:            public MessageDO findMessageByFolderMessageId(
536:                    final MailSession mailSession, final String folderName,
537:                    final String id) throws SystemException {
538:                return getMail().findMessageByFolderMessageId(mailSession,
539:                        folderName, id);
540:            }
541:
542:            /**
543:             * <p>Used in the main folder index page, this method returns the contents
544:             * of a folder as a <code>List</code> of
545:             * <code>MessageDO</code> instances.</p>
546:             *
547:             * <p><strong>Note:</strong> for efficiency reasons, this method does not fill the
548:             * text, format or attachment values of the returned <code>MessageDO</code>
549:             * instance. For that, you must call
550:             * {@link #findMessageByFolderMessageId findMessageByFolderMessageId}.</p>
551:             *
552:             * @param mailSession valid mail session to which the user should already be
553:             *     logged in.
554:             * @param folderName the name of the folder to list.
555:             * @param sortBy the field to sort the returned list by. Set to one of the
556:             *     <code>SORT_...</code> constants in {@link MailConstants MailConstants}.
557:             * @param sortAscending if <code>true</code> then the messages are sorted in
558:             *     ascending order, otherwise (<code>false</code>) they are descending.
559:             * @return <code>List</code> of
560:             *     <code>MessageDO</code> instances.
561:             *
562:             * @ejb.interface-method
563:             *      view-type = "remote"
564:             */
565:            public List findMessagesInFolder(final MailSession mailSession,
566:                    final String folderName, final Integer sortBy,
567:                    final boolean sortAscending) throws SystemException {
568:                return getMail().findMessagesInFolder(mailSession, folderName,
569:                        sortBy, sortAscending);
570:            }
571:
572:            /**
573:             * <p>Retrieve an attachment's content and it's MimeType. This method is
574:             * used to by the download servlet.</p>
575:             *
576:             * @param mailSession valid mail session to which the user should already be
577:             *     logged in.
578:             * @param folderName the name of the folder the message is located in.
579:             * @param messageId the unique identifier of the message.
580:             * @param attachmentId the unique identifier of the attachment.
581:             * @return attachment data object containing attachment content
582:             *     and mime type.
583:             * @exception MessageNotFoundException if the folder doesn't exist, or there
584:             *     is no matching mail in this folder.
585:             *
586:             * @ejb.interface-method
587:             *      view-type = "remote"
588:             */
589:            public final FileContentDO getAttachment(
590:                    final MailSession mailSession, final String folderName,
591:                    final String messageId, final String attachmentId)
592:                    throws SystemException {
593:                return getMail().getAttachment(mailSession, folderName,
594:                        messageId, attachmentId);
595:            }
596:
597:            /**
598:             * <p>Get the time the specified mail folder was last modified as a
599:             * <code>long</code>. This can then be saved and compared to subsequent
600:             * calls of this method to see if the folder has changed.</p>
601:             *
602:             * @param userName the name of the user for whom to locate the folder.
603:             * @param folderName the name of the folder to locate.
604:             * @return operating system specific timestamp indicating when the
605:             * folder was last changed.
606:             *
607:             * @ejb.interface-method
608:             *      view-type = "remote"
609:             */
610:            public final long getFolderModified(final String userName,
611:                    final String folderName) throws SystemException {
612:                // TODO: return getMail().getFolderModified(userName, folderName);
613:                return 0;
614:            }
615:
616:            /**
617:             * Get the mail implementation from the <code>PicoContainer</code>.
618:             *
619:             * @return valid mail implementation POJO.
620:             */
621:            private Mail getMail() throws SystemException {
622:                PicoContainer container = PicoContainerFactory.getInstance()
623:                        .getGlobalContainer();
624:
625:                return (Mail) container.getComponentInstance(Mail.class);
626:            }
627:
628:            /**
629:             * <p>Retrieve all of the email aliases for the user provided, on the curent
630:             * email server. The aliases returned each one containing just the 'user' (or
631:             * 'local') part of the email address, before the '@' sign.</p>
632:             *
633:             * @param userName the name of the user for whom to retrieve the email aliases.
634:             * @return a <code>Collection</code> of <code>String</code> instances containing
635:             *     the local part of the different email aliases this user has. If the user
636:             *     has no aliaes, an empty collection is returned.
637:             * @throws MandatoryFieldException if the user name is <code>null</code>.
638:             *
639:             * @ejb.interface-method
640:             *      view-type = "remote"
641:             */
642:            public final Collection getUserAliases(
643:                    final SecuritySession securitySession, final String userName)
644:                    throws SystemException {
645:                return getMail().getUserAliases(securitySession, userName);
646:            }
647:
648:            /**
649:             * <p>Get the vacation message for the user provided.</p>
650:             *
651:             * <p>The vacation message is a text the user can set, which will be sent
652:             * to all emails received at this address while the user is not present.</p>
653:             *
654:             * @param userName the name of the user for whom to get the vacation message.
655:             * @return the vacation message text for this user. If the user has no
656:             *     vacation message set, <code>null</code> is returned.
657:             * @throws MandatoryFieldException if the user name is <code>null</code>.
658:             *
659:             * @ejb.interface-method
660:             *      view-type = "remote"
661:             */
662:            public final String getVacationMessage(
663:                    final SecuritySession securitySession, final String userName)
664:                    throws SystemException {
665:                return getMail().getVacationMessage(securitySession, userName);
666:            }
667:
668:            /**
669:             * <p>Login to the mail system. This method should be called before any other,
670:             * to establish the mail session and store.</p>
671:             *
672:             * @param userName this user name is used to log into the remote system.
673:             * @param password the clear-text password to log into the remote system.
674:             * @throws EJBException if the person cannot log in.
675:             * @return the mail session (class <code>javax.mail.Session</code>) in a
676:             *    <code>SessionSerializer</code>.
677:             *
678:             * @ejb.interface-method
679:             *      view-type = "local"
680:             */
681:            public MailSession login(final UserDO user, final String password)
682:                    throws SystemException {
683:                return getMail().login(user, password);
684:            }
685:
686:            /**
687:             * <p>Move a list of messages from one folder to another.</p>
688:             *
689:             * @param mailSession valid mail session to which the user should already be
690:             *     logged in.
691:             * @param folderName the name of the folder the messages are currently located in.
692:             * @param ids the unique identifiers (<code>String</code> instances) of the
693:             *     messages to be moved.
694:             * @param targetFolderName the name of the the folder the message will be moved
695:             *     to.
696:             * @exception MessageNotFoundException if the folder doesn't exist, or there
697:             *     is no matching mail in this folder.
698:             *
699:             * @ejb.interface-method
700:             *      view-type = "remote"
701:             */
702:            public void moveMessages(final MailSession mailSession,
703:                    final String folderName, final List ids,
704:                    final String targetFolderName) throws SystemException {
705:                getMail().moveMessages(mailSession, folderName, ids,
706:                        targetFolderName);
707:            }
708:
709:            /**
710:             * <p>Send a mime email message that is already composed. If <code>id</code>
711:             * has been set in <code>messageDO</code> it is assumed to point to a
712:             * message in the drafts folder. Attachments are copied from the message
713:             * who match the contents of <code>getAttachmentIds</code>. (All other
714:             * attachments are discarded.)</p>
715:             *
716:             * @param mailSession valid mail session to which the user should already be
717:             *     logged in.
718:             * @param messageDO data object containing full details of the
719:             *     message to be sent.
720:             *
721:             * @ejb.interface-method
722:             *      view-type = "remote"
723:             */
724:            public void send(final MailSession mailSession,
725:                    final MessageDO messageDO) throws SystemException {
726:                getMail().send(mailSession, messageDO);
727:            }
728:
729:            /**
730:             * <p>Send an mime email message without using a data object.</p>
731:             *
732:             * @param mailSession valid mail session to which the user should already be
733:             *     logged in.
734:             * @param fromAddress the address of the person sending the mail. This must
735:             *    be formatted according to <a
736:             *    href='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
737:             * @param to recipients, a <code>Collection</code> containing instances of
738:             *    <code>String</code> or <code>UserLocal</code> or
739:             *    <code>PersonLocal</code>. A mixture of these types is allowed. If the
740:             *    type of an instance is <code>String</code>, then it must be formatted
741:             *    according to <a href='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
742:             *    Otherwise, if the type is <code>PersonLocal</code>, the method
743:             *    <code>getEmailAddress</code> must return a valid address string for
744:             *    this person.
745:             * @param cc cc recipients. For format, see <code>to</code> parameter.
746:             * @param bcc bcc recipients. For format, see <code>to</code> parameter.
747:             * @param subject clear-text email subject field.
748:             * @param content any valid email content type, as defined by
749:             *    <code>javax.mail.internet.MimeMessage</code>.
750:             * @param contentType mime type for the <code>content</code> field, as
751:             *    defined by <code>javax.mail.internet.MimeMessage</code>.
752:             * @param addToSentFolder if set to <code>true</code> then the mail is added
753:             *    to the sent folder of the current email session.
754:             *
755:             * @ejb.interface-method
756:             *      view-type = "both"
757:             */
758:            public void send(final MailSession mailSession,
759:                    final String fromAddress, final Collection to,
760:                    final Collection cc, final Collection bcc,
761:                    final String subject, Object content, String contentType,
762:                    boolean addToSentFolder) throws SystemException {
763:                getMail().send(mailSession, fromAddress, to, cc, bcc, subject,
764:                        content, contentType, addToSentFolder);
765:            }
766:
767:            /**
768:             * <p>Set up the context for this entity object. The session bean stores the
769:             * context for later use.</p>
770:             *
771:             * @param sessionContext the new context which the session object should store.
772:             */
773:            public final void setSessionContext(
774:                    final SessionContext sessionContext) {
775:                this .sessionContext = sessionContext;
776:            }
777:
778:            /**
779:             * <p>Set all of the email aliases for the user provided, on the curent
780:             * email server. Each alias in the collection should contain just the 'user'
781:             * (or 'local') part of the email address, before the '@' sign.</p>
782:             *
783:             * @param userName the name of the user for whom to retrieve the email aliases.
784:             * @param userAliases a <code>Collection</code> of <code>String</code>
785:             *     instances containing the local part of the different email aliases
786:             *     this user has. If the user has no aliaes, an empty collection should
787:             *     be provided.
788:             * @throws MandatoryFieldException if either input is <code>null</code>.
789:             *
790:             * @ejb.interface-method
791:             *      view-type = "remote"
792:             */
793:            public final void setUserAliases(
794:                    final SecuritySession securitySession,
795:                    final String userName, final Collection userAliases)
796:                    throws SystemException {
797:                getMail()
798:                        .setUserAliases(securitySession, userName, userAliases);
799:            }
800:
801:            /**
802:             * <p>Set the vacation message for the user provided.</p>
803:             *
804:             * <p>The vacation message is a text the user can set, which will be sent
805:             * to all emails received at this address while the user is not present.</p>
806:             *
807:             * @param userName the name of the user for whom to get the vacation message.
808:             * @param vacationMessage vacation message text for this user. If the user
809:             *     has no vacation message set, set to <code>null</code>.
810:             * @throws MandatoryFieldException if the user name is <code>null</code>.
811:             *
812:             * @ejb.interface-method
813:             *      view-type = "remote"
814:             */
815:            public final void setVacationMessage(
816:                    final SecuritySession securitySession,
817:                    final String userName, final String vacationMessage)
818:                    throws SystemException {
819:                getMail().setVacationMessage(securitySession, userName,
820:                        vacationMessage);
821:            }
822:
823:            /**
824:             * <p>Confirm all of the elements of the message are present and valid,
825:             * before the message is sent.</p>
826:             *
827:             * @param messageDO data object to check for consistency and
828:             *     completeness.
829:             * @return a collection of validation errors if any of the
830:             *     mandatory fields are missing, or if fields contain invalid values.
831:             *
832:             * @ejb.interface-method
833:             *      view-type = "remote"
834:             */
835:            public ValidationErrors validate(
836:                    final SecuritySession securitySession,
837:                    final MessageDO messageDO) throws SystemException {
838:                return getMail().validate(securitySession, messageDO);
839:            }
840:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.