/**
   * @param request the request being processed
   * @param response the response to return
   * @param preferences the portlet preferences
   */
  @ActionMapping(params = Consts.ACTION_ENDDELEGATEMODE)
  public void doActionEndDelegationMode(
      ActionRequest request, ActionResponse response, PortletPreferences preferences, Model model)
      throws Exception {
    LogHelper log = new LogHelper(request);
    RequestMessages rqm = RequestMessages.getRequestMessages(request);
    PortletSession session = request.getPortletSession();
    try {
      log.startTimer("doActionEndDelegationMode");
      BannerPortletData data =
          (BannerPortletData)
              session.getAttribute("BannerPortletData", PortletSession.APPLICATION_SCOPE);
      if (data == null) {
        data = new BannerPortletData();
        data.loadFromRequest(request);
        data.loadFromPreferences(request, rqm);
      }
      // ProtectBlock actionEndDelegationModeBody
      logger.debug("In the doActionEndDelegationMode of ServiceCreditsDeleationView Controller ");
      log.startTimer("doActionEndDelegationMode");
      // logger.info("In the doActionEndDelegationMode,Sessin clean up triggred. "
      // +session.getAttributeMap(PortletSession.APPLICATION_SCOPE).keySet());
      logger.info(
          "Clearing all session attribute set by the ServiceCreditsDelegationView Controller : "
              + Consts.SESSION_SUBJECT_USER_MAP
              + " "
              + Consts.TEMP_SUBJECT_USER_MAP_KEY_IN_SESSION);
      session.removeAttribute(Consts.SESSION_SUBJECT_USER_MAP, PortletSession.APPLICATION_SCOPE);
      session.removeAttribute(
          Consts.TEMP_SUBJECT_USER_MAP_KEY_IN_SESSION, PortletSession.APPLICATION_SCOPE);

      // logger.info("In the doActionEndDelegationMode,Sessin clean up triggred. "
      // +session.getAttributeMap(PortletSession.APPLICATION_SCOPE).keySet());
      logger.debug("Setting the Session Cleanup flag to true");
      // request.setAttribute("spf.cleanupSession", true);
      logger.debug("Ending the Delegation session");
      logger.info("Sending redirect to ServiceCredits home page");
      PortalURL url = Utility.getServiceCreditsHomeUrl(request);
      url.setParameter("spf.cleanupSession", "true");
      response.sendRedirect(url.toString());
      logger.debug("End of doActionEndDelegationMode of ServiceCreditsDeleationView Controller ");
      // TODO Fill In Action Body
      // ProtectBlock End
      session.setAttribute("BannerPortletData", data, PortletSession.APPLICATION_SCOPE);
    } catch (Exception ex) {
      log.endTimer("doActionEndDelegationMode");
      throw ex;
    } finally {
      rqm.saveToRequest();
      session.setAttribute("ActionMode", "action", PortletSession.PORTLET_SCOPE);
      log.endTimer("doActionEndDelegationMode");
    }
  }
  // Process action is called for action URLs / form posts, etc
  // Process action is called once for each click - doView may be called many times
  // Hence an obsession in process action with putting things in session to
  // Send to the render process.
  public void processAction(ActionRequest request, ActionResponse response)
      throws PortletException, IOException {

    // System.out.println("==== processAction called ====");

    PortletSession pSession = request.getPortletSession(true);

    // Our first challenge is to figure out which action we want to take
    // The view selects the "next action" either as a URL parameter
    // or as a hidden field in the POST data - we check both

    String doCancel = request.getParameter("sakai.cancel");
    String doUpdate = request.getParameter("sakai.update");

    // Our next challenge is to pick which action the previous view
    // has told us to do.  Note that the view may place several actions
    // on the screen and the user may have an option to pick between
    // them.  Make sure we handle the "no action" fall-through.

    pSession.removeAttribute("error.message");

    if (doCancel != null) {
      response.setPortletMode(PortletMode.VIEW);
    } else if (doUpdate != null) {
      processActionEdit(request, response);
    } else {
      // System.out.println("Unknown action");
      response.setPortletMode(PortletMode.VIEW);
    }

    // System.out.println("==== End of ProcessAction  ====");
  }
 private void sendAlert(RenderRequest request, Context context) {
   PortletSession pSession = request.getPortletSession(true);
   String str = (String) pSession.getAttribute(ALERT_MESSAGE);
   pSession.removeAttribute(ALERT_MESSAGE);
   if (str != null && str.length() > 0)
     context.put("alertMessage", validator.escapeHtml(str, false));
 }
 public void removeAttribute(String string) {
   try {
     session.removeAttribute(string);
   } catch (IllegalStateException e) {
     throw new SessionExpiredException(e);
   }
 }
예제 #5
0
 /**
  * Set the session attribute with the given name to the given value in the given scope. Removes
  * the session attribute if value is {@code null}, if a session existed at all. Does not create a
  * new session if not necessary!
  *
  * @param request current portlet request
  * @param name the name of the session attribute
  * @param value the value of the session attribute
  * @param scope session scope of this attribute
  */
 public static void setSessionAttribute(
     PortletRequest request, String name, Object value, int scope) {
   Assert.notNull(request, "Request must not be null");
   if (value != null) {
     request.getPortletSession().setAttribute(name, value, scope);
   } else {
     PortletSession session = request.getPortletSession(false);
     if (session != null) {
       session.removeAttribute(name, scope);
     }
   }
 }
 /**
  * @see javax.servlet.http.HttpSession#removeValue(String)
  * @deprecated
  */
 @Override
 @Deprecated
 public void removeValue(final String arg0) {
   portletSession.removeAttribute(arg0);
 }
 /** @see javax.servlet.http.HttpSession#removeAttribute(String) */
 @Override
 public void removeAttribute(final String arg0) {
   portletSession.removeAttribute(arg0);
 }
예제 #8
0
 /*
  * (non-Javadoc)
  *
  * @see javax.servlet.http.HttpSession#removeAttribute(java.lang.String)
  */
 public void removeAttribute(String name) {
   portletSession.removeAttribute(name);
 }
  protected void initBridgeRequestScope(
      PortletRequest portletRequest,
      PortletResponse portletResponse,
      Bridge.PortletPhase portletPhase) {

    boolean bridgeRequestScopeEnabled = true;

    if (portletPhase == Bridge.PortletPhase.RESOURCE_PHASE) {
      bridgeRequestScopeEnabled =
          PortletConfigParam.BridgeRequestScopeAjaxEnabled.getBooleanValue(portletConfig);
    }

    if (bridgeRequestScopeEnabled) {

      // Determine if there is a bridge request scope "id" saved as a render parameter. Note that in
      // order to
      // avoid collisions with bridge request scopes for other portlets, the render parameter name
      // has to be
      // namespaced with the portlet name.
      String portletName = portletConfig.getPortletName();
      String bridgeRequestScopeKey = portletName + PARAM_BRIDGE_REQUEST_SCOPE_ID;

      // If there is a render parameter value found for the "id", then return the cached bridge
      // request scope
      // associated with the "id".
      String bridgeRequestScopeId = portletRequest.getParameter(bridgeRequestScopeKey);

      if (bridgeRequestScopeId != null) {

        bridgeRequestScope = bridgeRequestScopeCache.get(bridgeRequestScopeId);

        if (bridgeRequestScope != null) {
          logger.debug(
              "Found render parameter name=[{0}] value=[{1}] and cached bridgeRequestScope=[{2}]",
              bridgeRequestScopeKey, bridgeRequestScopeId, bridgeRequestScope);
        } else {

          if (bridgeRequestScopePreserved) {
            logger.error(
                "Found render parameter name=[{0}] value=[{1}] BUT bridgeRequestScope is NOT in the cache",
                bridgeRequestScopeKey, bridgeRequestScopeId);
          }
        }
      }

      // Otherwise, if there is a portlet session attribute found for the "id", then return the
      // cached bridge
      // request scope associated with the "id". Note: This occurs after an Ajax-based
      // ResourceRequest so that
      // non-excluded request attributes can be picked up by a subsequent RenderRequest.
      if (bridgeRequestScope == null) {

        // TCK TestPage071: nonFacesResourceTest
        // TCK TestPage073: scopeAfterRedisplayResourcePPRTest
        PortletSession portletSession = portletRequest.getPortletSession();
        bridgeRequestScopeId = (String) portletSession.getAttribute(bridgeRequestScopeKey);

        if (bridgeRequestScopeId != null) {

          portletSession.removeAttribute(bridgeRequestScopeKey);

          bridgeRequestScope = bridgeRequestScopeCache.get(bridgeRequestScopeId);

          if (bridgeRequestScope != null) {

            logger.debug(
                "Found (and removed) session-attribute name=[{0}] value=[{1}] and cached bridgeRequestScope=[{2}]",
                bridgeRequestScopeKey, bridgeRequestScopeId, bridgeRequestScope);

            if (portletResponse instanceof StateAwareResponse) {
              logger.debug(
                  "Setting former session-attribute as render parameter name=[{0}] value=[{1}]",
                  bridgeRequestScopeKey, bridgeRequestScopeId);

              StateAwareResponse stateAwareResponse = (StateAwareResponse) portletResponse;
              stateAwareResponse.setRenderParameter(bridgeRequestScopeKey, bridgeRequestScopeId);
            }
          } else {

            logger.error(
                "Found session attribute name=[{0}] value=[{1}] but bridgeRequestScope is not in the cache",
                bridgeRequestScopeKey, bridgeRequestScopeId);
          }
        }
      }

      // Otherwise, return a new factory created instance.
      if (bridgeRequestScope == null) {
        bridgeRequestScope =
            BridgeRequestScopeFactory.getBridgeRequestScopeInstance(
                portletRequest, portletConfig, bridgeConfig);
      }
    }
  }
  @Override
  public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {
    LOGGER.entering(LOG_CLASS, "main portlet render entry");

    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);

    PrintWriter writer = portletResp.getWriter();

    PortletSession ps = portletReq.getPortletSession();
    String msg =
        (String)
            ps.getAttribute(
                RESULT_ATTR_PREFIX + "DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse",
                APPLICATION_SCOPE);
    if (msg != null) {
      writer.write("<p>" + msg + "</p><br/>\n");
      ps.removeAttribute(
          RESULT_ATTR_PREFIX + "DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse",
          APPLICATION_SCOPE);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_containsHeader */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.containsHeader must return false"         */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_containsHeader", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeRedirectURL1 */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.encodeRedirectURL must return null"       */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeRedirectURL1",
              aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeRedirectUrl */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.encodeRedirectUrl must return null"       */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeRedirectUrl",
              aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeURL1 */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.encodeURL must provide the same           */
    /* functionality as ActionResponse.encodeURL"                           */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeURL1", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeUrl */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.encodeUrl must provide the same           */
    /* functionality as ActionResponse.encodeURL"                           */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeUrl", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getBufferSize */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.getBufferSize must return 0"              */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getBufferSize", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getCharacterEncoding */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.getCharacterEncoding must return null"    */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getCharacterEncoding",
              aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getContentType */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.getContentType must return null"          */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getContentType", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getLocale */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.getLocale must return null"               */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getLocale", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_isCommitted */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.isCommitted must return true"             */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_isCommitted", aurl);
      tb.writeTo(writer);
    }
  }
  /**
   * @param request the render request being processed
   * @param response the render response to be returned
   * @param preferences portlet preferences
   * @param model model for rendering
   * @return the view name or view content for the content
   * @throws any exceptions that occur
   */
  @RenderMapping
  public String doRenderDelegationDefaultView(
      RenderRequest request, RenderResponse response, PortletPreferences preferences, Model model)
      throws Exception {
    LogHelper log = new LogHelper(request);
    RequestMessages rqm = RequestMessages.getRequestMessages(request);
    String viewName = Consts.DELEGATEUSERACCESSTOSERVICECREDITSDELEGATIONDEFAULTVIEWVIEWNAME;
    try {
      log.startTimer("doRenderDelegationDefaultView");
      TTT t = new TTT();
      PortletSession session = request.getPortletSession();
      session.setAttribute("x", t);
      String test = (String) session.getAttribute("ActionMode", PortletSession.PORTLET_SCOPE);
      boolean action = (test != null && "action".equals(test));
      if (action) session.removeAttribute("ActionMode");
      model.addAttribute("Consts", new Consts());
      BannerPortletData data =
          (BannerPortletData)
              session.getAttribute("BannerPortletData", PortletSession.APPLICATION_SCOPE);
      if (data == null) {
        data = new BannerPortletData();
        data.loadFromRequest(request);
        data.loadFromPreferences(request, rqm);
      }
      // ProtectBlock renderDelegationDefaultViewBody
      // TODO Fill In Render Body
      logger.debug("In the default render method of the ServiceCrerditsDelegationView Controller");

      logger.info(
          "Logged in user id in default render method: "
              + Utility.isLoggedInUserInDelegateMode(request)
              + "--->>"
              + Utility.retrieveDelegateUserProfileMapFromRequest(request));
      logger.info(
          "Subject user id in default render method: "
              + Utility.isLoggedInUserInDelegateMode(request)
              + "===>>"
              + Utility.retrieveUserId(request)
              + Utility.retrieveUserEmail(request));
      // logger.info("In the doRenderDefault,Sessin clean up triggred in previous action method. "
      // +session.getAttributeMap(PortletSession.APPLICATION_SCOPE).keySet());
      viewName = "FindCustomerUser";
      if (session.getAttribute("showOverlayFlag", PortletSession.APPLICATION_SCOPE) != null) {
        boolean showOverlayFlag =
            (Boolean) session.getAttribute("showOverlayFlag", PortletSession.APPLICATION_SCOPE);
        if (showOverlayFlag) {
          model.addAttribute("display_modal_overlay", "true");
          session.removeAttribute("showOverlayFlag", PortletSession.APPLICATION_SCOPE);
        }
      } else {
        model.addAttribute("display_modal_overlay", "false");
      }
      if (Utility.isLoggedInUserInDelegateMode(request)) {
        logger.debug(
            "Changing view to DelegationView as the Delegate has still not signed out of the delegation mode");
        logger.info(
            "Changing view to DelegationView as the Delegate has still not signed out of the delegation mode");
        // ExternalUserProfile userProfile =
        // (ExternalUserProfile)session.getAttribute(Consts.TEMP_SUBJECT_USER_MAP_KEY_IN_SESSION,
        // PortletSession.APPLICATION_SCOPE);
        Map<String, Object> userProfile =
            (Map<String, Object>)
                session.getAttribute(
                    Consts.SESSION_SUBJECT_USER_MAP, PortletSession.APPLICATION_SCOPE);

        if (userProfile == null) {
          logger.info("The user profile returned in the Do-render-Delegate view was null");
          viewName = "FindCustomerUser";
          return viewName;
        } else {
          logger.debug(
              "Adding a few attribute fo the subject user in to the model like the name,company name and email-id");
          logger.info(
              "Setting the attribute of the subject user to model :"
                  + (String) userProfile.get(Consts.KEY_FIRST_NAME)
                  + " "
                  + (String) userProfile.get(Consts.KEY_LAST_NAME));
          model.addAttribute("company_Name", (String) userProfile.get("Company"));
          model.addAttribute("user_ID", (String) userProfile.get(Consts.KEY_USER_NAME));
          model.addAttribute("last_Name", (String) userProfile.get(Consts.KEY_LAST_NAME));
          model.addAttribute("first_Name", (String) userProfile.get(Consts.KEY_FIRST_NAME));
          model.addAttribute("email_Address", (String) userProfile.get(Consts.KEY_EMAIL));
        }
        viewName = "DelegationView";
      }
      logger.debug("End of default render method of the ServiceCrerditsDelegationView Controller");
      // ProtectBlock End
      data.saveToModel(model, rqm);
      session.setAttribute("BannerPortletData", data, PortletSession.APPLICATION_SCOPE);
    } catch (Exception ex) {
      log.endTimer("doRenderDelegationDefaultView");
      throw ex;
    } finally {
      rqm.release();
      log.endTimer("doRenderDelegationDefaultView");
    }
    return viewName;
  }
  /**
   * @param request the request being processed
   * @param response the response to return
   * @param preferences the portlet preferences
   */
  @ActionMapping(params = Consts.ACTION_BEGINDELEGATIONMODE)
  public void doActionBeginDelegationMode(
      ActionRequest request, ActionResponse response, PortletPreferences preferences, Model model)
      throws Exception {
    LogHelper log = new LogHelper(request);
    RequestMessages rqm = RequestMessages.getRequestMessages(request);
    PortletSession session = request.getPortletSession();
    try {
      log.startTimer("doActionBeginDelegationMode");
      BannerPortletData data =
          (BannerPortletData)
              session.getAttribute("BannerPortletData", PortletSession.APPLICATION_SCOPE);
      if (data == null) {
        data = new BannerPortletData();
        data.loadFromRequest(request);
        data.loadFromPreferences(request, rqm);
      }
      // ProtectBlock actionBeginDelegationModeBody
      logger.debug("In the doActionBeginDelegationMode of ServiceCreditsDelegationView Controller");
      logger.info("Constructing the Subject user map from the ExternalUserProfile");
      Map<String, Object> subjectUserProfile =
          Utility.constructSubjectUserMap(
              (ExternalUserProfile)
                  session.getAttribute(
                      Consts.TEMP_SUBJECT_USER_MAP_KEY_IN_SESSION,
                      PortletSession.APPLICATION_SCOPE),
              request);

      logger.info(
          "Setting the constructed Subject user in to session under the name SPF_RETAIN_SESSION_SUBJECT_USER_MAP");
      session.setAttribute(
          Consts.SESSION_SUBJECT_USER_MAP, subjectUserProfile, PortletSession.APPLICATION_SCOPE);
      session.removeAttribute(
          Consts.TEMP_SUBJECT_USER_MAP_KEY_IN_SESSION, PortletSession.APPLICATION_SCOPE);
      logger.info(
          "The constructed Subject user "
              + session.getAttribute(
                  Consts.SESSION_SUBJECT_USER_MAP, PortletSession.APPLICATION_SCOPE));
      logger.info("Setting the Session cleanup attribute to true in the request");
      // request.setAttribute("spf.cleanupSession", true);
      // logger.info("In the doActionBeginDelegationMode,Sessin clean up triggred. "
      // +session.getAttributeMap(PortletSession.APPLICATION_SCOPE).keySet());
      PortalURL url = Utility.getServiceCreditsHomeUrl(request);
      if (session.getAttribute(Consts.SESSION_SUBJECT_USER_MAP, PortletSession.APPLICATION_SCOPE)
          != null) {
        url.setParameter("delegateuseraccesstoservicecredits1", "action", "delegationView");
        url.setParameter("spf.cleanupSession", "true");
      }
      logger.info("Redirecting to Service Credirs Home page");
      logger.debug("The deleagtion session has now begun");
      response.sendRedirect(url.toString());
      logger.debug("End of doActionBeginDelegationMode of ServiceCreditsDelegationView Controller");
      // TODO Fill In Action Body
      // ProtectBlock End
      session.setAttribute("BannerPortletData", data, PortletSession.APPLICATION_SCOPE);
    } catch (Exception ex) {
      log.endTimer("doActionBeginDelegationMode");
      throw ex;
    } finally {
      rqm.saveToRequest();
      session.setAttribute("ActionMode", "action", PortletSession.PORTLET_SCOPE);
      log.endTimer("doActionBeginDelegationMode");
    }
  }
  /**
   * @param request the render request being processed
   * @param response the render response to be returned
   * @param preferences portlet preferences
   * @param model model for rendering
   * @return the view name or view content for the content
   * @throws any exceptions that occur
   */
  @RenderMapping(params = Consts.ACTION_SEARCHRESULTVIEW)
  public String doRenderSearchResultView(
      RenderRequest request, RenderResponse response, PortletPreferences preferences, Model model)
      throws Exception {
    LogHelper log = new LogHelper(request);
    RequestMessages rqm = RequestMessages.getRequestMessages(request);
    String viewName = Consts.DELEGATEUSERACCESSTOSERVICECREDITSSEARCHRESULTVIEWVIEWNAME;
    try {
      log.startTimer("doRenderSearchResultView");
      PortletSession session = request.getPortletSession();
      String test = (String) session.getAttribute("ActionMode", PortletSession.PORTLET_SCOPE);
      boolean action = (test != null && "action".equals(test));
      if (action) session.removeAttribute("ActionMode");
      model.addAttribute("Consts", new Consts());
      BannerPortletData data =
          (BannerPortletData)
              session.getAttribute("BannerPortletData", PortletSession.APPLICATION_SCOPE);
      if (data == null) {
        data = new BannerPortletData();
        data.loadFromRequest(request);
        data.loadFromPreferences(request, rqm);
      }
      // ProtectBlock renderSearchResultViewBody
      logger.debug("In the render result view of the ServiceCreditsDelegationView Controller");
      logger.debug("setting modal overlay display flag to true");

      // logger.info("In the doRenderSearchResult,Sessin clean up triggred in previous action
      // method. " +session.getAttributeMap(PortletSession.APPLICATION_SCOPE).keySet());
      if (session.getAttribute("showOverlayFlag", PortletSession.APPLICATION_SCOPE) != null) {
        boolean showOverlayFlag =
            (Boolean) session.getAttribute("showOverlayFlag", PortletSession.APPLICATION_SCOPE);
        if (showOverlayFlag) {
          model.addAttribute("display_modal_overlay", "true");
          session.removeAttribute("showOverlayFlag", PortletSession.APPLICATION_SCOPE);
        }
      } else {
        model.addAttribute("display_modal_overlay", "false");
      }
      logger.debug("Setting the attribute of the subject user to model");
      ExternalUserProfile user_profile =
          (ExternalUserProfile)
              session.getAttribute(
                  Consts.TEMP_SUBJECT_USER_MAP_KEY_IN_SESSION, PortletSession.APPLICATION_SCOPE);
      model.addAttribute("company_Name", user_profile.getBusCompanyName());
      model.addAttribute("user_ID", user_profile.getHppUserId());
      model.addAttribute("last_Name", user_profile.getFamilyName());
      model.addAttribute("first_Name", user_profile.getGivenName());
      model.addAttribute("email_Address", user_profile.getEmail());
      viewName = "FindCustomerUser";
      logger.debug("End of render result view of ServiceCreditsDelegationView Controller");
      // TODO Fill In Render Body
      // ProtectBlock End
      data.saveToModel(model, rqm);
      session.setAttribute("BannerPortletData", data, PortletSession.APPLICATION_SCOPE);
    } catch (Exception ex) {
      log.endTimer("doRenderSearchResultView");
      throw ex;
    } finally {
      rqm.release();
      log.endTimer("doRenderSearchResultView");
    }
    return viewName;
  }
예제 #14
0
	/**
	 * Processes the actual dispatching to the handler for render requests.
	 * <p>The handler will be obtained by applying the portlet's HandlerMappings in order.
	 * The HandlerAdapter will be obtained by querying the portlet's installed
	 * HandlerAdapters to find the first that supports the handler class.
	 * @param request current portlet render request
	 * @param response current portlet render response
	 * @throws Exception in case of any kind of processing failure
	 */
	@Override
	protected void doRenderService(RenderRequest request, RenderResponse response) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("DispatcherPortlet with name '" + getPortletName() + "' received render request");
		}

		HandlerExecutionChain mappedHandler = null;
		int interceptorIndex = -1;

		try {
			ModelAndView mv;
			try {
				// Determine handler for the current request.
				mappedHandler = getHandler(request);
				if (mappedHandler == null || mappedHandler.getHandler() == null) {
					noHandlerFound(request, response);
					return;
				}

				// Apply preHandle methods of registered interceptors.
				HandlerInterceptor[] interceptors = mappedHandler.getInterceptors();
				if (interceptors != null) {
					for (int i = 0; i < interceptors.length; i++) {
						HandlerInterceptor interceptor = interceptors[i];
						if (!interceptor.preHandleRender(request, response, mappedHandler.getHandler())) {
							triggerAfterRenderCompletion(mappedHandler, interceptorIndex, request, response, null);
							return;
						}
						interceptorIndex = i;
					}
				}

				// Check for forwarded exception from the action phase
				PortletSession session = request.getPortletSession(false);
				if (session != null) {
					if (request.getParameter(ACTION_EXCEPTION_RENDER_PARAMETER) != null) {
						Exception ex = (Exception) session.getAttribute(ACTION_EXCEPTION_SESSION_ATTRIBUTE);
						if (ex != null) {
							logger.debug("Render phase found exception caught during action phase - rethrowing it");
							throw ex;
						}
					}
					else {
						session.removeAttribute(ACTION_EXCEPTION_SESSION_ATTRIBUTE);
					}
				}

				// Actually invoke the handler.
				HandlerAdapter ha = getHandlerAdapter(mappedHandler.getHandler());
				mv = ha.handleRender(request, response, mappedHandler.getHandler());

				// Apply postHandle methods of registered interceptors.
				if (interceptors != null) {
					for (int i = interceptors.length - 1; i >= 0; i--) {
						HandlerInterceptor interceptor = interceptors[i];
						interceptor.postHandleRender(request, response, mappedHandler.getHandler(), mv);
					}
				}
			}
			catch (ModelAndViewDefiningException ex) {
				logger.debug("ModelAndViewDefiningException encountered", ex);
				mv = ex.getModelAndView();
			}
			catch (Exception ex) {
				Object handler = (mappedHandler != null ? mappedHandler.getHandler() : null);
				mv = processHandlerException(request, response, handler, ex);
			}

			// Did the handler return a view to render?
			if (mv != null && !mv.isEmpty()) {
				render(mv, request, response);
			}
			else {
				if (logger.isDebugEnabled()) {
					logger.debug("Null ModelAndView returned to DispatcherPortlet with name '" +
							getPortletName() + "': assuming HandlerAdapter completed request handling");
				}
			}

			// Trigger after-completion for successful outcome.
			triggerAfterRenderCompletion(mappedHandler, interceptorIndex, request, response, null);
		}

		catch (Exception ex) {
			// Trigger after-completion for thrown exception.
			triggerAfterRenderCompletion(mappedHandler, interceptorIndex, request, response, ex);
			throw ex;
		}
		catch (Error err) {
			PortletException ex =
					new PortletException("Error occured during request processing: " + err.getMessage(), err);
			// Trigger after-completion for thrown exception.
			triggerAfterRenderCompletion(mappedHandler, interceptorIndex, request, response, ex);
			throw ex;
		}
	}