Package org.gatein.web.redirect.api

Examples of org.gatein.web.redirect.api.RedirectKey


        }

        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)) {
            if (debug) {
                log.debug("Redirect being requested with a referer from the portal site. Do not attempt redirect and follow link. Referer : " + referer);
            }
            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");
            if (debug) {
                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);
                if (debug) {
                    log.debug("Found device properties : " + deviceProperties);
                }
            }

            redirectSite = deviceRedirectionService.getRedirectSite(originSite.getName(), userAgentString, deviceProperties);

            if (redirectSite == null || redirectSite.getType() == RedirectType.NOREDIRECT) {
                if (debug) {
                    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) {
                    if (debug) {
                        log.debug("Need browser properties detection. Redirecting to BrowserDetectionPage : "
                                + browserDetectionPath);
                    }
View Full Code Here


                + "], 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);
View Full Code Here

TOP

Related Classes of org.gatein.web.redirect.api.RedirectKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.