| 
      
      
      From: <bra...@us...> - 2010-04-27 22:47:45
      
     | 
| Revision: 3081
          http://archive-access.svn.sourceforge.net/archive-access/?rev=3081&view=rev
Author:   bradtofel
Date:     2010-04-27 22:47:37 +0000 (Tue, 27 Apr 2010)
Log Message:
-----------
MAJOR REFACTOR of AccessPoint ServletContext linkage. Tons of code moved around, with a goal of not actually busting Wayback XML Spring configuration too badly..
Modified Paths:
--------------
    trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/ARCRecordingProxy.java
    trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/ARCUnwrappingProxy.java
    trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/BaseRequestParser.java
    trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/FormRequestParser.java
    trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/OpenSearchRequestParser.java
    trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/PathRequestParser.java
    trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FileProxyServlet.java
    trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/ResourceFileLocationDBServlet.java
    trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java
    trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/LiveWebAccessPoint.java
Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/ARCRecordingProxy.java
===================================================================
--- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/ARCRecordingProxy.java	2010-04-27 22:45:40 UTC (rev 3080)
+++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/ARCRecordingProxy.java	2010-04-27 22:47:37 UTC (rev 3081)
@@ -33,13 +33,13 @@
 
 import org.apache.commons.httpclient.URIException;
 import org.apache.log4j.Logger;
-import org.archive.wayback.webapp.ServletRequestContext;
+import org.archive.wayback.util.webapp.AbstractRequestHandler;
 
 /**
  * @author brad
  *
  */
-public class ARCRecordingProxy extends ServletRequestContext {
+public class ARCRecordingProxy extends AbstractRequestHandler {
 
 	private final static String EXPIRES_HEADER = "Expires";
 	private long expiresMS = 60 * 60 * 1000;
@@ -52,10 +52,7 @@
 
 	private ARCCacheDirectory arcCacheDir = null;
 	private URLtoARCCacher cacher = null;
-	/* (non-Javadoc)
-	 * @see org.archive.wayback.webapp.ServletRequestContext#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-	 */
-	@Override
+
 	public boolean handleRequest(HttpServletRequest httpRequest,
 			HttpServletResponse httpResponse) throws ServletException,
 			IOException {
Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/ARCUnwrappingProxy.java
===================================================================
--- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/ARCUnwrappingProxy.java	2010-04-27 22:45:40 UTC (rev 3080)
+++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/ARCUnwrappingProxy.java	2010-04-27 22:47:37 UTC (rev 3081)
@@ -40,7 +40,7 @@
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.archive.io.arc.ARCRecord;
 import org.archive.wayback.util.ByteOp;
-import org.archive.wayback.webapp.ServletRequestContext;
+import org.archive.wayback.util.webapp.AbstractRequestHandler;
 
 /**
  * 
@@ -54,7 +54,7 @@
  * @author brad
  *
  */
-public class ARCUnwrappingProxy extends ServletRequestContext {
+public class ARCUnwrappingProxy extends AbstractRequestHandler {
 	
     private MultiThreadedHttpConnectionManager connectionManager = null;
     private HostConfiguration hostConfiguration = null;
@@ -66,13 +66,6 @@
     	hostConfiguration = new HostConfiguration();
     }
 
-//	protected HttpClient http = new HttpClient(
-//            new MultiThreadedHttpConnectionManager());
-
-	/* (non-Javadoc)
-	 * @see org.archive.wayback.webapp.ServletRequestContext#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-	 */
-	@Override
 	public boolean handleRequest(HttpServletRequest httpRequest,
 			HttpServletResponse httpResponse) throws ServletException,
 			IOException {
@@ -81,7 +74,6 @@
 		if(query != null) {
 			sb.append("?").append(query);
 		}
-//		URL url = new URL(sb.toString());
         HttpMethod method = new GetMethod(sb.toString());
 //        method.addRequestHeader("User-Agent", userAgent);
         boolean got200 = false;
Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/BaseRequestParser.java
===================================================================
--- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/BaseRequestParser.java	2010-04-27 22:45:40 UTC (rev 3080)
+++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/BaseRequestParser.java	2010-04-27 22:47:37 UTC (rev 3081)
@@ -78,34 +78,6 @@
 			AccessPoint wbContext) throws BadQueryException, 
 			BetterRequestException;
 
-	protected static String getMapParam(Map<String,String[]> queryMap,
-			String field) {
-		String arr[] = queryMap.get(field);
-		if (arr == null || arr.length == 0) {
-			return null;
-		}
-		return arr[0];
-	}
-
-	protected static String getRequiredMapParam(Map<String,String[]> queryMap,
-			String field)
-	throws BadQueryException {
-		String value = getMapParam(queryMap,field);
-		if(value == null) {
-			throw new BadQueryException("missing field " + field);
-		}
-		if(value.length() == 0) {
-			throw new BadQueryException("empty field " + field);			
-		}
-		return value;
-	}
-
-	protected static String getMapParamOrEmpty(Map<String,String[]> map, 
-			String param) {
-		String val = getMapParam(map,param);
-		return (val == null) ? "" : val;
-	}
-
 	/**
 	 * @return the maxRecords to use with this RequestParser, when not specified
 	 * by the client request
Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/FormRequestParser.java
===================================================================
--- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/FormRequestParser.java	2010-04-27 22:45:40 UTC (rev 3080)
+++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/FormRequestParser.java	2010-04-27 22:47:37 UTC (rev 3081)
@@ -59,7 +59,7 @@
 	 * WaybackRequest object, except the Submit button argument.
 	 */
 	public WaybackRequest parse(HttpServletRequest httpRequest, 
-			AccessPoint wbContext) {
+			AccessPoint accessPoint) {
 
 		WaybackRequest wbRequest = null;
 		@SuppressWarnings("unchecked")
@@ -67,7 +67,7 @@
 		if(queryMap.size() > 0) {
 			wbRequest = new WaybackRequest();
 			
-			String base = wbContext.translateRequestPath(httpRequest);
+			String base = accessPoint.translateRequestPath(httpRequest);
 			if(base.startsWith(REPLAY_BASE)) {
 				wbRequest.setReplayRequest();
 			} else if(base.startsWith(QUERY_BASE)) {
@@ -88,7 +88,7 @@
 					continue;
 				}
 				// just jam everything else in:
-				String val = getMapParam(queryMap,key);
+				String val = AccessPoint.getMapParam(queryMap,key);
 				wbRequest.put(key,val);
 			}
 			String partialTS = wbRequest.getReplayTimestamp();
Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/OpenSearchRequestParser.java
===================================================================
--- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/OpenSearchRequestParser.java	2010-04-27 22:45:40 UTC (rev 3080)
+++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/OpenSearchRequestParser.java	2010-04-27 22:47:37 UTC (rev 3081)
@@ -88,7 +88,7 @@
 		WaybackRequest wbRequest = null;
 		@SuppressWarnings("unchecked")
 		Map<String,String[]> queryMap = httpRequest.getParameterMap();
-		String query = getMapParam(queryMap, SEARCH_QUERY);
+		String query = AccessPoint.getMapParam(queryMap, SEARCH_QUERY);
 		if(query == null) {
 			return null;
 		}
@@ -107,8 +107,8 @@
 			return null;
 		}
 		
-		String numResults = getMapParam(queryMap, SEARCH_RESULTS);
-		String startPage = getMapParam(queryMap, START_PAGE);
+		String numResults = AccessPoint.getMapParam(queryMap, SEARCH_RESULTS);
+		String startPage = AccessPoint.getMapParam(queryMap, START_PAGE);
 
 		if (numResults != null) {
 			int nr = Integer.parseInt(numResults);
Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/PathRequestParser.java
===================================================================
--- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/PathRequestParser.java	2010-04-27 22:45:40 UTC (rev 3080)
+++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/PathRequestParser.java	2010-04-27 22:47:37 UTC (rev 3081)
@@ -33,7 +33,7 @@
 
 /**
  * Subclass of RequestParser that acquires key request information from the
- * path component following the wayback context. 
+ * path component within the handling AccessPoint. 
  *
  * @author brad
  * @version $Date$, $Revision$
@@ -41,43 +41,35 @@
 public abstract class PathRequestParser extends WrappedRequestParser {
 
 	/**
-	 * @param wrapped
+	 * @param wrapped the BaseRequestParser being wrapped
 	 */
 	public PathRequestParser(BaseRequestParser wrapped) {
 		super(wrapped);
 	}
 
 	/**
-	 * @param requestPath
-	 * @param acessPoint 
-	 * @return WaybackRequest with information parsed from the requestPath, or
-	 * null if information could not be extracted.
-	 * @throws BetterRequestException 
-	 */
+	 * attempt to transform an incoming HttpServletRequest into a 
+	 * WaybackRequest object. returns null if there is missing information.
+	 * 
+	 * @param requestPath the AccessPoint relative path as received by the 
+	 * 		   AccessPoint
+	 * @param accessPoint AccessPoint which is attempting to parse the request 
+	 * @return populated WaybackRequest object if successful, null otherwise.
+	 * @throws BadQueryException if the request could match this AccessPoint,
+	 *         but is malformed: invalid datespec, URL, or flags
+	 * @throws BetterRequestException if the request should be redirected to
+	 *         provide better user feedback (corrected URL/date in address bar)
+	 */        
 	public abstract WaybackRequest parse(String requestPath, 
-			AccessPoint acessPoint) throws BetterRequestException;
+			AccessPoint accessPoint) throws BetterRequestException, 
+			BadQueryException;
 
-	/* (non-Javadoc)
-	 * @see org.archive.wayback.requestparser.BaseRequestParser#parse(javax.servlet.http.HttpServletRequest, org.archive.wayback.webapp.WaybackContext)
-	 */
-	@Override
 	public WaybackRequest parse(HttpServletRequest httpRequest,
-			AccessPoint acessPoint) 
+			AccessPoint accessPoint) 
 		throws BadQueryException, BetterRequestException {
 
-		String queryString = httpRequest.getQueryString();
-		String origRequestPath = httpRequest.getRequestURI();
-
-		if (queryString != null) {
-			origRequestPath += "?" + queryString;
-		}
-		String contextPath = acessPoint.getContextPath(httpRequest);
-		if (!origRequestPath.startsWith(contextPath)) {
-			return null;
-		}
-		String requestPath = origRequestPath.substring(contextPath.length());
-		
-		WaybackRequest wbRequest = parse(requestPath, acessPoint);
+		String requestPath = accessPoint.translateRequestPathQuery(httpRequest);
+		WaybackRequest wbRequest = parse(requestPath, accessPoint);
 		if(wbRequest != null) {
 			wbRequest.setResultsPerPage(getMaxRecords());
 		}
Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FileProxyServlet.java
===================================================================
--- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FileProxyServlet.java	2010-04-27 22:45:40 UTC (rev 3080)
+++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FileProxyServlet.java	2010-04-27 22:47:37 UTC (rev 3081)
@@ -45,7 +45,7 @@
 import org.archive.util.anvl.ANVLRecord;
 import org.archive.wayback.util.http.HttpRequestMessage;
 import org.archive.wayback.util.http.HttpResponse;
-import org.archive.wayback.webapp.ServletRequestContext;
+import org.archive.wayback.util.webapp.AbstractRequestHandler;
 
 /**
  * ServletRequestContext interface which uses a ResourceFileLocationDB to 
@@ -56,7 +56,7 @@
  * @author brad
  * @version $Date$, $Revision$
  */
-public class FileProxyServlet extends ServletRequestContext {
+public class FileProxyServlet extends AbstractRequestHandler {
 	private static final Logger LOGGER = Logger.getLogger(FileProxyServlet.class
 			.getName());
 
Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/ResourceFileLocationDBServlet.java
===================================================================
--- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/ResourceFileLocationDBServlet.java	2010-04-27 22:45:40 UTC (rev 3080)
+++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/ResourceFileLocationDBServlet.java	2010-04-27 22:47:37 UTC (rev 3081)
@@ -34,7 +34,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.archive.wayback.webapp.ServletRequestContext;
+import org.archive.wayback.exception.BadQueryException;
+import org.archive.wayback.util.webapp.AbstractRequestHandler;
 
 /**
  * ServletRequestContext enabling remote HTTP GET/POST access to a local 
@@ -44,7 +45,7 @@
  * @author brad
  * @version $Date$, $Revision$
  */
-public class ResourceFileLocationDBServlet extends ServletRequestContext {
+public class ResourceFileLocationDBServlet extends AbstractRequestHandler {
 
 	protected static final String OPERATION_ARGUMENT = "operation";
 	protected static final String NAME_ARGUMENT = "name";
@@ -77,18 +78,22 @@
 			e.printStackTrace();
 			httpResponse.sendError(HttpServletResponse.SC_BAD_REQUEST,
 					e.getMessage());
+		} catch(BadQueryException e) {
+			e.printStackTrace();
+			httpResponse.sendError(HttpServletResponse.SC_BAD_REQUEST,
+					e.getMessage());
 		}
 		return true;
 	}
 
 	private String handleOperation(Map<String,String[]> queryMap)
-			throws ParseException {
+			throws ParseException, BadQueryException {
 
-		String operation = getRequiredMapParam(queryMap, OPERATION_ARGUMENT);
+		String operation = AbstractRequestHandler.getRequiredMapParam(queryMap, OPERATION_ARGUMENT);
 		String message;
 		try {
 			if (operation.equals(LOOKUP_OPERATION)) {
-				String name = getRequiredMapParam(queryMap, NAME_ARGUMENT);
+				String name = AbstractRequestHandler.getRequiredMapParam(queryMap, NAME_ARGUMENT);
 
 				message = NO_LOCATION_PREFIX + " " + name;
 				String arcUrls[] = locationDB.nameToUrls(name);
@@ -107,8 +112,8 @@
 
 			} else if (operation.equals(GETRANGE_OPERATION)) {
 
-				long start = Long.parseLong(getRequiredMapParam(queryMap, START_ARGUMENT));
-				long end = Long.parseLong(getRequiredMapParam(queryMap, END_ARGUMENT));
+				long start = Long.parseLong(AbstractRequestHandler.getRequiredMapParam(queryMap, START_ARGUMENT));
+				long end = Long.parseLong(AbstractRequestHandler.getRequiredMapParam(queryMap, END_ARGUMENT));
 				Iterator<String> itr = locationDB.getNamesBetweenMarks(start,end);
 				StringBuilder str = new StringBuilder();
 				str.append("OK ");
@@ -120,8 +125,8 @@
 				
 			} else {
 
-				String name = getRequiredMapParam(queryMap, NAME_ARGUMENT);
-				String url = getRequiredMapParam(queryMap, URL_ARGUMENT);
+				String name = AbstractRequestHandler.getRequiredMapParam(queryMap, NAME_ARGUMENT);
+				String url = AbstractRequestHandler.getRequiredMapParam(queryMap, URL_ARGUMENT);
 				if (operation.equals(ADD_OPERATION)) {
 
 					locationDB.addNameUrl(name, url);
Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java
===================================================================
--- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java	2010-04-27 22:45:40 UTC (rev 3080)
+++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java	2010-04-27 22:47:37 UTC (rev 3081)
@@ -40,7 +40,6 @@
 import org.archive.wayback.ReplayRenderer;
 import org.archive.wayback.RequestParser;
 import org.archive.wayback.ResultURIConverter;
-import org.archive.wayback.WaybackConstants;
 import org.archive.wayback.accesscontrol.ExclusionFilterFactory;
 import org.archive.wayback.core.CaptureSearchResult;
 import org.archive.wayback.core.CaptureSearchResults;
@@ -58,7 +57,8 @@
 import org.archive.wayback.exception.WaybackException;
 import org.archive.wayback.resourceindex.filters.ExclusionFilter;
 import org.archive.wayback.util.operator.BooleanOperator;
-import org.springframework.beans.factory.BeanNameAware;
+import org.archive.wayback.util.webapp.AbstractRequestHandler;
+import org.archive.wayback.util.webapp.ShutdownListener;
 
 /**
  * Retains all information about a particular Wayback configuration
@@ -77,265 +77,38 @@
  * @author brad
  * @version $Date$, $Revision$
  */
-public class AccessPoint implements RequestContext, BeanNameAware {
+public class AccessPoint extends AbstractRequestHandler 
+implements ShutdownListener {
 
 	private static final Logger LOGGER = Logger.getLogger(
 			AccessPoint.class.getName());
 	
-	private String liveWebPrefix = null;
-	
-	private boolean useServerName = false;
-	private boolean useAnchorWindow = false;
-	private boolean exactSchemeMatch = true;
 	private boolean exactHostMatch = false;
+	private boolean exactSchemeMatch = true;
+	private boolean useAnchorWindow = false;
+	private boolean useServerName = false;
 
-	private int contextPort = 0;
-	private String contextName = null;
-	private String beanName = null;
-	private WaybackCollection collection = null;
-	private ReplayDispatcher replay = null;
-	private ExceptionRenderer exception = new BaseExceptionRenderer();
-	private QueryRenderer query = null;
-	private RequestParser parser = null;
-	private ResultURIConverter uriConverter = null;
-	private Properties configs = null;
-	private ExclusionFilterFactory exclusionFactory = null;
-	private BooleanOperator<WaybackRequest> authentication = null;
+	private String liveWebPrefix = null;
 	private String urlRoot = null;
+
 	private Locale locale = null;
+
+	private Properties configs = null;
+
 	private List<String> filePatterns = null;
 	private List<String> filePrefixes = null;
-	
-	/**
-	 * @return List of file patterns that will be matched when querying the 
-	 * ResourceIndex
-	 */
-	public List<String> getFilePatterns() {
-		return filePatterns;
-	}
 
-	/**
-	 * @param filePatterns List of file Patterns (regular expressions) that
-	 * 		will be matched when querying the ResourceIndex - only SearchResults
-	 *      matching one of these patterns will be returned.
-	 */
-	public void setFilePatterns(List<String> filePatterns) {
-		this.filePatterns = filePatterns;
-	}
+	private WaybackCollection  collection   = null;
+	private ExceptionRenderer  exception    = new BaseExceptionRenderer();
+	private QueryRenderer      query        = null;
+	private RequestParser      parser       = null;
+	private ReplayDispatcher   replay       = null;
+	private ResultURIConverter uriConverter = null;
 
-	/**
-	 * @return List of file String prefixes that will be matched when querying 
-	 * 		the ResourceIndex
-	 */
-	public List<String> getFilePrefixes() {
-		return filePrefixes;
-	}
-
-	/**
-	 * @param filePrefixes List of String file prefixes that will be matched
-	 * 		when querying the ResourceIndex - only SearchResults from files 
-	 * 		with a prefix matching one of those in this List will be returned.
-	 */
-	public void setFilePrefixes(List<String> filePrefixes) {
-		this.filePrefixes = filePrefixes;
-	}
-
-	/**
-	 * @return the contextName
-	 */
-	public String getContextName() {
-		return contextName;
-	}
-
-	/**
-	 * @return the replay
-	 */
-	public ReplayDispatcher getReplay() {
-		return replay;
-	}
-
-	/**
-	 * @return the query
-	 */
-	public QueryRenderer getQuery() {
-		return query;
-	}
-
-	/**
-	 * @return the parser
-	 */
-	public RequestParser getParser() {
-		return parser;
-	}
-
-	/**
-	 * @return the uriConverter
-	 */
-	public ResultURIConverter getUriConverter() {
-		return uriConverter;
-	}
-
-	/**
-	 * @return explicit Locale to use within this AccessPoint.
-	 */
-	public Locale getLocale() {
-		return locale;
-	}
-
-	/**
-	 * @param locale explicit Locale to use for requests within this 
-	 * 		AccessPoint. If not set, will attempt to use the one specified by
-	 * 		each requests User Agent via HTTP headers
-	 */
-	public void setLocale(Locale locale) {
-		this.locale = locale;
-	}
-
-	/**
-	 * 
-	 */
-	public AccessPoint() {
-		
-	}
+	private ExclusionFilterFactory exclusionFactory = null;
+	private BooleanOperator<WaybackRequest> authentication = null;
 	
-	/* (non-Javadoc)
-	 * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
-	 */
-	public void setBeanName(String beanName) {
-		this.beanName = beanName;
-		this.contextName = "";
-		int idx = beanName.indexOf(":");
-		if(idx > -1) {
-			contextPort = Integer.valueOf(beanName.substring(0,idx));
-			contextName = beanName.substring(idx + 1);
-		} else {
-			try {
-				this.contextPort = Integer.valueOf(beanName);
-			} catch(NumberFormatException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-	/**
-	 * @return the name of the bean in the Spring configuration which defined
-	 * 			this AccessPoint.
-	 */
-	public String getBeanName() {
-		return beanName;
-	}
-	/**
-	 * @param httpRequest HttpServletRequest which is being handled 
-	 * @return the prefix of paths received by this server that are handled by
-	 * this WaybackContext, including the trailing '/'
-	 */
-	public String getContextPath(HttpServletRequest httpRequest) {
-		String httpContextPath = httpRequest.getContextPath();
-		if(contextName.length() == 0) {
-			return httpContextPath + "/";
-		}
-		return httpContextPath + "/" + contextName + "/";
-	}
 
-	/**
-	 * Remove any leading ServletContext and AccessPoint name path elements
-	 * from the incoming request path, returning the result as a String
-	 * 
-	 * @param httpRequest HttpServletRequest which is being handled 
-	 * @param includeQuery if true, include any query arguments
-	 * @return the portion of the request following the path to this context
-	 * without leading '/'
-	 */
-	protected String translateRequest(HttpServletRequest httpRequest, 
-			boolean includeQuery) {
-
-		String origRequestPath = httpRequest.getRequestURI();
-		if(includeQuery) {
-			String queryString = httpRequest.getQueryString();
-			if (queryString != null) {
-				origRequestPath += "?" + queryString;
-			}
-		}
-		String contextPath = getContextPath(httpRequest);
-		if (!origRequestPath.startsWith(contextPath)) {
-			if(contextPath.startsWith(origRequestPath)) {
-				// missing trailing '/', just omit:
-				return "";
-			}
-			return null;
-		}
-		return origRequestPath.substring(contextPath.length());
-	}
-	
-	/**
-	 * Remove any leading ServletContext and AccessPoint name path elements
-	 * from the incoming request path, returning the result as a String
-
-	 * @param httpRequest HttpServletRequest which is being handled 
-	 * @return the portion of the request following the path to this context, 
-	 * including any query information,without leading '/'
-	 */
-	public String translateRequestPathQuery(HttpServletRequest httpRequest) {
-		return translateRequest(httpRequest,true);
-	}	
-
-	/**
-	 * @param httpRequest HttpServletRequest which is being handled 
-	 * @return the portion of the request following the path to this context, 
-	 * excluding any query information, without leading '/'
-	 */
-	public String translateRequestPath(HttpServletRequest httpRequest) {
-		return translateRequest(httpRequest,false);
-	}	
-	
-	/**
-	 * Construct an absolute URL that points to the root of the context that
-	 * received the request, including a trailing "/".
-	 * 
-	 * @return String absolute URL pointing to the Context root where the
-	 *         request was received.
-	 */
-	private String getAbsoluteContextPrefix(HttpServletRequest httpRequest, 
-			boolean useRequestServer) {
-		
-		StringBuilder prefix = new StringBuilder();
-		prefix.append(WaybackConstants.HTTP_URL_PREFIX);
-		String waybackPort = null;
-		if(useRequestServer) {
-			prefix.append(httpRequest.getLocalName());
-			waybackPort = String.valueOf(httpRequest.getLocalPort());
-		} else {
-			prefix.append(httpRequest.getServerName());
-			waybackPort = String.valueOf(httpRequest.getServerPort());
-		}
-		if (!waybackPort.equals(WaybackConstants.HTTP_DEFAULT_PORT)) {
-			prefix.append(":").append(waybackPort);
-		}
-		String contextPath = getContextPath(httpRequest);
-		prefix.append(contextPath);
-		return prefix.toString();
-	}
-	
-	/**
-	 * @param httpRequest HttpServletRequest which is being handled 
-	 * @return absolute URL pointing to the base of this WaybackContext, using
-	 * Server and port information from the HttpServletRequest argument.
-	 */
-	public String getAbsoluteServerPrefix(HttpServletRequest httpRequest) {
-		return getAbsoluteContextPrefix(httpRequest, true);
-	}
-
-	/**
-	 * @param httpRequest HttpServletRequest which is being handled 
-	 * @return absolute URL pointing to the base of this WaybackContext, using
-	 * Canonical server and port information.
-	 */
-	public String getAbsoluteLocalPrefix(HttpServletRequest httpRequest) {
-		if(urlRoot != null) {
-			return urlRoot;
-		}
-		return getAbsoluteContextPrefix(httpRequest, useServerName);
-	}
-
 	protected boolean dispatchLocal(HttpServletRequest httpRequest,
 			HttpServletResponse httpResponse) 
 	throws ServletException, IOException {
@@ -343,7 +116,7 @@
 		String translated = "/" + translateRequestPathQuery(httpRequest);
 
 		WaybackRequest wbRequest = new WaybackRequest();
-		wbRequest.setContextPrefix(getAbsoluteLocalPrefix(httpRequest));
+		wbRequest.setContextPrefix(getUrlRoot());
 		wbRequest.setAccessPoint(this);
 		wbRequest.fixup(httpRequest);
 		UIResults uiResults = new UIResults(wbRequest,uriConverter);
@@ -355,7 +128,7 @@
 		}
 		return false;
 	}
-	
+
 	/**
 	 * @param httpRequest HttpServletRequest which is being handled 
 	 * @param httpResponse HttpServletResponse which is being handled 
@@ -371,25 +144,28 @@
 		boolean handled = false;
 
 		try {
-			wbRequest = parser.parse(httpRequest, this);
+			wbRequest = getParser().parse(httpRequest, this);
 
 			if(wbRequest != null) {
 				handled = true;
 
 				// TODO: refactor this code into RequestParser implementations
 				wbRequest.setAccessPoint(this);
-				wbRequest.setContextPrefix(getAbsoluteLocalPrefix(httpRequest));
+//				wbRequest.setContextPrefix(getAbsoluteLocalPrefix(httpRequest));
+				wbRequest.setContextPrefix(getUrlRoot());
 				wbRequest.fixup(httpRequest);
 				// end of refactor
 
-				if(authentication != null) {
-					if(!authentication.isTrue(wbRequest)) {
-						throw new AuthenticationControlException("Not authorized");
+				if(getAuthentication() != null) {
+					if(!getAuthentication().isTrue(wbRequest)) {
+						throw new AuthenticationControlException(
+								"Unauthorized");
 					}
 				}
 
-				if(exclusionFactory != null) {
-					ExclusionFilter exclusionFilter = exclusionFactory.get();
+				if(getExclusionFactory() != null) {
+					ExclusionFilter exclusionFilter = 
+						getExclusionFactory().get();
 					if(exclusionFilter == null) {
 						throw new AdministrativeAccessControlException(
 								"AccessControl list unavailable");
@@ -399,8 +175,8 @@
 				// TODO: refactor this into RequestParser implementations, so a
 				// user could alter requests to change the behavior within a
 				// single AccessPoint. For now, this is a simple way to expose
-				// the feature to configuration.
-				wbRequest.setExactScheme(exactSchemeMatch);
+				// the feature to configuration.g
+				wbRequest.setExactScheme(isExactSchemeMatch());
 
 				if(wbRequest.isReplayRequest()) {
 
@@ -408,7 +184,7 @@
 					
 				} else {
 
-					wbRequest.setExactHost(exactHostMatch);
+					wbRequest.setExactHost(isExactHostMatch());
 					handleQuery(wbRequest,httpRequest,httpResponse);
 				}
 			} else {
@@ -422,20 +198,34 @@
 		} catch(WaybackException e) {
 			boolean drawError = true;
 			if(e instanceof ResourceNotInArchiveException) {
-				if(liveWebPrefix != null) {
-					String liveUrl = liveWebPrefix + wbRequest.getRequestUrl();
+				if(getLiveWebPrefix() != null) {
+					String liveUrl = 
+						getLiveWebPrefix() + wbRequest.getRequestUrl();
 					httpResponse.sendRedirect(liveUrl);
 					drawError = false;
 				}
 			}
 			if(drawError) {
 				logNotInArchive(e,wbRequest);
-				exception.renderException(httpRequest, httpResponse, wbRequest, e, 
-						uriConverter);
+				getException().renderException(httpRequest, httpResponse, 
+						wbRequest, e, getUriConverter());
 			}
 		}
 		return handled;
 	}
+	
+	private void logNotInArchive(WaybackException e, WaybackRequest r) {
+		// TODO: move this into ResourceNotInArchiveException constructor
+		if(e instanceof ResourceNotInArchiveException) {
+			String url = r.getRequestUrl();
+			StringBuilder sb = new StringBuilder(100);
+			sb.append("NotInArchive\t");
+			sb.append(getUrlRoot()).append("\t");
+			sb.append(url);
+			
+			LOGGER.info(sb.toString());
+		}
+	}
 
 	private void handleReplay(WaybackRequest wbRequest, 
 			HttpServletRequest httpRequest, HttpServletResponse httpResponse) 
@@ -443,24 +233,31 @@
 		Resource resource = null;
 		try {
 			PerformanceLogger p = new PerformanceLogger("replay");
-			SearchResults results = collection.getResourceIndex().query(wbRequest);
+			SearchResults results = 
+				getCollection().getResourceIndex().query(wbRequest);
 			p.queried();
 			if(!(results instanceof CaptureSearchResults)) {
 				throw new ResourceNotAvailableException("Bad results...");
 			}
-			CaptureSearchResults captureResults = (CaptureSearchResults) results;
+			CaptureSearchResults captureResults = 
+				(CaptureSearchResults) results;
 	
 			// TODO: check which versions are actually accessible right now?
 			CaptureSearchResult closest = captureResults.getClosest(wbRequest, 
-					useAnchorWindow);
+					isUseAnchorWindow());
 			closest.setClosest(true);
-			resource = collection.getResourceStore().retrieveResource(closest);
+			resource = 
+				getCollection().getResourceStore().retrieveResource(closest);
 			p.retrieved();
-			ReplayRenderer renderer = replay.getRenderer(wbRequest, closest, resource);
+			ReplayRenderer renderer = 
+				getReplay().getRenderer(wbRequest, closest, resource);
+			
 			renderer.renderResource(httpRequest, httpResponse, wbRequest,
-					closest, resource, uriConverter, captureResults);
+					closest, resource, getUriConverter(), captureResults);
+			
 			p.rendered();
-			p.write(wbRequest.getReplayTimestamp() + " " + wbRequest.getRequestUrl());
+			p.write(wbRequest.getReplayTimestamp() + " " +
+					wbRequest.getRequestUrl());
 		} finally {
 			if(resource != null) {
 				resource.close();
@@ -473,18 +270,19 @@
 	throws ServletException, IOException, WaybackException {
 
 		PerformanceLogger p = new PerformanceLogger("query");
-		SearchResults results = collection.getResourceIndex().query(wbRequest);
+		SearchResults results = 
+			getCollection().getResourceIndex().query(wbRequest);
 		p.queried();
 		if(results instanceof CaptureSearchResults) {
 			CaptureSearchResults cResults = (CaptureSearchResults) results;
 			cResults.markClosest(wbRequest);
-			query.renderCaptureResults(httpRequest,httpResponse,wbRequest,
-					cResults,uriConverter);
+			getQuery().renderCaptureResults(httpRequest,httpResponse,wbRequest,
+					cResults,getUriConverter());
 
 		} else if(results instanceof UrlSearchResults) {
 			UrlSearchResults uResults = (UrlSearchResults) results;
-			query.renderUrlResults(httpRequest,httpResponse,wbRequest,
-					uResults,uriConverter);
+			getQuery().renderUrlResults(httpRequest,httpResponse,wbRequest,
+					uResults,getUriConverter());
 		} else {
 			throw new WaybackException("Unknown index format");
 		}
@@ -492,172 +290,199 @@
 		p.write(wbRequest.getRequestUrl());
 	}
 	
+	
 	/**
 	 * Release any resources associated with this AccessPoint, including
 	 * stopping any background processing threads
-	 * 
-	 * @throws IOException per usual
 	 */
-	public void shutdown() throws IOException {
+	public void shutdown() {
 		if(collection != null) {
-			collection.shutdown();
+			try {
+				collection.shutdown();
+			} catch (IOException e) {
+				LOGGER.error("FAILED collection shutdown", e);
+			}
 		}
 		if(exclusionFactory != null) {
 			exclusionFactory.shutdown();
 		}
 	}
 	
-	private void logNotInArchive(WaybackException e, WaybackRequest r) {
-		// TODO: move this into ResourceNotInArchiveException constructor
-		if(e instanceof ResourceNotInArchiveException) {
-			String url = r.getRequestUrl();
-			StringBuilder sb = new StringBuilder(100);
-			sb.append("NotInArchive\t");
-			sb.append(contextName).append("\t");
-			sb.append(contextPort).append("\t");
-			sb.append(url);
-			
-			LOGGER.info(sb.toString());
-		}
+	/*
+	 * *******************************************************************
+	 * *******************************************************************
+	 * 
+	 *    ALL GETTER/SETTER BELOW HERE 
+	 * 
+	 * *******************************************************************
+	 * *******************************************************************
+	 */
+	
+	/**
+	 * @return the exactHostMatch
+	 */
+	public boolean isExactHostMatch() {
+		return exactHostMatch;
 	}
 
 	/**
-	 * @param contextPort the contextPort to set
+	 * @param exactHostMatch if true, then only SearchResults exactly matching
+	 * 		the requested hostname will be returned from this AccessPoint. If
+	 * 		false, then hosts which canonicalize to the same host as requested
+	 * 		hostname will be returned (www.)
 	 */
-	public void setContextPort(int contextPort) {
-		this.contextPort = contextPort;
+	public void setExactHostMatch(boolean exactHostMatch) {
+		this.exactHostMatch = exactHostMatch;
 	}
 
 	/**
-	 * @param contextName the contextName to set
+	 * @return the exactSchemeMatch
 	 */
-	public void setContextName(String contextName) {
-		this.contextName = contextName;
+	public boolean isExactSchemeMatch() {
+		return exactSchemeMatch;
 	}
 
 	/**
-	 * @param replay the replay to set
+	 * @param exactSchemeMatch the exactSchemeMatch to set
 	 */
-	public void setReplay(ReplayDispatcher replay) {
-		this.replay = replay;
+	public void setExactSchemeMatch(boolean exactSchemeMatch) {
+		this.exactSchemeMatch = exactSchemeMatch;
 	}
 
 	/**
-	 * @param query the query to set
+	 * @return true if this AccessPoint is configured to useAnchorWindow, that
+	 * is, to replay documents only if they are within a certain proximity to
+	 * the users requested AnchorDate
 	 */
-	public void setQuery(QueryRenderer query) {
-		this.query = query;
+	public boolean isUseAnchorWindow() {
+		return useAnchorWindow;
 	}
 
 	/**
-	 * @param parser the parser to set
+	 * @param useAnchorWindow , when set to true, causes this AccessPoint to
+	 * only replay documents if they are within a certain proximity to
+	 * the users requested AnchorDate
 	 */
-	public void setParser(RequestParser parser) {
-		this.parser = parser;
+	public void setUseAnchorWindow(boolean useAnchorWindow) {
+		this.useAnchorWindow = useAnchorWindow;
 	}
 
 	/**
-	 * @param uriConverter the uriConverter to set
+	 * @return the useServerName
+	 * @deprecated no longer used, use urlPrefix
 	 */
-	public void setUriConverter(ResultURIConverter uriConverter) {
-		this.uriConverter = uriConverter;
+	public boolean isUseServerName() {
+		return useServerName;
 	}
 
-
 	/**
-	 * @return the contextPort
+	 * @param useServerName the useServerName to set
+	 * @deprecated no longer used, use urlPrefix
 	 */
-	public int getContextPort() {
-		return contextPort;
+	public void setUseServerName(boolean useServerName) {
+		this.useServerName = useServerName;
 	}
 
 	/**
-	 * @return the configs
+	 * @return the liveWebPrefix String to use, or null, if this AccessPoint 
+	 * does not use the Live Web to fill in documents missing from the archive
 	 */
-	public Properties getConfigs() {
-		return configs;
+	public String getLiveWebPrefix() {
+		return liveWebPrefix;
 	}
 
 	/**
-	 * @param configs the configs to set
+	 * @param liveWebPrefix the String URL prefix to use to attempt to retrieve
+	 * documents missing from the collection from the live web, on demand.
 	 */
-	public void setConfigs(Properties configs) {
-		this.configs = configs;
+	public void setLiveWebPrefix(String liveWebPrefix) {
+		this.liveWebPrefix = liveWebPrefix;
 	}
 
 	/**
-	 * @return the useServerName
+	 * @return the String url prefix to use when generating self referencing 
+	 * 			URLs
 	 */
-	public boolean isUseServerName() {
-		return useServerName;
+	public String getUrlRoot() {
+		return urlRoot;
 	}
 
 	/**
-	 * @param useServerName the useServerName to set
+	 * @param urlRoot explicit URL prefix to use when creating self referencing
+	 * 		URLs
 	 */
-	public void setUseServerName(boolean useServerName) {
-		this.useServerName = useServerName;
+	public void setUrlRoot(String urlRoot) {
+		this.urlRoot = urlRoot;
 	}
 
 	/**
-	 * @return the useAnchorWindow
+	 * @return explicit Locale to use within this AccessPoint.
 	 */
-	public boolean isUseAnchorWindow() {
-		return useAnchorWindow;
+	public Locale getLocale() {
+		return locale;
 	}
 
 	/**
-	 * @param useAnchorWindow the useAnchorWindow to set
+	 * @param locale explicit Locale to use for requests within this 
+	 * 		AccessPoint. If not set, will attempt to use the one specified by
+	 * 		each requests User Agent via HTTP headers
 	 */
-	public void setUseAnchorWindow(boolean useAnchorWindow) {
-		this.useAnchorWindow = useAnchorWindow;
+	public void setLocale(Locale locale) {
+		this.locale = locale;
 	}
-	
+
 	/**
-	 * @return the exactSchemeMatch
+	 * @return the generic customization Properties used with this AccessPoint,
+	 * generally to tune the UI
 	 */
-	public boolean isExactSchemeMatch() {
-		return exactSchemeMatch;
+	public Properties getConfigs() {
+		return configs;
 	}
 
 	/**
-	 * @param exactSchemeMatch the exactSchemeMatch to set
+	 * @param configs the generic customization Properties to use with this
+	 * AccessPoint, generally used to tune the UI
 	 */
-	public void setExactSchemeMatch(boolean exactSchemeMatch) {
-		this.exactSchemeMatch = exactSchemeMatch;
+	public void setConfigs(Properties configs) {
+		this.configs = configs;
 	}
 
 	/**
-	 * @return the ExclusionFilterFactory in use with this AccessPoint
+	 * @return List of file patterns that will be matched when querying the 
+	 * ResourceIndex
 	 */
-	public ExclusionFilterFactory getExclusionFactory() {
-		return exclusionFactory;
+	public List<String> getFilePatterns() {
+		return filePatterns;
 	}
 
 	/**
-	 * @param exclusionFactory all requests to this AccessPoint will create an
-	 * 		exclusionFilter from this factory when handling requests
+	 * @param filePatterns List of file Patterns (regular expressions) that
+	 * 		will be matched when querying the ResourceIndex - only SearchResults
+	 *      matching one of these patterns will be returned.
 	 */
-	public void setExclusionFactory(ExclusionFilterFactory exclusionFactory) {
-		this.exclusionFactory = exclusionFactory;
+	public void setFilePatterns(List<String> filePatterns) {
+		this.filePatterns = filePatterns;
 	}
 
 	/**
-	 * @return the configured AuthenticationControl operator in use with this
-	 * 		AccessPoint.
+	 * @return List of file String prefixes that will be matched when querying 
+	 * 		the ResourceIndex
 	 */
-	public BooleanOperator<WaybackRequest> getAuthentication() {
-		return authentication;
+	public List<String> getFilePrefixes() {
+		return filePrefixes;
 	}
 
 	/**
-	 * @param authentication the BooleanOperator which determines if incoming
-	 * 		requests are allowed to connect to this AccessPoint.
+	 * @param filePrefixes List of String file prefixes that will be matched
+	 * 		when querying the ResourceIndex - only SearchResults from files 
+	 * 		with a prefix matching one of those in this List will be returned.
 	 */
-	public void setAuthentication(BooleanOperator<WaybackRequest> authentication) {
-		this.authentication = authentication;
+	public void setFilePrefixes(List<String> filePrefixes) {
+		this.filePrefixes = filePrefixes;
 	}
 
+
+	
 	/**
 	 * @return the WaybackCollection used by this AccessPoint
 	 */
@@ -687,49 +512,97 @@
 	}
 
 	/**
-	 * @return the String url prefix to use when generating self referencing 
-	 * 			URLs
+	 * @return the QueryRenderer to use with this AccessPoint
 	 */
-	public String getUrlRoot() {
-		return urlRoot;
+	public QueryRenderer getQuery() {
+		return query;
 	}
+	
+	/**
+	 * @param query the QueryRenderer responsible for returning query data to
+	 * clients.
+	 */
+	public void setQuery(QueryRenderer query) {
+		this.query = query;
+	}
 
 	/**
-	 * @param urlRoot explicit URL prefix to use when creating self referencing
-	 * 		URLs
+	 * @return the RequestParser used by this AccessPoint to attempt to 
+	 * translate incoming HttpServletRequest objects into WaybackRequest 
+	 * objects
 	 */
-	public void setUrlRoot(String urlRoot) {
-		this.urlRoot = urlRoot;
+	public RequestParser getParser() {
+		return parser;
 	}
+	
+	/**
+	 * @param parser the RequestParser to use with this AccessPoint
+	 */
+	public void setParser(RequestParser parser) {
+		this.parser = parser;
+	}
 
 	/**
-	 * @return the exactHostMatch
+	 * @return the ReplayDispatcher to use with this AccessPoint, responsible
+	 * for returning an appropriate ReplayRenderer given the user request and
+	 * the returned document type.
 	 */
-	public boolean isExactHostMatch() {
-		return exactHostMatch;
+	public ReplayDispatcher getReplay() {
+		return replay;
 	}
 
 	/**
-	 * @param exactHostMatch if true, then only SearchResults exactly matching
-	 * 		the requested hostname will be returned from this AccessPoint. If
-	 * 		false, then hosts which canonicalize to the same host as requested
-	 * 		hostname will be returned (www.)
+	 * @param replay the ReplayDispatcher to use with this AccessPoint.
 	 */
-	public void setExactHostMatch(boolean exactHostMatch) {
-		this.exactHostMatch = exactHostMatch;
+	public void setReplay(ReplayDispatcher replay) {
+		this.replay = replay;
 	}
 
 	/**
-	 * @return the liveWebPrefix
+	 * @return the ResultURIConverter used to construct Replay URLs within this
+	 * AccessPoint
 	 */
-	public String getLiveWebPrefix() {
-		return liveWebPrefix;
+	public ResultURIConverter getUriConverter() {
+		return uriConverter;
 	}
 
 	/**
-	 * @param liveWebPrefix the liveWebPrefix to set
+	 * @param uriConverter the ResultURIConverter to use with this AccessPoint
+	 * to construct Replay URLs
 	 */
-	public void setLiveWebPrefix(String liveWebPrefix) {
-		this.liveWebPrefix = liveWebPrefix;
+	public void setUriConverter(ResultURIConverter uriConverter) {
+		this.uriConverter = uriConverter;
 	}
+
+
+	/**
+	 * @return the ExclusionFilterFactory in use with this AccessPoint
+	 */
+	public ExclusionFilterFactory getExclusionFactory() {
+		return exclusionFactory;
+	}
+
+	/**
+	 * @param exclusionFactory all requests to this AccessPoint will create an
+	 * 		exclusionFilter from this factory when handling requests
+	 */
+	public void setExclusionFactory(ExclusionFilterFactory exclusionFactory) {
+		this.exclusionFactory = exclusionFactory;
+	}
+
+	/**
+	 * @return the configured AuthenticationControl BooleanOperator in use with 
+	 *      this AccessPoint.
+	 */
+	public BooleanOperator<WaybackRequest> getAuthentication() {
+		return authentication;
+	}
+
+	/**
+	 * @param auth the BooleanOperator which determines if incoming
+	 * 		requests are allowed to connect to this AccessPoint.
+	 */
+	public void setAuthentication(BooleanOperator<WaybackRequest> auth) {
+		this.authentication = auth;
+	}
 }
Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/LiveWebAccessPoint.java
===================================================================
--- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/LiveWebAccessPoint.java	2010-04-27 22:45:40 UTC (rev 3080)
+++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/LiveWebAccessPoint.java	2010-04-27 22:47:37 UTC (rev 3081)
@@ -45,84 +45,34 @@
 import org.archive.wayback.liveweb.LiveWebCache;
 import org.archive.wayback.resourceindex.filters.ExclusionFilter;
 import org.archive.wayback.resourcestore.resourcefile.ArcResource;
-import org.springframework.beans.factory.BeanNameAware;
+import org.archive.wayback.util.webapp.AbstractRequestHandler;
 
 /**
  * @author brad
  *
- * AccessPoint subclass which allows no Queries, but makes all replay requests
- * through a LiveWebCache
+ * RequestHandler which satisfies all incoming requests through a LiveWebCache,
+ * using an internal AccessPoint to rewrite replayed documents.
  *
  */
-public class LiveWebAccessPoint extends ServletRequestContext implements BeanNameAware {
+public class LiveWebAccessPoint extends AbstractRequestHandler {
 	private AccessPoint inner = null;
 	private LiveWebCache cache = null;
 	private RobotExclusionFilterFactory robotFactory = null;
 	private long maxCacheMS = 86400000;
-	private String beanName = null;
-	private int contextPort = 0;
-	private String contextName = null;
 	
-	public void setBeanName(String beanName) {
-		this.beanName = beanName;
-		this.contextName = "";
-		int idx = beanName.indexOf(":");
-		if(idx > -1) {
-			contextPort = Integer.valueOf(beanName.substring(0,idx));
-			contextName = beanName.substring(idx + 1);
-		} else {
-			try {
-				this.contextPort = Integer.valueOf(beanName);
-			} catch(NumberFormatException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-	/**
-	 * @param httpRequest HttpServletRequest which is being handled 
-	 * @return the prefix of paths received by this server that are handled by
-	 * this WaybackContext, including the trailing '/'
-	 */
-	public String getContextPath(HttpServletRequest httpRequest) {
-		String httpContextPath = httpRequest.getContextPath();
-		if(contextName.length() == 0) {
-			return httpContextPath + "/";
-		}
-		return httpContextPath + "/" + contextName + "/";
-	}
-
-	
-	protected String translateRequest(HttpServletRequest httpRequest, 
-			boolean includeQuery) {
-
-		String origRequestPath = httpRequest.getRequestURI();
-		if(includeQuery) {
-			String queryString = httpRequest.getQueryString();
-			if (queryString != null) {
-				origRequestPath += "?" + queryString;
-			}
-		}
-		String contextPath = getContextPath(httpRequest);
-		if (!origRequestPath.startsWith(contextPath)) {
-			if(contextPath.startsWith(origRequestPath)) {
-				// missing trailing '/', just omit:
-				return "";
-			}
-			return null;
-		}
-		return origRequestPath.substring(contextPath.length());
-	}
-	
 	public boolean handleRequest(HttpServletRequest httpRequest,
 			HttpServletResponse httpResponse) 
 	throws ServletException, IOException {
 		
-		String urlString = translateRequest(httpRequest,true);
+		String urlString = translateRequestPathQuery(httpRequest);
+
 		boolean handled = true;
 		WaybackRequest wbRequest = new WaybackRequest();
 		wbRequest.setAccessPoint(inner);
-		wbRequest.setContextPrefix(inner.getAbsoluteServerPrefix(httpRequest));
-		wbRequest.setServerPrefix(inner.getAbsoluteServerPrefix(httpRequest));
+
+		wbRequest.setContextPrefix(inner.getUrlRoot());
+		wbRequest.setServerPrefix(inner.getUrlRoot());
+		
 		wbRequest.setLiveWebRequest(true);
 		wbRequest.setRequestUrl(urlString);
 		URL url = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |