From: <bra...@us...> - 2010-04-05 23:43:22
|
Revision: 3029 http://archive-access.svn.sourceforge.net/archive-access/?rev=3029&view=rev Author: bradtofel Date: 2010-04-05 23:43:16 +0000 (Mon, 05 Apr 2010) Log Message: ----------- FEATURE: added configuration of a liveWebPrefix. If configured, a NotInArchiveException is redirected to: PREFIX+MISSING_URL which is assumed to be handled by another AccessPoint that can replay content from the live web. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java 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-05 23:36:47 UTC (rev 3028) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java 2010-04-05 23:43:16 UTC (rev 3029) @@ -82,6 +82,8 @@ 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; @@ -243,7 +245,7 @@ * @return the portion of the request following the path to this context * without leading '/' */ - private String translateRequest(HttpServletRequest httpRequest, + protected String translateRequest(HttpServletRequest httpRequest, boolean includeQuery) { String origRequestPath = httpRequest.getRequestURI(); @@ -334,7 +336,7 @@ return getAbsoluteContextPrefix(httpRequest, useServerName); } - private boolean dispatchLocal(HttpServletRequest httpRequest, + protected boolean dispatchLocal(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws ServletException, IOException { @@ -418,11 +420,20 @@ handled = true; } catch(WaybackException e) { - logNotInArchive(e,wbRequest); - exception.renderException(httpRequest, httpResponse, wbRequest, e, - uriConverter); + boolean drawError = true; + if(e instanceof ResourceNotInArchiveException) { + if(liveWebPrefix != null) { + String liveUrl = liveWebPrefix + wbRequest.getRequestUrl(); + httpResponse.sendRedirect(liveUrl); + drawError = false; + } + } + if(drawError) { + logNotInArchive(e,wbRequest); + exception.renderException(httpRequest, httpResponse, wbRequest, e, + uriConverter); + } } - return handled; } @@ -706,4 +717,18 @@ public void setExactHostMatch(boolean exactHostMatch) { this.exactHostMatch = exactHostMatch; } + + /** + * @return the liveWebPrefix + */ + public String getLiveWebPrefix() { + return liveWebPrefix; + } + + /** + * @param liveWebPrefix the liveWebPrefix to set + */ + public void setLiveWebPrefix(String liveWebPrefix) { + this.liveWebPrefix = liveWebPrefix; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |