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

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.SmtpRecordPostStep
All Implemented Interfaces:
com.taleo.integration.client.step.CustomStep, com.taleo.integration.client.step.Step

public class SmtpRecordPostStep
extends BaseCustomStep

Post-processing step to send an email for each record in an export result.

It executes over files containing individual emails. Those files must have been created previously using SplitFilePostStep.

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
SmtpRecordPostStep()
          Constructor without arguments.
 
Method Summary
protected  VelocityContext buildVelocityContext(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, File file)
          Execute the step over a file containing a single email record.
 String getArchiveFolder()
          Get the archive folder.
 String getDescription()
           
 String getErrorFolder()
          Get the error folder.
 String getFilePattern()
          Get the file pattern.
 String getIdentifier()
           
 String getName()
           
 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  Document render(Document document, VelocityContext context)
          Render the document in the given Velocity context.
protected  void sendEmail(javax.mail.Session session, Document document)
          Send an email with the content of an XML document.
 void setArchiveFolder(String archiveFolder)
          Set the archive folder.
 void setErrorFolder(String errorFolder)
          Set the error folder.
 void setFilePattern(String filePattern)
          Set the file pattern.
 void setOnHold(boolean onHold)
          Set the onHold flag.
 void setSmtpHost(String smtpHost)
           
 void setSmtpPort(int smtpPort)
           
 
Methods inherited from class com.taleo.integration.client.customstep.BaseCustomStep
getEncoding, 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, 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

SmtpRecordPostStep

public SmtpRecordPostStep()
Constructor without arguments.

Method Detail

getIdentifier

public 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 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 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 String getSmtpHost()
Returns:

setSmtpHost

public void setSmtpHost(String smtpHost)
Parameters:
smtpHost -

getSmtpPort

public int getSmtpPort()
Returns:

setSmtpPort

public void setSmtpPort(int smtpPort)
Parameters:
port -

getFilePattern

public String getFilePattern()
Get the file pattern.

Returns:

setFilePattern

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

Parameters:
filePattern -

getArchiveFolder

public String getArchiveFolder()
Get the archive folder.

Returns:

setArchiveFolder

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

Parameters:
archiveFolder -

getErrorFolder

public String getErrorFolder()
Get the error folder.

Returns:

setErrorFolder

public void setErrorFolder(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 Exception
Execute the step over files matching the file pattern and containing each one a single email record.

Throws:
Exception

execute

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

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

sendEmail

protected void sendEmail(javax.mail.Session session,
                         Document document)
                  throws IllegalArgumentException,
                         javax.mail.MessagingException,
                         IOException,
                         VelocityException,
                         DocumentException
Send an email with the content of an XML document.

Parameters:
session - The email session.
document - The document to process.
Throws:
IllegalArgumentException
javax.mail.MessagingException
IOException
DocumentException
VelocityException

buildVelocityContext

protected VelocityContext buildVelocityContext(Document document)
                                        throws DocumentException,
                                               FileNotFoundException
Build the Velocity context with the tokens element defined within the given file.

Parameters:
file - The file containing the document.
Returns:
Throws:
DocumentException
FileNotFoundException

render

protected Document render(Document document,
                          VelocityContext context)
                   throws IOException,
                          DocumentException
Render the document in the given Velocity context.

Parameters:
document -
context -
Returns:
Throws:
IOException
DocumentException