Class MailNotificationProcessor
- java.lang.Object
-
- org.craftercms.deployer.impl.processors.AbstractDeploymentProcessor
-
- org.craftercms.deployer.impl.processors.AbstractPostDeploymentProcessor
-
- org.craftercms.deployer.impl.processors.MailNotificationProcessor
-
- All Implemented Interfaces:
DeploymentProcessor
,InitializableByConfigBean
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
public class MailNotificationProcessor extends AbstractPostDeploymentProcessor
Post processor that sends an email notification with the result of a deployment, whenever a deployment fails or files where processed. The output file is attached if it's available. A processor instance can be configured with the following YAML properties:- templateName: The name of the Freemarker template used for email creation.
- from: The value of the From field in the emails.
- to: The value of the To field in the emails.
- subject: The value of the Subject field in the emails.
- html: Whether the emails are HTML.
- serverName: The hostname of the email server.
- dateTimePattern: The date time pattern to use when specifying a date in the email.
- Author:
- avasquez
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MailNotificationProcessor.StatusCondition
Status conditions used to control whe the notifications should be sent.
-
Field Summary
-
Fields inherited from class org.craftercms.deployer.impl.processors.AbstractDeploymentProcessor
alwaysRun, env, excludeFiles, includeFiles, JUMPING_TO_PARAM_NAME, jumpTo, label, name, siteName, targetId
-
-
Constructor Summary
Constructors Constructor Description MailNotificationProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doDestroy()
Allows extending classes perform any custom cleanupvoid
doInit(org.apache.commons.configuration2.Configuration config)
Allows extending classes perform any custom initializationprotected ChangeSet
doPostProcess(Deployment deployment, ChangeSet filteredChangeSet, ChangeSet originalChangeSet)
protected boolean
hasExecutionsFailures(Deployment deployment)
void
setDefaultDateTimePattern(String defaultDateTimePattern)
Sets the default date time pattern to use when specifying a date in the email.void
setDefaultFrom(String defaultFrom)
Sets the default value of the From field in the emails.void
setDefaultHtml(boolean defaultHtml)
Sets whether the emails are HTML by default.void
setDefaultStatusCondition(String defaultStatusCondition)
Sets the default condition to send emails.void
setDefaultSubject(String defaultSubject)
Sets the default value of the Subject field in the emails.void
setDefaultTemplateName(String defaultTemplateName)
Sets the default name of the Freemarker template used for email creation.void
setEmailFactory(org.craftercms.commons.mail.EmailFactory emailFactory)
Sets theEmailFactory
used to generate the emails.void
setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Sets theObjectMapper
used to serialize the deployment result.-
Methods inherited from class org.craftercms.deployer.impl.processors.AbstractPostDeploymentProcessor
doExecute, isPostDeployment, shouldExecute
-
Methods inherited from class org.craftercms.deployer.impl.processors.AbstractDeploymentProcessor
destroy, execute, getFilteredChangeSet, init, isJumpToActive, setBeanName, setEnv, setSiteName, setTargetId, shouldIncludeFile, startJumpTo, supportsMode
-
-
-
-
Field Detail
-
TEMPLATE_NAME_CONFIG_KEY
public static final String TEMPLATE_NAME_CONFIG_KEY
- See Also:
- Constant Field Values
-
FROM_CONFIG_KEY
public static final String FROM_CONFIG_KEY
- See Also:
- Constant Field Values
-
TO_CONFIG_KEY
public static final String TO_CONFIG_KEY
- See Also:
- Constant Field Values
-
SUBJECT_CONFIG_KEY
public static final String SUBJECT_CONFIG_KEY
- See Also:
- Constant Field Values
-
HTML_CONFIG_KEY
public static final String HTML_CONFIG_KEY
- See Also:
- Constant Field Values
-
SERVER_NAME_CONFIG_KEY
public static final String SERVER_NAME_CONFIG_KEY
- See Also:
- Constant Field Values
-
STATUS_CONDITION_KEY
public static final String STATUS_CONDITION_KEY
- See Also:
- Constant Field Values
-
DATETIME_PATTERN_CONFIG_KEY
public static final String DATETIME_PATTERN_CONFIG_KEY
- See Also:
- Constant Field Values
-
SERVER_NAME_MODEL_KEY
public static final String SERVER_NAME_MODEL_KEY
- See Also:
- Constant Field Values
-
TARGET_ID_MODEL_KEY
public static final String TARGET_ID_MODEL_KEY
- See Also:
- Constant Field Values
-
START_MODEL_KEY
public static final String START_MODEL_KEY
- See Also:
- Constant Field Values
-
END_MODEL_KEY
public static final String END_MODEL_KEY
- See Also:
- Constant Field Values
-
STATUS_MODEL_KEY
public static final String STATUS_MODEL_KEY
- See Also:
- Constant Field Values
-
OUTPUT_ATTACHED_MODEL_KEY
public static final String OUTPUT_ATTACHED_MODEL_KEY
- See Also:
- Constant Field Values
-
defaultTemplateName
protected String defaultTemplateName
-
defaultFrom
protected String defaultFrom
-
defaultSubject
protected String defaultSubject
-
defaultHtml
protected boolean defaultHtml
-
defaultStatusCondition
protected String defaultStatusCondition
-
defaultDateTimePattern
protected String defaultDateTimePattern
-
emailFactory
protected org.craftercms.commons.mail.EmailFactory emailFactory
-
objectMapper
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
templateName
protected String templateName
-
from
protected String from
-
to
protected String[] to
-
subject
protected String subject
-
html
protected boolean html
-
serverName
protected String serverName
-
statusCondition
protected MailNotificationProcessor.StatusCondition statusCondition
-
dateTimeFormatter
protected DateTimeFormatter dateTimeFormatter
-
-
Method Detail
-
setDefaultTemplateName
public void setDefaultTemplateName(String defaultTemplateName)
Sets the default name of the Freemarker template used for email creation.
-
setDefaultFrom
public void setDefaultFrom(String defaultFrom)
Sets the default value of the From field in the emails.
-
setDefaultSubject
public void setDefaultSubject(String defaultSubject)
Sets the default value of the Subject field in the emails.
-
setDefaultHtml
public void setDefaultHtml(boolean defaultHtml)
Sets whether the emails are HTML by default.
-
setDefaultStatusCondition
public void setDefaultStatusCondition(String defaultStatusCondition)
Sets the default condition to send emails.
-
setDefaultDateTimePattern
public void setDefaultDateTimePattern(String defaultDateTimePattern)
Sets the default date time pattern to use when specifying a date in the email.
-
setEmailFactory
public void setEmailFactory(org.craftercms.commons.mail.EmailFactory emailFactory)
Sets theEmailFactory
used to generate the emails.
-
setObjectMapper
public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Sets theObjectMapper
used to serialize the deployment result.
-
doInit
public void doInit(org.apache.commons.configuration2.Configuration config) throws org.craftercms.commons.config.ConfigurationException, DeployerException
Description copied from class:AbstractDeploymentProcessor
Allows extending classes perform any custom initialization- Specified by:
doInit
in classAbstractDeploymentProcessor
- Parameters:
config
- the bean's configuration- Throws:
org.craftercms.commons.config.ConfigurationException
- if there's configuration related exceptionDeployerException
- if there's a general exception on init
-
doDestroy
protected void doDestroy() throws DeployerException
Description copied from class:AbstractDeploymentProcessor
Allows extending classes perform any custom cleanup- Specified by:
doDestroy
in classAbstractDeploymentProcessor
- Throws:
DeployerException
- if an error occurs
-
doPostProcess
protected ChangeSet doPostProcess(Deployment deployment, ChangeSet filteredChangeSet, ChangeSet originalChangeSet) throws DeployerException
- Specified by:
doPostProcess
in classAbstractPostDeploymentProcessor
- Throws:
DeployerException
-
hasExecutionsFailures
protected boolean hasExecutionsFailures(Deployment deployment)
-
-