*/
public boolean handleRequest(HttpServletRequest httpRequest,
HttpServletResponse httpResponse)
throws ServletException, IOException {
WaybackRequest wbRequest = null;
boolean handled = false;
try {
PerfStats.clearAll();
if (this.isEnablePerfStatsHeader() && (perfStatsHeader != null)) {
PerfStats.timeStart(PerfStat.Total);
httpResponse = new PerfWritingHttpServletResponse(httpRequest, httpResponse, PerfStat.Total, perfStatsHeader);
}
String inputPath = translateRequestPathQuery(httpRequest);
Thread.currentThread().setName("Thread " +
Thread.currentThread().getId() + " " + getBeanName() +
" handling: " + inputPath);
LOGGER.fine("Handling translated: " + inputPath);
wbRequest = getParser().parse(httpRequest, this);
if (wbRequest != null) {
handled = true;
// TODO: refactor this code into RequestParser implementations
wbRequest.setAccessPoint(this);
// wbRequest.setContextPrefix(getAbsoluteLocalPrefix(httpRequest));
// wbRequest.setContextPrefix(getUrlRoot());
wbRequest.extractHttpRequestInfo(httpRequest);
// end of refactor
if(getAuthentication() != null) {
if(!getAuthentication().isTrue(wbRequest)) {
throw new AuthenticationControlException(
"Unauthorized", isRequestAuth());
}
}
if(getExclusionFactory() != null) {
ExclusionFilter exclusionFilter =
getExclusionFactory().get();
if(exclusionFilter == null) {
throw new AdministrativeAccessControlException(
"AccessControl list unavailable");
}
wbRequest.setExclusionFilter(exclusionFilter);
}
// TODO: refactor this into RequestParser implementations, so a
// user could alter requests to change the behavior within a
// single AccessPoint. For now, this is a simple way to expose
// the feature to configuration.g
wbRequest.setExactScheme(isExactSchemeMatch());
if(wbRequest.isReplayRequest()) {
if(bounceToReplayPrefix) {
// we don't accept replay requests on this AccessPoint
// bounce the user to the right place:
String suffix = translateRequestPathQuery(httpRequest);
String replayUrl = replayPrefix + suffix;
httpResponse.sendRedirect(replayUrl);
return true;
}
handleReplay(wbRequest,httpRequest,httpResponse);
} else {
if (bounceToQueryPrefix) {
// we don't accept replay requests on this AccessPoint
// bounce the user to the right place:
String suffix = translateRequestPathQuery(httpRequest);
String replayUrl = queryPrefix + suffix;
httpResponse.sendRedirect(replayUrl);
return true;
}
wbRequest.setExactHost(isExactHostMatch());
handleQuery(wbRequest,httpRequest,httpResponse);
}
} else {
handled = dispatchLocal(httpRequest,httpResponse);
}
} catch(BetterRequestException e) {
e.generateResponse(httpResponse, wbRequest);
httpResponse.getWriter(); // cause perf headers to be committed
handled = true;
} catch(WaybackException e) {
if (httpResponse.isCommitted()) {
return true;
}
if (wbRequest == null) {
wbRequest = new WaybackRequest();
wbRequest.setAccessPoint(this);
}
logError(httpResponse, errorMsgHeader, e, wbRequest);
LiveWebState liveWebState = LiveWebState.NOT_FOUND;
if ((getLiveWebRedirector() != null) &&
!wbRequest.hasMementoAcceptDatetime() && !wbRequest.isMementoTimemapRequest()) {
liveWebState = getLiveWebRedirector().handleRedirect(e, wbRequest, httpRequest, httpResponse);
}
// If not liveweb redirected, then render current exception
if (liveWebState != LiveWebState.REDIRECTED) {