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: MessageDO.java,v $
031: * Revision 1.6 2005/10/02 14:08:59 colinmacleod
032: * Added/improved log4j logging.
033: *
034: * Revision 1.5 2005/09/29 13:22:47 colinmacleod
035: * Added read-only functionality to data object classes (with a check on each
036: * setter).
037: *
038: * Revision 1.4 2005/09/14 16:16:52 colinmacleod
039: * Removed unused local and class variables.
040: * Added serialVersionUID.
041: *
042: * Revision 1.3 2005/04/10 18:47:42 colinmacleod
043: * Changed i tag to em and b tag to strong.
044: *
045: * Revision 1.2 2005/04/09 17:20:01 colinmacleod
046: * Changed copyright text to GPL v2 explicitly.
047: *
048: * Revision 1.1.1.1 2005/03/10 17:51:16 colinmacleod
049: * Restructured ivata op around Hibernate/PicoContainer.
050: * Renamed ivata groupware.
051: *
052: * Revision 1.6 2004/09/30 15:09:33 colinmacleod
053: * Bug fixes
054: *
055: * Revision 1.5 2004/07/13 19:48:12 colinmacleod
056: * Moved project to POJOs from EJBs.
057: * Applied PicoContainer to services layer (replacing session EJBs).
058: * Applied Hibernate to persistence layer (replacing entity EJBs).
059: *
060: * Revision 1.4 2004/03/21 21:16:39 colinmacleod
061: * Shortened name to ivata op.
062: *
063: * Revision 1.3 2004/02/10 19:57:26 colinmacleod
064: * Changed email address.
065: *
066: * Revision 1.2 2004/02/01 22:07:32 colinmacleod
067: * Added full names to author tags
068: *
069: * Revision 1.1.1.1 2004/01/27 20:59:57 colinmacleod
070: * Moved ivata openportal to SourceForge..
071: *
072: * Revision 1.2 2003/10/15 14:11:33 colin
073: * fixing for XDoclet
074: *
075: * Revision 1.2 2003/05/12 16:31:52 peter
076: * the attachments are a Vector of FileDOs now
077: * -----------------------------------------------------------------------------
078: */
079: package com.ivata.groupware.business.mail.message;
080:
081: import org.apache.log4j.Logger;
082:
083: import java.util.GregorianCalendar;
084: import java.util.List;
085:
086: import com.ivata.groupware.container.persistence.BaseDO;
087:
088: /**
089: * <p>This is a dependent value class, used to pass data back from
090: * the</p>
091: * {@link com.ivata.groupware.business.mail.MailBean MailBean} to a
092: * client application.</p>
093: *
094: * @since 2002-08-26
095: * @author Peter Illes
096: * @author Colin MacLeod
097: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
098: * @version $Revision: 1.6 $
099: * @see MailBean
100: */
101: public class MessageDO extends BaseDO {
102: /**
103: * Logger for this class.
104: */
105: private static final Logger logger = Logger
106: .getLogger(MessageDO.class);
107:
108: /**
109: * Serialization version (for <code>Serializable</code> interface).
110: */
111: private static final long serialVersionUID = 1L;
112: /**
113: * <p><code>List</code> of attachments as <code>FileDO</code>s. These can be used
114: * to identify the attachment for later downloading.</p>
115: */
116: private List attachments;
117: /**
118: * <p>The mail folder where this message is located.</p>
119: */
120: private String folderName;
121:
122: /**
123: * <p>The format of the text, must be set to one of the formats in
124: * {@link
125: * com.ivata.mask.web.format.FormatConstants
126: * FormatConstants}.</p>
127: */
128: private int format;
129:
130: /**
131: * <p>
132: * This is the <strong>JavaMail</strong> message id.
133: * </p>
134: */
135: private String messageID;
136:
137: /**
138: * <p>The date the message was received.</p>
139: */
140: private GregorianCalendar received;
141:
142: /**
143: * <p>Recipients of the message as a <code>List</code> of strings.</p>
144: */
145: private List recipients;
146:
147: /**
148: * <p>"Blind carbon copy" recipients as List of strings. These are
149: * additional
150: * recipients whose identity is <em>not</em> made known to all other
151: * recipients.</p>
152: */
153: private List recipientsBCC;
154:
155: /**
156: * <p>"Carbon copy" recipients as List of strings. These are
157: * additional
158: * recipients whose identity is made known to all other
159: * recipients.</p>
160: */
161: private List recipientsCC;
162:
163: /**
164: * <p>Senders of the message as a <code>List</code> of strings.</p>
165: */
166: private List senders;
167:
168: /**
169: * <p>The date the message was sent.</p>
170: */
171: private GregorianCalendar sent;
172:
173: /**
174: * <p>The size of the message, including attachments, in bytes.</p>
175: */
176: private Integer size;
177:
178: /**
179: * <p>The subject of the message.</p>
180: */
181: private String subject;
182:
183: /**
184: * <p>The textual content of the message. This can either be
185: * <code>HTML</code> formatted or plain-text, depending on the value
186: * of the
187: * <code>format</code> field.</p>
188: */
189: private String text;
190:
191: /**
192: * <p>Get all of the identifiers for message attachments. This method
193: * retrieves the ids, content types, sizes so they can be used to identify and download the
194: * message attachments.</p>
195: *
196: * @return <p><code>Vector</code> of <code>FileDO</code>s. These can be used to identify the
197: * attachment
198: * for later downloading.</p>
199: *
200: */
201: public List getAttachments() {
202: if (logger.isDebugEnabled()) {
203: logger.debug("getAttachments() - start");
204: }
205:
206: if (logger.isDebugEnabled()) {
207: logger.debug("getAttachments() - end - return value = "
208: + attachments);
209: }
210: return attachments;
211: }
212:
213: /**
214: * <p>Get the mail folder where this message is located.</p>
215: *
216: * @return name of the mail folder where this message is located.
217: *
218: */
219: public final String getFolderName() {
220: if (logger.isDebugEnabled()) {
221: logger.debug("getFolderName() - start");
222: }
223:
224: if (logger.isDebugEnabled()) {
225: logger.debug("getFolderName() - end - return value = "
226: + folderName);
227: }
228: return folderName;
229: }
230:
231: /**
232: * <p>Get the format of the text.</p>
233: *
234: * @return one of the formats in
235: * {@link com.ivata.mask.web.format.FormatConstants
236: * FormatConstants}.</p>
237: *
238: */
239: public final int getFormat() {
240: if (logger.isDebugEnabled()) {
241: logger.debug("getFormat() - start");
242: }
243:
244: if (logger.isDebugEnabled()) {
245: logger
246: .debug("getFormat() - end - return value = "
247: + format);
248: }
249: return format;
250: }
251:
252: /**
253: * <p>
254: * This is the <strong>JavaMail</strong> message id.
255: * </p>
256: *
257: * @return Returns the messageID.
258: */
259: public final String getMessageID() {
260: if (logger.isDebugEnabled()) {
261: logger.debug("getMessageID() - start");
262: }
263:
264: if (logger.isDebugEnabled()) {
265: logger.debug("getMessageID() - end - return value = "
266: + messageID);
267: }
268: return messageID;
269: }
270:
271: /**
272: * <p>Get the time the message was received.</p>
273: *
274: * @return time the message was received, or <code>null</code> if this
275: * has not
276: * been set for this message.
277: *
278: */
279: public final GregorianCalendar getReceived() {
280: if (logger.isDebugEnabled()) {
281: logger.debug("getReceived() - start");
282: }
283:
284: if (logger.isDebugEnabled()) {
285: logger.debug("getReceived() - end - return value = "
286: + this .received);
287: }
288: return this .received;
289: }
290:
291: /**
292: * <p>Get recipients of the message.</p>
293: *
294: * @return recipients of the message, as a <code>List</code>
295: * of <code>String</code> instances, each one formatted according to
296: * <a href='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
297: */
298: public List getRecipients() {
299: if (logger.isDebugEnabled()) {
300: logger.debug("getRecipients() - start");
301: }
302:
303: if (logger.isDebugEnabled()) {
304: logger.debug("getRecipients() - end - return value = "
305: + recipients);
306: }
307: return recipients;
308: }
309:
310: /**
311: * <p>Get "Blind carbon copy" recipients as List of strings. These are
312: * additional recipients whose identity is <em>not</em> made known to
313: * any
314: * other recipients.</p>
315: *
316: * @return recipients of the message, as a <code>List</code>
317: * of <code>String</code> instances, each one formatted according to
318: * <a href='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
319: *
320: */
321: public List getRecipientsBCC() {
322: if (logger.isDebugEnabled()) {
323: logger.debug("getRecipientsBCC() - start");
324: }
325:
326: if (logger.isDebugEnabled()) {
327: logger.debug("getRecipientsBCC() - end - return value = "
328: + recipientsBCC);
329: }
330: return recipientsBCC;
331: }
332:
333: /**
334: * <p>Get "Carbon copy" recipients of the message. These are
335: * additional
336: * recipients whose identity is made known to all other
337: * recipients.</p>
338: *
339: * @return recipients of the message, as a <code>List</code>
340: * of <code>String</code> instances, each one formatted according to
341: * <a href='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
342: */
343: public List getRecipientsCC() {
344: if (logger.isDebugEnabled()) {
345: logger.debug("getRecipientsCC() - start");
346: }
347:
348: if (logger.isDebugEnabled()) {
349: logger.debug("getRecipientsCC() - end - return value = "
350: + recipientsCC);
351: }
352: return recipientsCC;
353: }
354:
355: /**
356: * <p>Get senders of the message.</p>
357: *
358: * @return senders of the message, as a <code>List</code>
359: * of <code>String</code> instances, each one formatted according to
360: * <a href='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
361: *
362: */
363: public List getSenders() {
364: if (logger.isDebugEnabled()) {
365: logger.debug("getSenders() - start");
366: }
367:
368: if (logger.isDebugEnabled()) {
369: logger.debug("getSenders() - end - return value = "
370: + senders);
371: }
372: return senders;
373: }
374:
375: /**
376: * <p>Get the time the message was sent.</p>
377: *
378: * @return time the message was sent, or <code>null</code> if this has
379: * not
380: * been set for this message.
381: *
382: */
383: public final GregorianCalendar getSent() {
384: if (logger.isDebugEnabled()) {
385: logger.debug("getSent() - start");
386: }
387:
388: if (logger.isDebugEnabled()) {
389: logger.debug("getSent() - end - return value = " + sent);
390: }
391: return sent;
392: }
393:
394: /**
395: * <p>Get the size of the message, including attachments.</p>
396: *
397: * @return total size of the message and attachments, in bytes.
398: *
399: */
400: public final Integer getSize() {
401: if (logger.isDebugEnabled()) {
402: logger.debug("getSize() - start");
403: }
404:
405: if (logger.isDebugEnabled()) {
406: logger.debug("getSize() - end - return value = " + size);
407: }
408: return size;
409: }
410:
411: /**
412: * <p>Get the subject of this message.</p>
413: *
414: * @return the subject of the mail, in plain text without
415: * <code>HTML</code> code or character entities.
416: *
417: */
418: public final String getSubject() {
419: if (logger.isDebugEnabled()) {
420: logger.debug("getSubject() - start");
421: }
422:
423: if (logger.isDebugEnabled()) {
424: logger.debug("getSubject() - end - return value = "
425: + subject);
426: }
427: return subject;
428: }
429:
430: /**
431: * <p>Get the textual content of the message.</p>
432: *
433: * @return either be <code>HTML</code> formatted or plain-text,
434: * depending on
435: * the value of the <code>format</code> field.
436: * @see #setFormat
437: *
438: */
439: public final String getText() {
440: if (logger.isDebugEnabled()) {
441: logger.debug("getText() - start");
442: }
443:
444: if (logger.isDebugEnabled()) {
445: logger.debug("getText() - end - return value = " + text);
446: }
447: return text;
448: }
449:
450: /**
451: * <p>Set all of the identifiers for message attachments. This method
452: * will only every be called server-side to set up the atachment list the client can later locate the correct attachments.</p>
453: *
454: * @param attachments <code>List</code> of <code>FileDO</code>s.
455: */
456: public final void setAttachments(final List attachments) {
457: if (logger.isDebugEnabled()) {
458: logger.debug("setAttachments(List attachments = "
459: + attachments + ") - start");
460: }
461:
462: checkSetter();
463: this .attachments = attachments;
464:
465: if (logger.isDebugEnabled()) {
466: logger.debug("setAttachments(List) - end");
467: }
468: }
469:
470: /**
471: * <p>Set the mail folder where this message is located. <strong>Note:</strong>
472: * this
473: * method is not enough to actually <em>move</em> the folder. The
474: * <code>messageDO</code> merely records information about the
475: * message.</p>
476: *
477: * @param folderName new value of folder where this message is located.
478: *
479: */
480: public final void setFolderName(final String folderName) {
481: if (logger.isDebugEnabled()) {
482: logger.debug("setFolderName(String folderName = "
483: + folderName + ") - start");
484: }
485:
486: checkSetter();
487: this .folderName = folderName;
488:
489: if (logger.isDebugEnabled()) {
490: logger.debug("setFolderName(String) - end");
491: }
492: }
493:
494: /**
495: * <p>Set the format of the text.</p>
496: *
497: * @param format one of the formats in
498: * {@link com.ivata.mask.web.format.FormatConstants
499: * FormatConstants}.</p>
500: *
501: */
502: public final void setFormat(final int format) {
503: if (logger.isDebugEnabled()) {
504: logger.debug("setFormat(int format = " + format
505: + ") - start");
506: }
507:
508: checkSetter();
509: this .format = format;
510:
511: if (logger.isDebugEnabled()) {
512: logger.debug("setFormat(int) - end");
513: }
514: }
515:
516: /**
517: * <p>
518: * This is the <strong>JavaMail</strong> message id.
519: * </p>
520: *
521: * @param messageID The messageID to set.
522: * @hibernate.property
523: */
524: public final void setMessageID(final String messageID) {
525: if (logger.isDebugEnabled()) {
526: logger.debug("setMessageID(String messageID = " + messageID
527: + ") - start");
528: }
529:
530: checkSetter();
531: this .messageID = messageID;
532:
533: if (logger.isDebugEnabled()) {
534: logger.debug("setMessageID(String) - end");
535: }
536: }
537:
538: /**
539: * <p>Set the time the message was received.</p>
540: *
541: * @param received valid date and time the message was received.
542: *
543: */
544: public final void setReceived(final GregorianCalendar received) {
545: if (logger.isDebugEnabled()) {
546: logger.debug("setReceived(GregorianCalendar received = "
547: + received + ") - start");
548: }
549:
550: checkSetter();
551: this .received = received;
552:
553: if (logger.isDebugEnabled()) {
554: logger.debug("setReceived(GregorianCalendar) - end");
555: }
556: }
557:
558: /**
559: * <p>Set recipients of the message.</p>
560: *
561: * @param recipients recipients of the message, as a <code>List</code>
562: * of <code>String</code> instances, each one formatted according to
563: * <a href='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
564: *
565: */
566: public final void setRecipients(final List recipients) {
567: if (logger.isDebugEnabled()) {
568: logger.debug("setRecipients(List recipients = "
569: + recipients + ") - start");
570: }
571:
572: checkSetter();
573: this .recipients = recipients;
574:
575: if (logger.isDebugEnabled()) {
576: logger.debug("setRecipients(List) - end");
577: }
578: }
579:
580: /**
581: * <p>Set "Blind carbon copy" recipients as List of strings. These are
582: * additional recipients whose identity is <em>not</em> made known to
583: * any
584: * other recipients.</p>
585: *
586: * @param recipientsBCC recipients of the message, as a
587: * <code>List</code>
588: * of <code>String</code> instances, each one formatted according to
589: * <a href='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
590: *
591: */
592: public final void setRecipientsBCC(final List recipientsBCC) {
593: if (logger.isDebugEnabled()) {
594: logger.debug("setRecipientsBCC(List recipientsBCC = "
595: + recipientsBCC + ") - start");
596: }
597:
598: checkSetter();
599: this .recipientsBCC = recipientsBCC;
600:
601: if (logger.isDebugEnabled()) {
602: logger.debug("setRecipientsBCC(List) - end");
603: }
604: }
605:
606: /**
607: * <p>Set "Carbon copy" recipients of the message. These are
608: * additional
609: * recipients whose identity is made known to all other
610: * recipients.</p>
611: *
612: * @param recipientsCC recipients of the message, as a
613: * <code>List</code>
614: * of <code>String</code> instances, each one formatted according to
615: * <a href='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
616: *
617: */
618: public final void setRecipientsCC(final List recipientsCC) {
619: if (logger.isDebugEnabled()) {
620: logger.debug("setRecipientsCC(List recipientsCC = "
621: + recipientsCC + ") - start");
622: }
623:
624: checkSetter();
625: this .recipientsCC = recipientsCC;
626:
627: if (logger.isDebugEnabled()) {
628: logger.debug("setRecipientsCC(List) - end");
629: }
630: }
631:
632: /**
633: * <p>Set senders of the message.</p>
634: *
635: * @param senders senders of the message, as a <code>List</code>
636: * of <code>String</code> instances, each one formatted according to
637: * <a href='http://www.faqs.org/rfcs/rfc822.HTML'>RFC822</a>.
638: *
639: */
640: public final void setSenders(final List senders) {
641: if (logger.isDebugEnabled()) {
642: logger.debug("setSenders(List senders = " + senders
643: + ") - start");
644: }
645:
646: checkSetter();
647: this .senders = senders;
648:
649: if (logger.isDebugEnabled()) {
650: logger.debug("setSenders(List) - end");
651: }
652: }
653:
654: /**
655: * <p>Set the time the message was sent.</p>
656: *
657: * @param sent valid date and time the message was sent.
658: *
659: */
660: public final void setSent(final GregorianCalendar sent) {
661: if (logger.isDebugEnabled()) {
662: logger.debug("setSent(GregorianCalendar sent = " + sent
663: + ") - start");
664: }
665:
666: checkSetter();
667: this .sent = sent;
668:
669: if (logger.isDebugEnabled()) {
670: logger.debug("setSent(GregorianCalendar) - end");
671: }
672: }
673:
674: /**
675: * <p>Set the size of the message, including attachments.</p>
676: *
677: * @param size total size of the message and attachments, in bytes.
678: *
679: */
680: public final void setSize(final Integer size) {
681: if (logger.isDebugEnabled()) {
682: logger
683: .debug("setSize(Integer size = " + size
684: + ") - start");
685: }
686:
687: checkSetter();
688: this .size = size;
689:
690: if (logger.isDebugEnabled()) {
691: logger.debug("setSize(Integer) - end");
692: }
693: }
694:
695: /**
696: * <p>Set the subject of this message.</p>
697: *
698: * @param subject the subject of the mail, in plain text without
699: * <code>HTML</code> code or character entities.
700: *
701: */
702: public final void setSubject(final String subject) {
703: if (logger.isDebugEnabled()) {
704: logger.debug("setSubject(String subject = " + subject
705: + ") - start");
706: }
707:
708: checkSetter();
709: this .subject = subject;
710:
711: if (logger.isDebugEnabled()) {
712: logger.debug("setSubject(String) - end");
713: }
714: }
715:
716: /**
717: * <p>Set the textual content of the message.</p>
718: *
719: * @param text this can either be <code>HTML</code> formatted or
720: * plain-text,
721: * depending on the value of the <code>format</code> field.
722: * @see #setFormat
723: *
724: */
725: public final void setText(final String text) {
726: if (logger.isDebugEnabled()) {
727: logger.debug("setText(String text = " + text + ") - start");
728: }
729:
730: checkSetter();
731: this .text = text;
732:
733: if (logger.isDebugEnabled()) {
734: logger.debug("setText(String) - end");
735: }
736: }
737: }
|