net.sourceforge.cruisecontrol.publishers
Class HTMLEmailPublisher

java.lang.Object
  extended bynet.sourceforge.cruisecontrol.publishers.EmailPublisher
      extended bynet.sourceforge.cruisecontrol.publishers.HTMLEmailPublisher
All Implemented Interfaces:
Publisher, java.io.Serializable

public class HTMLEmailPublisher
extends EmailPublisher

Used to publish an HTML e-mail that includes the build report

Author:
Jeffrey Fredrick, Alden Almagro, Victor Wiewiorowski
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class net.sourceforge.cruisecontrol.publishers.EmailPublisher
EmailPublisher.Address, EmailPublisher.Alert, EmailPublisher.Always, EmailPublisher.Failure, EmailPublisher.Ignore, EmailPublisher.Success
 
Constructor Summary
HTMLEmailPublisher()
           
 
Method Summary
protected  void addContentToMessage(java.lang.String htmlContent, javax.mail.Message msg)
          sets the content as an attachment w/proper mime-type
protected  void appendFooter(java.lang.StringBuffer messageBuffer)
           
protected  void appendHeader(java.lang.StringBuffer messageBuffer)
           
protected  void appendTransform(java.io.File inFile, java.lang.StringBuffer messageBuffer, javax.xml.transform.TransformerFactory tFactory, java.io.File xsl)
           
protected  java.lang.String createLinkLine(java.lang.String logFileName)
           
protected  java.lang.String createMessage(XMLLogHelper logHelper)
          Create the message to be mailed
 Property createParameter()
           
protected  java.lang.String[] getXslFileNames()
          Provided as an alternative to setXSLFileNames for changing the list of files to use.
 void setCharset(java.lang.String characterSet)
           
 void setCSS(java.lang.String cssFilename)
          Path to cruisecontrol.css.
 void setLogDir(java.lang.String directory)
          Path to the log file as set in the log element of the configuration xml file.
 void setXSLDir(java.lang.String xslDirectory)
          Directory where xsl files are located.
 void setXSLFile(java.lang.String fullPathToXslFile)
          If xslFile is set then both xslDir and css are ignored.
 void setXSLFileList(java.lang.String relativePathToXslFile)
          updates xslFileNames, based on value of xslFileList If first character is + the list is appended, otherwise the list is replaced. xslFileNames is comma or space-separated list of existing files, located in xslDir.
protected  void setXSLFileNames(java.lang.String[] fileNames)
          Method to override the default list of file names that will be looked for in the directory specified by xslDir.
protected  java.lang.String transform(java.io.File inFile)
           
protected  java.lang.String transformFile(javax.xml.transform.Source logFile, javax.xml.transform.TransformerFactory tFactory, javax.xml.transform.Source xsl)
           
 void validate()
          Called after the configuration is read to make sure that all the mandatory parameters were specified..
 
Methods inherited from class net.sourceforge.cruisecontrol.publishers.EmailPublisher
add, add, createAlert, createAlertUserList, createAlertUserSet, createAlways, createEmailString, createFailure, createIgnore, createSubject, createSuccess, createUserList, createUserSet, getBuildResultsURL, getDefaultSuffix, getEmailMapper, getFromAddress, getMailHost, getMailPort, getMailProperties, getPassword, getReturnAddress, getReturnName, getSubjectPrefix, getUsername, matchRegExpr, publish, sendMail, setBuildResultsURL, setDefaultSuffix, setFailAsImportant, setMailHost, setMailPort, setPassword, setReportSuccess, setReturnAddress, setReturnName, setSkipUsers, setSpamWhileBroken, setSubjectPrefix, setUsername, setUseSSL, shouldSend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTMLEmailPublisher

public HTMLEmailPublisher()
Method Detail

validate

public void validate()
              throws CruiseControlException
Description copied from interface: Publisher
Called after the configuration is read to make sure that all the mandatory parameters were specified..

Specified by:
validate in interface Publisher
Overrides:
validate in class EmailPublisher
Throws:
CruiseControlException

createParameter

public Property createParameter()

addContentToMessage

protected void addContentToMessage(java.lang.String htmlContent,
                                   javax.mail.Message msg)
                            throws javax.mail.MessagingException
sets the content as an attachment w/proper mime-type

Overrides:
addContentToMessage in class EmailPublisher
Parameters:
htmlContent - content returned by createMessage
msg - mail Message with headers and addresses added elsewhere
Throws:
javax.mail.MessagingException

setXSLFileList

public void setXSLFileList(java.lang.String relativePathToXslFile)
updates xslFileNames, based on value of xslFileList If first character is + the list is appended, otherwise the list is replaced. xslFileNames is comma or space-separated list of existing files, located in xslDir. These files are used, in-order, to generate HTML email. If xslFileNames is not specified, xslFileList remains as default. if xslFile is set, this is ignored.


setXSLFile

public void setXSLFile(java.lang.String fullPathToXslFile)
If xslFile is set then both xslDir and css are ignored. Specified xslFile must take care of entire document -- html open/close, body tags, styles, etc.


setXSLDir

public void setXSLDir(java.lang.String xslDirectory)
Directory where xsl files are located.


setXSLFileNames

protected void setXSLFileNames(java.lang.String[] fileNames)
Method to override the default list of file names that will be looked for in the directory specified by xslDir. By default these are the standard CruseControl xsl files:
I expect this to be used by a derived class to allow someone to change the order of xsl files or to add/remove one to/from the list or a combination.

Parameters:
fileNames -

getXslFileNames

protected java.lang.String[] getXslFileNames()
Provided as an alternative to setXSLFileNames for changing the list of files to use.

Returns:
xsl files to use in generating the email

setCSS

public void setCSS(java.lang.String cssFilename)
Path to cruisecontrol.css. Only used with xslDir, not xslFile.


setLogDir

public void setLogDir(java.lang.String directory)
Path to the log file as set in the log element of the configuration xml file.


setCharset

public void setCharset(java.lang.String characterSet)

createMessage

protected java.lang.String createMessage(XMLLogHelper logHelper)
Create the message to be mailed

Specified by:
createMessage in class EmailPublisher
Parameters:
logHelper - utility object that has parsed the log files
Returns:
created message; empty string if logDir not set

transform

protected java.lang.String transform(java.io.File inFile)
                              throws javax.xml.transform.TransformerException,
                                     java.io.FileNotFoundException,
                                     java.io.IOException
Throws:
javax.xml.transform.TransformerException
java.io.FileNotFoundException
java.io.IOException

createLinkLine

protected java.lang.String createLinkLine(java.lang.String logFileName)

appendTransform

protected void appendTransform(java.io.File inFile,
                               java.lang.StringBuffer messageBuffer,
                               javax.xml.transform.TransformerFactory tFactory,
                               java.io.File xsl)

transformFile

protected java.lang.String transformFile(javax.xml.transform.Source logFile,
                                         javax.xml.transform.TransformerFactory tFactory,
                                         javax.xml.transform.Source xsl)
                                  throws java.io.IOException,
                                         javax.xml.transform.TransformerException
Throws:
java.io.IOException
javax.xml.transform.TransformerException

appendHeader

protected void appendHeader(java.lang.StringBuffer messageBuffer)
                     throws java.io.IOException
Throws:
java.io.IOException

appendFooter

protected void appendFooter(java.lang.StringBuffer messageBuffer)