Exemplo n.º 1
0
  public static List<BreadcrumbEntry> getPortletBreadcrumbEntries(HttpServletRequest request) {

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    String name = WebKeys.PORTLET_BREADCRUMBS;

    List<BreadcrumbEntry> breadcrumbEntries = (List<BreadcrumbEntry>) request.getAttribute(name);

    if (Validator.isNotNull(portletDisplay.getId())
        && !portletDisplay.isFocused()
        && !Validator.equals(
            portletDisplay.getId(),
            PortletProviderUtil.getPortletId(
                BreadcrumbEntry.class.getName(), PortletProvider.Action.VIEW))) {

      name = name.concat(StringPool.UNDERLINE.concat(portletDisplay.getId()));

      List<BreadcrumbEntry> portletBreadcrumbEntries =
          (List<BreadcrumbEntry>) request.getAttribute(name);

      if (portletBreadcrumbEntries != null) {
        breadcrumbEntries = portletBreadcrumbEntries;
      }
    }

    if (breadcrumbEntries == null) {
      return Collections.emptyList();
    }

    for (int i = 0; i < breadcrumbEntries.size() - 1; i++) {
      BreadcrumbEntry portletBreadcrumbEntry = breadcrumbEntries.get(i);

      String url = portletBreadcrumbEntry.getURL();

      if (Validator.isNotNull(url) && !CookieKeys.hasSessionId(request)) {
        HttpSession session = request.getSession();

        portletBreadcrumbEntry.setURL(PortalUtil.getURLWithSessionId(url, session.getId()));
      }
    }

    return breadcrumbEntries;
  }
Exemplo n.º 2
0
  private String _getURL(
      HttpServletRequest request, boolean resetMaxState, boolean resetRenderParameters)
      throws PortalException, SystemException {

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

    if (resetMaxState) {
      Layout layout = themeDisplay.getLayout();

      LayoutTypePortlet layoutTypePortlet = null;

      if (layout.equals(this)) {
        layoutTypePortlet = themeDisplay.getLayoutTypePortlet();
      } else {
        try {
          layoutTypePortlet = _getLayoutTypePortletClone(request);
        } catch (IOException ioe) {
          _log.error("Unable to clone layout settings", ioe);

          layoutTypePortlet = (LayoutTypePortlet) getLayoutType();
        }
      }

      if (layoutTypePortlet.hasStateMax()) {
        String portletId = StringUtil.split(layoutTypePortlet.getStateMax())[0];

        PortletURLImpl portletURLImpl =
            new PortletURLImpl(request, portletId, getPlid(), PortletRequest.ACTION_PHASE);

        try {
          portletURLImpl.setWindowState(WindowState.NORMAL);
          portletURLImpl.setPortletMode(PortletMode.VIEW);
        } catch (PortletException pe) {
          throw new SystemException(pe);
        }

        portletURLImpl.setAnchor(false);

        if (PropsValues.LAYOUT_DEFAULT_P_L_RESET && !resetRenderParameters) {

          portletURLImpl.setParameter("p_l_reset", "0");
        } else if (!PropsValues.LAYOUT_DEFAULT_P_L_RESET && resetRenderParameters) {

          portletURLImpl.setParameter("p_l_reset", "1");
        }

        return portletURLImpl.toString();
      }
    }

    String portalURL = PortalUtil.getPortalURL(request);

    String url = PortalUtil.getLayoutURL(this, themeDisplay);

    if (!CookieKeys.hasSessionId(request)
        && (url.startsWith(portalURL) || url.startsWith(StringPool.SLASH))) {

      url = PortalUtil.getURLWithSessionId(url, request.getSession().getId());
    }

    if (!resetMaxState) {
      return url;
    }

    if (PropsValues.LAYOUT_DEFAULT_P_L_RESET && !resetRenderParameters) {
      url = HttpUtil.addParameter(url, "p_l_reset", 0);
    } else if (!PropsValues.LAYOUT_DEFAULT_P_L_RESET && resetRenderParameters) {

      url = HttpUtil.addParameter(url, "p_l_reset", 1);
    }

    return url;
  }