public class EmailUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_FROM_ADDRESS
Default FROM address that can be used
|
Modifier | Constructor and Description |
---|---|
protected |
EmailUtil()
Does nothing, Spring is in charge of all instantiating
|
Modifier and Type | Method and Description |
---|---|
static org.apache.commons.collections.map.LinkedMap |
createEmailAttachments(java.lang.String ticket,
java.lang.String msgObjectId,
java.io.InputStream is,
java.lang.String parentFolderId,
boolean createEmailPdfRendition,
boolean forceFileExtensionInObjectName,
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> emailAttachmentProperties,
boolean isEmailCreated)
Parses an MSG file input stream and either returns a list of email attachment file names or creates the email attachments as objects in the repository.
|
static org.apache.commons.collections.map.LinkedMap |
createGmailAttachments(java.lang.String ticket,
java.lang.String newObjectId,
java.lang.String parentFolderId,
boolean createPdfRendition,
boolean showFileExtensions,
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> emailAttachmentProperties,
boolean createEmail,
java.lang.String gmailId,
java.lang.String gmailAuthToken,
java.lang.String gmailUser)
Creates objects in repository for each of the given attachments
|
static java.lang.String |
getSubject(java.io.InputStream is)
Gets subject from an InputStream.
|
static java.util.Map<java.lang.String,java.lang.Object> |
parseEmail(java.lang.String ticket,
boolean parseForLinks,
boolean createTempEmail,
java.lang.String parentFolderId,
boolean parseAttachments,
java.io.InputStream is)
Parse an email to strip links from the email body and downloaded the associated document links and to parse
attachments in an MSG file.
|
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
parseEmailLinks(com.auxilii.msgparser.Message msg,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> urlFragments)
Takes in map of URL fragments and scans the MSG body content for those fragments.
|
static void |
relateAttachmentsToEmail(java.lang.String ticket,
java.lang.String emailObjectId,
java.lang.String[] attachmentIds,
java.lang.String relationType)
Relates the given email object as a related child to each of the attachments.
|
void |
setDefaultFromAddress(java.lang.String defaultFromAddress) |
void |
setImageMimeTypeList(java.lang.String[] mimeTypeString) |
void |
setMinimumImageHeight(int minHeight) |
public static java.lang.String DEFAULT_FROM_ADDRESS
protected EmailUtil()
@Value(value="${oc.email.smtp.default.from}") public void setDefaultFromAddress(java.lang.String defaultFromAddress)
@Value(value="${oc.email.filterAttachments.image.minHeight}") public void setMinimumImageHeight(int minHeight)
@Value(value="#{\'${oc.email.filterAttachments.image.validImageTypes}\'.split(\',\')}") public void setImageMimeTypeList(java.lang.String[] mimeTypeString)
public static java.util.Map<java.lang.String,java.lang.Object> parseEmail(java.lang.String ticket, boolean parseForLinks, boolean createTempEmail, java.lang.String parentFolderId, boolean parseAttachments, java.io.InputStream is)
ticket
- A valid OC ticket.parseForLinks
- True if the MSG file should be parsed for cloud service links, false otherwise.createTempEmail
- True if the MSG file should be created in a "hidden" directory in the repository, false otherwise. If this
is "true", the parentFolderId param must be supplied as well so the "hidden" folder can be either created or used.parentFolderId
- The objectId of the parent folder a temporary email should be created in. The temporary email will be created
in a "hidden" directory in the repository. This is only relevant if the createTempEmail param is "true".parseAttachments
- True if the MSG file should be parsed for attachments, false otherwise.is
- The InputStream
for the MSG file content to parse.public static org.apache.commons.collections.map.LinkedMap createEmailAttachments(java.lang.String ticket, java.lang.String msgObjectId, java.io.InputStream is, java.lang.String parentFolderId, boolean createEmailPdfRendition, boolean forceFileExtensionInObjectName, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> emailAttachmentProperties, boolean isEmailCreated)
ticket
- A valid OC ticket to use, needed when creating objects in the repository.msgObjectId
- The objectId of the top level MSG object in the repository, so a rendition can be created for this MSG file.is
- The input stream object representing the content of the top level MSG file.parentFolderId
- The objectId of the parent folder to create the email attachment objects in.createEmailPdfRendition
- True to create a PDF rendition for the MSG file, false to let the repository create a rendition.forceFileExtensionInObjectName
- True to force the file extension in the attachment object names, false to remove the file extension.emailAttachmentProperties
- A map of properties to set on the OCOs of the created email attachment objects.isEmailCreated
- True if the top level MSG file has been created, false otherwise.public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> parseEmailLinks(com.auxilii.msgparser.Message msg, java.util.Map<java.lang.String,java.util.List<java.lang.String>> urlFragments)
msg
- The MSG file to parse for the cloud service links.urlFragments
- Pieces of the known supported and unsupported URLs to be matched when parsing.public static void relateAttachmentsToEmail(java.lang.String ticket, java.lang.String emailObjectId, java.lang.String[] attachmentIds, java.lang.String relationType)
#PARAM_EMAIL_REL_TYPE
to specify the relationship
type.ticket
- authentication ticketemailObjectId
- the email object IDattachmentIds
- the ID of each of the attachmentsrelationType
- the relation type for the emailpublic static org.apache.commons.collections.map.LinkedMap createGmailAttachments(java.lang.String ticket, java.lang.String newObjectId, java.lang.String parentFolderId, boolean createPdfRendition, boolean showFileExtensions, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> emailAttachmentProperties, boolean createEmail, java.lang.String gmailId, java.lang.String gmailAuthToken, java.lang.String gmailUser)
ticket
- authentication ticketnewObjectId
- the email object IDgmailUser
- user's email addressgmailAuthToken
- user's tokengmailId
- Gmail messageIdattachmentIds
- the ID of each of the attachmentsrelationType
- the relation type for the emailpublic static java.lang.String getSubject(java.io.InputStream is)
is
- InputStream of an email.