}
try {
urlkey = canon.urlStringToKey(wbRequest.getRequestUrl());
} catch (URIException ue) {
throw new BadQueryException(ue.toString());
}
//Do local access/url validation check
//AuthToken waybackAuthToken = new AuthToken(wbRequest.get(CDXServer.CDX_AUTH_TOKEN));
AuthToken waybackAuthToken = createAuthToken(wbRequest, urlkey);
CDXToSearchResultWriter resultWriter = null;
SearchResults searchResults = null;
if (wbRequest.isReplayRequest() || wbRequest.isCaptureQueryRequest()) {
resultWriter = this.getCaptureSearchWriter(wbRequest, waybackAuthToken, false);
} else if (wbRequest.isUrlQueryRequest()) {
resultWriter = this.getUrlSearchWriter(wbRequest);
} else {
throw new BadQueryException("Unknown Query Type");
}
try {
loadWaybackCdx(urlkey, wbRequest, resultWriter.getQuery(), waybackAuthToken, resultWriter, false);
if (resultWriter.getErrorMsg() != null) {
throw new BadQueryException(resultWriter.getErrorMsg());
}
searchResults = resultWriter.getSearchResults();
if ((searchResults.getReturnedCount() == 0) && (wbRequest.isReplayRequest() || wbRequest.isCaptureQueryRequest()) && tryFuzzyMatch) {