org.alltimeflashdreamer.filelister
Class FileListerFactory

java.lang.Object
  extended byorg.alltimeflashdreamer.filelister.FileListerFactory

public final class FileListerFactory
extends Object

Title: FileListerFactory

Description: This class is designed to be used by the various JSP sites, to avoid having too much code within those sites. The public methods serve the JSP sites directly, using a simple, static, one-line call.

Organization: All Time Flash Dreamer

Version:
0.5.1
Author:
Copyright (c) 2002-2004 by Florian Steinsiepe

Constructor Summary
FileListerFactory()
           
 
Method Summary
static FileListerConfig getFileListerConfig(HttpServletRequest request)
          Gets the instance of FileListerConfig that is specified by the URL parameter "window" from the session's attribute list.
static void handleFileListerException(HttpServletResponse response, FileListerConfig fileListerConfig, FileListerException fle)
          If the given FileListerConfig isn't null, the catched exception is stored therein and the client is redirected to the error site, else the exception itself is throw again.
static FileListerConfig initialize(HttpServletRequest request, HttpServletResponse response, ServletContext context)
          Does the jobs to be done before the result site's frame content sites can show the results/configuration appropriately:
- reads the configuration file
- verifies that the connection pool is initialized
- verifies that a FileListerConfig instance is initialized and stored within the session, together with a unique window id (which is stored in the new FileListerConfig instance) - return the new instance for immediate work
static void printRequestParameters(HttpServletRequest request)
          Prints out all the parameter key/value pairs to the standard out.
static void processSearch(HttpServletRequest request, HttpServletResponse response)
          Processes the task of executing a search within the index or the file system by reading the URL parameters and reacting according to them.
static void redirectToAppRoot(HttpServletResponse response)
          Returns the client to the application root in one of the many possible cases
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileListerFactory

public FileListerFactory()
Method Detail

initialize

public static FileListerConfig initialize(HttpServletRequest request,
                                          HttpServletResponse response,
                                          ServletContext context)
                                   throws FileListerException,
                                          IOException
Does the jobs to be done before the result site's frame content sites can show the results/configuration appropriately:
- reads the configuration file
- verifies that the connection pool is initialized
- verifies that a FileListerConfig instance is initialized and stored within the session, together with a unique window id (which is stored in the new FileListerConfig instance) - return the new instance for immediate work

Parameters:
request - the request of the "JSP servlet"
response - the response of the "JSP servlet"
context - the servlet context of the "JSP servlet"
Returns:
the newly created FileListerConfig, ready to work with it
Throws:
FileListerException - thrown only if the FileListerConfig wasn't stored in the user's session
IOException - if the redirect to the error site somehow failed

processSearch

public static void processSearch(HttpServletRequest request,
                                 HttpServletResponse response)
                          throws FileListerException,
                                 IOException
Processes the task of executing a search within the index or the file system by reading the URL parameters and reacting according to them.
There are several possibilities/scenarios what's to be processed:
- Click on a link within a column header
- Click on the "jump-to-site" button
- Click on the "Show results:" button
- Click on a navigation button (first, previous, next, last)
Everything but the column header link click is done within the optionbar site, so those URL inputs are handled together , which means the user may change the number of visible entries and the shown site together.

Parameters:
request - the request of the "JSP servlet"
response - the response of the "JSP servlet"
Throws:
FileListerException - if the processing of the URL input or the search itself threw an exception which couldn't be shown to the client
IOException - if the redirect to the error site somehow failed

handleFileListerException

public static void handleFileListerException(HttpServletResponse response,
                                             FileListerConfig fileListerConfig,
                                             FileListerException fle)
                                      throws FileListerException,
                                             IOException
If the given FileListerConfig isn't null, the catched exception is stored therein and the client is redirected to the error site, else the exception itself is throw again.

Parameters:
response - the response to redirect the client to
fileListerConfig - the magic config object, ready to take the given exception
fle - the exception to handle
Throws:
FileListerException - the given exception, in case the FileListerConfig is null
IOException - in case the redirection failed somehow

getFileListerConfig

public static FileListerConfig getFileListerConfig(HttpServletRequest request)
Gets the instance of FileListerConfig that is specified by the URL parameter "window" from the session's attribute list. If no such URL parameter is specified, this means that a new window was created and a new instance of FileListerConfig must be created.

Parameters:
request - the request to get an attribute of
Returns:
the specified FileListerConfig or null, it not stored

redirectToAppRoot

public static void redirectToAppRoot(HttpServletResponse response)
                              throws IOException
Returns the client to the application root in one of the many possible cases

Parameters:
response -
Throws:
IOException

printRequestParameters

public static void printRequestParameters(HttpServletRequest request)
Prints out all the parameter key/value pairs to the standard out.

Parameters:
request - the request to read the parameters from