當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewSessionPolicy.isRenderTimeoutView方法代碼示例

本文整理匯總了Java中org.kuali.rice.krad.uif.view.ViewSessionPolicy.isRenderTimeoutView方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewSessionPolicy.isRenderTimeoutView方法的具體用法?Java ViewSessionPolicy.isRenderTimeoutView怎麽用?Java ViewSessionPolicy.isRenderTimeoutView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.kuali.rice.krad.uif.view.ViewSessionPolicy的用法示例。


在下文中一共展示了ViewSessionPolicy.isRenderTimeoutView方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRedirectUrl

import org.kuali.rice.krad.uif.view.ViewSessionPolicy; //導入方法依賴的package包/類
/**
 * Inspects the given view session policy to determine how the request should be redirected
 *
 * <p>
 * The request will either be redirected to the application home, a custom URL, the same request URL but
 * modified to call the <code>sessionTimeout</code> method, or a redirect to show the session timeout view
 * </p>
 *
 * @param sessionPolicy session policy instance to inspect
 * @param httpServletRequest request instance for pulling parameters
 * @return redirect URL or null if no redirect was configured
 */
protected String getRedirectUrl(ViewSessionPolicy sessionPolicy, HttpServletRequest httpServletRequest) {
    String redirectUrl = null;

    if (sessionPolicy.isRedirectToHome()) {
        redirectUrl = CoreApiServiceLocator.getKualiConfigurationService().getPropertyValueAsString(
                KRADConstants.APPLICATION_URL_KEY);
    } else if (StringUtils.isNotBlank(sessionPolicy.getRedirectUrl())) {
        redirectUrl = sessionPolicy.getRedirectUrl();
    } else if (sessionPolicy.isRenderTimeoutView()) {
        String kradUrl = CoreApiServiceLocator.getKualiConfigurationService().getPropertyValueAsString(
                KRADConstants.KRAD_URL_KEY);
        redirectUrl = KRADUtils.buildViewUrl(kradUrl, KRADConstants.REQUEST_MAPPING_SESSION_TIMEOUT,
                KRADConstants.SESSION_TIMEOUT_VIEW_ID);
    }

    return redirectUrl;
}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:30,代碼來源:UifSessionTimeoutFilter.java

示例2: doFilter

import org.kuali.rice.krad.uif.view.ViewSessionPolicy; //導入方法依賴的package包/類
/**
 * Checks for a session timeout and if one has occurred pulls the view session policy to determine whether
 * a redirect needs to happen
 *
 * <p>
 * To determine whether a session timeout has occurred, the filter looks for the existence of a request parameter
 * named {@link org.kuali.rice.krad.uif.UifParameters#SESSION_ID}. If found it then compares that id to the id
 * on the current session. If they are different, or a session does not currently exist a timeout is assumed.
 *
 * In addition, if a request was made for a form key and the view has session storage enabled, a check is made
 * to verify the form manager contains a session form. If not this is treated like a session timeout
 * </p>
 *
 * <p>
 * If a timeout has occurred an attempt is made to resolve a view from the request (based on the view id or
 * type parameters), then the associated {@link ViewSessionPolicy} is pulled which indicates how the timeout should
 * be handled. This either results in doing a redirect or nothing
 * </p>
 *
 * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse,
 *      javax.servlet.FilterChain)
 */
public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain filerChain) throws IOException, ServletException {
    HttpServletRequest httpServletRequest = (HttpServletRequest) request;
    HttpSession httpSession = (httpServletRequest).getSession(false);

    boolean timeoutOccurred = false;

    // compare session id in request to id on current session, if different or a session does not exist
    // then assume a session timeout has occurred
    if (request.getParameter(UifParameters.SESSION_ID) != null) {
        String requestedSessionId = request.getParameter(UifParameters.SESSION_ID);

        if ((httpSession == null) || !StringUtils.equals(httpSession.getId(), requestedSessionId)) {
            timeoutOccurred = true;
        }
    }

    String viewId = getViewIdFromRequest(httpServletRequest);
    if (StringUtils.isBlank(viewId)) {
        //  can't retrieve a session policy if view id was not passed
        filerChain.doFilter(request, response);

        return;
    }

    // check for requested form key for a POST and if found and session storage is enabled for the
    // view, verify the form is present in the form manager
    boolean isGetRequest = RequestMethod.GET.name().equals(httpServletRequest.getMethod());

    String formKeyParam = request.getParameter(UifParameters.FORM_KEY);
    if (StringUtils.isNotBlank(formKeyParam) && !isGetRequest && getViewDictionaryService().isSessionStorageEnabled(
            viewId) && (httpSession != null)) {
        UifFormManager uifFormManager = (UifFormManager) httpSession.getAttribute(UifParameters.FORM_MANAGER);

        // if session form not found, treat like a session timeout
        if ((uifFormManager != null) && !uifFormManager.hasSessionForm(formKeyParam)) {
            timeoutOccurred = true;
        }
    }

    // if no timeout occurred continue filter chain
    if (!timeoutOccurred) {
        filerChain.doFilter(request, response);

        return;
    }

    // retrieve timeout policy associated with the view to determine what steps to take
    ViewSessionPolicy sessionPolicy = getViewDictionaryService().getViewSessionPolicy(viewId);

    if (sessionPolicy.isRedirectToHome() || StringUtils.isNotBlank(sessionPolicy.getRedirectUrl()) || sessionPolicy
            .isRenderTimeoutView()) {
        String redirectUrl = getRedirectUrl(sessionPolicy, httpServletRequest);

        sendRedirect(httpServletRequest, (HttpServletResponse) response, redirectUrl);
    }
}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:80,代碼來源:UifSessionTimeoutFilter.java

示例3: doFilter

import org.kuali.rice.krad.uif.view.ViewSessionPolicy; //導入方法依賴的package包/類
/**
 * Checks for a session timeout and if one has occurred pulls the view session policy to determine whether
 * a redirect needs to happen
 *
 * <p>
 * To determine whether a session timeout has occurred, the filter looks for the existence of a request parameter
 * named {@link org.kuali.rice.krad.uif.UifParameters#SESSION_ID}. If found it then compares that id to the id
 * on the current session. If they are different, or a session does not currently exist a timeout is assumed.
 *
 * In addition, if a request was made for a form key and the view has session storage enabled, a check is made
 * to verify the form manager contains a session form. If not this is treated like a session timeout
 * </p>
 *
 * <p>
 * If a timeout has occurred an attempt is made to resolve a view from the request (based on the view id or
 * type parameters), then the associated {@link ViewSessionPolicy} is pulled which indicates how the timeout should
 * be handled. This either results in doing a redirect or nothing
 * </p>
 *
 * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse,
 *      javax.servlet.FilterChain)
 */
public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain filerChain) throws IOException, ServletException {
    HttpServletRequest httpServletRequest = (HttpServletRequest) request;
    HttpSession httpSession = (httpServletRequest).getSession(false);

    boolean timeoutOccurred = false;

    // compare session id in request to id on current session, if different or a session does not exist
    // then assume a session timeout has occurred
    if (request.getParameter(UifParameters.SESSION_ID) != null) {
        String requestedSessionId = request.getParameter(UifParameters.SESSION_ID);

        if ((httpSession == null) || !StringUtils.equals(httpSession.getId(), requestedSessionId)) {
            timeoutOccurred = true;
        }
    }

    String viewId = UifControllerHelper.getViewIdFromRequest(httpServletRequest);
    if (StringUtils.isBlank(viewId)) {
        //  can't retrieve a session policy if view id was not passed
        filerChain.doFilter(request, response);

        return;
    }

    // check for requested form key for a POST and if found and session storage is enabled for the
    // view, verify the form is present in the form manager
    boolean isGetRequest = RequestMethod.GET.name().equals(httpServletRequest.getMethod());

    String formKeyParam = request.getParameter(UifParameters.FORM_KEY);
    if (StringUtils.isNotBlank(formKeyParam) && !isGetRequest && getViewDictionaryService().isSessionStorageEnabled(
            viewId) && (httpSession != null)) {
        UifFormManager uifFormManager = (UifFormManager) httpSession.getAttribute(UifParameters.FORM_MANAGER);

        // if session form not found, treat like a session timeout
        if ((uifFormManager != null) && !uifFormManager.hasSessionForm(formKeyParam)) {
            timeoutOccurred = true;
        }
    }

    // if no timeout occurred continue filter chain
    if (!timeoutOccurred) {
        filerChain.doFilter(request, response);

        return;
    }

    // retrieve timeout policy associated with the view to determine what steps to take
    ViewSessionPolicy sessionPolicy = getViewDictionaryService().getViewSessionPolicy(viewId);

    if (sessionPolicy.isRedirectToHome() || StringUtils.isNotBlank(sessionPolicy.getRedirectUrl()) || sessionPolicy
            .isRenderTimeoutView()) {
        String redirectUrl = getRedirectUrl(sessionPolicy, httpServletRequest);

        sendRedirect(httpServletRequest, (HttpServletResponse) response, redirectUrl);
    }
}
 
開發者ID:aapotts,項目名稱:kuali_rice,代碼行數:80,代碼來源:UifSessionTimeoutFilter.java


注:本文中的org.kuali.rice.krad.uif.view.ViewSessionPolicy.isRenderTimeoutView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。