Beispiel #1
0
  public static PortletURL getCurrent(PortletRequest portletRequest, MimeResponse mimeResponse) {

    PortletURL portletURL = mimeResponse.createRenderURL();

    Enumeration<String> enu = portletRequest.getParameterNames();

    while (enu.hasMoreElements()) {
      String param = enu.nextElement();
      String[] values = portletRequest.getParameterValues(param);

      boolean addParam = true;

      // Don't set paramter values that are over 32 kb. See LEP-1755.

      for (int i = 0; i < values.length; i++) {
        if (values[i].length() > _CURRENT_URL_PARAMETER_THRESHOLD) {
          addParam = false;

          break;
        }
      }

      if (addParam) {
        portletURL.setParameter(param, values);
      }
    }

    return portletURL;
  }
Beispiel #2
0
  public static PortletURL clone(
      LiferayPortletURL liferayPortletURL, String lifecycle, MimeResponse mimeResponse)
      throws PortletException {

    LiferayPortletURL newURLImpl = null;

    if (lifecycle.equals(PortletRequest.ACTION_PHASE)) {
      newURLImpl = (LiferayPortletURL) mimeResponse.createActionURL();
    } else if (lifecycle.equals(PortletRequest.RENDER_PHASE)) {
      newURLImpl = (LiferayPortletURL) mimeResponse.createRenderURL();
    }

    newURLImpl.setPortletId(liferayPortletURL.getPortletId());

    WindowState windowState = liferayPortletURL.getWindowState();

    if (windowState != null) {
      newURLImpl.setWindowState(windowState);
    }

    PortletMode portletMode = liferayPortletURL.getPortletMode();

    if (portletMode != null) {
      newURLImpl.setPortletMode(portletMode);
    }

    newURLImpl.setParameters(liferayPortletURL.getParameterMap());

    return newURLImpl;
  }