org.archive.wayback.util.webapp
Class AbstractRequestHandler

java.lang.Object
  extended by org.archive.wayback.util.webapp.AbstractRequestHandler
All Implemented Interfaces:
RequestHandler, org.springframework.beans.factory.BeanNameAware
Direct Known Subclasses:
AccessPoint, ARCRecordingProxy, ARCUnwrappingProxy, FileProxyServlet, LiveWebAccessPoint, ResourceFileLocationDBServlet, ServerRelativeArchivalRedirect, StaticFileRequestHandler

public abstract class AbstractRequestHandler
extends Object
implements RequestHandler

Abstract RequestHandler implementation which performs the minimal behavior for self registration with a RequestMapper, requiring subclasses to implement only handleRequest().

Author:
brad

Constructor Summary
AbstractRequestHandler()
           
 
Method Summary
 String getBeanName()
           
static String getMapParam(Map<String,String[]> queryMap, String field)
          Extract the first value in the array mapped to by field in queryMap
static String getMapParamOrEmpty(Map<String,String[]> map, String param)
          Extract the first value in the array mapped to by field in queryMap
static String getRequiredMapParam(Map<String,String[]> queryMap, String field)
          Extract the first value in the array mapped to by field in queryMap
 javax.servlet.ServletContext getServletContext()
           
 void registerPortListener(RequestMapper requestMapper)
          Called at webapp context initialization, to allow the RequestHandler to register itself with the RequestMapper, which will delegate request handling to the appropriate RequestHandler.
 void setBeanName(String beanName)
           
 void setServletContext(javax.servlet.ServletContext servletContext)
          Called before registerPortListener(), to enable the registration process and subsequent handleRequest() calls to access the ServletContext, via the getServletContext() method.
 String translateRequestPath(javax.servlet.http.HttpServletRequest httpRequest)
           
 String translateRequestPathQuery(javax.servlet.http.HttpServletRequest httpRequest)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.archive.wayback.util.webapp.RequestHandler
handleRequest
 

Constructor Detail

AbstractRequestHandler

public AbstractRequestHandler()
Method Detail

setBeanName

public void setBeanName(String beanName)
Specified by:
setBeanName in interface org.springframework.beans.factory.BeanNameAware

getBeanName

public String getBeanName()
Specified by:
getBeanName in interface RequestHandler
Returns:
the "name" property of the bean from the SpringConfiguration

setServletContext

public void setServletContext(javax.servlet.ServletContext servletContext)
Description copied from interface: RequestHandler
Called before registerPortListener(), to enable the registration process and subsequent handleRequest() calls to access the ServletContext, via the getServletContext() method.

Specified by:
setServletContext in interface RequestHandler
Parameters:
servletContext - the ServletContext where the RequestHandler is registered.

getServletContext

public javax.servlet.ServletContext getServletContext()
Specified by:
getServletContext in interface RequestHandler
Returns:
the ServletContext where the RequestHandler is registered.

registerPortListener

public void registerPortListener(RequestMapper requestMapper)
Description copied from interface: RequestHandler
Called at webapp context initialization, to allow the RequestHandler to register itself with the RequestMapper, which will delegate request handling to the appropriate RequestHandler.

Specified by:
registerPortListener in interface RequestHandler
Parameters:
requestMapper - the RequestMapper on which this RequestHandler should register itself, including to register for notification of context shutdown.

translateRequestPath

public String translateRequestPath(javax.servlet.http.HttpServletRequest httpRequest)
Specified by:
translateRequestPath in interface RequestHandler
Parameters:
httpRequest - the HttpServletRequest being handled
Returns:
the portion of the original incoming request that falls within this RequestHandler, not including any query information

translateRequestPathQuery

public String translateRequestPathQuery(javax.servlet.http.HttpServletRequest httpRequest)
Specified by:
translateRequestPathQuery in interface RequestHandler
Parameters:
httpRequest - the HttpServletRequest being handled
Returns:
the portion of the original incoming request that falls within this RequestHandler, including any query information

getMapParam

public static String getMapParam(Map<String,String[]> queryMap,
                                 String field)
Extract the first value in the array mapped to by field in queryMap

Parameters:
queryMap - the Map in which to search
field - the field value desired
Returns:
the first value in the array mapped to field in queryMap, if present, null otherwise

getRequiredMapParam

public static String getRequiredMapParam(Map<String,String[]> queryMap,
                                         String field)
                                  throws BadQueryException
Extract the first value in the array mapped to by field in queryMap

Parameters:
queryMap - the Map in which to search
field - the field value desired
Returns:
the first value in the array mapped to field in queryMap, if present. A BadQueryException is thrown if there is no appropriate value
Throws:
BadQueryException - if there is nothing mapped to field, or if the Array mapped to field is empty

getMapParamOrEmpty

public static String getMapParamOrEmpty(Map<String,String[]> map,
                                        String param)
Extract the first value in the array mapped to by field in queryMap

Parameters:
map - the Map in which to search
param - the field value desired
Returns:
the first value in the array mapped to field in queryMap, if present, or an empty string otherwise


Copyright © 2005-2011 Internet Archive. All Rights Reserved.