コード例 #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
  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);
  }