public class MailFunctions extends Object
Modifier and Type | Class and Description |
---|---|
static class |
MailFunctions.DefaultMailFunction
DefaultMailFunctions defines the default actions of the mail client as
entered in
admin.xml . |
Constructor and Description |
---|
MailFunctions() |
Modifier and Type | Method and Description |
---|---|
static List<Part> |
getAttachmentParts(List<DMSObject> dmsAttachments,
List<Pair<String,File>> files)
Returns an
ArrayList of Part objects. |
static DMSFolder |
getEmailsFolder(DMSFolder folder,
boolean createFolder)
returns the folder "Emails" of given DMSFolder
|
static DMSFolder |
getEmailsFolder(ProcessInstance pi,
boolean createFolder)
returns the folder "Emails" of given process instance
|
static Pair<String,String> |
getMailText(String actionId,
Message msg)
Returns the default mail text of given message in text/plain and text/html format
|
static Map<Message.RecipientType,String> |
getRecipients(String actionId,
DMSDocForm email,
Message msg)
Get the recipients depending on the given default actions.
|
static String |
getReplyRecipient(DMSDocForm email)
Returns the appropriate recipient.
|
static String |
getSubject(String actionId,
ProcessInstance pi,
Message msg)
Get the subject depending on the given default action and message.
|
static boolean |
hasMailQueueEntry(Persistent refObj)
Checks, if a mailqueue item exists for the referenced object
|
static boolean |
hasMails(DMSFolder emailFldr)
Method to check, if mails exist in the given folder.
|
static boolean |
hasMails(ProcessInstance pi)
Method to check, if mails exist in "Emails" folder of the process
instance.
|
static boolean |
hasRightForMailList(List<DMSObject> mails)
Method to check, if the current user has the
Right.VIEW for given mail list. |
static boolean |
isDefaultMailAction(String actionId)
Checks, if given actionId in String format is a default action (see
MailFunctions.DefaultMailFunction ). |
static String |
outgoingMailSubject(ProcessInstance pi,
String subject)
Returns the subject of given process instance as defined with configuration
parameter "ep.mail.subjpattern".
|
Page |
showMailPane(HttpServletRequest req)
Returns a page holding the mail pane of the passed object.
|
static Page |
showMailPane(Persistent object,
String mailPane,
String mailHandlerClass)
Returns a page holding the mail pane of the passed object.
|
static JSONObject |
toJSON(DMSDocForm emailObj)
Returns the following JSON structure of given email object:
{"_toString":"<the_toString_of_emailObj>",
"objectId":"<classname_of_emailObj>:<oid>",
"mailstatus":"mailqueued|draftmail|mailrec|mailsent",
"subj":"<the_subj_of_emailObj>", ====> only, if field 'subj' in emailObj is given; otherwise the text '<No subject>'
"sender":"<the_sender_emailAddr_of_emailObj>", ====> only, if field 'sender' in emailObj is given
"recipient":"<the_recipient_emailAddr_of_emailObj>", ====> only, if field 'recipient' in emailObj is given
"maildate":<sent_date_of_msg_in_ms>,
"avwcreatedat":<creation_date_of_emailObj_in_ms>,
"replytoid":"<reply_to_oid_of_msg>",
"hasAttachments":true|false
}
|
public static boolean isDefaultMailAction(String actionId)
MailFunctions.DefaultMailFunction
).actionId
- the id of the mail function that is executed in following format:<xml-id>.<node-id>
(e.g. in case of default action "compose" the id is "admin.composeSC"))true
, if action is a default action, otherwise false
public static DMSFolder getEmailsFolder(ProcessInstance pi, boolean createFolder)
pi
- the process instance which should contain folder "Emails"createFolder
- if true, email folder is created automaticallynull
, if no folder could be found (or created)public static DMSFolder getEmailsFolder(DMSFolder folder, boolean createFolder)
folder
- the DMS folder which should contain folder "Emails"createFolder
- if true, email folder is created automaticallynull
, if no folder could be found (or created)public static String outgoingMailSubject(ProcessInstance pi, String subject)
pi
- the process instance for getting pidsubject
- the mail subjectpublic static String getSubject(String actionId, ProcessInstance pi, Message msg) throws Exception
actionId
- the id of the mail function that is executed which must be a MailFunctions.DefaultMailFunction
in following format:<xml-id>.<node-id>
(e.g. in case of default action "compose" the id is "admin.composeSC"))pi
- the ProcessInstance
for determining the subject; can be null
msg
- the referenced Message
object; can be null
null
, if no subject could be determined.
Returned subject depending on action:
outgoingMailSubject(ProcessInstance, String)
Exception
public static Map<Message.RecipientType,String> getRecipients(String actionId, DMSDocForm email, Message msg) throws Exception
actionId
- the id of the mail function that is executed which must be a MailFunctions.DefaultMailFunction
in following format:<xml-id>.<node-id>
(e.g. in case of default action "compose" the id is "admin.composeSC"))email
- the email object stored in @enterprise as DMSDocForm
msg
- the referenced Message
objectHashMap
containing the Message.RecipientType
as key and the
appropriate recipient email addresses as string value.
Returned recipients depending on action:
Message.RecipientType.TO
only where value is determined by getReplyRecipient(DMSDocForm)
Message.RecipientType.TO
and Message.RecipientType.CC
of given Message
Message.RecipientType.TO
, Message.RecipientType.CC
and Message.RecipientType.BCC
of given Message
Exception
public static Pair<String,String> getMailText(String actionId, Message msg) throws Exception
actionId
- the id of the mail function that is executed which must be a MailFunctions.DefaultMailFunction
in following format:<xml-id>.<node-id>
(e.g. in case of default action "compose" the id is "admin.composeSC"))msg
- the Message
object that is used for extraction of mail text (body)Pair
containing the mail text as text/plain (key) and text/html (value)Exception
public static String getReplyRecipient(DMSDocForm email)
email
- the mail object where reply should be performedpublic static List<Part> getAttachmentParts(List<DMSObject> dmsAttachments, List<Pair<String,File>> files) throws Exception
Returns an ArrayList
of Part
objects. These
objects represent the attachments (DMS and File
attachments
that are passed as parameters.
Note that DMS attachments which are not of type
DocForm
are omitted.
public static boolean hasMails(ProcessInstance pi)
pi
- the ProcessInstance
to check, if "Emails" folder contains mailstrue
, if mails are available and the current user has the
permissions to see them; otherwise false
public static boolean hasMails(DMSFolder emailFldr)
emailFldr
- the DMSFolder
where mails are storedtrue
, if mails are available and the current user has the
permissions to see them (Right.VIEW
); otherwise false
public static boolean hasMailQueueEntry(Persistent refObj)
refObj
- the referenced objecttrue
, if mailqueue item could be found; otherwise false
public static JSONObject toJSON(DMSDocForm emailObj) throws Exception
{"_toString":"<the_toString_of_emailObj>", "objectId":"<classname_of_emailObj>:<oid>", "mailstatus":"mailqueued|draftmail|mailrec|mailsent", "subj":"<the_subj_of_emailObj>", ====> only, if field 'subj' in emailObj is given; otherwise the text '<No subject>' "sender":"<the_sender_emailAddr_of_emailObj>", ====> only, if field 'sender' in emailObj is given "recipient":"<the_recipient_emailAddr_of_emailObj>", ====> only, if field 'recipient' in emailObj is given "maildate":<sent_date_of_msg_in_ms>, "avwcreatedat":<creation_date_of_emailObj_in_ms>, "replytoid":"<reply_to_oid_of_msg>", "hasAttachments":true|false }
emailObj
- the email object for that a JSON representation is neededJSONObject
Exception
public static boolean hasRightForMailList(List<DMSObject> mails)
Right.VIEW
for given mail list.mails
- a list of mails represented as DMSObject
true
if the current user has the permissions to see them;
otherwise false
public Page showMailPane(HttpServletRequest req)
DMSFolder
the subfolder with name "Emails" is used in MailPane as context object.
In case of a ProcessInstance
the process instance itself is used in MailPane as context object.req
- the request which must contain following elements:
DMSFolder
or a ProcessInstance
in following format: <classname>:<oid>com.groiss.smartclient.mail.MailActionsHandler
class. If this parameter is empty, no mail handler is usedpublic static Page showMailPane(Persistent object, String mailPane, String mailHandlerClass)
DMSFolder
a new created sub-folder with name "Emails" is used in MailPane as context object.
In case of a ProcessInstance
the process instance itself is used in MailPane as context object.object
- a DMSFolder
or ProcessInstance
mailPane
- an own defined MailPane widget; if this parameter is empty, the default "ep/widget/smartclient/wl/MailPane" is usedmailHandlerClass
- an own defined com.groiss.smartclient.mail.MailActionsHandler
class; if this parameter is empty, no mail handler is used@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.