org.liquidsite.app.servlet
Class RequestProcessor

java.lang.Object
  extended byorg.liquidsite.app.servlet.RequestProcessor
Direct Known Subclasses:
AdminRequestProcessor, DefaultRequestProcessor, ForumRequestProcessor, InstallRequestProcessor

public abstract class RequestProcessor
extends java.lang.Object

A request processor.


Constructor Summary
RequestProcessor(ContentManager manager, java.io.File baseDir)
          Creates a new request processor.
 
Method Summary
abstract  void destroy()
          Destroys this request processor.
protected  ContentManager getContentManager()
          Returns the content manager used by this processor.
protected  java.io.File getFile(java.lang.String path)
          Returns an application file.
abstract  void process(Request request)
          Processes a request.
protected  void processLiquidSite(Request request, java.lang.String path)
          Processes a request for the special "/liquidsite" path at the root of each site.
protected  void processNormal(Request request, ContentSite site, java.lang.String path, boolean preview)
          Processes a request for a normal resource in a content site.
protected  void sendContent(Request request, Content content)
          Processes a request to a content object.
protected  void sendTemplate(Request request, java.lang.String templateName)
          Processes a request to a template file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestProcessor

public RequestProcessor(ContentManager manager,
                        java.io.File baseDir)
Creates a new request processor.

Parameters:
manager - the content manager to use
baseDir - the base directory for application files
Method Detail

getContentManager

protected ContentManager getContentManager()
Returns the content manager used by this processor.

Returns:
the content manager used by this processor

getFile

protected java.io.File getFile(java.lang.String path)
Returns an application file. The file path should be specified relative to the base application directory.

Parameters:
path - the relative file path
Returns:
the absolute file path

process

public abstract void process(Request request)
                      throws RequestException
Processes a request.

Parameters:
request - the request to process
Throws:
RequestException - if the request couldn't be processed

destroy

public abstract void destroy()
Destroys this request processor. This method frees all internal resources used by this processor.


processNormal

protected void processNormal(Request request,
                             ContentSite site,
                             java.lang.String path,
                             boolean preview)
                      throws RequestException
Processes a request for a normal resource in a content site. If the preview flag is set a special "revision" request parameter may be used to modify the content object to display.

Parameters:
request - the request object
site - the content site object
path - the request path (inside the site)
preview - the preview flag
Throws:
RequestException - if the request couldn't be processed

processLiquidSite

protected void processLiquidSite(Request request,
                                 java.lang.String path)
                          throws RequestException
Processes a request for the special "/liquidsite" path at the root of each site.

Parameters:
request - the request object
path - the request path (inside the directory)
Throws:
RequestException - if the request couldn't be processed

sendContent

protected void sendContent(Request request,
                           Content content)
                    throws ContentException,
                           ContentSecurityException,
                           TemplateException,
                           RequestException
Processes a request to a content object.

Parameters:
request - the request object
content - the content object requested
Throws:
ContentException - if the database couldn't be accessed properly
ContentSecurityException - if the requested content object wasn't readable by the user
TemplateException - if the page template couldn't be processed correctly
RequestException - if the content wasn't found

sendTemplate

protected void sendTemplate(Request request,
                            java.lang.String templateName)
                     throws TemplateException
Processes a request to a template file. The template file name is relative to the web context directory, and the output MIME type will always be set to "text/html".

Parameters:
request - the request object
templateName - the template file name
Throws:
TemplateException - if the file template couldn't be processed correctly