public boolean isInvalidParameter(String name) {
    if (Validator.isNull(name)
        || name.startsWith(PortletQName.PUBLIC_RENDER_PARAMETER_NAMESPACE)
        || name.startsWith(PortletQName.REMOVE_PUBLIC_RENDER_PARAMETER_NAMESPACE)
        || PortalUtil.isReservedParameter(name)) {

      return true;
    } else {
      return false;
    }
  }
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();
  }