protected void forwardLayout(HttpServletRequest request) throws Exception {
    Layout layout = (Layout) request.getAttribute(WebKeys.LAYOUT);

    long plid = LayoutConstants.DEFAULT_PLID;

    String layoutFriendlyURL = null;

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

    if (layout != null) {
      plid = layout.getPlid();

      layoutFriendlyURL = PortalUtil.getLayoutFriendlyURL(layout, themeDisplay);
    }

    String forwardURL = layoutFriendlyURL;

    if (Validator.isNull(forwardURL)) {
      forwardURL = themeDisplay.getPathMain() + "/portal/layout?p_l_id=" + plid;
    }

    if (Validator.isNotNull(themeDisplay.getDoAsUserId())) {
      forwardURL = HttpUtil.addParameter(forwardURL, "doAsUserId", themeDisplay.getDoAsUserId());
    }

    if (Validator.isNotNull(themeDisplay.getDoAsUserLanguageId())) {
      forwardURL =
          HttpUtil.addParameter(
              forwardURL, "doAsUserLanguageId", themeDisplay.getDoAsUserLanguageId());
    }

    if (_log.isDebugEnabled()) {
      _log.debug("Forward layout to " + forwardURL);
    }

    request.setAttribute(WebKeys.FORWARD_URL, forwardURL);
  }
Beispiel #2
0
  public static String getRefreshURL(HttpServletRequest request, ThemeDisplay themeDisplay) {

    StringBundler sb = new StringBundler(32);

    sb.append(themeDisplay.getPathMain());
    sb.append("/portal/render_portlet?p_l_id=");

    long plid = themeDisplay.getPlid();

    sb.append(plid);

    Portlet portlet = (Portlet) request.getAttribute(WebKeys.RENDER_PORTLET);

    String portletId = portlet.getPortletId();

    sb.append("&p_p_id=");
    sb.append(portletId);

    sb.append("&p_p_lifecycle=0&p_t_lifecycle=");
    sb.append(themeDisplay.getLifecycle());

    WindowState windowState = WindowState.NORMAL;

    if (themeDisplay.isStatePopUp()) {
      windowState = LiferayWindowState.POP_UP;
    } else {
      LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet();

      if (layoutTypePortlet.hasStateMaxPortletId(portletId)) {
        windowState = WindowState.MAXIMIZED;
      } else if (layoutTypePortlet.hasStateMinPortletId(portletId)) {
        windowState = WindowState.MINIMIZED;
      }
    }

    sb.append("&p_p_state=");
    sb.append(windowState);

    sb.append("&p_p_mode=view&p_p_col_id=");

    String columnId = (String) request.getAttribute(WebKeys.RENDER_PORTLET_COLUMN_ID);

    sb.append(columnId);

    Integer columnPos = (Integer) request.getAttribute(WebKeys.RENDER_PORTLET_COLUMN_POS);

    sb.append("&p_p_col_pos=");
    sb.append(columnPos);

    Integer columnCount = (Integer) request.getAttribute(WebKeys.RENDER_PORTLET_COLUMN_COUNT);

    sb.append("&p_p_col_count=");
    sb.append(columnCount);

    if (portlet.isStatic()) {
      sb.append("&p_p_static=1");

      if (portlet.isStaticStart()) {
        sb.append("&p_p_static_start=1");
      }
    }

    sb.append("&p_p_isolated=1");

    String doAsUserId = themeDisplay.getDoAsUserId();

    if (Validator.isNotNull(doAsUserId)) {
      sb.append("&doAsUserId=");
      sb.append(HttpUtil.encodeURL(doAsUserId));
    }

    String currentURL = PortalUtil.getCurrentURL(request);

    sb.append("&currentURL=");
    sb.append(HttpUtil.encodeURL(currentURL));

    String ppid = ParamUtil.getString(request, "p_p_id");

    if (ppid.equals(portletId)) {
      String namespace = PortalUtil.getPortletNamespace(portletId);

      Map<String, String[]> parameters = request.getParameterMap();

      for (Map.Entry<String, String[]> entry : parameters.entrySet()) {
        String name = entry.getKey();

        if (!PortalUtil.isReservedParameter(name)
            && !name.equals("currentURL")
            && !isRefreshURLReservedParameter(name, namespace)) {

          String[] values = entry.getValue();

          for (int i = 0; i < values.length; i++) {
            sb.append(StringPool.AMPERSAND);
            sb.append(name);
            sb.append(StringPool.EQUAL);
            sb.append(HttpUtil.encodeURL(values[i]));
          }
        }
      }
    }

    String outerPortletId = PortalUtil.getOuterPortletId(request);

    if (outerPortletId != null) {
      sb.append(StringPool.AMPERSAND);
      sb.append("p_o_p_id");
      sb.append(StringPool.EQUAL);
      sb.append(HttpUtil.encodeURL(outerPortletId));
    }

    return sb.toString();
  }