From: Brad <bra...@us...> - 2005-10-20 00:40:56
|
Update of /cvsroot/archive-access/archive-access/projects/wayback/src/java/org/archive/wayback/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12804/src/java/org/archive/wayback/core Modified Files: Timestamp.java WMRequest.java Log Message: Major UI Overhaul: Moved templates up to top of webapp Created css, images directories, moved relevant files into them UI-Header.txt => UI-Header.jsp (now uses ContextPath) UI-Footer.txt => UI-Footer.jsp (now uses ContextPath) added requestform.jsp pages for ReplayUI and QueryUI ReplayUI servlet url .../retrieve => .../replay Form in header of all Query/Error pages now works WMRequest Parsing: WMRequest now can parse Replay or Query requests with arguments encoded as CGI parameters. If the filter did not already parse the request, then an attemp is made with the WMRequest CGI parameter parsing... This allows for direct CGI GET requests to the individual servlets, making the requestform.jsp FORMs possible. Timestamp: added static method to construct a "current" Timestamp. Index: Timestamp.java =================================================================== RCS file: /cvsroot/archive-access/archive-access/projects/wayback/src/java/org/archive/wayback/core/Timestamp.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Timestamp.java 19 Oct 2005 01:22:36 -0000 1.2 --- Timestamp.java 20 Oct 2005 00:40:41 -0000 1.3 *************** *** 86,89 **** --- 86,101 ---- /** + * @return Timestamp object representing the current date. + * @throws ParseException + */ + public static Timestamp currentTimestamp() throws ParseException { + Timestamp ts = new Timestamp(); + ts.date = new Date(); + ts.dateStr = ArchiveUtils.get14DigitDate(ts.date); + return ts; + } + + + /** * @return Timestamp object representing the earliest possible date. * @throws ParseException *************** *** 100,106 **** */ public static Timestamp latestTimestamp() throws ParseException { ! Timestamp ts = new Timestamp(); ! ts.setDateStr(LAST2_TIMESTAMP); ! return ts; } --- 112,119 ---- */ public static Timestamp latestTimestamp() throws ParseException { ! return currentTimestamp(); ! // Timestamp ts = new Timestamp(); ! // ts.setDateStr(LAST2_TIMESTAMP); ! // return ts; } Index: WMRequest.java =================================================================== RCS file: /cvsroot/archive-access/archive-access/projects/wayback/src/java/org/archive/wayback/core/WMRequest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WMRequest.java 19 Oct 2005 01:22:36 -0000 1.2 --- WMRequest.java 20 Oct 2005 00:40:41 -0000 1.3 *************** *** 24,30 **** --- 24,33 ---- package org.archive.wayback.core; + import java.text.ParseException; + import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; + import org.apache.commons.httpclient.URIException; import org.archive.net.UURI; *************** *** 236,240 **** --- 239,378 ---- return retrieval; } + private String getMapParam(Map queryMap,String field) { + String arr[] = (String[]) queryMap.get(field); + if(arr == null || arr.length == 0) { + return null; + } + return arr[0]; + } + + /** + * @param queryMap + * @throws ParseException + * @throws URIException + * @throws IllegalArgumentException + */ + public void parseCGIArgsReplay(Map queryMap) + throws ParseException, URIException, IllegalArgumentException { + + String requestType = getMapParam(queryMap,"type"); + String requestURIStr = getMapParam(queryMap,"url"); + if(requestType == null) { + throw new IllegalArgumentException("No type argument"); + } + if(requestURIStr == null) { + throw new IllegalArgumentException("No url argument"); + } + + if(!requestType.equals("replay")) { + throw new IllegalArgumentException("request type must be 'replay' for this URL"); + } + parseCGIArgsDates(queryMap); + if (!requestURIStr.startsWith("http://")) { + requestURIStr = "http://" + requestURIStr; + } + requestURI = new UURI(requestURIStr,false); + setRetrieval(); + } + + /** + * @param queryMap + * @throws ParseException + * @throws URIException + * @throws IllegalArgumentException + */ + public void parseCGIArgsQuery(Map queryMap) + throws ParseException, URIException, IllegalArgumentException { + + String requestType = getMapParam(queryMap,"type"); + String requestURIStr = getMapParam(queryMap,"url"); + if(requestType == null) { + throw new IllegalArgumentException("No type argument"); + } + if(requestURIStr == null) { + throw new IllegalArgumentException("No url argument"); + } + + if(requestType.equals("query")) { + setQuery(); + } else if(requestType.equals("pathQuery")) { + setPathQuery(); + } else { + throw new IllegalArgumentException("request type must be 'replay' for this URL"); + } + parseCGIArgsDates(queryMap); + if (!requestURIStr.startsWith("http://")) { + requestURIStr = "http://" + requestURIStr; + } + + requestURI = new UURI(requestURIStr,false); + } + + /** + * @param queryMap + * @throws ParseException + */ + public void parseCGIArgsDates(Map queryMap) throws ParseException { + // first the exact: + String origExactDateRequest = getMapParam(queryMap,"date"); + if(origExactDateRequest == null) { + + exactTimestamp = Timestamp.currentTimestamp(); + exactDateRequest = exactTimestamp.getDateStr(); + + } else { + + exactTimestamp = Timestamp.parseBefore(origExactDateRequest); + exactDateRequest = origExactDateRequest; + } + + // then the starting boundary: + String startTimestampStr = getMapParam(queryMap,"earliest"); + if(startTimestampStr == null) { + // no start specified -- if the exact is not specified, assume + // the earliest possible: + if(origExactDateRequest == null) { + startTimestamp = Timestamp.earliestTimestamp(); + } else { + // no start specified, but they asked for an exact date. + // if the exact date was partial, use the earliest possible + // of the partial: + + if(origExactDateRequest.equals(exactTimestamp.getDateStr())) { + startTimestamp = Timestamp.earliestTimestamp(); + } else { + startTimestamp = Timestamp.parseBefore(exactDateRequest); + } + + } + } else { + startTimestamp = Timestamp.parseBefore(startTimestampStr); + } + + + // then the ending boundary: + String endTimestampStr = getMapParam(queryMap,"latest"); + if(endTimestampStr == null) { + // no end specified -- if the exact is not specified, assume + // the latest possible: + if(origExactDateRequest == null) { + endTimestamp = Timestamp.latestTimestamp(); + } else { + // no end specified, but they asked for an exact date. + // if the exact date was partial, use the latest possible + // of the partial: + + if(origExactDateRequest.equals(exactTimestamp.getDateStr())) { + endTimestamp = Timestamp.latestTimestamp(); + } else { + endTimestamp = Timestamp.parseAfter(exactDateRequest); + } + } + } else { + endTimestamp = Timestamp.parseAfter(endTimestampStr); + } + } + /** * @param args |