org.olat.core.util.mail
Class MailTemplate

java.lang.Object
  extended by org.olat.core.util.mail.MailTemplate

public abstract class MailTemplate
extends java.lang.Object

Description:
The MailTemplate holds a mail subject/body template and the according methods to populate the velocity contexts with the user values

Usage:
See MailTest.testMailTemplate() to learn how you can use this abstract class and how you have to implement the putVariablesInMailContext() method.

Initial Date: 21.11.2006

Author:
Florian Gnaegi, frentix GmbH
http://www.frentix.com

Constructor Summary
MailTemplate(java.lang.String subjectTemplate, java.lang.String bodyTemplate, java.io.File[] attachments)
          Constructor for a mail using a template
 
Method Summary
 void addToContext(java.lang.String name, java.lang.String value)
           
 java.io.File[] getAttachments()
           
 java.lang.String getBodyTemplate()
           
 org.apache.velocity.VelocityContext getContext()
           
 java.lang.Boolean getCpfrom()
           
 java.lang.String getSubjectTemplate()
           
abstract  void putVariablesInMailContext(org.apache.velocity.VelocityContext context, Identity recipient)
          Method that puts all necessary variables for those templates into the give velocity context.
 void setAttachments(java.io.File[] attachments)
           
 void setBodyTemplate(java.lang.String bodyTemplate)
           
 void setCpfrom(java.lang.Boolean cpfrom)
           
 void setSubjectTemplate(java.lang.String subjectTemplate)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailTemplate

public MailTemplate(java.lang.String subjectTemplate,
                    java.lang.String bodyTemplate,
                    java.io.File[] attachments)
Constructor for a mail using a template

Parameters:
subjectTemplate - Template for mail subject. Must not be NULL
bodyTemplate - Template for mail body. Must not be NULL
attachments - File array for mail attachments. Can be NULL
Method Detail

getCpfrom

public java.lang.Boolean getCpfrom()
Returns:

setCpfrom

public void setCpfrom(java.lang.Boolean cpfrom)
Parameters:
cpfrom -

getSubjectTemplate

public java.lang.String getSubjectTemplate()
Returns:
mail subject template as string

getBodyTemplate

public java.lang.String getBodyTemplate()
Returns:
mail body template as string

getAttachments

public java.io.File[] getAttachments()
Returns:
attachments as File array

setAttachments

public void setAttachments(java.io.File[] attachments)
Parameters:
attachments - set file attachments

setBodyTemplate

public void setBodyTemplate(java.lang.String bodyTemplate)
Parameters:
bodyTemplate - Set body template

setSubjectTemplate

public void setSubjectTemplate(java.lang.String subjectTemplate)
Parameters:
subjectTemplate - Set subject template

putVariablesInMailContext

public abstract void putVariablesInMailContext(org.apache.velocity.VelocityContext context,
                                               Identity recipient)
Method that puts all necessary variables for those templates into the give velocity context. This method must match all variables used in the subject and body template.

Parameters:
context - The context where to put the variables
recipient - The current identity which will get the email

addToContext

public void addToContext(java.lang.String name,
                         java.lang.String value)

getContext

public org.apache.velocity.VelocityContext getContext()