public class SendEmailAction extends GenericTemplateAction
Modifier and Type | Class and Description |
---|---|
static class |
SendEmailAction.EmailContent |
CachedAction.OutputProvider
Modifier and Type | Field and Description |
---|---|
protected EmailModule |
email |
protected java.lang.String |
from |
protected boolean |
parseFrom |
protected boolean |
parseRecipients |
protected boolean |
parseSubject |
protected java.lang.String |
recipients |
protected java.lang.String |
subject |
defaultRequestParameters, forwardRequestParameters, requestContextKey, staticContext, templateKey, templateManager
cache, caching, threadPool
actionParamKey, handledActions, httpHeaders, isDefaultAction, replacements, replacementsInitialized, servletModule
engine, initScript, persistentObjects, scriptManager, startScript, stopScript
autoStart, isInitialized, isRunning, logging, loggingModule, moduleManager
Constructor and Description |
---|
SendEmailAction() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
doOutput(javax.servlet.http.HttpServletRequest req,
ModulesServlet.HttpMethod method,
java.lang.String action,
CachedAction.OutputProvider out,
User user)
Does the output that might be either cached or returned directly.
|
java.util.Collection<Module> |
getDependencies(ModuleManager manager)
Returns all the modules this module depends on.
|
boolean |
handleAction(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
ModulesServlet.HttpMethod method,
java.lang.String action,
User user)
Handles this action.
|
void |
init(ModuleManager manager,
java.util.HashMap<java.lang.String,java.lang.Object> settings)
Initialises the module.
|
static SendEmailAction.EmailContent |
parseEmail(byte[] bytes,
java.lang.String encoding,
boolean parseRecipients,
boolean parseSubject,
boolean parseFrom) |
protected boolean |
parseOutputAndSend(byte[] bytes,
java.lang.String contentType,
java.lang.String encoding) |
protected void |
returnOutput(java.io.InputStream cacheIn,
javax.servlet.http.HttpServletResponse resp)
Writes a page read from an input stream into an HTTP servlet response.
|
void |
start(ModuleManager manager)
Starts the module.
|
void |
stop(ModuleManager manager)
Stops the module.
|
getCacheKey, getCacheKeyParams, getForwardedParameters, getStaticTemplateContext, getTemplate, getTemplateContext, putStaticContext
buildCacheKey, readMetadata, writeMetadata
addHandledAction, doReplacements, handleRequest, isHandleAction, setActionParamKey, setHttpHeaders
getScriptEngine
isInitialized, isRunning, requireLogging, toString
protected EmailModule email
protected java.lang.String from
protected java.lang.String subject
protected java.lang.String recipients
protected boolean parseSubject
protected boolean parseRecipients
protected boolean parseFrom
public java.util.Collection<Module> getDependencies(ModuleManager manager) throws ModuleException
Module
getDependencies
in interface Module
getDependencies
in class GenericTemplateAction
manager
- The module manager handling this module.ModuleException
public void init(ModuleManager manager, java.util.HashMap<java.lang.String,java.lang.Object> settings) throws ModuleException
Module
Initialises the module. After constructor, this is the first method called in the life cycle of a module. It should not perform anything time consuming or anything with notable outside side effects. It should only read the parameters and initialise the module so that it can later be started. Note that a module being initialised doesn't mean that it necessarily will ever be started.
A ModuleException may be thrown if something vital is missing from the parameters or they are not sensible. In some cases you may not want to throw an exception even if vital initialisation information is missing. If, for example, it is possible that the module is initialised in some other way between the init and the start method calls. A ModuleException may also be thrown at the start method if the module is still not initialised.
init
in interface Module
init
in class GenericTemplateAction
manager
- The module manager handling this module. You may keep a
reference to it if needed.ModuleException
public void start(ModuleManager manager) throws ModuleException
Module
start
in interface Module
start
in class GenericTemplateAction
manager
- The module manager handling this module.ModuleException
public void stop(ModuleManager manager)
Module
stop
in interface Module
stop
in class GenericTemplateAction
manager
- The module manager handling this module.public static SendEmailAction.EmailContent parseEmail(byte[] bytes, java.lang.String encoding, boolean parseRecipients, boolean parseSubject, boolean parseFrom) throws java.io.IOException
java.io.IOException
protected boolean parseOutputAndSend(byte[] bytes, java.lang.String contentType, java.lang.String encoding) throws java.io.IOException
java.io.IOException
public boolean handleAction(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, ModulesServlet.HttpMethod method, java.lang.String action, User user) throws javax.servlet.ServletException, java.io.IOException, ActionException
AbstractAction
handleAction
in class CachedAction
req
- The HTTP Request.resp
- The HTTP response.method
- The HTTP method of the request.action
- The parsed action id.user
- The logged in user, or null if not applicable.javax.servlet.ServletException
java.io.IOException
ActionException
protected void returnOutput(java.io.InputStream cacheIn, javax.servlet.http.HttpServletResponse resp) throws java.io.IOException
CachedAction
Writes a page read from an input stream into an HTTP servlet response. The input stream might be coming from a cached file, or directly from the doOutput method if caching is not in use. In any case, the contents of it need to be written to the response object. Note that any HTTP headers must be set before writing anything else.
If you used writeMetadata in doOutput, you have to override this method and use readMetadata correspondingly to read the metadata from the start of the stream. You can then, for example, set any HTTP headers you read from the metadata. After this, you can call this super implementation which will do the rest of the stream copying.
Make absolutely certain that the input stream is closed before returning from this method. Failing to do so may cause the caching service to become locked which can then lock the whole application. It is best to put the contents in a try-finally block and then call cacheIn.close in the finally part. Do this even if you call the super implementation as your code could possibly fail before reaching that part.
returnOutput
in class GenericTemplateAction
java.io.IOException
protected boolean doOutput(javax.servlet.http.HttpServletRequest req, ModulesServlet.HttpMethod method, java.lang.String action, CachedAction.OutputProvider out, User user) throws javax.servlet.ServletException, java.io.IOException
CachedAction
Does the output that might be either cached or returned directly. The OutputProvider is used to get the output stream where the output should be written. Before you get this stream, you may abort the action by returning false but after the output stream is retrieved, you are committed to outputting the page that then might be cached for future use. Therefore you should do all the preparations first, and only then get the output stream when you know that you will be able to output something sensible.
If you opened the output stream using the output provider, you must make sure that the stream is properly closed. It is best to place all your code after this in a try-finally block and close the stream in the finally part. Failing to do this may cause the caching service to become locked, which in turn could potentially lock the whole application.
doOutput
in class GenericTemplateAction
javax.servlet.ServletException
java.io.IOException
Copyright 2004-2015 Wandora Team