From: <bra...@us...> - 2008-07-08 06:06:33
|
Revision: 2419 http://archive-access.svn.sourceforge.net/archive-access/?rev=2419&view=rev Author: bradtofel Date: 2008-07-07 23:06:41 -0700 (Mon, 07 Jul 2008) Log Message: ----------- REFACTOR: WaybackRequest now has get/set for all standard request values. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/ArchivalUrlReplayDispatcher.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathDatePrefixQueryRequestParser.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathDateRangeQueryRequestParser.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathPrefixDatePrefixQueryRequestParser.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathPrefixDateRangeQueryRequestParser.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/ReplayRequestParser.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/authenticationcontrol/HTTPAuthBooleanOperator.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/authenticationcontrol/IPMatchesBooleanOperator.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResults.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UIResults.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackRequest.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/domainprefix/DomainPrefixReplayDispatcher.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/domainprefix/DomainPrefixRequestParser.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/exception/BaseExceptionRenderer.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/LiveWebCache.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/proxy/ProxyReplayRequestParser.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/proxy/ProxyRequestParser.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/query/Renderer.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/query/UIQueryResults.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/resourceindex/LocalResourceIndex.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/NutchResourceIndex.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/RemoteResourceIndex.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/distributed/AlphaPartitionedIndex.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/test/java/org/archive/wayback/resourceindex/distributed/AlphaPartitionedIndexTest.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/ArchivalUrlReplayDispatcher.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/ArchivalUrlReplayDispatcher.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/ArchivalUrlReplayDispatcher.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -75,7 +75,7 @@ // if the result is not for the exact date requested, redirect to the // exact date. some capture dates are not 14 digits, only compare as // many digits as are in the result date: - String reqDateStr = wbRequest.get(WaybackRequest.REQUEST_DATE); + String reqDateStr = wbRequest.getReplayTimestamp(); String resDateStr = result.getCaptureTimestamp(); if(!resDateStr.equals(reqDateStr.substring(0, resDateStr.length()))) { return redirect; Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathDatePrefixQueryRequestParser.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathDatePrefixQueryRequestParser.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathDatePrefixQueryRequestParser.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -27,7 +27,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.httpclient.URIException; import org.archive.wayback.core.Timestamp; import org.archive.wayback.core.WaybackRequest; import org.archive.wayback.requestparser.PathRequestParser; @@ -66,15 +65,10 @@ startDate = Timestamp.parseBefore(dateStr).getDateStr(); endDate = Timestamp.parseAfter(dateStr).getDateStr(); } - wbRequest.put(WaybackRequest.REQUEST_START_DATE,startDate); - wbRequest.put(WaybackRequest.REQUEST_END_DATE,endDate); - wbRequest.put(WaybackRequest.REQUEST_TYPE, - WaybackRequest.REQUEST_URL_QUERY); - try { - wbRequest.setRequestUrl(urlStr); - } catch (URIException e) { - wbRequest = null; - } + wbRequest.setStartTimestamp(startDate); + wbRequest.setEndTimestamp(endDate); + wbRequest.setCaptureQueryRequest(); + wbRequest.setRequestUrl(urlStr); } return wbRequest; } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathDateRangeQueryRequestParser.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathDateRangeQueryRequestParser.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathDateRangeQueryRequestParser.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -27,7 +27,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.httpclient.URIException; import org.archive.wayback.core.Timestamp; import org.archive.wayback.core.WaybackRequest; import org.archive.wayback.requestparser.PathRequestParser; @@ -61,15 +60,10 @@ String startDate = Timestamp.parseBefore(startDateStr).getDateStr(); String endDate = Timestamp.parseAfter(endDateStr).getDateStr(); - wbRequest.put(WaybackRequest.REQUEST_START_DATE,startDate); - wbRequest.put(WaybackRequest.REQUEST_END_DATE,endDate); - wbRequest.put(WaybackRequest.REQUEST_TYPE, - WaybackRequest.REQUEST_URL_QUERY); - try { - wbRequest.setRequestUrl(urlStr); - } catch (URIException e) { - wbRequest = null; - } + wbRequest.setStartTimestamp(startDate); + wbRequest.setEndTimestamp(endDate); + wbRequest.setCaptureQueryRequest(); + wbRequest.setRequestUrl(urlStr); } return wbRequest; } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathPrefixDatePrefixQueryRequestParser.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathPrefixDatePrefixQueryRequestParser.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathPrefixDatePrefixQueryRequestParser.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -27,7 +27,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.httpclient.URIException; import org.archive.wayback.core.Timestamp; import org.archive.wayback.core.WaybackRequest; import org.archive.wayback.requestparser.PathRequestParser; @@ -66,17 +65,11 @@ endDate = Timestamp.parseAfter(dateStr).getDateStr(); } - wbRequest.put(WaybackRequest.REQUEST_START_DATE, - startDate); - wbRequest.put(WaybackRequest.REQUEST_END_DATE,endDate); + wbRequest.setStartTimestamp(startDate); + wbRequest.setEndTimestamp(endDate); - wbRequest.put(WaybackRequest.REQUEST_TYPE, - WaybackRequest.REQUEST_URL_PREFIX_QUERY); - try { - wbRequest.setRequestUrl(urlStr); - } catch (URIException e) { - wbRequest = null; - } + wbRequest.setUrlQueryRequest(); + wbRequest.setRequestUrl(urlStr); } return wbRequest; } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathPrefixDateRangeQueryRequestParser.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathPrefixDateRangeQueryRequestParser.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/PathPrefixDateRangeQueryRequestParser.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -27,7 +27,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.httpclient.URIException; import org.archive.wayback.core.Timestamp; import org.archive.wayback.core.WaybackRequest; import org.archive.wayback.requestparser.PathRequestParser; @@ -58,17 +57,11 @@ String urlStr = matcher.group(3); String startDate = Timestamp.parseBefore(startDateStr).getDateStr(); String endDate = Timestamp.parseAfter(endDateStr).getDateStr(); - wbRequest.put(WaybackRequest.REQUEST_START_DATE, - startDate); - wbRequest.put(WaybackRequest.REQUEST_END_DATE,endDate); + wbRequest.setStartTimestamp(startDate); + wbRequest.setEndTimestamp(endDate); - wbRequest.put(WaybackRequest.REQUEST_TYPE, - WaybackRequest.REQUEST_URL_PREFIX_QUERY); - try { - wbRequest.setRequestUrl(urlStr); - } catch (URIException e) { - wbRequest = null; - } + wbRequest.setUrlQueryRequest(); + wbRequest.setRequestUrl(urlStr); } return wbRequest; } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/ReplayRequestParser.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/ReplayRequestParser.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/archivalurl/requestparser/ReplayRequestParser.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -24,12 +24,9 @@ */ package org.archive.wayback.archivalurl.requestparser; -import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; - -import org.apache.commons.httpclient.URIException; import org.archive.wayback.core.Timestamp; import org.archive.wayback.core.WaybackRequest; import org.archive.wayback.requestparser.PathRequestParser; @@ -42,8 +39,6 @@ * @version $Date$, $Revision$ */ public class ReplayRequestParser extends PathRequestParser { - private static final Logger LOGGER = Logger.getLogger( - ReplayRequestParser.class.getName()); /** * Regex which parses Archival URL replay requests into timestamp + url */ @@ -65,8 +60,6 @@ // based upon amount given (2001 => 20010101... - 20011231...) // AND assume the user asked for the LATEST possible date // within that range... - // - // ...don't ask me, I just work here. String startDate = null; String endDate = null; @@ -76,36 +69,22 @@ } else { // classic behavior: - // startDate = Timestamp.parseBefore(dateStr).getDateStr(); - // endDate = Timestamp.parseAfter(dateStr).getDateStr(); - // dateStr = endDate; + startDate = Timestamp.parseBefore(dateStr).getDateStr(); + endDate = Timestamp.parseAfter(dateStr).getDateStr(); + dateStr = endDate; - // "better" behavior: - startDate = getEarliestTimestamp(); - endDate = getLatestTimestamp(); - dateStr = Timestamp.parseAfter(dateStr).getDateStr(); + // maybe "better" behavior: +// startDate = getEarliestTimestamp(); +// endDate = getLatestTimestamp(); +// dateStr = Timestamp.parseAfter(dateStr).getDateStr(); } - wbRequest.put(WaybackRequest.REQUEST_DATE, dateStr); - wbRequest.put(WaybackRequest.REQUEST_START_DATE, startDate); - wbRequest.put(WaybackRequest.REQUEST_END_DATE, endDate); + wbRequest.setReplayTimestamp(dateStr); + wbRequest.setStartTimestamp(startDate); + wbRequest.setEndTimestamp(endDate); - wbRequest.put(WaybackRequest.REQUEST_TYPE, - WaybackRequest.REQUEST_REPLAY_QUERY); - - try { -// String wbPrefix = wbRequest.getDefaultWaybackPrefix(); -// if (urlStr.startsWith(wbPrefix)) { -// wbRequest.setBetterRequestURI(urlStr); -// } - wbRequest.setRequestUrl(urlStr); - } catch (URIException e) { - if(urlStr != null) { - LOGGER.severe("Failed parse of url(" + urlStr + ")"); - } - e.printStackTrace(); - wbRequest = null; - } + wbRequest.setReplayRequest(); + wbRequest.setRequestUrl(urlStr); } return wbRequest; } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/authenticationcontrol/HTTPAuthBooleanOperator.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/authenticationcontrol/HTTPAuthBooleanOperator.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/authenticationcontrol/HTTPAuthBooleanOperator.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -11,7 +11,7 @@ if(allowedUsers == null) { return false; } - String currentUser = value.get(WaybackRequest.REQUEST_REMOTE_USER); + String currentUser = value.getRemoteUser(); if(currentUser == null) { return false; } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/authenticationcontrol/IPMatchesBooleanOperator.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/authenticationcontrol/IPMatchesBooleanOperator.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/authenticationcontrol/IPMatchesBooleanOperator.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -33,7 +33,7 @@ if(allowedRanges == null) { return false; } - String ipString = value.get(WaybackRequest.REQUEST_REMOTE_ADDRESS); + String ipString = value.getRemoteIPAddress(); if(ipString == null) { return false; } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResults.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResults.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResults.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -109,16 +109,12 @@ CaptureSearchResult closest = null; long closestDistance = 0; CaptureSearchResult cur = null; - String anchorDate = wbRequest.get(WaybackRequest.REQUEST_ANCHOR_DATE); + String anchorDate = wbRequest.getAnchorTimestamp(); long maxWindow = -1; - long wantTime = Timestamp.parseBefore(wbRequest - .get(WaybackRequest.REQUEST_EXACT_DATE)).getDate().getTime(); + long wantTime = wbRequest.getReplayDate().getTime(); if(anchorDate != null) { wantTime = Timestamp.parseBefore(anchorDate).getDate().getTime(); - String anchorWindow = wbRequest.get(WaybackRequest.REQUEST_ANCHOR_WINDOW); - if(anchorWindow != null) { - maxWindow = Long.parseLong(anchorWindow); - } + maxWindow = wbRequest.getAnchorWindow(); } Iterator<CaptureSearchResult> itr = results.iterator(); @@ -132,7 +128,7 @@ closestDistance = curDistance; } } - if(err && (maxWindow != -1)) { + if(err && (maxWindow > 0)) { if(closestDistance > maxWindow) { throw new AnchorWindowTooSmallException("Closest is " + closestDistance + " seconds away, Window is " + Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UIResults.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UIResults.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UIResults.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -28,7 +28,6 @@ import javax.servlet.http.HttpServletRequest; -import org.apache.commons.httpclient.URIException; import org.archive.wayback.ResultURIConverter; import org.archive.wayback.util.StringFormatter; import org.archive.wayback.webapp.AccessPoint; @@ -72,14 +71,8 @@ public String makeCaptureQueryUrl(String url) { WaybackRequest newWBR = wbRequest.clone(); - newWBR.put(WaybackRequest.REQUEST_TYPE, - WaybackRequest.REQUEST_URL_QUERY); - try { - newWBR.setRequestUrl(url); - } catch (URIException e) { - // should not happen... - e.printStackTrace(); - } + newWBR.setCaptureQueryRequest(); + newWBR.setRequestUrl(url); return newWBR.getContextPrefix() + "query?" + newWBR.getQueryArguments(1); } @@ -214,7 +207,7 @@ */ public String getContextConfig(final String configName) { String configValue = null; - AccessPoint context = getWbRequest().getContext(); + AccessPoint context = getWbRequest().getAccessPoint(); if(context != null) { Properties configs = context.getConfigs(); if(configs != null) { Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackRequest.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackRequest.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackRequest.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -23,6 +23,7 @@ package org.archive.wayback.core; +import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.Locale; @@ -34,9 +35,6 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; -import org.apache.commons.httpclient.URIException; -import org.archive.net.UURI; -import org.archive.net.UURIFactory; import org.archive.wayback.requestparser.OpenSearchRequestParser; import org.archive.wayback.util.ObjectFilter; import org.archive.wayback.util.StringFormatter; @@ -51,185 +49,315 @@ */ public class WaybackRequest { - public final static String REQUEST_ANCHOR_DATE = "request.anchordate"; - public final static String REQUEST_ANCHOR_WINDOW = "request.anchorwindow"; - + /** + * indicates the number of requests per page, only makes sense for + * Capture/Url queries. + */ private int resultsPerPage = 10; - + /** + * indicates the specific page of results to show, for paginated requests, + * only makes sense for Capture/Url queries. + */ private int pageNum = 1; - + /** + * absolute URL prefix to the AccessPoint which received this request + */ private String contextPrefix = null; + /** + * absolute URL prefix to the Server(webapp) which received this request + */ private String serverPrefix = null; - private AccessPoint context = null; + /** + * reference to the AccessPoint which received this request. + */ + private AccessPoint accessPoint = null; + /** + * custom CaptureSearchResult Filter to use for this specific request. Can + * be null, and is sometimes useful to allow an AccessPoint to have specific + * and possibly variable filters. + */ private ObjectFilter<CaptureSearchResult> exclusionFilter = null; - - private HashMap<String,String> filters = new HashMap<String,String>(); - - private StringFormatter formatter = null; /** - * Request: Authorization Type: "BASIC", "SSL", or "" if none. + * StringFormatter object set up with the users specific Locale, and the + * Wayback UI ResourceBundle prepared for use, simplifying UI generation + * somewhat. */ - public static final String REQUEST_AUTH_TYPE = "requestauthtype"; + private StringFormatter formatter = null; /** - * Request: Wayback Context: the string context used in the request, - * if applicable. + * generic String-to-String map of various request filters and type + * information. See constants below for keys & values. */ - public static final String REQUEST_WAYBACK_CONTEXT = "waybackcontext"; + private HashMap<String,String> filters = new HashMap<String,String>(); + + + /* + * ********************** + * REQUEST TYPE CONSTANTS + * ********************** + */ /** - * Request: Wayback Port: the port the remote user connected to for this - * request. + * specifies the TYPE of the this particular request. One of: + * *) REQUEST_REPLAY_QUERY + * *) REQUEST_CAPTURE_QUERY + * *) REQUEST_URL_QUERY */ - public static final String REQUEST_WAYBACK_PORT = "waybackport"; + public static final String REQUEST_TYPE = "type"; /** - * Request: Wayback Hostname: the string "Host:" HTTP header + * REQUEST_TYPE option indicating a request for Replay of the Resource + * matching REQUEST_URL closest in time to REQUEST_DATE */ - public static final String REQUEST_WAYBACK_HOSTNAME = "waybackhostname"; + public static final String REQUEST_REPLAY_QUERY = "replay"; /** - * Request: Remote Address, string IP address: "127.0.0.1" + * REQUEST_TYPE option indicating a query against the ResourceIndex for + * captures of URLs matching the REQUEST_URL */ - public static final String REQUEST_REMOTE_ADDRESS = "remoteaddress"; + public static final String REQUEST_CAPTURE_QUERY = "capturequery"; /** - * Request: auto resolution (TimeLine mode) + * REQUEST_TYPE option indicating a query against the ResourceIndex for + * summaries of URLs prefixed with the REQUEST_URL */ - public static final String REQUEST_RESOLUTION_AUTO = "auto"; + public static final String REQUEST_URL_QUERY = "urlquery"; + /* + * ********************** + * /REQUEST TYPE CONSTANTS + * ********************** + */ + + + /* + * ****************** + * URL/DATE CONSTANTS + * ****************** + */ /** - * Request: year resolution (TimeLine mode) + * GUARANTEED PRESENT: Original(RAW) URL or URL prefix requested, before any + * cleanup/fixing */ - public static final String REQUEST_RESOLUTION_YEARS = "years"; + public static final String REQUEST_URL = "url"; + /** - * Request: two-month resolution (TimeLine mode) + * Cleaned up version of original requested URL or URL prefix, as performed + * by UURIFactory. */ - public static final String REQUEST_RESOLUTION_TWO_MONTHS = "twomonths"; +// public static final String REQUEST_URL_CLEANED = "cleanedurl"; + /** - * Request: month resolution (TimeLine mode) + * GUARANTEED PRESENT: omit results after this 14-digit String timestamp. + * Possibly created from: + * 1) specified directly in request + * 2) a partial REQUEST_DATE (latest possible given a prefix) + * 3) RequestParser default + * 4) 14-digit representation of the moment the request was recieved. */ - public static final String REQUEST_RESOLUTION_MONTHS = "months"; + public static final String REQUEST_END_DATE = "enddate"; + /** - * Request: day resolution (TimeLine mode) + * GUARANTEED PRESENT: omit results before this 14-digit String timestamp. + * Possibly created from: + * 1) specified directly in request + * 2) a partial REQUEST_DATE (earliest possible given a prefix) + * 3) RequestParser default + * 4) 14-digit representation of midnight Jan 1, 1996. */ - public static final String REQUEST_RESOLUTION_DAYS = "days"; + public static final String REQUEST_START_DATE = "startdate"; + /** - * Request: hour resolution (TimeLine mode) + * GUARANTEED PRESENT for Replay requests only, no meaning for Query + * requests. + * Original (RAW/possibly partial) 14-digit timestamp of date requested for + * Replay */ - public static final String REQUEST_RESOLUTION_HOURS = "hours"; + public static final String REQUEST_DATE = "date"; + /** - * Request: replay actual document or metadata for document: "yes" means - * replay metadata only, not the actual document: (TimeLine mode) + * GUARANTEED PRESENT for Replay requests only, no meaning for Query + * requests. + * Cleaned up version of original REQUEST_DATE, padded to 14 digits assuming + * the */ - public static final String REQUEST_META_MODE = "metamode"; + public static final String REQUEST_EXACT_DATE = "exactdate"; + /** - * Request: resolution of results to be displayed: (TimeLine mode) + * Indicates user only wants results that exactly match the hostname within + * REQUEST_URL -- no canonicalization. */ - public static final String REQUEST_RESOLUTION = "resolution"; + public static final String REQUEST_EXACT_HOST_ONLY = "requestexacthost"; + /** - * Request: closest type request + * indicates positive value for any request boolean flag. */ - public static final String REQUEST_CLOSEST_QUERY = "urlclosestquery"; + public static final String REQUEST_YES = "yes"; + /** - * Request: replay type request + * Replay-Only: indicates the date to tend towards when computing closest + * matches within time. Used to prevent "time drift" while surfing from a + * particular date. */ - public static final String REQUEST_REPLAY_QUERY = "replay"; + public final static String REQUEST_ANCHOR_DATE = "request.anchordate"; + /** - * Request: urlprefixquery type request + * Replay-Only: String representation of number of seconds. Used only in + * conjunction with REQUEST_ANCHOR_DATE, and indicates that documents more + * than this many seconds should not be shown in a replay session. Useful + * for QA purposes, to ensure that all content within a replay session was + * crawled near a particular point, the REQUEST_ANCHOR_DATE. */ - public static final String REQUEST_URL_PREFIX_QUERY = "urlprefixquery"; + public final static String REQUEST_ANCHOR_WINDOW = "request.anchorwindow"; + /* + * ****************** + * /URL/DATE CONSTANTS + * ****************** + */ + + + /* + * ******************************* + * OUTPUT TYPE CONSTANTS + * ******************************* + */ /** - * Request: urlquery type request + * Request: replay actual document or metadata for document: "yes" means + * replay metadata only, not the actual document: (TimeLine mode) */ - public static final String REQUEST_URL_QUERY = "urlquery"; + public static final String REQUEST_META_MODE = "metamode"; /** * Request: xml data requested */ public static final String REQUEST_XML_DATA = "xmldata"; + /* + * ******************************* + * /OUTPUT TYPE CONSTANTS + * ******************************* + */ + + /* + * ******************************* + * CONTEXT & ACCESSPOINT CONSTANTS + * ******************************* + */ /** - * Request: defines type - urlquery, urlprefixquery, or replay + * the string (webapp) context that received this request */ - public static final String REQUEST_TYPE = "type"; + public static final String REQUEST_WAYBACK_CONTEXT = "waybackcontext"; /** - * Request: URL of referrer, if supplied, or "" if not + * the port the remote user connected to for this request */ + public static final String REQUEST_WAYBACK_PORT = "waybackport"; + /* + * ******************************* + * /CONTEXT & ACCESSPOINT CONSTANTS + * ******************************* + */ + + /* + * ***************************** + * HTTP HEADER/REQUEST CONSTANTS + * ***************************** + */ + /** + * incoming requests HTTP "Host:" header, or null + */ + public static final String REQUEST_WAYBACK_HOSTNAME = "waybackhostname"; + /** + * incoming requests HTTP "Referer:" header, or null + */ public static final String REQUEST_REFERER_URL = "refererurl"; /** - * Request: Original URL or URL prefix requested. - * This version differs from @{link {@link REQUEST_URL} in that its - * the URL before it was passed via the UURIFactory cleanup. + * Remote Address that connected to this webapp to create the request + * string IP address: "127.0.0.1" */ - public static final String REQUEST_URL_CLEANED = "cleanedurl"; + public static final String REQUEST_REMOTE_ADDRESS = "remoteaddress"; /** - * Request: URL or URL prefix requested + * Remote User or null if the request did not contain auth info. + * see HttpServletRequest.getRemoteUser() */ - public static final String REQUEST_URL = "url"; + public static final String REQUEST_REMOTE_USER = "requestremoteuser"; + /** - * Request: (replay) find closest result to this 14-digit timestamp + * User Locale name: Best Guess at users requested locale. + * see ServletRequest.getLocale().getDisplayLanguage() */ - public static final String REQUEST_EXACT_DATE = "exactdate"; + public static final String REQUEST_LOCALE_LANG = "requestlocalelang"; /** - * Request: filter results after this 14-digit timestamp + * Authorization Type: "BASIC", "SSL", or null if none. + * see HttpServletRequest.getAuthType() */ - public static final String REQUEST_END_DATE = "enddate"; + public static final String REQUEST_AUTH_TYPE = "requestauthtype"; + /* + * *********************** + * /HTTP HEADER/REQUEST CONSTANTS + * *********************** + */ + + /* + * *********************** + * TIMELINE MODE CONSTANTS + * *********************** + */ /** - * Request: filter results before this 14-digit timestamp + * resolution of results to be displayed: (TimeLine mode) */ - public static final String REQUEST_START_DATE = "startdate"; + public static final String REQUEST_RESOLUTION = "resolution"; /** - * Request: (query) filter results to those prefixed with this (possibly - * partial) 14-digit timestamp + * auto resolution (TimeLine mode) */ - public static final String REQUEST_DATE = "date"; + public static final String REQUEST_RESOLUTION_AUTO = "auto"; /** - * Request: Remote User or "" if the request did not contain auth info. + * year resolution (TimeLine mode) */ - public static final String REQUEST_REMOTE_USER = "requestremoteuser"; + public static final String REQUEST_RESOLUTION_YEARS = "years"; /** - * Request: Best Guess at users requested locale. + * two-month resolution (TimeLine mode) */ - public static final String REQUEST_LOCALE_LANG = "requestlocalelang"; + public static final String REQUEST_RESOLUTION_TWO_MONTHS = "twomonths"; /** - * Request: Indicates user only wants results that exactly match the - * requested hostname -- no canonicalization. + * month resolution (TimeLine mode) */ - public static final String REQUEST_EXACT_HOST_ONLY = "requestexacthost"; + public static final String REQUEST_RESOLUTION_MONTHS = "months"; /** - * Request: indicates positive value for any request boolean flag. + * day resolution (TimeLine mode) */ - public static final String REQUEST_YES = "yes"; + public static final String REQUEST_RESOLUTION_DAYS = "days"; + /** + * hour resolution (TimeLine mode) + */ + public static final String REQUEST_RESOLUTION_HOURS = "hours"; + /* + * *********************** + * /TIMELINE MODE CONSTANTS + * *********************** + */ + private static String UI_RESOURCE_BUNDLE_NAME = "WaybackUI"; + /** + * set of filter keys that are not forwarded to subsequent paginated + * requests. + */ private final static String standardHeaders[] = { - WaybackRequest.REQUEST_REFERER_URL, - WaybackRequest.REQUEST_REMOTE_ADDRESS, - WaybackRequest.REQUEST_WAYBACK_HOSTNAME, - WaybackRequest.REQUEST_WAYBACK_PORT, - WaybackRequest.REQUEST_WAYBACK_CONTEXT, - WaybackRequest.REQUEST_AUTH_TYPE, - WaybackRequest.REQUEST_REMOTE_USER, - WaybackRequest.REQUEST_LOCALE_LANG }; + REQUEST_REFERER_URL, + REQUEST_REMOTE_ADDRESS, + REQUEST_WAYBACK_HOSTNAME, + REQUEST_WAYBACK_PORT, + REQUEST_WAYBACK_CONTEXT, + REQUEST_AUTH_TYPE, + REQUEST_REMOTE_USER, + REQUEST_LOCALE_LANG }; /** - * Constructor, possibly/probably this should BE a Properties, instead of - * HAVEing a Properties... + * @return Returns the resultsPerPage. */ - public WaybackRequest() { - super(); + public int getResultsPerPage() { + return resultsPerPage; } /** - * @return true if REQUEST_TYPE is set, and is set to REQUEST_REPLAY_QUERY + * @param resultsPerPage + * The resultsPerPage to set. */ - public boolean isReplayRequest() { - String type = get(WaybackRequest.REQUEST_TYPE); - if(type != null && type.equals(WaybackRequest.REQUEST_REPLAY_QUERY)) { - return true; - } - return false; + public void setResultsPerPage(int resultsPerPage) { + this.resultsPerPage = resultsPerPage; } - /** - * @return true if true if REQUEST_TYPE is not set, or is set to a value - * other than REQUEST_REPLAY_QUERY - */ - public boolean isQueryRequest() { - return !isReplayRequest(); - } /** * @return Returns the pageNum. @@ -247,34 +375,82 @@ } /** - * @return Returns the resultsPerPage. + * @param prefix */ - public int getResultsPerPage() { - return resultsPerPage; + public void setContextPrefix(String prefix) { + contextPrefix = prefix; } /** - * @param resultsPerPage - * The resultsPerPage to set. + * 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. */ - public void setResultsPerPage(int resultsPerPage) { - this.resultsPerPage = resultsPerPage; + public String getContextPrefix() { + if(contextPrefix == null) { + return ""; + } + return contextPrefix; } /** - * @param key - * @return boolean, true if the request contains key 'key' + * @param prefix */ - public boolean containsKey(String key) { - return filters.containsKey(key); + public void setServerPrefix(String prefix) { + serverPrefix = prefix; } /** + * @param prefix + * @return an absolute String URL that will point to the root of the + * server that is handling the request. + */ + public String getServerPrefix() { + if(serverPrefix == null) { + return ""; + } + return serverPrefix; + } + /** + * @return the accessPoint + */ + public AccessPoint getAccessPoint() { + return accessPoint; + } + + /** + * @param accessPoint the accessPoint to set + */ + public void setAccessPoint(AccessPoint accessPoint) { + this.accessPoint = accessPoint; + } + + public ObjectFilter<CaptureSearchResult> getExclusionFilter() { + return exclusionFilter; + } + + public void setExclusionFilter(ObjectFilter<CaptureSearchResult> exclusionFilter) { + this.exclusionFilter = exclusionFilter; + } + + /** + * @return StringFormatter based on user request info + */ + public StringFormatter getFormatter() { + if(formatter == null) { + setLocale(Locale.getAvailableLocales()[0]); + } + return formatter; + } + + /** * @param key * @return String value for key 'key', or null if no value exists */ public String get(String key) { - return (String) filters.get(key); + return filters.get(key); } /** @@ -284,14 +460,238 @@ public void put(String key, String value) { filters.put(key, value); } + public void remove(String key) { + filters.remove(key); + } - private String emptyIfNull(String arg) { - if (arg == null) { - return ""; + private void setBoolean(String key, boolean value) { + if(value) { + put(key,REQUEST_YES); + } else { + remove(key); } - return arg; + } + private boolean getBoolean(String key) { + String value = get(key); + return(value == null || !value.equals(REQUEST_YES)); + } + /** + * @param key + * @return boolean, true if the request contains key 'key' + * @deprecated + */ + public boolean containsKey(String key) { + return filters.containsKey(key); } + + private void putUnlessNull(String key, String val) { + if (val != null) { + put(key,val); + } + } + + private boolean isRequestType(String requestType) { + String type = get(REQUEST_TYPE); + if(type != null && type.equals(requestType)) { + return true; + } + return false; + } + + /** + * @return true if this is a Replay request + */ + public boolean isReplayRequest() { + return isRequestType(REQUEST_REPLAY_QUERY); + } + /** + * marks this request as a Replay request + */ + public void setReplayRequest() { + put(REQUEST_TYPE,REQUEST_REPLAY_QUERY); + } + /** + * @return true if this is a Capture Query request + */ + public boolean isCaptureQueryRequest() { + return isRequestType(REQUEST_CAPTURE_QUERY); + } + /** + * marks this request as a Replay request + */ + public void setCaptureQueryRequest() { + put(REQUEST_TYPE,REQUEST_CAPTURE_QUERY); + } + /** + * @return true if this is an Url Query request + */ + public boolean isUrlQueryRequest() { + return isRequestType(REQUEST_URL_QUERY); + } + /** + * marks this request as a Replay request + */ + public void setUrlQueryRequest() { + put(REQUEST_TYPE,REQUEST_URL_QUERY); + } + + public String getRequestUrl() { + return get(REQUEST_URL); + } + /** + * Set the request URL. + * @param urlStr Request URL. + */ + public void setRequestUrl(String urlStr) { + // TODO: fix this to use other schemes + if (!urlStr.startsWith("http://")) { + if(urlStr.startsWith("http:/")) { + urlStr = "http://" + urlStr.substring(6); + } else { + urlStr = "http://" + urlStr; + } + } +// UURI requestURI = UURIFactory.getInstance(urlStr); +// put(REQUEST_URL_CLEANED, requestURI.toString()); + put(REQUEST_URL, urlStr); + } + public String getEndTimestamp() { + return get(REQUEST_END_DATE); + } + public Date getEndDate() { + return Timestamp.parseAfter(get(REQUEST_END_DATE)).getDate(); + } + public void setEndDate(Date date) { + put(REQUEST_END_DATE,new Timestamp(date).getDateStr()); + } + public void setEndTimestamp(String timestamp) { + put(REQUEST_END_DATE,timestamp); + } + + public String getStartTimestamp() { + return get(REQUEST_START_DATE); + } + public Date getStartDate() { + return Timestamp.parseBefore(get(REQUEST_START_DATE)).getDate(); + } + public void setStartDate(Date date) { + put(REQUEST_START_DATE,new Timestamp(date).getDateStr()); + } + public void setStartTimestamp(String timestamp) { + put(REQUEST_START_DATE,timestamp); + } + + public String getReplayTimestamp() { + return get(REQUEST_DATE); + } + public Date getReplayDate() { + return Timestamp.parseAfter(get(REQUEST_DATE)).getDate(); + } + public void setReplayDate(Date date) { + put(REQUEST_DATE,new Timestamp(date).getDateStr()); + } + public void setReplayTimestamp(String timestamp) { + put(REQUEST_DATE,timestamp); + } + + public void setExactHost(boolean isExactHost) { + setBoolean(REQUEST_EXACT_HOST_ONLY,isExactHost); + } + public boolean isExactHost() { + return getBoolean(REQUEST_EXACT_HOST_ONLY); + } + + public String getAnchorTimestamp() { + return get(REQUEST_ANCHOR_DATE); + } + public Date getAnchorDate() { + return Timestamp.parseAfter(get(REQUEST_ANCHOR_DATE)).getDate(); + } + public void setAnchorDate(Date date) { + put(REQUEST_ANCHOR_DATE,new Timestamp(date).getDateStr()); + } + public void setAnchorTimestamp(String timestamp) { + put(REQUEST_ANCHOR_DATE,timestamp); + } + + public long getAnchorWindow() { + String seconds = get(REQUEST_ANCHOR_WINDOW); + if(seconds == null) { + return 0; + } + return Long.parseLong(seconds); + } + public void setAnchorWindow(long seconds) { + put(REQUEST_ANCHOR_WINDOW,String.valueOf(seconds));; + } + + public void setMetaMode(boolean isMetaMode) { + setBoolean(REQUEST_META_MODE,isMetaMode); + } + public boolean isMetaMode() { + return getBoolean(REQUEST_META_MODE); + } + + public void setXMLMode(boolean isXMLMode) { + setBoolean(REQUEST_XML_DATA,isXMLMode); + } + public boolean isXMLMode() { + return getBoolean(REQUEST_XML_DATA); + } + + public String getWaybackContext() { + return get(REQUEST_WAYBACK_CONTEXT); + } + public int getWaybackPort() { + String port = get(REQUEST_WAYBACK_PORT); + if(port == null) { + return 0; + } + return Integer.parseInt(port); + } + + public String getWaybackHostname() { + return get(REQUEST_WAYBACK_HOSTNAME); + } + public String getRefererUrl() { + return get(REQUEST_REFERER_URL); + } + public String getRemoteIPAddress() { + return get(REQUEST_REMOTE_ADDRESS); + } + public String getRemoteUser() { + return get(REQUEST_REMOTE_USER); + } + public String getLocaleLanguage() { + return get(REQUEST_LOCALE_LANG); + } + public String getAuthType() { + return get(REQUEST_AUTH_TYPE); + } + + public String getTimelineResolution() { + return get(REQUEST_RESOLUTION); + } + public void setTimelineAutoResolution() { + put(REQUEST_RESOLUTION,REQUEST_RESOLUTION_AUTO); + } + public void setTimelineYearResolution() { + put(REQUEST_RESOLUTION,REQUEST_RESOLUTION_YEARS); + } + public void setTimelineTwoMonthResolution() { + put(REQUEST_RESOLUTION,REQUEST_RESOLUTION_TWO_MONTHS); + } + public void setTimelineMonthResolution() { + put(REQUEST_RESOLUTION,REQUEST_RESOLUTION_MONTHS); + } + public void setTimelineDayResolution() { + put(REQUEST_RESOLUTION,REQUEST_RESOLUTION_DAYS); + } + public void setTimelineHourResolution() { + put(REQUEST_RESOLUTION,REQUEST_RESOLUTION_HOURS); + } + /** * Set the Locale for the request, which impacts UI Strings * @param l @@ -301,14 +701,6 @@ formatter = new StringFormatter(b,l); } - private String getUserLocale(HttpServletRequest httpRequest) { - Locale l = httpRequest.getLocale(); - ResourceBundle b = ResourceBundle.getBundle(UI_RESOURCE_BUNDLE_NAME, - httpRequest.getLocale()); - formatter = new StringFormatter(b,l); - return emptyIfNull(httpRequest.getLocale().getDisplayLanguage()); - } - /** * extract REFERER, remote IP and authorization information from the * HttpServletRequest @@ -316,23 +708,22 @@ * @param httpRequest */ private void extractHttpRequestInfo(HttpServletRequest httpRequest) { - // attempt to get the HTTP referer if present.. - put(WaybackRequest.REQUEST_REFERER_URL, emptyIfNull(httpRequest - .getHeader("REFERER"))); - put(WaybackRequest.REQUEST_REMOTE_ADDRESS, emptyIfNull(httpRequest - .getRemoteAddr())); - put(WaybackRequest.REQUEST_WAYBACK_HOSTNAME, emptyIfNull(httpRequest - .getLocalName())); - put(WaybackRequest.REQUEST_WAYBACK_PORT, String.valueOf(httpRequest - .getLocalPort())); - put(WaybackRequest.REQUEST_WAYBACK_CONTEXT, emptyIfNull(httpRequest - .getContextPath())); - put(WaybackRequest.REQUEST_AUTH_TYPE, emptyIfNull(httpRequest - .getAuthType())); - put(WaybackRequest.REQUEST_REMOTE_USER, emptyIfNull(httpRequest - .getRemoteUser())); - put(WaybackRequest.REQUEST_LOCALE_LANG,getUserLocale(httpRequest)); + + putUnlessNull(REQUEST_REFERER_URL, httpRequest.getHeader("REFERER")); + putUnlessNull(REQUEST_REMOTE_ADDRESS, httpRequest.getRemoteAddr()); + putUnlessNull(REQUEST_WAYBACK_HOSTNAME, httpRequest.getLocalName()); + putUnlessNull(REQUEST_AUTH_TYPE, httpRequest.getAuthType()); + putUnlessNull(REQUEST_REMOTE_USER, httpRequest.getRemoteUser()); + putUnlessNull(REQUEST_WAYBACK_PORT, + String.valueOf(httpRequest.getLocalPort())); + putUnlessNull(REQUEST_WAYBACK_CONTEXT, httpRequest.getContextPath()); + Locale l = httpRequest.getLocale(); + ResourceBundle b = ResourceBundle.getBundle(UI_RESOURCE_BUNDLE_NAME, + httpRequest.getLocale()); + formatter = new StringFormatter(b,l); + putUnlessNull(REQUEST_LOCALE_LANG,l.getDisplayLanguage()); + Cookie[] cookies = httpRequest.getCookies(); if(cookies != null) { for(Cookie cookie : cookies) { @@ -342,46 +733,6 @@ } /** - * @param prefix - */ - public void setServerPrefix(String prefix) { - serverPrefix = prefix; - } - - /** - * @param prefix - * @return an absolute String URL that will point to the root of the - * server that is handling the request. - */ - public String getServerPrefix() { - if(serverPrefix == null) { - return ""; - } - return serverPrefix; - } - - - /** - * @param prefix - */ - public void setContextPrefix(String prefix) { - contextPrefix = prefix; - } - /** - * Construct an absolute URL that points to the root of the context that - * recieved the request, including a trailing "/". - * - * @return String absolute URL pointing to the Context root where the - * request was revieved. - */ - public String getContextPrefix() { - if(contextPrefix == null) { - return ""; - } - return contextPrefix; - } - - /** * attempt to fixup this WaybackRequest, mostly with respect to dates: if * only "date" was specified, infer start and end dates from it. Also grab * useful info from the HttpServletRequest, cookies, remote address, etc. @@ -390,32 +741,32 @@ */ public void fixup(HttpServletRequest httpRequest) { extractHttpRequestInfo(httpRequest); - String startDate = get(WaybackRequest.REQUEST_START_DATE); - String endDate = get(WaybackRequest.REQUEST_END_DATE); - String exactDate = get(WaybackRequest.REQUEST_EXACT_DATE); - String partialDate = get(WaybackRequest.REQUEST_DATE); + String startDate = get(REQUEST_START_DATE); + String endDate = get(REQUEST_END_DATE); + String exactDate = get(REQUEST_EXACT_DATE); + String partialDate = get(REQUEST_DATE); if (partialDate == null) { partialDate = ""; } if (startDate == null || startDate.length() == 0) { - put(WaybackRequest.REQUEST_START_DATE, Timestamp + put(REQUEST_START_DATE, Timestamp .padStartDateStr(partialDate)); } else if (startDate.length() < 14) { - put(WaybackRequest.REQUEST_START_DATE, Timestamp + put(REQUEST_START_DATE, Timestamp .padStartDateStr(startDate)); } if (endDate == null || endDate.length() == 0) { - put(WaybackRequest.REQUEST_END_DATE, Timestamp + put(REQUEST_END_DATE, Timestamp .padEndDateStr(partialDate)); } else if (endDate.length() < 14) { - put(WaybackRequest.REQUEST_END_DATE, Timestamp + put(REQUEST_END_DATE, Timestamp .padEndDateStr(endDate)); } if (exactDate == null || exactDate.length() == 0) { - put(WaybackRequest.REQUEST_EXACT_DATE, Timestamp + put(REQUEST_EXACT_DATE, Timestamp .padEndDateStr(partialDate)); } else if (exactDate.length() < 14) { - put(WaybackRequest.REQUEST_EXACT_DATE, Timestamp + put(REQUEST_EXACT_DATE, Timestamp .padEndDateStr(exactDate)); } } @@ -469,35 +820,6 @@ + OpenSearchRequestParser.START_PAGE + "=" + pageNum; } - /** - * Set the request URL. - * Also populates request url cleaned. - * @param urlStr Request URL. - * @throws URIException - */ - public void setRequestUrl(String urlStr) throws URIException { - if (!urlStr.startsWith("http://")) { - if(urlStr.startsWith("http:/")) { - urlStr = "http://" + urlStr.substring(6); - } else { - urlStr = "http://" + urlStr; - } - } - // If its not http, next line throws exception. TODO: Fix. - UURI requestURI = UURIFactory.getInstance(urlStr); - put(WaybackRequest.REQUEST_URL_CLEANED, requestURI.toString()); - put(WaybackRequest.REQUEST_URL, urlStr); - } - - /** - * @return StringFormatter based on user request info - */ - public StringFormatter getFormatter() { - if(formatter == null) { - setLocale(Locale.getAvailableLocales()[0]); - } - return formatter; - } public WaybackRequest clone() { WaybackRequest wbRequest = new WaybackRequest(); @@ -521,27 +843,10 @@ } /** - * @return the context + * + * @return + * @deprecated */ - public AccessPoint getContext() { - return context; - } - - /** - * @param context the context to set - */ - public void setContext(AccessPoint context) { - this.context = context; - } - - public ObjectFilter<CaptureSearchResult> getExclusionFilter() { - return exclusionFilter; - } - - public void setExclusionFilter(ObjectFilter<CaptureSearchResult> exclusionFilter) { - this.exclusionFilter = exclusionFilter; - } - public Set<String> keySet() { return filters.keySet(); } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/domainprefix/DomainPrefixReplayDispatcher.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/domainprefix/DomainPrefixReplayDispatcher.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/domainprefix/DomainPrefixReplayDispatcher.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -59,7 +59,7 @@ // if the result is not for the exact date requested, redirect to the // exact date. some capture dates are not 14 digits, only compare as // many digits as are in the result date: - String reqDateStr = wbRequest.get(WaybackRequest.REQUEST_EXACT_DATE); + String reqDateStr = wbRequest.getReplayTimestamp(); String resDateStr = result.getCaptureTimestamp(); if((resDateStr.length() > reqDateStr.length()) || !resDateStr.equals(reqDateStr.substring(0, resDateStr.length()))) { Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/domainprefix/DomainPrefixRequestParser.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/domainprefix/DomainPrefixRequestParser.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/domainprefix/DomainPrefixRequestParser.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -29,7 +29,6 @@ import javax.servlet.http.HttpServletRequest; -import org.apache.commons.httpclient.URIException; import org.archive.wayback.core.Timestamp; import org.archive.wayback.core.WaybackRequest; import org.archive.wayback.exception.BadQueryException; @@ -89,21 +88,19 @@ String requestUrl = getRequestString(host,httpRequest); - wbRequest.put(WaybackRequest.REQUEST_EXACT_DATE, dateStr); - wbRequest.put(WaybackRequest.REQUEST_TYPE, - WaybackRequest.REQUEST_REPLAY_QUERY); - try { - wbRequest.setRequestUrl(requestUrl); - } catch (URIException e) { - e.printStackTrace(); - wbRequest = null; - } + wbRequest.setReplayRequest(); + wbRequest.setReplayTimestamp(dateStr); + wbRequest.setRequestUrl(requestUrl); + } else { Matcher queryMatcher = QUERY_REGEX.matcher(prefix); if(queryMatcher != null && queryMatcher.matches()) { wbRequest = new WaybackRequest(); String dateStr = queryMatcher.group(1); String host = queryMatcher.group(2); + + String requestUrl = getRequestString(host,httpRequest); + String startDate; String endDate; if(dateStr.length() == 0) { @@ -113,20 +110,13 @@ startDate = Timestamp.parseBefore(dateStr).getDateStr(); endDate = Timestamp.parseAfter(dateStr).getDateStr(); } - wbRequest.put(WaybackRequest.REQUEST_START_DATE,startDate); - wbRequest.put(WaybackRequest.REQUEST_END_DATE,endDate); - wbRequest.put(WaybackRequest.REQUEST_TYPE, - WaybackRequest.REQUEST_URL_QUERY); - - String requestUrl = getRequestString(host,httpRequest); - - try { - wbRequest.setRequestUrl(requestUrl); - } catch (URIException e) { - e.printStackTrace(); - wbRequest = null; - } + wbRequest.setCaptureQueryRequest(); + wbRequest.setStartTimestamp(startDate); + wbRequest.setEndTimestamp(endDate); + wbRequest.setRequestUrl(requestUrl); } + // TODO: what if it doesn't match the QUERY_REGEX? + // throw a BadQueryException? } } } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/exception/BaseExceptionRenderer.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/exception/BaseExceptionRenderer.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/exception/BaseExceptionRenderer.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -68,13 +68,13 @@ if (wbRequest == null) { return false; } - String referer = wbRequest.get(WaybackRequest.REQUEST_REFERER_URL); + String referer = wbRequest.getRefererUrl(); return (referer != null && referer.length() > 0); } protected boolean requestIsImage(HttpServletRequest httpRequest, WaybackRequest wbRequest) { - String requestUrl = wbRequest.get(WaybackRequest.REQUEST_URL); + String requestUrl = wbRequest.getRequestUrl(); if (requestUrl == null) return false; Matcher matcher = IMAGE_REGEX.matcher(requestUrl); @@ -84,14 +84,14 @@ protected boolean requestIsJavascript(HttpServletRequest httpRequest, WaybackRequest wbRequest) { - String requestUrl = wbRequest.get(WaybackRequest.REQUEST_URL); + String requestUrl = wbRequest.getRequestUrl(); return (requestUrl != null) && requestUrl.endsWith(".js"); } protected boolean requestIsCSS(HttpServletRequest httpRequest, WaybackRequest wbRequest) { - String requestUrl = wbRequest.get(WaybackRequest.REQUEST_URL); + String requestUrl = wbRequest.getRequestUrl(); return (requestUrl != null) && requestUrl.endsWith(".css"); } @@ -101,9 +101,9 @@ // the "standard HTML" response handler: String jspPath = errorJsp; - if(wbRequest.isQueryRequest()) { + if(!wbRequest.isReplayRequest()) { - if(wbRequest.containsKey(WaybackRequest.REQUEST_XML_DATA)) { + if(wbRequest.isXMLMode()) { jspPath = xmlErrorJsp; } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/LiveWebCache.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/LiveWebCache.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/liveweb/LiveWebCache.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -80,10 +80,8 @@ boolean bUseOlder) throws URIException { WaybackRequest req = new WaybackRequest(); req.setRequestUrl(url.toString()); - req.put(WaybackRequest.REQUEST_TYPE, - WaybackRequest.REQUEST_CLOSEST_QUERY); - req.put(WaybackRequest.REQUEST_EXACT_DATE, - Timestamp.currentTimestamp().getDateStr()); + req.setReplayRequest(); + req.setReplayTimestamp(Timestamp.currentTimestamp().getDateStr()); Timestamp earliest = null; if(bUseOlder) { earliest = Timestamp.earliestTimestamp(); @@ -91,11 +89,10 @@ Date d = new Date(System.currentTimeMillis() - maxCacheMS); earliest = new Timestamp(d); } - req.put(WaybackRequest.REQUEST_START_DATE,earliest.getDateStr()); + req.setStartTimestamp(earliest.getDateStr()); // for now, assume all live web requests are only satisfiable by the // exact host -- no massaging. - req.put(WaybackRequest.REQUEST_EXACT_HOST_ONLY, - WaybackRequest.REQUEST_YES); + req.setExactHost(true); return req; } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/proxy/ProxyReplayRequestParser.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/proxy/ProxyReplayRequestParser.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/proxy/ProxyReplayRequestParser.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -28,7 +28,6 @@ import javax.servlet.http.HttpServletRequest; -import org.apache.commons.httpclient.URIException; import org.archive.util.InetAddressUtil; import org.archive.wayback.core.WaybackRequest; import org.archive.wayback.exception.BadQueryException; @@ -85,14 +84,8 @@ String requestUrl = requestScheme + "://" + requestServer + requestPath; wbRequest = new WaybackRequest(); - try { - wbRequest.setRequestUrl(requestUrl); - } catch (URIException e) { - e.printStackTrace(); - return null; - } - wbRequest.put(WaybackRequest.REQUEST_TYPE, - WaybackRequest.REQUEST_REPLAY_QUERY); + wbRequest.setRequestUrl(requestUrl); + wbRequest.setReplayRequest(); wbRequest.setResultsPerPage(maxRecords); return wbRequest; } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/proxy/ProxyRequestParser.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/proxy/ProxyRequestParser.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/proxy/ProxyRequestParser.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -70,8 +70,10 @@ String id = httpRequest.getHeader("Proxy-Id"); if (id == null) id = httpRequest.getRemoteAddr(); - wbRequest.put(WaybackRequest.REQUEST_EXACT_DATE, Timestamp - .getTimestampForId(httpRequest.getContextPath(), id)); + // TODO: This is hacky. + String replayDateStr = Timestamp.getTimestampForId( + httpRequest.getContextPath(), id); + wbRequest.setReplayTimestamp(replayDateStr); wbRequest.fixup(httpRequest); } return wbRequest; Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/query/Renderer.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/query/Renderer.java 2008-07-07 22:07:22 UTC (rev 2418) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/query/Renderer.java 2008-07-08 06:06:41 UTC (rev 2419) @@ -72,10 +72,10 @@ CaptureSearchResults results, ResultURIConverter uriConverter) throws ServletException, IOException { - UICaptureQueryResults uiResults = new UICaptureQueryResults(httpRequest, wbRequest, - results, uriConverter); + UICaptureQueryResults uiResults = new UICaptureQueryResults(httpRequest, + wbRequest, results, uriConverter); String jsp = captureJsp; - if(wbRequest.containsKey(WaybackRequest.REQUEST_XML_DATA)) { + if(wbRequest.isXMLMode()) { jsp = xmlCaptureJsp; } @@ -95,7 +95,7 @@ UIUrlQueryResults uiResults = new UIUrlQueryResults(httpRequest, wbRequest, results, uriConverter); String jsp = urlJsp; - if(wbRequest.containsKey(WaybackRequest.REQUEST_XML_DATA)) { + if(wbRequest.is... [truncated message content] |