com.jalios.jcms.mail
Class MailMessage

java.lang.Object
  extended by com.jalios.jstore.BasicStorable
      extended by com.jalios.jcms.Data
          extended by com.jalios.jcms.Publication
              extended by com.jalios.jcms.Content
                  extended by com.jalios.jcms.mail.MailMessage
All Implemented Interfaces:
EditableData, JcmsConstants, ImportConstants, MashupConstants, Searchable, Storable, JaliosConstants, LangPropertyArgument, TreeNode, Cloneable, Comparable<BasicStorable>

public class MailMessage
extends Content

Class used to build and send a mail message.

Example :

   MailMessage msg = new MailMessage("myplugin.log-mail");
   msg.setTo(channel.getDefaultAdmin());
   msg.setSubject("[" + channel.getName() + "] Daily log");
   msg.setContentText("Daily log attached");
   msg.addFile(new File(channel.getRealPath("WEB-INF/data/logs/jcms.log")));
   msg.send();
   
   logger.info("Log mail sent in " + Util.formatDuration(msg.getDuration()));
 
   MailMessage msg = new MailMessage("starwarsplugin.war-mail-alert");
   msg.setFrom("Darth Vader <dv@deathstar.com>");
   msg.setTo("Son <luke@alliance.com>");
   msg.setBcc("Palpatine <palpatine@deathstar.com>");
   for (Member sithMember : sithGroup.getMemberSet()) {   
      msg.addCc(sithMember);
   }
   msg.setSubject("I am your father");
   msg.setContentText("The Force is with you, young Skywalker. But you are not a Jedi yet.");
   msg.setContentHtml("The <strong>Force</strong> is with you, young Skywalker. But you are not a Jedi yet.");
   msg.send();
 

Since:
jcms-6.0.1
Version:
$Revision: 69521 $

Nested Class Summary
static class MailMessage.Part
          Convenient recursive structure to wrap javax.mail.Message Part
static class MailMessage.SentDateComparator<T extends MailMessage>
          Compares two MailMessage using their SentDate in descending order (newest date first).
 
Nested classes/interfaces inherited from class com.jalios.jcms.Publication
Publication.AdateComparator<T extends Publication>, Publication.AdateSelector, Publication.AudienceRightComparator<T extends Publication>, Publication.AudienceRightSelector, Publication.AuthorComparator<T extends Publication>, Publication.AuthorizedSelector, Publication.CanWorkOnSelector, Publication.DdateComparator<T extends Publication>, Publication.EdateComparator<T extends Publication>, Publication.EdateSelector, Publication.PdateComparator<T extends Publication>, Publication.PdateSelector, Publication.PstatusComparator<T extends Publication>, Publication.PstatusSelector, Publication.RatingComparator<T extends Publication>, Publication.ReaderComparator<T extends Publication>, Publication.ReadRightSelector, Publication.ReviewCountComparator<T extends Publication>, Publication.RightComparator<T extends Publication>, Publication.SdateComparator<T extends Publication>, Publication.SdateSelector, Publication.TitleComparator<T extends Publication>, Publication.TrackedSelector, Publication.TypeComparator<T extends Publication>, Publication.UdateComparator<T extends Publication>, Publication.UdateSelector, Publication.UserContentSelector, Publication.VisibleStateSelector, Publication.WorkspaceAuthorSelector, Publication.WorkspaceComparator<T extends Publication>, Publication.WorkspaceSelector
 
Nested classes/interfaces inherited from class com.jalios.jcms.Data
Data.AuthorSelector, Data.CdateSelector, Data.DataNameComparator<T extends Data>, Data.DeletableSelector, Data.ImportSelector, Data.MdateSelector, Data.OpAuthorComparator<T extends Data>, Data.RowIdComparator<T extends Data>, Data.StrongLockSelector
 
Nested classes/interfaces inherited from class com.jalios.jstore.BasicStorable
BasicStorable.CdateComparator<T extends Storable>, BasicStorable.IdComparator<T extends Storable>, BasicStorable.MdateComparator<T extends Storable>
 
Field Summary
protected static int ASCII_WIDTH
           
static String DB_MESSAGE_ACCOUNT
           
static String DB_MESSAGE_BCC
           
static String DB_MESSAGE_CC
           
static String DB_MESSAGE_FROM
           
static String DB_MESSAGE_ID
           
static String DB_MESSAGE_INREPLYTO
           
static String DB_MESSAGE_REFERENCES
           
static String DB_MESSAGE_REPLYTO
           
static String DB_MESSAGE_SUBJECT
           
static String DB_MESSAGE_THREAD
           
static String DB_MESSAGE_TO
           
protected  long duration
           
protected  Map<File,String> fileMap
           
protected  Map<String,Object> headers
           
protected  javax.mail.Message message
           
protected  Collection<MailMessage.Part> multiparts
           
static String REVISION
           
static String SEP
           
 
Fields inherited from class com.jalios.jcms.Publication
adate, allCatIdSet, authGrpIdSet, authGrpIdSetDirty, authGrpIdSetInit, authMbrIdSet, authMbrIdSetDirty, authMbrIdSetInit, authorizedGroupSet, authorizedMemberSet, categories, categorySet, catIdSet, catIdSetDirty, catIdSetInit, CTRL_TOPIC_ADVANCED, CTRL_TOPIC_CATEGORIES, CTRL_TOPIC_WORKFLOW, edate, friendlyURLSet, hasNoReadRightsDBData, indexMgr, isTracked, mainInstance, mainLanguage, majorVersion, mergeDate, mergeId, minorVersion, pdate, pstatus, readerCount, roleMap, sdate, templates, title, titleML, udate, updateGroupSet, updateMemberSet, wfExpressAlarmEntry, wfReminderAlarmEntry, workflowId, workspace
 
Fields inherited from class com.jalios.jcms.Data
author, authorDBID, channel, DISPLAY_URL_EXTRA_INFO, extension, extraDataMap, extraDBDataMapToSaveOnOp, importMap, opAuthor, opDelegate
 
Fields inherited from class com.jalios.jstore.BasicStorable
cdate, ddate, id, mdate, store
 
Fields inherited from interface com.jalios.jcms.mashup.ImportConstants
IMPORT_ALARM_MGR, IMPORT_AUTHOR_PROP, IMPORT_CATEGORY_DEFAULT, IMPORT_DC_ATTR, IMPORT_DC_STEP, IMPORT_DIR, IMPORT_ENABLED, IMPORT_JDOM_ELEMENT, IMPORT_LOG_FILE, IMPORT_LOG_MAX, IMPORT_OPTIONS, IMPORT_OPTIONS_DC_CONTEXT, IMPORT_ROOT_PROP, IMPORT_SOURCE_FILE, IMPORT_SOURCE_PREFIX_PROP, IMPORT_SOURCES_DIR, IMPORT_STEP_CLEAN, IMPORT_STEP_IMPORT, IMPORT_STEP_UPDATE_REF, IMPORT_WS_PROP
 
Fields inherited from interface com.jalios.jcms.mashup.MashupConstants
DATA_TAG, DATASET_TAG, FIELD_CLASS, FIELD_ENTRY, FIELD_ITEM, FIELD_KEY, FIELD_NAME, FIELD_TAG, FIELD_VALUE, FILE_FIELD, FILE_ID, FILE_MTIME, FILE_SIZE, FILE_TAG, FILE_TICKET, FILESET_TAG, RELATED_TAG
 
Fields inherited from interface com.jalios.jcms.JcmsConstants
ADATE_SEARCH, ADMIN_NOTES_PROP, ADVANCED_TAB, ARCHIVES_DIR, CATEGORY_TAB, CDATE_SEARCH, COMMON_ALARM, CONTENT_TAB, COOKIE_MAX_AGE, CTRL_TOPIC_INTERNAL, CTRL_TOPIC_REF, CTRL_TOPIC_VALUE, CTRL_TOPIC_WRITE, CUSTOM_PROP, DOCCHOOSER_HEIGHT, DOCCHOOSER_WIDTH, DOCS_DIR, EDATE_SEARCH, EMAIL_REGEXP, ERROR_MSG, FORBIDDEN_FILE_ACCESS, FORBIDDEN_REDIRECT, FORCE_REDIRECT, ICON_ARCHIVE, ICON_LOCK, ICON_LOCK_STRONG, ICON_WARN, ICON_WH_BOOK_CLOSED, ICON_WH_BOOK_OPEN, INFORMATION_MSG, JALIOS_JUNIT_PROP, JCMS_CADDY, JCMS_MSG_LIST, JSYNC_DOWNLOAD_DIR, JSYNC_SYNC_ALARM, LOG_FILE, LOG_TOPIC_SECURITY, LOGGER_PROP, LOGGER_XMLPROP, MBR_PHOTO_DIR, MDATE_SEARCH, MONITOR_XML, OP_CREATE, OP_DEEP_COPY, OP_DEEP_DELETE, OP_DELETE, OP_MERGE, OP_UPDATE, PDATE_SEARCH, PHOTO_DIR, PHOTO_ICON, PHOTO_ICON_HEIGHT, PHOTO_ICON_WIDTH, PHOTO_LARGE, PHOTO_LARGE_HEIGHT, PHOTO_LARGE_WIDTH, PHOTO_NORMAL, PHOTO_NORMAL_HEIGHT, PHOTO_NORMAL_WIDTH, PHOTO_SMALL, PHOTO_SMALL_HEIGHT, PHOTO_SMALL_WIDTH, PHOTO_TINY, PHOTO_TINY_HEIGHT, PHOTO_TINY_WIDTH, PREVIOUS_TAB, PRINT_VIEW, PRIVATE_FILE_ACCESS, PUBLIC_FILE_ACCESS, READ_RIGHT_TAB, SDATE_SEARCH, SEARCHENGINE_ALARM, SESSION_AUTHORIZED_FILENAMES_SET, STATS_REPORT_DIR, STATUS_PROP, STORE_XML, TEMPLATE_TAB, THUMBNAIL_LARGE_HEIGHT, THUMBNAIL_LARGE_WIDTH, THUMBNAIL_SMALL_HEIGHT, THUMBNAIL_SMALL_WIDTH, UDATE_SEARCH, UPDATE_RIGHT_TAB, UPLOAD_DIR, URL_REGEXP, WARNING_MSG, WEBAPP_PROP, WFEXPRESS_ALARM, WFREMINDER_ALARM, WORKFLOW_TAB, WORKFLOW_XML
 
Fields inherited from interface com.jalios.util.JaliosConstants
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR
 
Constructor Summary
MailMessage()
           
MailMessage(MailMessage other)
           
MailMessage(javax.mail.Message msg)
           
MailMessage(String origin)
           
 
Method Summary
 MailMessage addAttachements(FileDocument v)
           
 MailMessage addAttachements(Set<FileDocument> v)
           
 MailMessage addBcc(Member v)
           
 MailMessage addBcc(Set<Member> v)
           
 MailMessage addBcc(String v)
           
 MailMessage addCc(Member v)
           
 MailMessage addCc(Set<Member> v)
           
 MailMessage addCc(String v)
           
 MailMessage addFile(File file)
          Add a file to send with this MailMessage.
 MailMessage addFile(File file, String id)
          Add a file to send with this MailMessage.
 MailMessage addTo(Member v)
           
 MailMessage addTo(Set<Member> v)
           
 MailMessage addTo(String v)
           
protected  javax.mail.Message buildOneMessageForAll()
          Create one message to be sent to all recipients.
protected  javax.mail.Message[] buildOneMessageForEach()
          Create one message one for each recipients.
protected  void fillMessageContent(javax.mail.Message message)
           
 String getAccount()
           
protected  Set<String> getAddressSet(javax.mail.Address[] ia)
          Returns a Set of Address.toString()
 Set<FileDocument> getAttachements()
           
 Set<FileDocument> getAttachements(boolean b)
           
 Set<String> getBcc()
           
 javax.mail.internet.InternetAddress[] getBccIA()
           
 Set<Member> getBccMember()
           
 Set<Member> getBccMember(boolean b)
           
 Set<String> getCc()
           
 javax.mail.internet.InternetAddress[] getCcIA()
           
 Set<Member> getCcMember()
           
 Set<Member> getCcMember(boolean b)
           
 String getContentHtml()
           
 String getContentText()
           
 javax.mail.BodyPart[] getCustomBodyParts()
           
protected  javax.activation.DataHandler getDataHandler(File file)
          Compute the correct handler to manage this file
 long getDuration()
          Retrieve the time the sending process took to execute.
 Map<File,String> getFileMap()
          Retrieve the Map of File/id to send in this MailMessage.
protected  String getFirstAddress(javax.mail.Address[] ia)
          Returns the first Address.toString()
 javax.mail.internet.InternetAddress getFirstFromIA()
          Resolve "From" from all froms and Member's from
protected  javax.mail.internet.InternetAddress getFirstIA(String email, Member mbr)
           
 String getFrom()
           
 javax.mail.internet.InternetAddress[] getFromIA()
           
 Member getFromMember()
           
protected  javax.mail.internet.InternetAddress[] getIAQuietly(Set<String> address, Set<Member> addressMember)
          Returns an array of InternetAddress joins of addresses and Member's addresses
 String getInReplyTo()
           
 Collection<? extends MailMessage> getMailMessageReplies()
          Returns a Collection of MailMessage replies of the current MailMessage
 Collection<? extends MailMessage> getMailMessageThread()
          Returns a Collection of MailMessage, thread of the current discussion in ascending order (oldest date first).
 String getMatchingRecipient(Pattern pattern)
          Returns the address matching the given pattern in all recipient and members
 String getMatchingRecipient(String address)
          Returns the address matching (indexOf) the given address in all recipient and members
 String getMessageId()
           
 String getOrigin()
           
 int getPriority()
           
 Date getReceivedDate()
           
 Set<String> getRecipient()
           
 Set<Member> getRecipientMember()
           
 Set<String> getReferences()
           
 String getReplyTo()
           
 javax.mail.internet.InternetAddress[] getReplyToIA()
           
 Member getReplyToMember()
           
 boolean getSendAcknowledge()
          Get whether acknowledge message should be sent at end of process.
 Member getSenderMember()
           
 boolean getSendOneMailPerRecipient()
          Get sending mode, one mail for all recipients (false), or one mail for each recipients (true).
 Date getSentDate()
           
 Member getSingleRecipient()
          Returns the single Member recipients of the message or null if there is multiple recipients
 String getSubject()
           
 Map<String,Object> getTemporaryHeaders()
          Returns a temporary Map of all mail's header.
 javax.mail.Message getTemporaryMessage()
          Returns temporary javax.mail.Message store while fetching mail Message might be null. Message fields calls can throw Exception if MailBox is closed.
 Collection<MailMessage.Part> getTemporaryMultiparts()
          Returns flatten collection of MailMessage.Part with decoded Files and Contents
 String getThread()
           
 Set<String> getTo()
           
 javax.mail.internet.InternetAddress[] getToIA()
           
 Set<Member> getToMember()
           
 Set<Member> getToMember(boolean b)
           
 Collection<? extends TreeNode> getTreeChildren()
          Returns a Collection of TreeNode children of the current node
 TreeNode getTreeParent()
          Returns parent of the current node
protected  void performBeforeWrite(int op, Member mbr, Map context)
          Called to perform some action before the write.
 void send()
          Send this MailMessage.
 void send(HashMap<String,Object> ctxt)
          Send this MailMessage.
protected  void sendAcknowledge(Collection<javax.mail.Message> successMessages, Collection<javax.mail.Message> errorMessages)
           
 void sendInThread()
          Send this MailMessage in a seperate thread.
 void sendInThread(HashMap<String,Object> ctxt)
          Send this MailMessage in a seperate thread.
 void setAccount(String v)
           
 void setAttachements(Set<FileDocument> v)
           
 MailMessage setBcc(Member v)
           
 void setBcc(Set<String> v)
           
 MailMessage setBcc(String v)
           
 void setBccMember(Set<Member> v)
           
 MailMessage setCc(Member v)
           
 void setCc(Set<String> v)
           
 MailMessage setCc(String v)
           
 void setCcMember(Set<Member> v)
           
 void setContentHtml(String v)
           
 MailMessage setContentHtmlFromJsp(String jspPath, Member loggedMember, String language, HashMap<Object,Object> requestAttribute, HashMap<Object,Object> sessionAttribute)
          Set the HTML text content of this MailMessage from the rendering of the specified jsp.
 void setContentText(String v)
           
 MailMessage setContentTextFromJsp(String jspPath, Member loggedMember, String language, HashMap<Object,Object> requestAttribute, HashMap<Object,Object> sessionAttribute)
          Set the plain text content of this MailMessage from the rendering of the specified jsp.
 void setCustomBodyParts(javax.mail.BodyPart[] v)
           
 MailMessage setFrom(Member v)
           
 void setFrom(String v)
           
 void setFromMember(Member v)
           
 void setInReplyTo(String v)
           
protected  void setMessage(javax.mail.Message msg)
          Set fields for the given Message and download attachements in temporary folder Caller should also set: Account setAccount() Author setAuthor()
 void setMessageId(String v)
           
 void setOrigin(String origin)
           
 void setPriority(int v)
           
 void setReceivedDate(Date v)
           
 void setReferences(Set<String> v)
           
 MailMessage setReplyTo(Member v)
           
 void setReplyTo(String v)
           
 void setReplyToMember(Member v)
           
 void setSendAcknowledge(boolean sendAcknowledge)
          Set whether acknowledge message should be sent at end of process.
 void setSendOneMailPerRecipient(boolean sendOneMailPerRecipient)
          Set sending mode, one mail for all recipients (false), or one mail for each recipients (true).
 void setSentDate(Date v)
           
 void setSubject(String v)
           
 void setThread(String v)
           
 MailMessage setTo(Member v)
           
 void setTo(Set<String> v)
           
 MailMessage setTo(String v)
           
 void setToMember(Set<Member> v)
           
 
Methods inherited from class com.jalios.jcms.Publication
addAuthorizedGroup, addAuthorizedMember, addCategory, addFollower, addWeakReferrer, addWFExpressAlarm, addWFReminderAlarm, assignCommonPublicationFields, assignRole, assignRole, canBeArchived, canBeArchived, canBeEditedFieldByField, canBeFollowedBy, canBeReadBy, canBeReadBy, canBeReadBy, canBeReadBy, canBeReadBy, canCreateCopy, canCreateCopy, canCreateWorkCopy, canMergeWorkCopy, checkCreate, checkDelete, checkIntegrity, checkLang, checkMember, checkMerge, checkStateChange, checkStateChange, checkTemplateEntry, checkUpdate, checkWrite, clearTransientIndex, cloneDBDataCollections, computeSignature, computeSignature, containsCategory, createCopy, createWFNote, createWFNote, createWorkCopy, exportXmlField, getAbstract, getAbstract, getAbstract, getAbstractML, getAccessCount, getAdate, getAdateComparator, getAdateSelector, getAllCatIdSet, getAllFilePath, getAllWikiText, getAllWysiwygText, getAudiencedRightsString, getAudienceRightComparator, getAudienceRightSelector, getAuthGrpIdSet, getAuthMbrIdSet, getAuthorizedGroupSet, getAuthorizedMemberSet, getAuthorizedSelector, getCanWorkOnSelector, getCategories, getCategories, getCategorySet, getCatIdSet, getComparator, getComparator, getComparator, getCSVHeader, getDataName, getDate, getDate, getDateSelector, getDBDataRevision, getDdateComparator, getDefaultTemplateUsage, getDescendantCategorySet, getDescendantCategorySet, getDescendantCategorySet, getDisplayTemplateFile, getDocumentLinkSet, getEdate, getEdateComparator, getEdateSelector, getEstimatedReminderCount, getExternalLinkSet, getFieldInMainLanguage, getFieldValue, getFirstDescendantCategory, getFirstDescendantCategory, getFirstDescendantCategory, getFollowerList, getFriendlyURLSet, getGlobalRating, getHasNoReadRights, getImportConflictCopy, getImportVersion, getIndexingDate, getInternalWorkflow, getLinkDataSet, getMainInstance, getMainLanguage, getMajorVersion, getMemberSetAssignedToRole, getMergeDate, getMergeId, getMinorVersion, getNextWFStateSet, getPdate, getPdateComparator, getPdateSelector, getPstatus, getPstatusAlarmEntry, getPstatusComparator, getPstatusSelector, getPstatusSelector, getQueryTemplateFile, getRatingComparator, getReaderComparator, getReaderCount, getReaderTrackerList, getReadRightSelector, getReadRightsString, getReview, getReviewCount, getReviewCountComparator, getReviewList, getReviewList, getRightComparator, getRoleMap, getRoleMapStr, getSdate, getSdateComparator, getSdateSelector, getSearchStrings, getTemplate, getTemplateEntry, getTemplateEntry, getTemplateEntrySet, getTemplatePath, getTemplatePath, getTemplates, getTitle, getTitle, getTitle, getTitleComparator, getTitleComparator, getTitleML, getTrackedSelector, getTreeRoot, getTypeComparator, getTypeLabel, getUdate, getUdateComparator, getUdateSelector, getUpdateGroupSet, getUpdateMemberSet, getVersionString, getVisibleStateSelector, getWeakReferrerSet, getWFNoteList, getWFState, getWFStateLabel, getWFStateLabelHtml, getWorkCopySet, getWorkflow, getWorkflowId, getWorkspace, getWorkspaceAuthorSelector, getWorkspaceComparator, getWorkspaceId, getWorkspaceSelector, getWSTypeEntry, getWSTypeEntry, hasAlreadyVoted, hasAnyReadRights, hasBeenReadBy, hasCategory, hasImportConflict, hasNoReadRights, hasReview, hasWeakReferrers, importConvertToLocal, importMarkAsMerged, importOverrideAndUpdate, importXml, init, initCopy, initializeDBDataCollections, internalCanBeReadBy, isAudienced, isDefaultTemplate, isFollowedBy, isImportConflictCopy, isInRole, isInVisibleState, isPublic, isRoleAssigned, isTracked, isTreeLeaf, isTreeNode, isUserContent, isUserContentType, isVersioned, isWorkCopy, majorUpdate, notifyFollowers, performAfterWrite, performCreate, performDelete, performMerge, performMerge, performUpdate, prepareMergeCopy, putPstatusAlarmEntry, removeAllDescendants, removeAllFollowers, removeAllReaderTracker, removeAuthorizedGroup, removeAuthorizedMember, removeCategory, removeDataSet, removeFollower, removeImportMetadata, removePstatusAlarmEntry, removeWeakReferrer, removeWFExpressAlarm, removeWFReminderAlarm, resolveTypeTemplateEntry, setAbstract, setAbstract, setAdate, setAllCatIdSet, setAuthGrpIdSet, setAuthMbrIdSet, setAuthorizedGroupSet, setAuthorizedMemberSet, setCategories, setCategorySet, setCatIdSet, setCdate, setEdate, setFieldValue, setFriendlyURLSet, setHasNoReadRights, setImportConflictCopy, setImportVersion, setMainInstance, setMainLanguage, setMajorVersion, setMergeDate, setMergeId, setMinorVersion, setPdate, setPstatus, setReaderCount, setRoleMap, setRoleMapStr, setRoleMemberSetMap, setSdate, setTemplate, setTemplates, setTitle, setTitle, setTitleML, setTracked, setUdate, setUpdateGroupSet, setUpdateMemberSet, setWorkflow, setWorkflowId, setWorkspace, setWorkspaceId, toCSV, toFullString, toString, trackReader, unassignMember, unassignRole, updatePstatus, updateTemplate
 
Methods inherited from class com.jalios.jcms.Data
canRequestLock, checkCreate, checkDelete, checkIntegrity, checkLockMember, checkStrongLockMember, checkUpdate, clone, computeDBIDArray, exportXml, exportXml, exportXml, exportXml, exportXmlRelated, exportXmlRelated, fillExportXmlFieldAttributes, getAllReferrerSet, getAllReferrerSet, getAllTypeFieldEntry, getAuthor, getAuthor, getAuthorComparator, getAuthorDBID, getAuthorId, getAuthorSelector, getBooleanFieldValue, getBooleanFieldValue, getCaddyComparator, getCategoryFieldValue, getCategoryFieldValue, getCdateSelector, getDataImage, getDataImage, getDataImage, getDataNameComparator, getDeletableSelector, getDisplayLink, getDisplayLink, getDisplayUrl, getDoubleFieldValue, getDoubleFieldValue, getExportXmlDataValue, getExtension, getExtraData, getExtraDataMap, getExtraDBData, getExtraDBDataMap, getExtraInfo, getExtraInfoMap, getFieldStatusMap, getFieldValue, getFieldValue, getFieldValue, getGenericThumbnail, getImportAuthor, getImportBatch, getImportDate, getImportDisplayUrl, getImportId, getImportMap, getImportMdate, getImportSelector, getImportSignature, getImportSource, getImportSourceUrl, getImportUrl, getIntFieldValue, getIntFieldValue, getLangPropertyValue, getLinkCount, getLinkIndexedDataSet, getLinkIndexedDataSet, getLockDate, getLockInfo, getLockMember, getLongFieldValue, getLongFieldValue, getMdateSelector, getNewDefaultExtraDataMap, getNewDefaultExtraDataMap, getNewDefaultExtraDataMap, getNewDefaultExtraDataMap, getNewDefaultExtraDBDataMap, getNewDefaultExtraDBDataMap, getNewDefaultExtraDBDataMap, getNewDefaultExtraDBDataMap, getOpAuthor, getOpAuthorComparator, getOpDelegate, getRowId, getRowIdComparator, getStrongLock, getStrongLockDate, getStrongLockInfo, getStrongLockMember, getStrongLockSelector, getTypeEntry, getTypeFieldsEntries, getUpdateInstance, hashCode, importXmlFieldsWithReferences, importXmlFiles, importXmlReferences, isDBData, isImported, isImportUpdated, isInDatabase, isLocked, isPersisted, isStrongLocked, lock, markNewImport, mergeHybridLink, performCreate, performDelete, performUpdate, prepareUpdateContext, printDataName, printDisplayLinkEnd, printDisplayLinkStart, printDisplayUrl, printDisplayUrl, putStrongLock, releaseStrongLock, releaseStrongLock, removeExtraData, removeExtraDBData, removeExtraInfo, setAuthor, setAuthorDBID, setAuthorId, setBooleanFieldValue, setCategoryFieldValue, setDoubleFieldValue, setExtension, setExtraData, setExtraDataMap, setExtraDBData, setExtraDBDataMap, setExtraDBDataMap, setExtraInfo, setFieldValue, setImportAuthor, setImportBatch, setImportDate, setImportDisplayUrl, setImportId, setImportMap, setImportMdate, setImportSignature, setImportSource, setImportSourceUrl, setImportUpdated, setIntFieldValue, setLongFieldValue, setMdate, setOpAuthor, setOpDelegate, setRowId, unlock, unlock, unmarkNewImport, updateExtraDataMap, updateExtraDBDataMap, updateIndexTreeSet
 
Methods inherited from class com.jalios.jstore.BasicStorable
clearId, compareTo, equals, getAttribute, getAttributes, getCdate, getCdateComparator, getDdate, getId, getIdComparator, getMdate, getMdateComparator, getStore, getUrid, hasBeenUpdated, isStored, resolveAtt, resolveVal, setAttributes, setDdate, setId, setStore, toXml
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

SEP

public static final String SEP
See Also:
Constant Field Values

DB_MESSAGE_ID

public static final String DB_MESSAGE_ID
See Also:
Constant Field Values

DB_MESSAGE_FROM

public static final String DB_MESSAGE_FROM
See Also:
Constant Field Values

DB_MESSAGE_TO

public static final String DB_MESSAGE_TO
See Also:
Constant Field Values

DB_MESSAGE_CC

public static final String DB_MESSAGE_CC
See Also:
Constant Field Values

DB_MESSAGE_BCC

public static final String DB_MESSAGE_BCC
See Also:
Constant Field Values

DB_MESSAGE_REPLYTO

public static final String DB_MESSAGE_REPLYTO
See Also:
Constant Field Values

DB_MESSAGE_INREPLYTO

public static final String DB_MESSAGE_INREPLYTO
See Also:
Constant Field Values

DB_MESSAGE_REFERENCES

public static final String DB_MESSAGE_REFERENCES
See Also:
Constant Field Values

DB_MESSAGE_SUBJECT

public static final String DB_MESSAGE_SUBJECT
See Also:
Constant Field Values

DB_MESSAGE_ACCOUNT

public static final String DB_MESSAGE_ACCOUNT
See Also:
Constant Field Values

DB_MESSAGE_THREAD

public static final String DB_MESSAGE_THREAD
See Also:
Constant Field Values

message

protected transient javax.mail.Message message

headers

protected transient Map<String,Object> headers

multiparts

protected transient Collection<MailMessage.Part> multiparts

fileMap

protected transient Map<File,String> fileMap

duration

protected transient long duration

ASCII_WIDTH

protected static final int ASCII_WIDTH
See Also:
Constant Field Values
Constructor Detail

MailMessage

public MailMessage()

MailMessage

public MailMessage(MailMessage other)

MailMessage

public MailMessage(javax.mail.Message msg)
            throws IOException,
                   javax.mail.MessagingException
Throws:
IOException
javax.mail.MessagingException

MailMessage

public MailMessage(String origin)
Method Detail

getSubject

public String getSubject()

getOrigin

public String getOrigin()

getFrom

public String getFrom()

getTo

public Set<String> getTo()

getCc

public Set<String> getCc()

getBcc

public Set<String> getBcc()

getReplyTo

public String getReplyTo()

getFromMember

public Member getFromMember()

getToMember

public Set<Member> getToMember()

getToMember

public Set<Member> getToMember(boolean b)

getCcMember

public Set<Member> getCcMember()

getCcMember

public Set<Member> getCcMember(boolean b)

getBccMember

public Set<Member> getBccMember()

getBccMember

public Set<Member> getBccMember(boolean b)

getReplyToMember

public Member getReplyToMember()

getSenderMember

public Member getSenderMember()

getAttachements

public Set<FileDocument> getAttachements()

getAttachements

public Set<FileDocument> getAttachements(boolean b)

getContentText

public String getContentText()

getContentHtml

public String getContentHtml()

getAccount

public String getAccount()

getPriority

public int getPriority()

getSentDate

public Date getSentDate()

getReceivedDate

public Date getReceivedDate()

getMessageId

public String getMessageId()

getInReplyTo

public String getInReplyTo()

getReferences

public Set<String> getReferences()

getThread

public String getThread()

getCustomBodyParts

public javax.mail.BodyPart[] getCustomBodyParts()

setSubject

public void setSubject(String v)

setOrigin

public void setOrigin(String origin)

setFrom

public void setFrom(String v)

setTo

public void setTo(Set<String> v)

setCc

public void setCc(Set<String> v)

setBcc

public void setBcc(Set<String> v)

setReplyTo

public void setReplyTo(String v)

setFromMember

public void setFromMember(Member v)

setToMember

public void setToMember(Set<Member> v)

setCcMember

public void setCcMember(Set<Member> v)

setBccMember

public void setBccMember(Set<Member> v)

setReplyToMember

public void setReplyToMember(Member v)

setAttachements

public void setAttachements(Set<FileDocument> v)

setContentText

public void setContentText(String v)

setContentHtml

public void setContentHtml(String v)

setAccount

public void setAccount(String v)

setPriority

public void setPriority(int v)

setSentDate

public void setSentDate(Date v)

setReceivedDate

public void setReceivedDate(Date v)

setMessageId

public void setMessageId(String v)

setInReplyTo

public void setInReplyTo(String v)

setReferences

public void setReferences(Set<String> v)

setThread

public void setThread(String v)

setCustomBodyParts

public void setCustomBodyParts(javax.mail.BodyPart[] v)

setSendOneMailPerRecipient

public void setSendOneMailPerRecipient(boolean sendOneMailPerRecipient)
Set sending mode, one mail for all recipients (false), or one mail for each recipients (true).

Default is false, ie send one mail for all.

Parameters:
sendOneMailPerRecipient - set to true to send one mail to each recipient, false to send one mail for all.
Since:
jcms-6.1

setSendAcknowledge

public void setSendAcknowledge(boolean sendAcknowledge)
Set whether acknowledge message should be sent at end of process. Default is false, ie no acknowledge is sent.

Parameters:
sendAcknowledge - the acknowledge message
Since:
jcms-6.1

getFromIA

public javax.mail.internet.InternetAddress[] getFromIA()

getToIA

public javax.mail.internet.InternetAddress[] getToIA()

getCcIA

public javax.mail.internet.InternetAddress[] getCcIA()

getBccIA

public javax.mail.internet.InternetAddress[] getBccIA()

getReplyToIA

public javax.mail.internet.InternetAddress[] getReplyToIA()

setTo

public MailMessage setTo(String v)

setCc

public MailMessage setCc(String v)

setBcc

public MailMessage setBcc(String v)

setFrom

public MailMessage setFrom(Member v)

setTo

public MailMessage setTo(Member v)

setCc

public MailMessage setCc(Member v)

setBcc

public MailMessage setBcc(Member v)

setReplyTo

public MailMessage setReplyTo(Member v)

addTo

public MailMessage addTo(String v)

addCc

public MailMessage addCc(String v)

addBcc

public MailMessage addBcc(String v)

addTo

public MailMessage addTo(Member v)

addCc

public MailMessage addCc(Member v)

addBcc

public MailMessage addBcc(Member v)

addTo

public MailMessage addTo(Set<Member> v)

addCc

public MailMessage addCc(Set<Member> v)

addBcc

public MailMessage addBcc(Set<Member> v)

addAttachements

public MailMessage addAttachements(FileDocument v)

addAttachements

public MailMessage addAttachements(Set<FileDocument> v)

getRecipient

public Set<String> getRecipient()
Returns:
E-mails union of To, Cc, and Bcc fields.

getRecipientMember

public Set<Member> getRecipientMember()
Returns:
Members union of To, Cc, and Bcc fields.

getSendOneMailPerRecipient

public boolean getSendOneMailPerRecipient()
Get sending mode, one mail for all recipients (false), or one mail for each recipients (true).

Default is false, ie send one mail for all.

Returns:
true to send one mail to each recipient, false to send one mail for all.
Since:
jcms-6.1

getSendAcknowledge

public boolean getSendAcknowledge()
Get whether acknowledge message should be sent at end of process. Default is false, ie no acknowledge is sent

Returns:
true if acknowledge should be sent, false otherwise.
Since:
jcms-6.1

getMatchingRecipient

public String getMatchingRecipient(String address)
Returns the address matching (indexOf) the given address in all recipient and members

Parameters:
address - to match
Returns:
String the matiching address or null

getMatchingRecipient

public String getMatchingRecipient(Pattern pattern)
Returns the address matching the given pattern in all recipient and members

Parameters:
pattern - to match
Returns:
String email

getFirstFromIA

public javax.mail.internet.InternetAddress getFirstFromIA()
Resolve "From" from all froms and Member's from

Returns:
InternetAddress from email

getFirstIA

protected javax.mail.internet.InternetAddress getFirstIA(String email,
                                                         Member mbr)

getSingleRecipient

public Member getSingleRecipient()
Returns the single Member recipients of the message or null if there is multiple recipients

Returns:
Member the recipients

getIAQuietly

protected javax.mail.internet.InternetAddress[] getIAQuietly(Set<String> address,
                                                             Set<Member> addressMember)
Returns an array of InternetAddress joins of addresses and Member's addresses

Parameters:
address - Set of email address
addressMember - Set of member
Returns:
Array of InternetAddress

getAddressSet

protected Set<String> getAddressSet(javax.mail.Address[] ia)
Returns a Set of Address.toString()

Parameters:
ia - an array of Address
Returns:
Set of String

getFirstAddress

protected String getFirstAddress(javax.mail.Address[] ia)
Returns the first Address.toString()

Parameters:
ia - an array of Address
Returns:
String the first address

setContentHtmlFromJsp

public MailMessage setContentHtmlFromJsp(String jspPath,
                                         Member loggedMember,
                                         String language,
                                         HashMap<Object,Object> requestAttribute,
                                         HashMap<Object,Object> sessionAttribute)
Set the HTML text content of this MailMessage from the rendering of the specified jsp.

Parameters:
jspPath - a jsp path relative to the webapp root e.g "/custom/jcms/doNotificationText.jsp"
loggedMember - the Member that will be set as the logged member when invoking jsp
language - the language that will be set when invoking jsp
requestAttribute - a HashMap of request attribute available to the jsp execution
sessionAttribute - a HashMap of session attribute available to the jsp execution
Returns:
this (for method chaining)

setContentTextFromJsp

public MailMessage setContentTextFromJsp(String jspPath,
                                         Member loggedMember,
                                         String language,
                                         HashMap<Object,Object> requestAttribute,
                                         HashMap<Object,Object> sessionAttribute)
Set the plain text content of this MailMessage from the rendering of the specified jsp.

Parameters:
jspPath - a jsp path relative to the webapp root e.g "/custom/jcms/doNotificationText.jsp"
loggedMember - the Member that will be set as the logged member when invoking jsp
language - the language that will be set when invoking jsp
requestAttribute - a HashMap of request attribute available to the jsp execution
sessionAttribute - a HashMap of session attribute available to the jsp execution
Returns:
this (for method chaining)

getTemporaryMessage

public javax.mail.Message getTemporaryMessage()
Returns temporary javax.mail.Message store while fetching mail

Returns:
Message

getTemporaryMultiparts

public Collection<MailMessage.Part> getTemporaryMultiparts()
Returns flatten collection of MailMessage.Part with decoded Files and Contents

Returns:
MailMessage.Part

getTemporaryHeaders

public Map<String,Object> getTemporaryHeaders()
Returns a temporary Map of all mail's header.

Returns:
Map of String/Object

setMessage

protected void setMessage(javax.mail.Message msg)
                   throws javax.mail.MessagingException,
                          IOException
Set fields for the given Message and download attachements in temporary folder Caller should also set:

Parameters:
msg - the message
Throws:
javax.mail.MessagingException - if an error occurs
IOException - if an error occurs

performBeforeWrite

protected void performBeforeWrite(int op,
                                  Member mbr,
                                  Map context)
Description copied from class: Data
Called to perform some action before the write.

Overrides:
performBeforeWrite in class Publication
Parameters:
op - the operation (OP_CREATE, OP_UPDATE, ...)
mbr - the member which requests the write operation
context - a map which contains context parameters (may be null)

getFileMap

public Map<File,String> getFileMap()
Retrieve the Map of File/id to send in this MailMessage. The map is transient and never stored in the CMS

Returns:
a Map with File as the key and an optionnal id as the value (may return null if no file was added yet).

addFile

public MailMessage addFile(File file)
Add a file to send with this MailMessage. The file never stored in the CMS

Parameters:
file - a File to send.
Returns:
this (for method chaining)

addFile

public MailMessage addFile(File file,
                           String id)
Add a file to send with this MailMessage. The file never stored in the CMS

Parameters:
file - a File to send.
id - an optionnal identifier for this file
Returns:
this (for method chaining)

buildOneMessageForAll

protected javax.mail.Message buildOneMessageForAll()
                                            throws javax.mail.MessagingException
Create one message to be sent to all recipients.

Returns:
the message
Throws:
javax.mail.MessagingException - if an error occurs

buildOneMessageForEach

protected javax.mail.Message[] buildOneMessageForEach()
                                               throws javax.mail.MessagingException
Create one message one for each recipients.

Returns:
the message
Throws:
javax.mail.MessagingException - if an error occurs

fillMessageContent

protected void fillMessageContent(javax.mail.Message message)
                           throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

getDataHandler

protected javax.activation.DataHandler getDataHandler(File file)
                                               throws javax.mail.MessagingException
Compute the correct handler to manage this file

Parameters:
file - the File to add
Returns:
the correct DataHandler
Throws:
javax.mail.MessagingException - if any exception occurs

getDuration

public long getDuration()
Retrieve the time the sending process took to execute.

Returns:
a duration in millisecond (0 if sending did not occured yet)

send

public void send()
          throws javax.mail.MessagingException
Send this MailMessage.

Throws:
javax.mail.MessagingException - if an error occurs

send

public void send(HashMap<String,Object> ctxt)
          throws javax.mail.MessagingException
Send this MailMessage.

Parameters:
ctxt - an optionnal context used to store information for this mail sending (context may be used by MailPolicyFilters in beforeSendMail and afterSensMail)
Throws:
javax.mail.MessagingException - if an error occurs
Since:
jcms-6.1

sendInThread

public void sendInThread()
Send this MailMessage in a seperate thread.

Since:
jcms-6.1

sendInThread

public void sendInThread(HashMap<String,Object> ctxt)
Send this MailMessage in a seperate thread.

Parameters:
ctxt - an optionnal context used to store information for this mail sending (context may be used by MailPolicyFilters in beforeSendMail and afterSensMail)
Since:
jcms-6.1

sendAcknowledge

protected void sendAcknowledge(Collection<javax.mail.Message> successMessages,
                               Collection<javax.mail.Message> errorMessages)

getTreeParent

public TreeNode getTreeParent()
Description copied from interface: TreeNode
Returns parent of the current node

Specified by:
getTreeParent in interface TreeNode
Overrides:
getTreeParent in class Publication
Returns:
TreeNode parent Node
See Also:
TreeNode.getTreeParent()

getTreeChildren

public Collection<? extends TreeNode> getTreeChildren()
Description copied from interface: TreeNode
Returns a Collection of TreeNode children of the current node

Specified by:
getTreeChildren in interface TreeNode
Overrides:
getTreeChildren in class Publication
Returns:
Collection of TreeNode
See Also:
TreeNode.getTreeChildren()

getMailMessageReplies

public Collection<? extends MailMessage> getMailMessageReplies()
Returns a Collection of MailMessage replies of the current MailMessage

Returns:
Collection of MailMessage

getMailMessageThread

public Collection<? extends MailMessage> getMailMessageThread()
Returns a Collection of MailMessage, thread of the current discussion in ascending order (oldest date first).

Returns:
Collection of MailMessage


Copyright © 2001-2010 Jalios SA. All Rights Reserved.