コード例 #1
0
  protected void remoteProcessAction(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    OAuthRequest oAuthRequest = new OAuthRequest(Verb.POST, getServerPortletURL());

    setRequestParameters(actionRequest, actionResponse, oAuthRequest);

    addOAuthParameter(oAuthRequest, "p_p_lifecycle", "1");
    addOAuthParameter(oAuthRequest, "p_p_state", WindowState.NORMAL.toString());

    Response response = getResponse(themeDisplay.getUser(), oAuthRequest);

    if (response.getCode() == HttpServletResponse.SC_FOUND) {
      String redirectLocation = response.getHeader(HttpHeaders.LOCATION);

      actionResponse.sendRedirect(redirectLocation);
    } else {
      HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(actionResponse);

      httpServletResponse.setContentType(response.getHeader(HttpHeaders.CONTENT_TYPE));

      ServletResponseUtil.write(httpServletResponse, response.getStream());
    }
  }
コード例 #2
0
  @Override
  public void actionURL(long plid, String portletName, String queryString) throws Exception {

    String windowState = WindowState.NORMAL.toString();
    String portletMode = PortletMode.VIEW.toString();

    actionURL(windowState, portletMode, plid, portletName, queryString);
  }
コード例 #3
0
ファイル: MyPortlet.java プロジェクト: kidaak/jetexpress
  public void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {

    if (WindowState.MINIMIZED.equals(request.getWindowState())) {
      return;
    }

    if (WindowState.NORMAL.equals(request.getWindowState())) {
      normalView.include(request, response);
    } else {
      maximizedView.include(request, response);
    }
  }
コード例 #4
0
  @Override
  protected void writeAjaxPage(
      RenderRequest request, RenderResponse response, Window window, Application application)
      throws IOException, MalformedURLException, PortletException {
    MailApplication mailApplication = (MailApplication) application;

    // user is set in the portlet listener by the application
    if (mailApplication.getController().getUser() == null) {
      // normally, the portal takes care of this
      // this branch is in case the user has not been registered in the controller
      writeNotLoggedInPageHtml(request, response, window);
    } else if (PortletMode.VIEW.equals(request.getPortletMode())
        && WindowState.NORMAL.equals(request.getWindowState())) {
      mailApplication.writeViewPageHtml(request, response, window);
    } else {
      // this includes other modes as well as the maximized state
      super.writeAjaxPage(request, response, window, application);
    }
  }
コード例 #5
0
  public void getPrepackagedApps(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    OAuthRequest oAuthRequest = new OAuthRequest(Verb.POST, getServerPortletURL());

    setBaseRequestParameters(actionRequest, actionResponse, oAuthRequest);

    addOAuthParameter(oAuthRequest, "p_p_lifecycle", "1");
    addOAuthParameter(oAuthRequest, "p_p_state", WindowState.NORMAL.toString());

    String serverNamespace = getServerNamespace();

    addOAuthParameter(
        oAuthRequest,
        serverNamespace.concat("compatibility"),
        String.valueOf(ReleaseInfo.getBuildNumber()));
    addOAuthParameter(
        oAuthRequest, serverNamespace.concat("javax.portlet.action"), "getPrepackagedApps");

    Map<String, String> prepackagedApps = _appLocalService.getPrepackagedApps();

    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

    Set<String> keys = prepackagedApps.keySet();

    for (String key : keys) {
      jsonObject.put(key, prepackagedApps.get(key));
    }

    addOAuthParameter(
        oAuthRequest, serverNamespace.concat("prepackagedApps"), jsonObject.toString());

    Response response = getResponse(themeDisplay.getUser(), oAuthRequest);

    JSONObject responseJSONObject = JSONFactoryUtil.createJSONObject(response.getBody());

    writeJSON(actionRequest, actionResponse, responseJSONObject);
  }
コード例 #6
0
  public void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {

    long clock = System.currentTimeMillis();

    try {
      System.out.println("hi: " + clock);
      log.debug("Rendering view.");

      if (WindowState.MINIMIZED.equals(request.getWindowState())) {
        return;
      }

      if (WindowState.NORMAL.equals(request.getWindowState())) {
        normalView.include(request, response);
      } else {
        maximizedView.include(request, response);
      }
    } finally {
      long duration = System.currentTimeMillis() - clock;
      log.debug(String.format("View rendering took %s ms.", duration));
    }
  }