+ "], and request path [" + originRequestPath + "]");
String redirectFlagValue = request.getParameter(REDIRECT_FLAG);
if (redirectFlagValue != null && !redirectFlagValue.isEmpty()) {
SiteKey redirectSiteKey = new SiteKey(originSite.getType(), redirectFlagValue);
RedirectKey redirectKey = RedirectKey.redirect(redirectSiteKey.getName());
return performRedirect(originSite, redirectKey, originRequestPath, context, true);
}
String referer = request.getHeader("Referer");
String siteURL = request.getRequestURL().substring(0,
request.getRequestURL().length() - request.getServletPath().length());
if (referer != null && referer.startsWith(siteURL)
&& (context.getRequest().getSession(true).getAttribute(DEVICE_DETECTION_ATTEMPTED) == null)) {
return false;
}
RedirectKey redirectSite = getRedirect(originSite, request, context);
if (redirectSite != null) {
// a redirect has already been set, use it
// do the redirect
return performRedirect(originSite, redirectSite, originRequestPath, context, false);
} else {
// no redirect set yet, we need to check if a redirect is requested or not
Map<String, String> deviceProperties = null;
String userAgentString = request.getHeader("User-Agent");
log.debug("Found user-agent string : " + userAgentString);
// we only care if this exists or not, no need to set it to anything other than Object
Object attemptedDeviceDetection = context.getRequest().getSession(true).getAttribute(DEVICE_DETECTION_ATTEMPTED);
if (attemptedDeviceDetection != null) {
deviceProperties = getDeviceProperties(request);
context.getRequest().getSession().removeAttribute(DEVICE_DETECTION_ATTEMPTED);
log.debug("Found device properties : " + deviceProperties);
}
redirectSite = deviceRedirectionService.getRedirectSite(originSite.getName(), userAgentString, deviceProperties);
if (redirectSite == null || redirectSite.getType() == RedirectType.NOREDIRECT) {
log.debug("Redirect returned is null or NO_REDIRECT_DETECTED. Setting NO_REDIRECT for this user");
setRedirect(originSite, RedirectKey.noRedirect(), request, response, context);
return false;
} else if (redirectSite.getType() == RedirectType.NEEDDEVICEINFO) {
if (attemptedDeviceDetection == null) {
log.debug("Need browser properties detection. Redirecting to BrowserDetectionPage : "
+ browserDetectionPath);
request.getSession().setAttribute(DEVICE_DETECTION_ATTEMPTED, true);
performRedirectToDeviceDetector(request, response);