}
private void handleReplay(WaybackRequest wbRequest,
HttpServletRequest httpRequest, HttpServletResponse httpResponse)
throws IOException, ServletException {
Resource resource = null;
try {
SearchResults results = collection.getResourceIndex().query(wbRequest);
if(!(results instanceof CaptureSearchResults)) {
throw new ResourceNotAvailableException("Bad results...");
}
CaptureSearchResults captureResults = (CaptureSearchResults) results;
// TODO: check which versions are actually accessible right now?
SearchResult closest = captureResults.getClosest(wbRequest);
resource = collection.getResourceStore().retrieveResource(closest);
replay.renderResource(httpRequest, httpResponse, wbRequest,
closest, resource, uriConverter, captureResults);
} catch(WaybackException e) {
logNotInArchive(e,wbRequest);
replay.renderException(httpRequest, httpResponse, wbRequest, e);
} finally {
if(resource != null) {
resource.close();
}
}
}