Pluto
  1. Pluto
  2. PLUTO-517

PortletWindowConfig#createPortletId generates troublesome id with leading slash

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.0
    • Component/s: portal driver
    • Labels:
      None

      Description

      PortletWindowConfig#createPortletId uses the context as the beginning of the ID, but leaves the leading slash on if it exists. This is troublesome for parsing to resultant portlet id from urls (for example with Wicket portlet support). The reason to avoid '/' in the portlet id is so that you can discover the portlet id, by simply looking between two slashes.
      I propose the following:

              String trimContextPath = null;
      		if (contextPath.startsWith("/"))
      		{
      			trimContextPath = contextPath.substring(1);
      		}
      		else
      		{
      			trimContextPath = contextPath;
      		}
      		return trimContextPath + "." + portletName + "!" + metaInfo;
      

      Is the a reason why the leading slash should be kept for portlet ids?

      After further investigation, this doesn't seem to be where the portlet id is actually generated.
      However, it does seem to do. I'm afraid of the inconsistencies this change may introduce though.

      However, there seems to be a circular sort of dependency (which is why i thought it wasn't generated there), as some code relies on being able to extract the context path from the portal ID, so I also added this:

      PortletWindowConfig#parseContextPath:
      public static String parseContextPath(String portletId) {
      int index = getSeparatorIndex(portletId);
      String context = portletId.substring(0, index);
      if (!context.startsWith("/"))

      { context = "/" + context; }

      return context;
      }

      this makes sure that the context path always starts with a / as is required by the servlet context look-up functions.

      So to sum it up, this removes the / from the beginning of the portlet id, so the wicket portal urls end up looking like:
      http://localhost:8080/non-gizmo-wicket-portlet/wicket/ps:non-gizmo-wicket-portlet.HelloWorld-PotletName!-649619114|0/resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js
      instead of:
      http://localhost:8080/non-gizmo-wicket-portlet/wicket/ps:/non-gizmo-wicket-portlet.HelloWorld-PotletName!-649619114|0/resources/org.apache.wicket.ajax.WicketAjaxReference/wicket-ajax.js

      which appears to work with the current wicket/portal implementation, as it looks for the portlet id between the two /'s.

      nb of course that this may effect other portal web frameworks as well.

        Activity

        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12565331 ] jira [ 12585982 ]
        Mark Thomas made changes -
        Workflow jira [ 12444600 ] Default workflow, editable Closed status [ 12565331 ]
        Ate Douma made changes -
        Fix Version/s 2.0.0 [ 12312914 ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Ate Douma made changes -
        Field Original Value New Value
        Assignee Ate Douma [ adouma ]
        Antony Stubbs created issue -

          People

          • Assignee:
            Ate Douma
            Reporter:
            Antony Stubbs
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development