//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) {
resultWriter = this.getCaptureSearchWriter(wbRequest, waybackAuthToken, true);
if (resultWriter != null) {
loadWaybackCdx(urlkey, wbRequest, resultWriter.getQuery(), waybackAuthToken, resultWriter, true);
searchResults = resultWriter.getSearchResults();
}
}
if (searchResults.getReturnedCount() == 0) {
throw new ResourceNotInArchiveException(wbRequest.getRequestUrl() + " was not found");
}
} catch (IOException e) {
throw new ResourceIndexNotAvailableException(e.toString());