PageRenderTime 60ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/ivatagroupware-0.11.3/webmail/src/java/com/ivata/groupware/business/mail/MailBean.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 850 lines | 151 code | 32 blank | 667 comment | 0 complexity | 534a4fd4c49fd14189735dd41d141dbb MD5 | raw file
  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. import java.util.Collection;
  296. import java.util.List;
  297. import javax.ejb.CreateException;
  298. import javax.ejb.EJBException;
  299. import javax.ejb.RemoveException;
  300. import javax.ejb.SessionBean;
  301. import javax.ejb.SessionContext;
  302. import org.picocontainer.PicoContainer;
  303. import com.ivata.groupware.admin.security.server.SecuritySession;
  304. import com.ivata.groupware.admin.security.user.UserDO;
  305. import com.ivata.groupware.business.drive.file.FileContentDO;
  306. import com.ivata.groupware.business.mail.message.MessageDO;
  307. import com.ivata.groupware.business.mail.message.MessageNotFoundException;
  308. import com.ivata.groupware.business.mail.session.MailSession;
  309. import com.ivata.groupware.container.PicoContainerFactory;
  310. import com.ivata.mask.util.SystemException;
  311. import com.ivata.mask.validation.ValidationErrors;
  312. /**
  313. * <p>This session bean provides an interface to the mail system. Every mail
  314. * operation for retrieving deleting and sending messages takes place in this
  315. * class.</p>
  316. *
  317. * @since 2002-07-12
  318. * @author Colin MacLeod
  319. * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
  320. * @author Peter Illes
  321. * @version $Revision: 1.3 $
  322. *
  323. * @ejb.bean
  324. * name="Mail"
  325. * display-name="Mail"
  326. * type="Stateless"
  327. * view-type="both"
  328. * local-jndi-name = "MailLocal"
  329. * jndi-name="MailRemote"
  330. *
  331. * @ejb.transaction
  332. * type = "Required"
  333. *
  334. * @ejb.home
  335. * generate="false"
  336. * remote-class="com.ivata.groupware.business.mail.MailRemoteHome"
  337. *
  338. * @ejb.interface
  339. * remote-class="com.ivata.groupware.business.mail.MailRemote"
  340. */
  341. public class MailBean implements SessionBean {
  342. /**
  343. * <p>Provides the session bean with container-specific information.</p>
  344. */
  345. SessionContext sessionContext;
  346. /**
  347. * <p>Add a composed message to the drafts folder for later sending.</p>
  348. *
  349. * @param mailSession valid mail session to which the user should already be
  350. * logged in.
  351. * @param messageDO data object containing full details of the
  352. * message to be added to the drafts.
  353. * @return new <code>MessageDO</code> with the <code>id</code> set to the
  354. * current value in the mail system.
  355. *
  356. * @ejb.interface-method
  357. * view-type = "remote"
  358. */
  359. public MessageDO addMessageToDraftsFolder(final MailSession mailSession,
  360. final MessageDO messageDO) throws SystemException {
  361. return getMail().addMessageToDraftsFolder(mailSession, messageDO);
  362. }
  363. /**
  364. * <p>Append attachments to a message located in the drafts folder.</p>
  365. *
  366. * @param mailSession valid mail session to which the user should already be
  367. * logged in.
  368. * @param id the unique identifier of the message to which we want to append
  369. * attachments.
  370. * @param attachments <code>List</code> of <code>String</code>s -
  371. * filenames of files waiting in upload directory.
  372. * @return <code>null</code> when the operation failed, otherwise the new
  373. * message id.
  374. * @exception MessageNotFoundException if the folder doesn't exist, or there
  375. * is no matching mail in this folder.
  376. *
  377. * @ejb.interface-method
  378. * view-type = "remote"
  379. */
  380. public MessageDO appendAttachments(final MailSession mailSession,
  381. final String id,
  382. final List attachments) throws SystemException {
  383. return getMail().appendAttachments(mailSession, id, attachments);
  384. }
  385. /**
  386. * <p>Create a new mail folder.</p>
  387. *
  388. * @param mailSession valid mail session to which the user should already be
  389. * logged in.
  390. * @param folderName the full path name of the folder to create.
  391. *
  392. * @ejb.interface-method
  393. * view-type = "remote"
  394. */
  395. public void createFolder(final MailSession mailSession,
  396. final String folderName)
  397. throws SystemException{
  398. getMail().createFolder(mailSession, folderName);
  399. }
  400. /**
  401. * <p>Create a new message in the drafts folder from an existing one,
  402. * based on a 'thread'. The thread indicates that the message is a:<br/>
  403. * <ul>
  404. * <li>reply to all recipients of a previous message</li>
  405. * <li>reply to one recipient of a previous message</li>
  406. * <li>previous message(s) forwarded to new recipients</li>
  407. * <li>an existing (draft) message being altered for resending</li>
  408. * </ul></p>
  409. *
  410. * <p>This new message in the drafts folder can then be used to store
  411. * attachments or for reviewing before sending.</p>
  412. *
  413. * @param mailSession valid mail session to which the user should already be
  414. * logged in.
  415. * @param folderName the name of the folder to copy existing messages from.
  416. * @param messageIds the unique identifier of the messages to be extended.
  417. * Can be <code>null</code> if a new message is requeested. When
  418. * forwarding, multiple address identifiers may be specified otherwise
  419. * (if editing a draft message or replying) only one message identifier
  420. * should be set in the list.
  421. * @param thread set to one of the constants in {@link MailConstants
  422. * MailConstants}.
  423. * @return populated message data object matching the required
  424. * message, and with the <code>id</code> set to the message in the
  425. * drafts folder.
  426. *
  427. * @ejb.interface-method
  428. * view-type = "remote"
  429. */
  430. public MessageDO createThreadMessage(final MailSession mailSession,
  431. final String folderName,
  432. final List messageIds,
  433. final Integer thread)
  434. throws SystemException{
  435. return getMail().createThreadMessage(mailSession, folderName,
  436. messageIds, thread);
  437. }
  438. /**
  439. * <p>Delete a list of messages from the trash folder.</p>
  440. *
  441. * @param mailSession valid mail session to which the user should already be
  442. * logged in.
  443. * @param ids the unique identifiers (<code>String</code> instances) of the
  444. * messages to be removed.
  445. * @exception MessageNotFoundException if the folder doesn't exist, or there
  446. * is no matching mail in this folder.
  447. *
  448. * @ejb.interface-method
  449. * view-type = "remote"
  450. */
  451. public void deleteMessagesFromTrash(final MailSession mailSession,
  452. final List ids)
  453. throws SystemException {
  454. getMail().deleteMessagesFromTrash(mailSession, ids);
  455. }
  456. /**
  457. * <p>Check whether or not a given folder pathname exists.</p>
  458. *
  459. * @param mailSession valid mail session to which the user should already be
  460. * logged in.
  461. * @param folderName the full path name of the folder to check.
  462. * @return <code>true</code> if the folder exists, otherwise <code>false</code>.
  463. *
  464. * @ejb.interface-method
  465. * view-type = "remote"
  466. */
  467. public boolean doesFolderExist(final MailSession mailSession,
  468. final String folderName)
  469. throws SystemException {
  470. return getMail().doesFolderExist(mailSession, folderName);
  471. }
  472. /**
  473. * <p>Called by the container to notify an entity object it has been
  474. * activated.</p>
  475. */
  476. public void ejbActivate() {
  477. }
  478. /**
  479. * <p>Called by the container just after the bean has been created.</p>
  480. *
  481. * @throws CreateException if any error occurs. Never thrown by this class.
  482. *
  483. * @ejb.create-method
  484. */
  485. public void ejbCreate() throws CreateException {
  486. }
  487. /**
  488. * <p>Called by the container to notify the entity object it will be
  489. * deactivated. Called just before deactivation.</p>
  490. */
  491. public void ejbPassivate() {
  492. }
  493. /**
  494. * <p>This method is called by the container when the bean is about
  495. * to be removed.</p>
  496. *
  497. * <p>This method will be called after a client calls the <code>remove</code>
  498. * method of the remote/local home interface.</p>
  499. *
  500. * @throws RemoveException if any error occurs. Currently never thrown by
  501. * this class.
  502. */
  503. public void ejbRemove() {
  504. }
  505. /**
  506. * <p>This method retrieves the requested message and sets all the
  507. * attributes of a MessageDO object for use on client side.</p>
  508. *
  509. * @param mailSession valid mail session to which the user should already be
  510. * logged in.
  511. * @param folderName the name of the folder the message is located in.
  512. * @param id the unique identifier of the message.
  513. * @return a MessageDO instance filled up with the messages attributes,
  514. * except the contents of the attachments.
  515. * @exception MessageNotFoundException if the folder doesn't exist, or there
  516. * is no matching mail in this folder.
  517. *
  518. * @ejb.interface-method
  519. * view-type = "remote"
  520. */
  521. public MessageDO findMessageByFolderMessageId(final MailSession mailSession,
  522. final String folderName,
  523. final String id)
  524. throws SystemException {
  525. return getMail().findMessageByFolderMessageId(mailSession, folderName,
  526. id);
  527. }
  528. /**
  529. * <p>Used in the main folder index page, this method returns the contents
  530. * of a folder as a <code>List</code> of
  531. * <code>MessageDO</code> instances.</p>
  532. *
  533. * <p><strong>Note:</strong> for efficiency reasons, this method does not fill the
  534. * text, format or attachment values of the returned <code>MessageDO</code>
  535. * instance. For that, you must call
  536. * {@link #findMessageByFolderMessageId findMessageByFolderMessageId}.</p>
  537. *
  538. * @param mailSession valid mail session to which the user should already be
  539. * logged in.
  540. * @param folderName the name of the folder to list.
  541. * @param sortBy the field to sort the returned list by. Set to one of the
  542. * <code>SORT_...</code> constants in {@link MailConstants MailConstants}.
  543. * @param sortAscending if <code>true</code> then the messages are sorted in
  544. * ascending order, otherwise (<code>false</code>) they are descending.
  545. * @return <code>List</code> of
  546. * <code>MessageDO</code> instances.
  547. *
  548. * @ejb.interface-method
  549. * view-type = "remote"
  550. */
  551. public List findMessagesInFolder(final MailSession mailSession,
  552. final String folderName,
  553. final Integer sortBy,
  554. final boolean sortAscending)
  555. throws SystemException {
  556. return getMail().findMessagesInFolder(mailSession, folderName, sortBy,
  557. sortAscending);
  558. }
  559. /**
  560. * <p>Retrieve an attachment's content and it's MimeType. This method is
  561. * used to by the download servlet.</p>
  562. *
  563. * @param mailSession valid mail session to which the user should already be
  564. * logged in.
  565. * @param folderName the name of the folder the message is located in.
  566. * @param messageId the unique identifier of the message.
  567. * @param attachmentId the unique identifier of the attachment.
  568. * @return attachment data object containing attachment content
  569. * and mime type.
  570. * @exception MessageNotFoundException if the folder doesn't exist, or there
  571. * is no matching mail in this folder.
  572. *
  573. * @ejb.interface-method
  574. * view-type = "remote"
  575. */
  576. public final FileContentDO getAttachment(final MailSession mailSession,
  577. final String folderName,
  578. final String messageId,
  579. final String attachmentId)
  580. throws SystemException {
  581. return getMail().getAttachment(mailSession, folderName, messageId,
  582. attachmentId);
  583. }
  584. /**
  585. * <p>Get the time the specified mail folder was last modified as a
  586. * <code>long</code>. This can then be saved and compared to subsequent
  587. * calls of this method to see if the folder has changed.</p>
  588. *
  589. * @param userName the name of the user for whom to locate the folder.
  590. * @param folderName the name of the folder to locate.
  591. * @return operating system specific timestamp indicating when the
  592. * folder was last changed.
  593. *
  594. * @ejb.interface-method
  595. * view-type = "remote"
  596. */
  597. public final long getFolderModified(final String userName,
  598. final String folderName)
  599. throws SystemException {
  600. // TODO: return getMail().getFolderModified(userName, folderName);
  601. return 0;
  602. }
  603. /**
  604. * Get the mail implementation from the <code>PicoContainer</code>.
  605. *
  606. * @return valid mail implementation POJO.
  607. */
  608. private Mail getMail() throws SystemException {
  609. PicoContainer container = PicoContainerFactory.getInstance()
  610. .getGlobalContainer();
  611. return (Mail) container.getComponentInstance(Mail.class);
  612. }
  613. /**
  614. * <p>Retrieve all of the email aliases for the user provided, on the curent
  615. * email server. The aliases returned each one containing just the 'user' (or
  616. * 'local') part of the email address, before the '@' sign.</p>
  617. *
  618. * @param userName the name of the user for whom to retrieve the email aliases.
  619. * @return a <code>Collection</code> of <code>String</code> instances containing
  620. * the local part of the different email aliases this user has. If the user
  621. * has no aliaes, an empty collection is returned.
  622. * @throws MandatoryFieldException if the user name is <code>null</code>.
  623. *
  624. * @ejb.interface-method
  625. * view-type = "remote"
  626. */
  627. public final Collection getUserAliases(final SecuritySession securitySession,
  628. final String userName)
  629. throws SystemException {
  630. return getMail().getUserAliases(securitySession, userName);
  631. }
  632. /**
  633. * <p>Get the vacation message for the user provided.</p>
  634. *
  635. * <p>The vacation message is a text the user can set, which will be sent
  636. * to all emails received at this address while the user is not present.</p>
  637. *
  638. * @param userName the name of the user for whom to get the vacation message.
  639. * @return the vacation message text for this user. If the user has no
  640. * vacation message set, <code>null</code> is returned.
  641. * @throws MandatoryFieldException if the user name is <code>null</code>.
  642. *
  643. * @ejb.interface-method
  644. * view-type = "remote"
  645. */
  646. public final String getVacationMessage(final SecuritySession securitySession,
  647. final String userName)
  648. throws SystemException {
  649. return getMail().getVacationMessage(securitySession, userName);
  650. }
  651. /**
  652. * <p>Login to the mail system. This method should be called before any other,
  653. * to establish the mail session and store.</p>
  654. *
  655. * @param userName this user name is used to log into the remote system.
  656. * @param password the clear-text password to log into the remote system.
  657. * @throws EJBException if the person cannot log in.
  658. * @return the mail session (class <code>javax.mail.Session</code>) in a
  659. * <code>SessionSerializer</code>.
  660. *
  661. * @ejb.interface-method
  662. * view-type = "local"
  663. */
  664. public MailSession login(final UserDO user,
  665. final String password)
  666. throws SystemException {
  667. return getMail().login(user, password);
  668. }
  669. /**
  670. * <p>Move a list of messages from one folder to another.</p>
  671. *
  672. * @param mailSession valid mail session to which the user should already be
  673. * logged in.
  674. * @param folderName the name of the folder the messages are currently located in.
  675. * @param ids the unique identifiers (<code>String</code> instances) of the
  676. * messages to be moved.
  677. * @param targetFolderName the name of the the folder the message will be moved
  678. * to.
  679. * @exception MessageNotFoundException if the folder doesn't exist, or there
  680. * is no matching mail in this folder.
  681. *
  682. * @ejb.interface-method
  683. * view-type = "remote"
  684. */
  685. public void moveMessages(final MailSession mailSession,
  686. final String folderName,
  687. final List ids,
  688. final String targetFolderName) throws SystemException {
  689. getMail().moveMessages(mailSession, folderName, ids, targetFolderName);
  690. }
  691. /**
  692. * <p>Send a mime email message that is already composed. If <code>id</code>
  693. * has been set in <code>messageDO</code> it is assumed to point to a
  694. * message in the drafts folder. Attachments are copied from the message
  695. * who match the contents of <code>getAttachmentIds</code>. (All other
  696. * attachments are discarded.)</p>
  697. *
  698. * @param mailSession valid mail session to which the user should already be
  699. * logged in.
  700. * @param messageDO data object containing full details of the
  701. * message to be sent.
  702. *
  703. * @ejb.interface-method
  704. * view-type = "remote"
  705. */
  706. public void send(final MailSession mailSession,
  707. final MessageDO messageDO)
  708. throws SystemException {
  709. getMail().send(mailSession, messageDO);
  710. }
  711. /**
  712. * <p>Send an mime email message without using a data object.</p>
  713. *
  714. * @param mailSession valid mail session to which the user should already be
  715. * logged in.
  716. * @param fromAddress the address of the person sending the mail. This must
  717. * be formatted according to <a
  718. * href='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
  719. * @param to recipients, a <code>Collection</code> containing instances of
  720. * <code>String</code> or <code>UserLocal</code> or
  721. * <code>PersonLocal</code>. A mixture of these types is allowed. If the
  722. * type of an instance is <code>String</code>, then it must be formatted
  723. * according to <a href='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
  724. * Otherwise, if the type is <code>PersonLocal</code>, the method
  725. * <code>getEmailAddress</code> must return a valid address string for
  726. * this person.
  727. * @param cc cc recipients. For format, see <code>to</code> parameter.
  728. * @param bcc bcc recipients. For format, see <code>to</code> parameter.
  729. * @param subject clear-text email subject field.
  730. * @param content any valid email content type, as defined by
  731. * <code>javax.mail.internet.MimeMessage</code>.
  732. * @param contentType mime type for the <code>content</code> field, as
  733. * defined by <code>javax.mail.internet.MimeMessage</code>.
  734. * @param addToSentFolder if set to <code>true</code> then the mail is added
  735. * to the sent folder of the current email session.
  736. *
  737. * @ejb.interface-method
  738. * view-type = "both"
  739. */
  740. public void send(final MailSession mailSession,
  741. final String fromAddress,
  742. final Collection to,
  743. final Collection cc,
  744. final Collection bcc,
  745. final String subject,
  746. Object content, String contentType, boolean addToSentFolder)
  747. throws SystemException {
  748. getMail().send(mailSession, fromAddress, to, cc, bcc, subject, content,
  749. contentType, addToSentFolder);
  750. }
  751. /**
  752. * <p>Set up the context for this entity object. The session bean stores the
  753. * context for later use.</p>
  754. *
  755. * @param sessionContext the new context which the session object should store.
  756. */
  757. public final void setSessionContext(final SessionContext sessionContext) {
  758. this.sessionContext = sessionContext;
  759. }
  760. /**
  761. * <p>Set all of the email aliases for the user provided, on the curent
  762. * email server. Each alias in the collection should contain just the 'user'
  763. * (or 'local') part of the email address, before the '@' sign.</p>
  764. *
  765. * @param userName the name of the user for whom to retrieve the email aliases.
  766. * @param userAliases a <code>Collection</code> of <code>String</code>
  767. * instances containing the local part of the different email aliases
  768. * this user has. If the user has no aliaes, an empty collection should
  769. * be provided.
  770. * @throws MandatoryFieldException if either input is <code>null</code>.
  771. *
  772. * @ejb.interface-method
  773. * view-type = "remote"
  774. */
  775. public final void setUserAliases(final SecuritySession securitySession,
  776. final String userName,
  777. final Collection userAliases)
  778. throws SystemException {
  779. getMail().setUserAliases(securitySession, userName, userAliases);
  780. }
  781. /**
  782. * <p>Set the vacation message for the user provided.</p>
  783. *
  784. * <p>The vacation message is a text the user can set, which will be sent
  785. * to all emails received at this address while the user is not present.</p>
  786. *
  787. * @param userName the name of the user for whom to get the vacation message.
  788. * @param vacationMessage vacation message text for this user. If the user
  789. * has no vacation message set, set to <code>null</code>.
  790. * @throws MandatoryFieldException if the user name is <code>null</code>.
  791. *
  792. * @ejb.interface-method
  793. * view-type = "remote"
  794. */
  795. public final void setVacationMessage(final SecuritySession securitySession,
  796. final String userName,
  797. final String vacationMessage)
  798. throws SystemException {
  799. getMail().setVacationMessage(securitySession, userName, vacationMessage);
  800. }
  801. /**
  802. * <p>Confirm all of the elements of the message are present and valid,
  803. * before the message is sent.</p>
  804. *
  805. * @param messageDO data object to check for consistency and
  806. * completeness.
  807. * @return a collection of validation errors if any of the
  808. * mandatory fields are missing, or if fields contain invalid values.
  809. *
  810. * @ejb.interface-method
  811. * view-type = "remote"
  812. */
  813. public ValidationErrors validate(final SecuritySession securitySession,
  814. final MessageDO messageDO)
  815. throws SystemException {
  816. return getMail().validate(securitySession, messageDO);
  817. }
  818. }