Uploaded image for project: 'Jetspeed 2 (Retired)'
  1. Jetspeed 2 (Retired)
  2. JS2-266

The content search pathes of page omit portlet-decorator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0-M3
    • None
    • Aggregation
    • None
    • WinXP SP2, JDK1.4.2_07

    Description

      The following code is from class org.apache.jetspeed.aggregator.impl.PageAggregatorImpl.build()

      List contentPathes = (List) context.getSessionAttribute(ContentFilter.SESSION_CONTENT_PATH_ATTR);

      if (contentPathes == null)

      { contentPathes = new ArrayList(2); context.setSessionAttribute(ContentFilter.SESSION_CONTENT_PATH_ATTR, contentPathes); }
      String mediaType = context.getCapabilityMap().getPreferredMediaType().getName();
      if (contentPathes.size() < 1)
      {
      // define the lookup order

      contentPathes.add(root.getType() + "/" + mediaType + "/" + layoutDecorator);
      contentPathes.add(ContentFragment.PORTLET + "/" + mediaType + "/" + defaultPortletDecorator);
      Iterator defaults = fallBackContentPathes.iterator();
      while (defaults.hasNext())
      {
      String path = (String) defaults.next();
      contentPathes.add(path.replaceAll("
      {mediaType\\}", mediaType));
      }

      }
      else
      { contentPathes.set(0, root.getType() + "/" + mediaType + "/" + layoutDecorator); }

      According to the above code, the contentPathes which is stored in session, contains the current layout decorator path, fallBack ContentPathes which are specified in the jetspeed-spring.xml.

      But content pathes does not include current page's portlet-decorator. All the portlet level entities are from the path "portlet/{mediaType}/jetspeed" which is specified in jetspeed-spring.xml(the default portlet-decorator?). That will cause some mistakes if I don't want to include jetspeed portlet-decorator style.

      So I suggest:
      1. Remove the default portlet-decorator definition in jetspeed-spring.xml like the following:
      <!-- Aggregation: Page -->
      <bean id="org.apache.jetspeed.aggregator.PageAggregator"
      class="org.apache.jetspeed.aggregator.impl.PageAggregatorImpl" >
      <constructor-arg index="0" ><ref bean="org.apache.jetspeed.aggregator.PortletRenderer" /></constructor-arg>
      <!-- Aggregation Strategies:
      0 = PageAggregatorImpl.STRATEGY_SEQUENTIAL
      1 = PageAggregatorImpl.STRATEGY_PARALLEL
      -->
      <constructor-arg index="1"><value>0</value></constructor-arg>
      <constructor-arg index="2">
      <list>
      <!--<value>portlet/{mediaType}/jetspeed</value>-->
      <value>portlet/{mediaType}</value>
      <value>layout/{mediaType}</value>
      <value>generic/{mediaType}</value>
      <value>{mediaType}</value>
      </list>
      </constructor-arg>
      </bean>

      2. Change the following code org.apache.jetspeed.aggregator.impl.PageAggregatorImpl.build()

      public void build( RequestContext context ) throws JetspeedException, IOException
      {
      ContentPage page = context.getPage();
      if (null == page)
      { throw new JetspeedException("Failed to find PSML Pin ContentPageAggregator.build"); }

      ContentFragment root = page.getRootContentFragment();

      if (root == null)
      { throw new JetspeedException("No root ContentFragment found in ContentPage"); }

      String layoutDecorator = root.getDecorator();
      if (layoutDecorator == null)
      { layoutDecorator = page.getDefaultDecorator(root.getType()); }

      String defaultPortletDecorator = page.getDefaultDecorator(ContentFragment.PORTLET);

      ///////////////////////////////////////////////////////////////////////////////////////////////
      //TODO: Remove hard coding of locations and use CM + TL
      // DST: Im going to encapsulate this into a class, which can be accessed
      // by
      // the PowerTool when aggregating content, and make sure to modify the
      // search path
      // according to the current decorator. Assigned issue to JiRa JS2-24
      List contentPathes = (List) context.getSessionAttribute(ContentFilter.SESSION_CONTENT_PATH_ATTR);

      if (contentPathes == null)
      { contentPathes = new ArrayList(2); context.setSessionAttribute(ContentFilter.SESSION_CONTENT_PATH_ATTR, contentPathes); }

      String mediaType = context.getCapabilityMap().getPreferredMediaType().getName();
      if (contentPathes.size() < 1)
      {
      // define the lookup order
      contentPathes.add(root.getType() + "/" + mediaType + "/" + layoutDecorator);
      // Start added by jamesliao, 27-05-2005
      contentPathes.add(ContentFragment.PORTLET + "/" + mediaType + "/" + defaultPortletDecorator);
      // End

      Iterator defaults = fallBackContentPathes.iterator();
      while (defaults.hasNext())
      {
      String path = (String) defaults.next();
      contentPathes.add(path.replaceAll("

      {mediaType\\}

      ", mediaType));
      }

      }
      else

      { contentPathes.set(0, root.getType() + "/" + mediaType + "/" + layoutDecorator); // Start added by jamesliao, 27-05-2005, override the previous portlet-decorator contentPathes.set(1, ContentFragment.PORTLET + "/" + mediaType + "/" + defaultPortletDecorator); // End }

      if (layoutDecorator != null)

      { addStyle(context, layoutDecorator, ContentFragment.LAYOUT); }

      ///////////////////////////////////////////////////////////////////////////////////////////////
      ContentDispatcher dispatcher = renderer.getDispatcher(context, (strategy == STRATEGY_PARALLEL));
      // handle maximized state
      NavigationalState nav = context.getPortalURL().getNavigationalState();
      PortletWindow window = nav.getMaximizedWindow();
      if (null != window)

      { renderMaximizedWindow(context, page, root, window); }

      else

      { aggregateAndRender(root, context, page); }

      //dispatcher.include(root);
      context.getResponse().getWriter().write(root.getRenderedContent());

      if (null != window)

      { context.getRequest().removeAttribute(PortalReservedParameters.MAXIMIZED_FRAGMENT_ATTRIBUTE); context.getRequest().removeAttribute(PortalReservedParameters.MAXIMIZED_LAYOUT_ATTRIBUTE); }

      }

      Attachments

        1. patch3.txt
          2 kB
          Jian Liao
        2. better-patch.txt
          2 kB
          Jian Liao

        Activity

          People

            taylor David Sean Taylor
            norwaywoods Jian Liao
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: