com.taleo.integration.client.customstep.mail
Class SendEmailsPostStep

java.lang.Object
  extended by com.taleo.integration.client.step.BaseStep
      extended by com.taleo.integration.client.step.BaseCustomStep
          extended by com.taleo.integration.client.customstep.BaseCustomStep
              extended by com.taleo.integration.client.customstep.mail.SendEmailsPostStep
All Implemented Interfaces:
com.taleo.integration.client.step.CustomStep, com.taleo.integration.client.step.Step

public class SendEmailsPostStep
extends BaseCustomStep

Post-processing step to send individual emails from the results of an export.

It executes over files containing individual emails. Those files must have been created previously using SplitFilePostStep and match the structure presented below.

This step takes all parameters from its base class BaseCustomStep and the following additional parameters:

Email files are structured as follows.

 <email>
   <from></from>
   <to></to>
   <cc></cc>
   <bcc></bcc>
   <subject>...</subject>
   <content mimeType="">...</content>
   <tokens>
     <token name="xyz" value=""/>
     ...
   </tokens>
 </email>
 
The XML tags are:
After processing, the status element is added with the following structure:
 <email>
   ...
   <status>
     <success date=""/>
     or
     <error date="">...</error>
   </status>
 </email>
 
Those XML tags are:

The following variables are also made available to build the email template:

Example uses of these variables in the templates:

If an error prevents processing the complete list of files (e.g. mail server down), those that have not been processed remain in place for processing on the next run. If an error is specific to a given file, this will not interrupt the process, the file will simply be moved to the error folder. Note that this step does not handle bouncing emails. Therefore, it is important to set a meaningful sender address (from) in order to receive that kind of error.

This class is dependent on:

Here is an example of how to define this custom step in the TCC configuration file:

Author:
Romain Guay, Taleo Corporation

Field Summary
 
Fields inherited from class com.taleo.integration.client.customstep.BaseCustomStep
parameterNames
 
Fields inherited from class com.taleo.integration.client.step.BaseCustomStep
parameters
 
Fields inherited from class com.taleo.integration.client.step.BaseStep
commType, ERROR_NULL_GLOBAL_CONFIG, ERROR_NULL_PIPELINE, ERROR_NULL_STEP_CONFIG, productCode, tempFolder, type, version
 
Constructor Summary
SendEmailsPostStep()
          Constructor without arguments.
 
Method Summary
protected  org.apache.velocity.VelocityContext buildVelocityContext(org.dom4j.Document document)
          Build the Velocity context with the tokens element defined within the given file.
protected  void execute()
          Execute the step over files matching the file pattern and containing each one a single email record.
 void execute(com.taleo.ws.integration.client.Pipeline pipeline)
           
protected  void execute(javax.mail.Session session, java.io.File file)
          Execute the step over a file containing a single email record.
 java.lang.String getArchiveFolder()
          Get the archive folder.
 java.lang.String getDescription()
           
 java.lang.String getErrorFolder()
          Get the error folder.
 java.lang.String getFilePattern()
          Get the file pattern.
 java.lang.String getIdentifier()
           
 java.lang.String getName()
           
 java.lang.String getSmtpHost()
           
 int getSmtpPort()
           
 com.taleo.ws.integration.client.SupportedPipeline getSupportedPipeline()
           
 void init(com.taleo.ws.integration.client.GlobalConfig config)
           
 boolean isOnHold()
          Get the onHold flag.
protected  org.dom4j.Document render(org.dom4j.Document document, org.apache.velocity.VelocityContext context)
          Render the document in the given Velocity context.
protected  void sendEmail(javax.mail.Session session, org.dom4j.Document document)
          Send an email with the content of an XML document.
 void setArchiveFolder(java.lang.String archiveFolder)
          Set the archive folder.
 void setErrorFolder(java.lang.String errorFolder)
          Set the error folder.
 void setFilePattern(java.lang.String filePattern)
          Set the file pattern.
 void setOnHold(boolean onHold)
          Set the onHold flag.
 void setSmtpHost(java.lang.String smtpHost)
           
 void setSmtpPort(int smtpPort)
           
 
Methods inherited from class com.taleo.integration.client.customstep.BaseCustomStep
createTempFile, createTempFile, getEncoding, getTempFolder, isActive, registerParameterName, setActive, setEncoding, validateParameterNames
 
Methods inherited from class com.taleo.integration.client.step.BaseCustomStep
getType, init
 
Methods inherited from class com.taleo.integration.client.step.BaseStep
getAllProcessSupportPipeline, getCurrentFile, getCurrentFile, getCurrentMessage, getPostProcessSupportPipeline, getPreProcessSupportPipeline, isOriginalFile, validateLastStepType, validateMessageType, validatePipeline
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.taleo.integration.client.step.Step
validatePipeline
 

Constructor Detail

SendEmailsPostStep

public SendEmailsPostStep()
Constructor without arguments.

Method Detail

getIdentifier

public java.lang.String getIdentifier()
Specified by:
getIdentifier in interface com.taleo.integration.client.step.CustomStep
Specified by:
getIdentifier in interface com.taleo.integration.client.step.Step
Specified by:
getIdentifier in class com.taleo.integration.client.step.BaseCustomStep

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in interface com.taleo.integration.client.step.CustomStep
Specified by:
getDescription in interface com.taleo.integration.client.step.Step
Specified by:
getDescription in class com.taleo.integration.client.step.BaseCustomStep

getName

public java.lang.String getName()
Specified by:
getName in interface com.taleo.integration.client.step.CustomStep
Specified by:
getName in interface com.taleo.integration.client.step.Step
Specified by:
getName in class com.taleo.integration.client.step.BaseCustomStep

getSmtpHost

public java.lang.String getSmtpHost()
Returns:

setSmtpHost

public void setSmtpHost(java.lang.String smtpHost)
Parameters:
smtpHost -

getSmtpPort

public int getSmtpPort()
Returns:

setSmtpPort

public void setSmtpPort(int smtpPort)
Parameters:
port -

getFilePattern

public java.lang.String getFilePattern()
Get the file pattern.

Returns:

setFilePattern

public void setFilePattern(java.lang.String filePattern)
Set the file pattern.

Parameters:
filePattern -

getArchiveFolder

public java.lang.String getArchiveFolder()
Get the archive folder.

Returns:

setArchiveFolder

public void setArchiveFolder(java.lang.String archiveFolder)
Set the archive folder.

Parameters:
archiveFolder -

getErrorFolder

public java.lang.String getErrorFolder()
Get the error folder.

Returns:

setErrorFolder

public void setErrorFolder(java.lang.String errorFolder)
Set the error folder.

Parameters:
errorFolder -

isOnHold

public boolean isOnHold()
Get the onHold flag.

Returns:

setOnHold

public void setOnHold(boolean onHold)
Set the onHold flag.

Parameters:
onHold -

getSupportedPipeline

public com.taleo.ws.integration.client.SupportedPipeline getSupportedPipeline()
Specified by:
getSupportedPipeline in interface com.taleo.integration.client.step.Step
Overrides:
getSupportedPipeline in class com.taleo.integration.client.step.BaseCustomStep

init

public void init(com.taleo.ws.integration.client.GlobalConfig config)
Overrides:
init in class BaseCustomStep

execute

public void execute(com.taleo.ws.integration.client.Pipeline pipeline)
             throws com.taleo.integration.client.step.StepException
Throws:
com.taleo.integration.client.step.StepException

execute

protected void execute()
                throws java.lang.Exception
Execute the step over files matching the file pattern and containing each one a single email record.

Throws:
java.lang.Exception

execute

protected void execute(javax.mail.Session session,
                       java.io.File file)
                throws java.lang.Exception
Execute the step over a file containing a single email record.

Parameters:
session - The email session.
file - The file to process.
Throws:
java.lang.Exception

sendEmail

protected void sendEmail(javax.mail.Session session,
                         org.dom4j.Document document)
                  throws java.lang.IllegalArgumentException,
                         javax.mail.MessagingException,
                         java.io.IOException,
                         org.apache.velocity.exception.VelocityException,
                         org.dom4j.DocumentException
Send an email with the content of an XML document.

Parameters:
session - The email session.
document - The document to process.
Throws:
java.lang.IllegalArgumentException
javax.mail.MessagingException
java.io.IOException
org.dom4j.DocumentException
org.apache.velocity.exception.VelocityException

buildVelocityContext

protected org.apache.velocity.VelocityContext buildVelocityContext(org.dom4j.Document document)
                                                            throws org.dom4j.DocumentException,
                                                                   java.io.FileNotFoundException
Build the Velocity context with the tokens element defined within the given file.

Parameters:
file - The file containing the document.
Returns:
Throws:
org.dom4j.DocumentException
java.io.FileNotFoundException

render

protected org.dom4j.Document render(org.dom4j.Document document,
                                    org.apache.velocity.VelocityContext context)
                             throws java.io.IOException,
                                    org.dom4j.DocumentException
Render the document in the given Velocity context.

Parameters:
document -
context -
Returns:
Throws:
java.io.IOException
org.dom4j.DocumentException