From: <bra...@us...> - 2008-11-07 22:29:48
|
Revision: 2635 http://archive-access.svn.sourceforge.net/archive-access/?rev=2635&view=rev Author: bradtofel Date: 2008-11-07 22:29:45 +0000 (Fri, 07 Nov 2008) Log Message: ----------- FEATURE: now supports more schemes within setRequestUrl() - any defined within org.archive.wayback.util.url.UrlOperations FEATURE: now supports boolean exactScheme flag to indicate that user wishes only to match records with the same scheme as the requestUrl TWEAK: removed some code that had been commented out and is no longer used/needed. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackRequest.java 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-11-07 02:11:09 UTC (rev 2634) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackRequest.java 2008-11-07 22:29:45 UTC (rev 2635) @@ -39,6 +39,7 @@ import org.archive.wayback.util.ObjectFilter; import org.archive.wayback.util.StringFormatter; import org.archive.wayback.util.Timestamp; +import org.archive.wayback.util.url.UrlOperations; import org.archive.wayback.webapp.AccessPoint; /** @@ -186,6 +187,12 @@ public static final String REQUEST_EXACT_HOST_ONLY = "requestexacthost"; /** + * Indicates user only wants results that were captured using the same + * scheme as that specified in REQUEST_URL. + */ + public static final String REQUEST_EXACT_SCHEME_ONLY = "requestexactscheme"; + + /** * indicates positive value for any request boolean flag. */ public static final String REQUEST_YES = "yes"; @@ -556,16 +563,27 @@ * @param urlStr Request URL. */ public void setRequestUrl(String urlStr) { - // TODO: fix this to use other schemes - if (!urlStr.startsWith("http://")) { + + // This looks a little confusing: We're trying to fixup an incoming + // request URL that starts with: + // "http:/www.archive.org" + // so it becomes: + // "http://www.archive.org" + // (note the missing second "/" in the first) + // + // if that is not the case, then see if the incoming scheme + // is known, adding an implied "http://" scheme if there doesn't appear + // to be a scheme.. + // TODO: make the default "http://" configurable. + if (!urlStr.startsWith(UrlOperations.HTTP_SCHEME)) { if(urlStr.startsWith("http:/")) { - urlStr = "http://" + urlStr.substring(6); + urlStr = UrlOperations.HTTP_SCHEME + urlStr.substring(6); } else { - urlStr = "http://" + urlStr; + if(UrlOperations.urlToScheme(urlStr) == null) { + urlStr = UrlOperations.HTTP_SCHEME + urlStr; + } } } -// UURI requestURI = UURIFactory.getInstance(urlStr); -// put(REQUEST_URL_CLEANED, requestURI.toString()); put(REQUEST_URL, urlStr); } @@ -614,6 +632,13 @@ public boolean isExactHost() { return getBoolean(REQUEST_EXACT_HOST_ONLY); } + + public void setExactScheme(boolean isExactScheme) { + setBoolean(REQUEST_EXACT_SCHEME_ONLY,isExactScheme); + } + public boolean isExactScheme() { + return getBoolean(REQUEST_EXACT_SCHEME_ONLY); + } public String getAnchorTimestamp() { return get(REQUEST_ANCHOR_DATE); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |