You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Next »

CSF Email Service Technical Spec

# Introduction

The CSF Email Service is a module in CSF to handle various functions related to sending emails to a single or group of recipients.

The implementation will include all the methods in the existing EmailServiceImpl in CSF common-legacy. New methods are added to
handle the bulk email and email preview functionality. The EmailServiceImpl is not annotated so it has to be configured in one
of the application Context files in the web application. It is not annotated so we can inject the ApplicationConfiguration for
those web applications that are using sais-common.

2. Dependencies

2.1 CSF base

We will utilize CSF base module to obtain the application configuration information.

3. Object Model

3.1 Class Diagram

A new domain class EmailModel will be created to hold all the fields in an email message.
This diagram represents the domain class EmailModel.





3.2 Class Description.

3.2.1 EmailModel

This is the domain class that represents an Email Message object. It contains the following fields:

  1. emailFrom – the email address of the sender
  2. emailSubject – the subject of the email
  3. emailTos – the list of email addresses of those who will be sent a copy of the email
  4. emailCC – the list of email addresses of those will get a cc copy of the email.
  5. emailBcc – the list of email addresses of those will get a bcc copy of the email.
  6. emailReportRecipient – the list of email addresses of those who will get a copy of the summary report.
  7. emailText – the content of the email.

4. Service Modules

4.1 Class Diagram

4.2 Class Descriptions.

4.2.1 EmailCentralService Interface

This is the interface that defines the methods available for the other web applications to utilize when they are required to send out emails to a single or a list of recipients. The service includes the following methods:
<span style="color: #000091">public</span> <span style="color: #910091">void</span> sendBulkEmail(EmailModel emailModel)
<span style="color: #000091">public</span> <span style="color: #910091">void</span> sendBulkEmailWithTemplate(EmailModel emailModel, String velocityTemplate, Map context)
<span style="color: #000091">public</span> <span style="color: #910091">Map<String, Integer></span> sendBulkEmailWithCounts(EmailModel emailModel)
<span style="color: #000091">public</span> <span style="color: #910091">Map<String, Object></span> generateEmailPreviewWithTemplate(EmailModel emailModel, String type, String velocityTemplate, Map context)
public <span style="color: #910091">Map<String, Object></span> generateSummaryReportPreview(EmailModel emailModel)
<span style="color: #000091">public</span> <span style="color: #910091">void</span> newEmail(String velocityTemplate, Map context, String to, String from, String subject, boolean html)
<span style="color: #000091">public</span> <span style="color: #910091">void</span> newEmail(String velocityTemplate, Map context, String[] tos, String from, String subject, boolean html)
<span style="color: #000091">public</span> <span style="color: #910091">void</span> newEmail(String velocityTemplate, Map context, String to, String subject, boolean html)
<span style="color: #000091">public</span> <span style="color: #910091">void</span> newEmail(String velocityTemplate, Map context, String[] tos, String subject, boolean html)
<span style="color: #000091">public</span> <span style="color: #910091">void</span> newEmail(String body, String to, String subject, boolean html)
<span style="color: #000091">public</span> <span style="color: #910091">void</span> newEmail(String from, String[] to, String subject, String body, String[] cc, String[] bcc, String[] rr)
<span style="color: #000091">public</span> <span style="color: #910091">List</span> getMessageQueue()
public <span style="color: #910091">void</span> batchSend()
public <span style="color: #910091">boolean</span> validateEmailAddress(String emailAddress)

4.2.3 EmailCentralService Implementation

This is the implementation class for the EmailCentralService. It contains an EmailService object (in csf common-legacy module) to perform its tasks.

4.2.3.1 sendBulkEmail

This method obtains an EmailModelDomain Object. It will then process the data and call the newEmail method to send the email and the summary report to the intended recipients. The call to the newEmail method should be configured with the following parameters:
newEmail(String from, String[] to, String subject, String body, String[] cc, String[] bcc, String[] rr);
The following attributes in the EmailModel Object will affect the generation of email:

  1. a list of email addresses of the recipients specified in the "To" field <required>
  2. a list of email addresses of the recipients specified in the "cc" field <optional>
  3. a list of email addresses of the recipients specified in the "Bcc" field <optional>
  4. a list of email addresses of the recipients speicified in the "Report Recipient" field <optional>
  5. email subject<optional>
  6. email text <required>
4.2.3.2 sendBulkEmailWithTemplate

This method obtains an EmailModel Object, a velocity template name and a map that contains the values for the variables in the template. It will use the velocity template and the map to generate the text for the email. Then, it will call the sendBulkEmail method to send the email message and the summary report to intended recipients.

4.2.3.3 sendBulkEmailWithCounts

This method obtains an EmailModel Object. It will call the sendBulkEmail method to send the email message and the summary report to intended recipients. Then, it will call the BatchSend to send out the email and return the counts of successful and failed delivery.

4.2.3.4 generateEmailPreviewWithTemplate

This method obtains an EmailModel Object, a string to specify the type of preview, a velocity template name, and a Map that contains the values for the variables within the velocity template. It will use the velocity template and the map to generate the text for the email. Then, it will updated the email test to the email model object and put the updated object into the returned Map. If a summary report preview is required, it will call the generateSummaryReportPreview method to add the attributes necessary to generate the summary report preview to the returned map.

4.2.3.5 generateSummaryReportPreview

This private method adds the objects/attributes necessary to create a preview of the summary report. The objects to be added are as follow:

  1. A String that contains the content of the summary report


4.2.3.6 newEmail
These sets of methods are the same public methods available in the EmailService in the CSF common-legacy module.
4.2.3.7 prepare
These 3 methods are static public methods available in the EmailService in the CSF common-legacy module.
4.2.3.8 getMessageQueue
This method is a public method migrated over from the EmailServiceImpl in common-legacy module.
4.2.3.9 batchSend
This method is a public method migrated over from the EmailServiceImpl in common-legacy module.
4.2.3.10 createReportRecipientContent
This method is a public method migrated over from the EmailServiceImpl in common-legacy module.
4.2.3.11 createMessage
This method is a public method migrated over from the EmailServiceImpl in common-legacy module.
4.2.3.12 sendMessage
These methods are public methods that are migrated over from the EmailServiceImpl in common-legacy module.
4.2.3.13 validateEmailAddress
This method takes an input of email address in String and validate if the email address is valid. If the email address is valid, it will return true. If not, it will return false. The input email address is validated according to the following conditions:

  1. The system will create a new InternetAddress object using the input email address and then invoke the validate method of the InternetAddress object to verify it is a real email address



  • No labels