com.knowgate.scheduler.jobs
Class EmailSender

java.lang.Object
  extended by com.knowgate.dataobjs.DBPersist
      extended by com.knowgate.scheduler.Job
          extended by com.knowgate.scheduler.jobs.EmailSender
All Implemented Interfaces:
java.io.Serializable, java.util.Map

public class EmailSender
extends Job

Add database fields to a document template and send it to a mail recipient

Mails are send using Sun JavaMail

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class com.knowgate.scheduler.Job
COMMAND_DUMY, COMMAND_FAX, COMMAND_FTP, COMMAND_MAIL, COMMAND_SAVE, COMMAND_SEND, iPendingAtoms, STATUS_ABORTED, STATUS_FINISHED, STATUS_INTERRUPTED, STATUS_PENDING, STATUS_RUNNING, STATUS_SUSPENDED
 
Fields inherited from class com.knowgate.dataobjs.DBPersist
AllVals, sAuditCls, sAuditUsr, sTransactId
 
Constructor Summary
EmailSender()
           
 
Method Summary
 void free()
          This method must free all the resource allocated by a Job
 java.lang.Object process(Atom oAtm)
          Send PageSet document instance by e-mail.
 void setStatus(JDCConnection oConn, int iStatus)
          Set Job Status If Status if set to Job.STATUS_FINISHED then dt_finished is set to current system date.
 
Methods inherited from class com.knowgate.scheduler.Job
abort, delete, delete, getDataBaseBind, getIdFromTitle, getParameter, getParameters, getProperties, getProperty, getStatus, insertRecipients, instantiate, instantiate, load, log, logFile, main, pending, resolveAtomsEMails, setDataBaseBind, store
 
Methods inherited from class com.knowgate.dataobjs.DBPersist
allcaps, allcaps, changelog, clear, clone, containsKey, containsValue, entrySet, exists, get, get, getAuditClassName, getCreationDate, getDate, getDateFormated, getDateShort, getDateTime, getDateTime24, getDecimal, getDecimalFormated, getDecimalFormated, getDouble, getDoubleFormated, getFloat, getFloatFormated, getInt, getInteger, getIntervalPart, getItemMap, getItems, getMoney, getShort, getSQLDate, getSQLTime, getString, getStringHtml, getStringNull, getTable, getTable, getTableName, getTime, getTimeOfDay, getTimestamp, getUIdFromName, isEmpty, isNull, iterator, keySet, load, parseXML, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putAll, putAll, remove, remove, replace, replace, replace, replace, replace, replace, replace, replace, setAuditTransact, setAuditUser, setCreationDate, size, toLowerCase, toUpperCase, toXML, toXML, toXML, toXML, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

EmailSender

public EmailSender()
Method Detail

free

public void free()
Description copied from class: Job

This method must free all the resource allocated by a Job

Specified by:
free in class Job

setStatus

public void setStatus(JDCConnection oConn,
                      int iStatus)
               throws java.sql.SQLException

Set Job Status

If Status if set to Job.STATUS_FINISHED then dt_finished is set to current system date.

If Status if set to any value other than Job.STATUS_RUNNING then the MailTransport is closed.

Overrides:
setStatus in class Job
Parameters:
oConn - Database Connection
iStatus - Job Status
Throws:
java.sql.SQLException

process

public java.lang.Object process(Atom oAtm)
                         throws java.io.FileNotFoundException,
                                java.io.IOException,
                                MessagingException

Send PageSet document instance by e-mail.

Transforming and sending aPageSet is a two stages task. First the PageSet stylesheet is combined via XSLT with user defined XML data and an XHTML document is pre-generated. This document still contains fixed database reference tags. At second stage the database reference tags are replaced for each document using FastStreamReplacer. Thus PageSet templates must have been previously transformed via XSLT before sending the PageSet instance by e-mail.

This method uses javax.mail package for e-mail sending

Parameters for locating e-mail server are stored at properties mail.transport.protocol, mail.host, mail.user from hipergate.cnf

If parameter bo_attachimages is set to "1" then any <IMG SRC=""> tag will be replaced by a cid: reference to an attached file.

Specified by:
process in class Job
Parameters:
oAtm - Atom containing reference to PageSet.
Atom must have the following parameters set:
gu_workareaGUID of WorkArea owner of document to be sent
gu_pagesetGUID of PageSet to be sent
nm_pagesetName of PageSet to be sent
nm_pageFile Name of HTML page to be sent
bo_attachimages"1" if must attach images on document,
"0" if images must be absolute references
tx_senderFull Name of sender to be displayed
tx_fromSender e-mail address
tx_subjecte-mail subject
Returns:
String with document template after replacing database tags
Throws:
java.io.FileNotFoundException
java.io.IOException
MessagingException
See Also:
FastStreamReplacer