org.archive.wayback.memento
Class TimeGateRequestParser

java.lang.Object
  extended by org.archive.wayback.requestparser.BaseRequestParser
      extended by org.archive.wayback.requestparser.WrappedRequestParser
          extended by org.archive.wayback.memento.TimeGateRequestParser
All Implemented Interfaces:
RequestParser

public class TimeGateRequestParser
extends WrappedRequestParser

RequestParser subclass which matches ".../timegate/URL" requests, and parses the Accept-Datetime header


Field Summary
 
Fields inherited from class org.archive.wayback.requestparser.BaseRequestParser
DEFAULT_MAX_RECORDS, QUERY_BASE, REPLAY_BASE, XQUERY_BASE
 
Constructor Summary
TimeGateRequestParser(BaseRequestParser wrapped)
           
 
Method Summary
 Date checkDateValidity(String httpdate, List<SimpleDateFormat> list)
          Attempt to parse the String httpdate argument using one of the SimpleDateFormats provided.
 String getHttpDate(javax.servlet.http.HttpServletRequest req)
          Extract the value of the "Accept-Datetime" HTTP request header, if present, and further strips the date value from any surrounding "{","}"
 WaybackRequest parse(javax.servlet.http.HttpServletRequest httpRequest, AccessPoint accessPoint)
          attempt to transform an incoming HttpServletRequest into a WaybackRequest object.
 
Methods inherited from class org.archive.wayback.requestparser.WrappedRequestParser
getEarliestTimestamp, getLatestTimestamp, getMaxRecords
 
Methods inherited from class org.archive.wayback.requestparser.BaseRequestParser
setEarliestTimestamp, setLatestTimestamp, setMaxRecords
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeGateRequestParser

public TimeGateRequestParser(BaseRequestParser wrapped)
Parameters:
wrapped - BaseRequestParser with configuration
Method Detail

parse

public WaybackRequest parse(javax.servlet.http.HttpServletRequest httpRequest,
                            AccessPoint accessPoint)
                     throws BadQueryException,
                            BetterRequestException
Description copied from interface: RequestParser
attempt to transform an incoming HttpServletRequest into a WaybackRequest object. returns null if there is missing information.

Specified by:
parse in interface RequestParser
Specified by:
parse in class BaseRequestParser
Parameters:
httpRequest - ServletHttpRequest being handled
accessPoint - AccessPoint which is attempting to parse the request
Returns:
populated WaybackRequest object if successful, null otherwise.
Throws:
BadQueryException - if the request could match this AccessPoint, but is malformed: invalid datespec, URL, or flags
BetterRequestException - if the request should be redirected to provide better user feedback (corrected URL/date in address bar)

getHttpDate

public String getHttpDate(javax.servlet.http.HttpServletRequest req)
Extract the value of the "Accept-Datetime" HTTP request header, if present, and further strips the date value from any surrounding "{","}"

Parameters:
req - HttpServletRequest for this request
Returns:
the raw String containing the date information, or null if no such HTTP header exists.

checkDateValidity

public Date checkDateValidity(String httpdate,
                              List<SimpleDateFormat> list)
Attempt to parse the String httpdate argument using one of the SimpleDateFormats provided.

Parameters:
httpdate - String version of a Date
list - of SimpleDateFormats to parse the httpdate
Returns:
Date object set to the time parsed, or null if not parsed


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