@ Override public LiveWebState handleRedirect ( WaybackException e , WaybackRequest wbRequest , HttpServletRequest httpRequest , HttpServletResponse httpResponse ) throws IOException { if ( statusLiveWebPolicy == null ) { return LiveWebState . NOT_FOUND ; } // Don't do any redirect for identity context or if no handler is set if ( ( wbRequest == null ) || wbRequest . isIdentityContext ( ) || ( liveWebHandler == null ) ) { return LiveWebState . NOT_FOUND ; } int status = e . getStatus ( ) ; String stateName = statusLiveWebPolicy . getProperty ( String . valueOf ( status ) ) ; if ( stateName == null ) { stateName = statusLiveWebPolicy . getProperty ( DEFAULT ) ; } RedirectType state = RedirectType . ALL ; if ( stateName != null ) { state = RedirectType . valueOf ( stateName ) ; } String redirUrl = null ; if ( state == RedirectType . NONE ) { return LiveWebState . NOT_FOUND ; } // If embeds_only and not embed return if it was found if ( state == RedirectType . EMBEDS_ONLY ) { // boolean allowRedirect = wbRequest.isAnyEmbeddedContext(); // if (!allowRedirect) { // String referrer = wbRequest.getRefererUrl(); // String replayPrefix = wbRequest.getAccessPoint().getReplayPrefix(); // // if ((referrer != null) && (replayPrefix != null) && referrer.startsWith(replayPrefix)) { // allowRedirect = true; // } // } if ( ! wbRequest . isAnyEmbeddedContext ( ) ) { return LiveWebState . FOUND ; } // if (!wbRequest.isAnyEmbeddedContext()) { // redirUrl = wbRequest.getRequestUrl(); // } } // Now try to do a redirect redirUrl = liveWebHandler . getLiveWebRedirect ( httpRequest , wbRequest , e ) ; // Don't redirect if redirUrl null if ( redirUrl == null ) { return LiveWebState . NOT_FOUND ; } // If set to DEFAULT then compute the standard redir url if ( redirUrl . equals ( DEFAULT ) ) { redirUrl = getLiveWebPrefix ( ) + wbRequest . getRequestUrl ( ) ; } httpResponse . sendRedirect ( redirUrl ) ; return LiveWebState . REDIRECTED ; }
Check the statusLiveWebType to see if given the WaybackExceptions status code should redirect ALL NONE or EMBEDS_ONLY