Package org.faceless.publisher.ext
Class MailExtension.Configuration
java.lang.Object
org.faceless.publisher.ext.MailExtension.Configuration
- Enclosing class:
- MailExtension
A Configuration controls how an arbitrary mail message is converted to input that can be
used by BFO Publisher. A number of standard configurations are available, or a custom
one can be created that optionally extends an existing configuration.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
apply
(MailExtension.ParsedMimeMessage message, Report report) Apply the suppliedMailExtension.ParsedMimeMessage
to theReport
.getMetadata
(MailExtension.ParsedMimeMessage message, Report report) Return any Metadata to add to the Report as a String.getNames()
Return the list of names that this Configuration is known byReturn the URL to use to format the message, ornull
to use the message without any additional formatting.getTemplateAttachments
(MailExtension.ParsedMimeMessage message, Report report) Return the text to replace${ATTACHMENTS}
in the template loaded fromgetTemplate()
method.getTemplateHeaders
(MailExtension.ParsedMimeMessage message, Report report) Return the text to replace${HEADERS}
in the template loaded fromgetTemplate()
method.wrapXHTML
(MailExtension.ParsedMimeMessage message, Report report, AbstractBlob blob) Given the main part of the message, optionally wrap it in XHTML to include headers, footers and so on.
-
Constructor Details
-
Configuration
public Configuration()
-
-
Method Details
-
getNames
Return the list of names that this Configuration is known by -
apply
public void apply(MailExtension.ParsedMimeMessage message, Report report) throws IOException, MessagingException Apply the suppliedMailExtension.ParsedMimeMessage
to theReport
. By default this method creates metadata by calling thegetMetadata(org.faceless.publisher.ext.MailExtension.ParsedMimeMessage, org.faceless.publisher.Report)
method, optionally wrapps the HTML by callingwrapXHTML(org.faceless.publisher.ext.MailExtension.ParsedMimeMessage, org.faceless.publisher.Report, org.faceless.publisher.type.AbstractBlob)
, adds the parts returned byMailExtension.ParsedMimeMessage.getParts()
to theResourceLoader
used by theReport
, then loads the main part for conversion- Parameters:
message
- theMailExtension.ParsedMimeMessage
to read as inputreport
- theReport
to write to as output.- Throws:
IOException
MessagingException
-
getMetadata
public String getMetadata(MailExtension.ParsedMimeMessage message, Report report) throws IOException, MessagingException Return any Metadata to add to the Report as a String. The returned String should be inapplication/rdf+xml
orapplication/ld+json
format.- Parameters:
message
- theMailExtension.ParsedMimeMessage
to read as inputreport
- theReport
- Throws:
IOException
MessagingException
-
wrapXHTML
public String wrapXHTML(MailExtension.ParsedMimeMessage message, Report report, AbstractBlob blob) throws IOException, MessagingException Given the main part of the message, optionally wrap it in XHTML to include headers, footers and so on. If the message is to be formatted as supplied, returnnull
. Note the return value is XML, not HTML. The default implementation loads the template fromgetTemplate()
for substitition, and if it's not-null subsitutes the values${HEADERS}
,${ATTACHMENTS}
and${BODY}
with the return values ofgetTemplateHeaders(org.faceless.publisher.ext.MailExtension.ParsedMimeMessage, org.faceless.publisher.Report)
,getTemplateAttachments(org.faceless.publisher.ext.MailExtension.ParsedMimeMessage, org.faceless.publisher.Report)
and the message content respectively. If the template URL isnull
or not available, this method returns null.- Parameters:
message
- theMailExtension.ParsedMimeMessage
to read as inputreport
- theReport
blob
- the main part of the message body, which will usually (but not always) be castable toMailExtension.PartBlob
- Returns:
- an XHTML string that should be used as the document body instead of the supplied blob, or
null
to use the blob - Throws:
IOException
MessagingException
-
getTemplate
Return the URL to use to format the message, ornull
to use the message without any additional formatting. -
getTemplateHeaders
public String getTemplateHeaders(MailExtension.ParsedMimeMessage message, Report report) throws IOException, MessagingException Return the text to replace${HEADERS}
in the template loaded fromgetTemplate()
method. By default this is a simple table with From, Date, To and Subject set.- Parameters:
message
- the message- Returns:
- the text to replace
${HEADERS}
- Throws:
IOException
MessagingException
-
getTemplateAttachments
public String getTemplateAttachments(MailExtension.ParsedMimeMessage message, Report report) throws IOException, MessagingException Return the text to replace${ATTACHMENTS}
in the template loaded fromgetTemplate()
method. By default this is a simple table with From, Date, To and Subject set.- Parameters:
message
- the message- Returns:
- the text to replace
${HEADERS}
- Throws:
IOException
MessagingException
-