portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl Worker.java RenderingJob.java PortletAggregatorImpl.java ContentDispatcherImpl.java PortletRendererImpl.java PageAggregatorImpl.java
Date Tue, 04 Jan 2005 16:05:46 GMT
weaver      2005/01/04 08:05:46

  Modified:    portal/src/java/org/apache/jetspeed/aggregator/impl
                        Worker.java RenderingJob.java
                        PortletAggregatorImpl.java
                        ContentDispatcherImpl.java PortletRendererImpl.java
                        PageAggregatorImpl.java
  Log:
  see: http://issues.apache.org/jira/browse/JS2-183
  
  Revision  Changes    Path
  1.5       +2 -2      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/Worker.java
  
  Index: Worker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/Worker.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Worker.java	22 Nov 2004 23:58:21 -0000	1.4
  +++ Worker.java	4 Jan 2005 16:05:44 -0000	1.5
  @@ -29,7 +29,7 @@
    * When no work is available, the worker simply sets itself in a waiting mode
    * pending reactivation by the WorkerMonitor
    *
  - * @author <a href="mailto:raphael@apache.org">RaphaŰl Luta</a>
  + * @author <a href="mailto:raphael@apache.org">Rapha´┐Żl Luta</a>
    * @version $Id$
    */
   public class Worker extends Thread
  
  
  
  1.6       +66 -56    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJob.java
  
  Index: RenderingJob.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJob.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RenderingJob.java	25 Mar 2004 21:39:22 -0000	1.5
  +++ RenderingJob.java	4 Jan 2005 16:05:44 -0000	1.6
  @@ -23,7 +23,12 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.jetspeed.PortalReservedParameters;
  +import org.apache.jetspeed.aggregator.ContentDispatcher;
   import org.apache.jetspeed.aggregator.ContentDispatcherCtrl;
  +import org.apache.jetspeed.aggregator.UnrenderedContentException;
  +import org.apache.jetspeed.om.page.Fragment;
  +import org.apache.jetspeed.request.RequestContext;
   import org.apache.pluto.PortletContainer;
   import org.apache.pluto.om.window.PortletWindow;
   
  @@ -32,7 +37,7 @@
    * asynchronous portlet rendering as well as implementing the rendering logic
    * in its Runnable method.
    *
  - * @author <a href="mailto:raphael@apache.org">RaphaŰl Luta</a>
  + * @author <a href="mailto:raphael@apache.org">Rapha´┐Żl Luta</a>
    * @version $Id$
    */
   public class RenderingJob implements Runnable
  @@ -44,57 +49,23 @@
       private PortletWindow window = null;
       private HttpServletRequest request = null;
       private HttpServletResponse response = null;
  -    private ContentDispatcherCtrl dispatcher = null;
  +    private ContentDispatcherCtrl dispatcherCtrl = null;
  +    private ContentDispatcher dispatcher = null;
       private PortletContainer container = null;
  -
  -    public void setWindow(PortletWindow window)
  -    {
  -        this.window = window;
  -    }
  -
  -    public PortletWindow getWindow()
  -    {
  -        return this.window;
  -    }
  -
  -    public void setRequest(HttpServletRequest request)
  +    private Fragment fragment = null;
  +    private RequestContext requestContext = null;
  +    
  +    public RenderingJob(PortletContainer container, ContentDispatcher dispatcher, Fragment fragment, HttpServletRequest request, HttpServletResponse response, RequestContext requestContext, PortletWindow window)
       {
  +        this.container = container;
  +        this.dispatcher = dispatcher;
  +        this.dispatcherCtrl = (ContentDispatcherCtrl) dispatcher;
  +        this.fragment = fragment;
           this.request = request;
  -    }
  -
  -    public HttpServletRequest getRequest()
  -    {
  -        return this.request;
  -    }
  -
  -    public void setResponse(HttpServletResponse response)
  -    {
           this.response = response;
  -    }
  -
  -    public HttpServletResponse getResponse()
  -    {
  -        return this.response;
  -    }
  -
  -    public void setDispatcher(ContentDispatcherCtrl dispatcher)
  -    {
  -        this.dispatcher = dispatcher;
  -    }
  -
  -    public ContentDispatcherCtrl getDispatcher()
  -    {
  -        return this.dispatcher;
  -    }
  -
  -    public void setContainer(PortletContainer container)
  -    {
  -        this.container = container;
  -    }
  -
  -    public PortletContainer getContainer()
  -    {
  -        return this.container;
  +        this.requestContext = requestContext; 
  +        this.window = window;
  +        
       }
   
       /**
  @@ -102,13 +73,40 @@
        * the WorkerMonitor. When done, pause until next scheduled scan.
        */
       public void run()
  -    {
  +    {       
           try
           {
  -            log.debug("Rendering OID "+this.window.getId()+" "+ this.request +" "+this.response);
  -            container.renderPortlet(this.window, this.request, this.response);
  +            execute();
  +            dispatcher.include(fragment);                   
  +        }
  +        catch (UnrenderedContentException e)
  +        {
  +            log.error("Failed to include fragment: "+e.toString(), e);
  +        }
  +        finally
  +        {
               log.debug("Notifying dispatcher OID "+this.window.getId());
  -          
  +            dispatcherCtrl.notify(this.window.getId());
  +        }
  +    }
  +    
  +    /**
  +     * <p>
  +     * execute
  +     * </p>
  +     *
  +     * 
  +     */
  +    protected void execute()
  +    {
  +        try
  +        {
  +            log.debug("Rendering OID "+this.window.getId()+" "+ this.request +" "+this.response);            
  +            this.request.setAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE, fragment);
  +            this.request.setAttribute(PortalReservedParameters.PAGE_ATTRIBUTE, requestContext.getPage());
  +            this.request.setAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE, requestContext);
  +            this.request.setAttribute(PortalReservedParameters.CONTENT_DISPATCHER_ATTRIBUTE,dispatcher);
  +            container.renderPortlet(this.window, this.request, this.response);     
           }
           catch (Throwable t)
           {
  @@ -116,7 +114,7 @@
               log.error("Error rendering portlet OID " + this.window.getId(), t);
   			try
               {
  -                t.printStackTrace(this.response.getWriter());
  +                t.printStackTrace(dispatcherCtrl.getResponseForWindow(this.window, this.requestContext).getWriter());
               }
               catch (IOException e)
               {
  @@ -127,13 +125,25 @@
           {
   			try
               {            	
  -                this.response.flushBuffer();
  -                dispatcher.notify(this.window.getId());
  +                this.response.flushBuffer();                       
               }
               catch (Exception e)
               {
                   log.error("Error flushing response buffer: "+e.toString(), e);
               }
           }
  +    }
  +
  +    /**
  +     * 
  +     * <p>
  +     * getWindow
  +     * </p>
  +     *
  +     * @return The window this job is in charge of rendering
  +     */
  +    public PortletWindow getWindow()
  +    {
  +        return window;
       }
   }
  
  
  
  1.8       +9 -3      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletAggregatorImpl.java
  
  Index: PortletAggregatorImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletAggregatorImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PortletAggregatorImpl.java	2 Sep 2004 17:09:15 -0000	1.7
  +++ PortletAggregatorImpl.java	4 Jan 2005 16:05:44 -0000	1.8
  @@ -15,12 +15,14 @@
    */
   package org.apache.jetspeed.aggregator.impl;
   
  +import java.io.IOException;
   import java.util.HashSet;
   import java.util.Set;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.jetspeed.PortalReservedParameters;
  +import org.apache.jetspeed.aggregator.ContentDispatcher;
   import org.apache.jetspeed.aggregator.PortletAggregator;
   import org.apache.jetspeed.aggregator.PortletRenderer;
   import org.apache.jetspeed.exception.JetspeedException;
  @@ -50,7 +52,7 @@
       /* (non-Javadoc)
        * @see org.apache.jetspeed.aggregator.Aggregator#build(org.apache.jetspeed.request.RequestContext)
        */
  -    public void build(RequestContext context) throws JetspeedException
  +    public void build(RequestContext context) throws JetspeedException, IOException
       {
           Fragment fragment = new FragmentImpl(); // TODO: fragment factory
           fragment.setType(Fragment.PORTLET);
  @@ -77,8 +79,12 @@
   //        {
   //            log.debug("no decorator for portlet:" + fragment.getId());
   //        }
  -
  +        
  +        ContentDispatcher dispatcher = renderer.getDispatcher(context, false);
           renderer.renderNow(fragment, context);
  +        dispatcher.include(fragment);
  +        context.getResponse().getWriter().write(fragment.getRenderedContent());
  +        
       }
       
       private void addStyle(RequestContext context, String decoratorName, String decoratorType) 
  
  
  
  1.8       +97 -225   jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/ContentDispatcherImpl.java
  
  Index: ContentDispatcherImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/ContentDispatcherImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ContentDispatcherImpl.java	23 Sep 2004 03:30:52 -0000	1.7
  +++ ContentDispatcherImpl.java	4 Jan 2005 16:05:44 -0000	1.8
  @@ -17,20 +17,17 @@
   
   import java.io.CharArrayWriter;
   import java.io.PrintWriter;
  -import java.util.Map;
   import java.util.Hashtable;
  +import java.util.Map;
   
  -import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  -import javax.servlet.http.HttpServletRequestWrapper;
  -import javax.servlet.http.HttpServletResponseWrapper;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.jetspeed.aggregator.ContentDispatcher;
   import org.apache.jetspeed.aggregator.ContentDispatcherCtrl;
   import org.apache.jetspeed.aggregator.FailedToRenderFragmentException;
  -import org.apache.jetspeed.aggregator.PortletRenderer;
  +import org.apache.jetspeed.aggregator.UnrenderedContentException;
   import org.apache.jetspeed.om.page.Fragment;
   import org.apache.jetspeed.request.RequestContext;
   import org.apache.jetspeed.util.JetspeedObjectID;
  @@ -38,10 +35,12 @@
   import org.apache.pluto.om.window.PortletWindow;
   
   /**
  - * <p>The ContentDispatcher allows customer classes to retrieved
  - *    rendered content for a specific fragment</p>
  - *
  - * @author <a href="mailto:raphael@apache.org">RaphaŰl Luta</a>
  + * <p>
  + * The ContentDispatcher allows customer classes to retrieved rendered content
  + * for a specific fragment
  + * </p>
  + * 
  + * @author <a href="mailto:raphael@apache.org">Rapha´┐Żl Luta </a>
    * @version $Id$
    */
   public class ContentDispatcherImpl implements ContentDispatcher, ContentDispatcherCtrl
  @@ -55,250 +54,99 @@
   
       private static int debugLevel = 1;
   
  -    private PortletRenderer renderer;
       
  -    public ContentDispatcherImpl(boolean isParallel, PortletRenderer renderer)
  -    {
  -        this.renderer = renderer;
  +
  +    public ContentDispatcherImpl( boolean isParallel )
  +    {        
           this.isParallel = isParallel;
       }
   
       /**
  -     * Include in the provided PortletResponse output stream the rendered content
  -     * of the request fragment.
  -     * If the fragment rendered content is not yet available, the method will
  -     * hold until it's completely rendered.
  -     * @throws FailedToRenderFragmentException if the Fragment to include could not be rendered.
  +     * Include in the provided PortletResponse output stream the rendered
  +     * content of the request fragment. If the fragment rendered content is not
  +     * yet available, the method will hold until it's completely rendered.
  +     * 
  +     * @throws FailedToRenderFragmentException
  +     *                   if the Fragment to include could not be rendered.
  +     * @throws UnrenderedContentException
        */
  -    public void include(Fragment fragment, HttpServletRequest req, HttpServletResponse rsp) throws FailedToRenderFragmentException 
  +    public void include( Fragment fragment )
  +            throws  UnrenderedContentException
       {
           ObjectID oid = JetspeedObjectID.createFromString(fragment.getId());
  +        PortletContent content = (PortletContent) contents.get(oid);
  +        log.debug("Including content for OID " + oid);
   
  -        if ((debugLevel > 1) && log.isDebugEnabled())
  -        {
  -            log.debug("Including content for OID "+ oid);
  -        }
  -
  -        // If we work synchronously, call Renderer.renderNow
           if (!isParallel)
           {
  -            if ((debugLevel > 0) && log.isDebugEnabled())
  -            {
  -                log.debug("Synchronous rendering for OID "+ oid);
  -            }
  -
  -            // access servlet request to determine request context in order
  -            // to render inner layout fragment with appropriate request attributes
  -            if (fragment.getType().equals(Fragment.LAYOUT))
  -            {
  -                RequestContext context = (RequestContext) req.getAttribute("org.apache.jetspeed.request.RequestContext");
  -                renderer.renderNow(fragment, context);
  -                return;
  -            }
  -            // render synchronously
  -            renderer.renderNow(fragment,req,rsp);
  -            return;
  -        }
  -
  -        PortletContent content = (PortletContent)contents.get(oid);
  -
  -        if (content!=null)
  -        {
  -            synchronized (content)
  -            {
  -                if (!content.isComplete())
  -                {
  -                    if ((debugLevel > 0) && log.isDebugEnabled())
  -                    {
  -                        log.debug("Waiting for content OID "+oid);
  -                    }
  -
  -                    try
  -                    {
  -                        content.wait();
  -                    }
  -                    catch (InterruptedException e)
  -                    {
  -                    }
  -
  -                    if ((debugLevel > 0) && log.isDebugEnabled())
  -                    {
  -                        log.debug("Been notified that OID "+oid+" is complete");
  -                    }
  -                }
  -
  -                if ((debugLevel > 1) && log.isDebugEnabled())
  -                {
  -                    log.debug("Content OID "+oid+": "+content.toString());
  -                }
  -            }
  -
  -            try
  -            {
  -                try
  -                {
  -                    rsp.getWriter().write(content.toString());
  -                }
  -                catch (IllegalStateException e)
  -                {
  -                    rsp.getOutputStream().print(content.toString());
  -                }
  -            }
  -            catch (Exception e)
  -            {
  -                log.error("Unable to include content OID "+oid+" in response object", e);
  -            }
  -            finally
  -            {
  -                synchronized(contents)
  -                {
  -                    if ((debugLevel > 1) && log.isDebugEnabled())
  -                    {
  -                        log.debug("Removing content OID "+oid);
  -                    }
  -                    ((PortletContent)contents.remove(oid)).release();
  -                }
  -            }
  +             log.debug("Synchronous rendering for OID " + oid);
  +             if(content.toString().length() > 0)
  +             {
  +                fragment.setRenderedContent(content.toString());
  +             }
           }
           else
           {
  -            // should only happen when a layout tries to render an inner layout
  -            // trigger a synchronous rendering of this fragment
  -
  -            if ((debugLevel > 1) && log.isDebugEnabled())
  -            {
  -                log.debug("Content is null for OID "+oid);
  -            }
   
  -            // access servlet request to determine request context in order
  -            // to render inner layout fragment with appropriate request attributes
  -            if (fragment.getType().equals(Fragment.LAYOUT))
  +            if (content != null)
               {
  -                RequestContext context = (RequestContext) req.getAttribute("org.apache.jetspeed.request.RequestContext");
  -                renderer.renderNow(fragment, context);
  -                return;
  -            }
  -            // render synchronously
  -            renderer.renderNow(fragment,req,rsp);
  -            return;
  -        }
  -    }
  -
  -    /**
  -     * Include in the provided PortletResponse output stream the rendered content
  -     * of the request fragment.
  -     * If the fragment rendered content is not yet available, the method will
  -     * hold until it's completely rendered.
  -     * @throws FailedToRenderFragmentException if the Fragment to include could not be rendered.
  -     */
  -    public void include(Fragment fragment, javax.portlet.RenderRequest req, javax.portlet.RenderResponse rsp) throws FailedToRenderFragmentException
  -    {
  -        ObjectID oid = JetspeedObjectID.createFromString(fragment.getId());
  -
  -        if ((debugLevel > 1) && log.isDebugEnabled())
  -        {
  -            log.debug("Including content for OID "+ oid);
  -        }
  -
  -        PortletContent content = (PortletContent)contents.get(oid);
  -
  -        if (content!=null)
  -        {
  -            synchronized (content)
  -            {
  -                if (!content.isComplete())
  +                synchronized (content)
                   {
  -                    if ((debugLevel > 0) && log.isDebugEnabled())
  +                    if (!content.isComplete())
                       {
  -                        log.debug("Waiting for content OID "+oid);
  +                        log.debug("Waiting for content OID " + oid);
  +                        try
  +                        {
  +                            content.wait();
  +                        }
  +                        catch (InterruptedException e)
  +                        {
  +                        }
  +                        log.debug("Been notified that OID " + oid + " is complete");
                       }
   
  -                    try
  -                    {
  -                        content.wait();
  -                    }
  -                    catch (InterruptedException e)
  -                    {
  -                    }
  -
  -                    if ((debugLevel > 0) && log.isDebugEnabled())
  -                    {
  -                        log.debug("Been notified that OID "+oid+" is complete");
  -                    }
  -                }
  -
  -                if ((debugLevel > 1) && log.isDebugEnabled())
  -                {
  -                    log.debug("Content OID "+oid+": "+content.toString());
  +                    log.debug("Content OID " + oid + ": " + content.toString());
                   }
  -            }
   
  -            try
  -            {
                   try
                   {
  -                    rsp.getWriter().write(content.toString());
  +                    if(content.toString().length() > 0)
  +                    {
  +                        fragment.setRenderedContent(content.toString());
  +                    }
                   }
  -                catch (IllegalStateException e)
  +                catch (Exception e)
                   {
  -                    //rsp.getPortletOutputStream().print(content.toString());
  +                    log.error("Unable to include content OID " + oid + " in response object", e);
                   }
  -            }
  -            catch (Exception e)
  -            {
  -                log.error("Unable to include content OID "+oid+" in response object", e);
  -            }
  -            finally
  -            {
  -                synchronized(contents)
  +                finally
                   {
  -                    if ((debugLevel > 1) && log.isDebugEnabled())
  +                    synchronized (contents)
                       {
  -                        log.debug("Removing content OID "+oid);
  +                        log.debug("Removing content OID " + oid);
  +                        ((PortletContent) contents.remove(oid)).release();
                       }
  -                    ((PortletContent)contents.remove(oid)).release();
                   }
               }
  -        }
  -        else
  -        {
  -            // should only happen when a layout tries to render an inner layout
  -            // trigger a synchronous rendering of this fragment
  -
  -            if ((debugLevel > 1) && log.isDebugEnabled())
  -            {
  -                log.debug("Content is null for OID "+oid);
  -            }
  -
  -            // access servlet request to determine request context in order
  -            // to render inner layout fragment with appropriate request attributes
  -            if (fragment.getType().equals(Fragment.LAYOUT))
  +            else
               {
  -                HttpServletRequest request = (HttpServletRequest)((HttpServletRequestWrapper)req).getRequest();
  -                RequestContext context = (RequestContext) request.getAttribute("org.apache.jetspeed.request.RequestContext");
  -                renderer.renderNow(fragment, context);
  -                return;
  +                throw new UnrenderedContentException("It appears that the content for fragment "+oid+" was not rendered.  "+
  +                        "Please verify that your aggregagtion implementation fully renders all content.");
               }
  -            // unwrap the RenderRequest and RenderResponse to avoid having to cascade several
  -            // portlet requests/responses
  -            HttpServletRequest request = (HttpServletRequest)((HttpServletRequestWrapper)req).getRequest();
  -            HttpServletResponse response = (HttpServletResponse)((HttpServletResponseWrapper)rsp).getResponse();
  -            renderer.renderNow(fragment,request,response);
  -            return;
           }
       }
   
  -    public void notify(ObjectID oid)
  +    public void notify( ObjectID oid )
       {
  -        PortletContent content = (PortletContent)contents.get(oid);
  +        PortletContent content = (PortletContent) contents.get(oid);
   
  -        if (content!=null)
  +        if (content != null)
           {
               synchronized (content)
               {
                   if ((debugLevel > 0) && log.isDebugEnabled())
                   {
  -                    log.debug("Notifying complete OID "+oid);
  +                    log.debug("Notifying complete OID " + oid);
                   }
                   content.setComplete(true);
                   content.notifyAll();
  @@ -306,16 +154,39 @@
           }
       }
   
  -    public HttpServletResponse getResponseForWindow(PortletWindow window, RequestContext request)
  +    public HttpServletResponse getResponseForWindow( PortletWindow window, RequestContext request )
  +    {
  +        PortletContent myContent = new PortletContent();
  +
  +        return getResponseForId(request, myContent, window.getId());
  +    }
  +    
  +    public HttpServletResponse getResponseForFragment( Fragment fragment, RequestContext request )
       {
           PortletContent myContent = new PortletContent();
  +        ObjectID oid = JetspeedObjectID.createFromString(fragment.getId());
  +        
  +        return getResponseForId(request, myContent, oid);
  +    }
   
  +    /**
  +     * <p>
  +     * getResponseForId
  +     * </p>
  +     *
  +     * @param request
  +     * @param myContent
  +     * @param oid
  +     * @return
  +     */
  +    protected HttpServletResponse getResponseForId( RequestContext request, PortletContent myContent, ObjectID oid )
  +    {
           synchronized (contents)
           {
  -            contents.put(window.getId(), myContent);
  +            contents.put(oid, myContent);
           }
   
  -        return new HttpBufferedResponse(request.getResponse(),myContent.getWriter());
  +        return new HttpBufferedResponse(request.getResponse(), myContent.getWriter());
       }
   
       protected class PortletContent
  @@ -351,7 +222,7 @@
               return cw.toString();
           }
   
  -        public void writeTo(java.io.Writer out) throws java.io.IOException
  +        public void writeTo( java.io.Writer out ) throws java.io.IOException
           {
               writer.flush();
               cw.writeTo(out);
  @@ -368,29 +239,30 @@
               return complete;
           }
   
  -        void setComplete(boolean state)
  +        void setComplete( boolean state )
           {
               this.complete = state;
           }
       }
  -    
  -    /* 
  +
  +    /*
        * Sequentially wait on content generation
  +     * 
        * @see org.apache.jetspeed.aggregator.ContentDispatcher#sync(org.apache.jetspeed.om.page.Fragment)
        */
  -    public void sync(Fragment fragment)
  +    public void sync( Fragment fragment )
       {
           ObjectID oid = JetspeedObjectID.createFromString(fragment.getId());
   
  -        PortletContent content = (PortletContent)contents.get(oid);
  -        
  +        PortletContent content = (PortletContent) contents.get(oid);
  +
           synchronized (content)
           {
               if (!content.isComplete())
               {
                   if ((debugLevel > 0) && log.isDebugEnabled())
                   {
  -                    log.debug("Waiting for content OID "+oid);
  +                    log.debug("Waiting for content OID " + oid);
                   }
   
                   try
  @@ -403,16 +275,16 @@
   
                   if ((debugLevel > 0) && log.isDebugEnabled())
                   {
  -                    log.debug("Been notified that OID "+oid+" is complete");
  +                    log.debug("Been notified that OID " + oid + " is complete");
                   }
               }
   
               if ((debugLevel > 1) && log.isDebugEnabled())
               {
  -                log.debug("Content OID "+oid+": "+content.toString());
  +                log.debug("Content OID " + oid + ": " + content.toString());
               }
           }
  -        
  +
       }
  -    
  +
   }
  
  
  
  1.25      +128 -119  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
  
  Index: PortletRendererImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- PortletRendererImpl.java	13 Oct 2004 15:53:22 -0000	1.24
  +++ PortletRendererImpl.java	4 Jan 2005 16:05:44 -0000	1.25
  @@ -29,7 +29,6 @@
   import org.apache.jetspeed.container.window.FailedToRetrievePortletWindow;
   import org.apache.jetspeed.container.window.PortletWindowAccessor;
   import org.apache.jetspeed.om.page.Fragment;
  -import org.apache.jetspeed.om.page.Page;
   import org.apache.jetspeed.request.RequestContext;
   import org.apache.jetspeed.util.JetspeedObjectID;
   import org.apache.pluto.PortletContainer;
  @@ -39,12 +38,14 @@
   import org.apache.pluto.om.window.PortletWindow;
   
   /**
  - * <h4>PortletRendererService<br />
  + * <h4>PortletRendererService <br />
    * Jetspeed-2 Rendering service.</h4>
  - * <p>This service process all portlet rendering requests and interfaces with the portlet
  - * container to generate the resulting markup</p>
  - *
  - * @author <a href="mailto:raphael@apache.org">RaphaŰl Luta</a>
  + * <p>
  + * This service process all portlet rendering requests and interfaces with the
  + * portlet container to generate the resulting markup
  + * </p>
  + * 
  + * @author <a href="mailto:raphael@apache.org">Rapha´┐Żl Luta </a>
    * @version $Id$
    */
   public class PortletRendererImpl implements PortletRenderer
  @@ -56,188 +57,196 @@
       private PortletContainer container;
       private PortletWindowAccessor windowAccessor;
   
  -    public PortletRendererImpl(PortletContainer container, 
  -                               PortletWindowAccessor windowAccessor)
  +    public PortletRendererImpl( PortletContainer container, PortletWindowAccessor windowAccessor )
       {
           this.container = container;
           this.windowAccessor = windowAccessor;
       }
  -        
  +
       public void start()
       {
           this.monitor = new WorkerMonitor();
           this.monitor.init();
       }
  -    
  +
       public void stop()
       {
           // this.monitor.shutdown ?
       }
  -          
  +
       /**
  -        Render the specified Page fragment.
  -        Result is returned in the PortletResponse.
  +     * Render the specified Page fragment. Result is returned in the
  +     * PortletResponse.
  +     * 
        * @throws FailedToRenderFragmentException
  +     * @throws FailedToRetrievePortletWindow
        */
  -    public void renderNow(Fragment fragment, RequestContext request) throws FailedToRenderFragmentException
  +    public void renderNow( Fragment fragment, RequestContext requestContext ) throws FailedToRenderFragmentException, FailedToRetrievePortletWindow
       {
  -        //
  -        // create the portlet window and render the portlet
  -        //
  +
           HttpServletRequest servletRequest = null;
  -        Page outerPage = null;
  -        Fragment outerFragment = null;
  -        ContentDispatcher outerFragmentDispatcher = null;
  +        HttpServletResponse servletResponse = null;
  +        ContentDispatcher dispatcher = null;
  +        PortletWindow portletWindow = getPortletWindow(fragment);
  +        
           try
           {
  -            PortletContainerServices.prepare("jetspeed");
  -            
  -            PortletWindow portletWindow = getPortletWindow(fragment);
  -
  -            servletRequest = request.getRequestForWindow(portletWindow);
  -            HttpServletResponse servletResponse = request.getResponseForWindow(portletWindow);
  +            PortletContainerServices.prepare("jetspeed");           
  +            ContentDispatcherCtrl dispatcherCtrl = getDispatcherCtrl(requestContext, true);
  +            dispatcher = getDispatcher(requestContext, true);
  +            servletRequest = requestContext.getRequestForWindow(portletWindow);
  +            servletResponse = dispatcherCtrl.getResponseForWindow(portletWindow, requestContext);
   
  -            // save and set servlet request attributes required
  -            // for rendering layout portlets
  -            outerPage = (Page) servletRequest.getAttribute(PortalReservedParameters.PAGE_ATTRIBUTE_KEY);
  -            outerFragment = (Fragment) servletRequest.getAttribute("org.apache.jetspeed.Fragment");
  -            outerFragmentDispatcher = (ContentDispatcher) servletRequest.getAttribute("org.apache.jetspeed.ContentDispatcher");
  -            servletRequest.setAttribute(PortalReservedParameters.PAGE_ATTRIBUTE_KEY,request.getPage());
  -            servletRequest.setAttribute("org.apache.jetspeed.Fragment",fragment);
  -            servletRequest.setAttribute("org.apache.jetspeed.ContentDispatcher",getDispatcher(request,true));
  +            RenderingJob rJob = buildRenderingJob(fragment, servletRequest, servletResponse, requestContext);
  +            rJob.execute();
   
  -            // should we decorate here instead of rendering Portlet ?
  -            container.renderPortlet(portletWindow, servletRequest, servletResponse);
           }
           catch (Exception e)
  -        {            
  -            throw new FailedToRenderFragmentException("Unable to render fragment because: "+e.toString(), e);
  -        }
  -        finally
           {
  -            if (servletRequest!=null)
  -            {
  -                // restore servlet request attributes
  -                if (outerFragmentDispatcher == null)
  -                {
  -                    servletRequest.removeAttribute("org.apache.jetspeed.ContentDispatcher");
  -                }
  -                else
  -                {
  -                    servletRequest.setAttribute("org.apache.jetspeed.ContentDispatcher",outerFragmentDispatcher);
  -                }
  -                if (outerFragment == null)
  -                {
  -                    servletRequest.removeAttribute("org.apache.jetspeed.Fragment");
  -                }
  -                else
  -                {
  -                    servletRequest.setAttribute("org.apache.jetspeed.Fragment",outerFragment);
  -                }
  -                if (outerPage == null)
  -                {
  -                    servletRequest.removeAttribute(PortalReservedParameters.PAGE_ATTRIBUTE_KEY);
  -                }
  -                else
  -                {
  -                    servletRequest.setAttribute(PortalReservedParameters.PAGE_ATTRIBUTE_KEY,outerPage);
  -                }
  -            }
  +            fragment.setRenderedContent(e.toString());
  +            log.error(e.toString(), e);
           }
       }
   
       /**
  -        Render the specified Page fragment.
  -        Result is returned in the PortletResponse.
  +     * Render the specified Page fragment. Result is returned in the
  +     * PortletResponse.
  +     * 
        * @throws FailedToRenderFragmentException
  +     * @throws FailedToRetrievePortletWindow
        */
  -    public void renderNow(Fragment fragment, HttpServletRequest request, HttpServletResponse response) throws FailedToRenderFragmentException
  +    public void renderNow( Fragment fragment, HttpServletRequest request, HttpServletResponse response )
  +            throws FailedToRenderFragmentException, FailedToRetrievePortletWindow
       {
  -        //
  -        // create the portlet window and render the portlet
  -        //
  +
  +        RequestContext requestContext = (RequestContext) request
  +                .getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
  +        ContentDispatcher dispatcher = getDispatcher(requestContext, true);
  +        PortletWindow portletWindow = getPortletWindow(fragment);
  +        
           try
           {
  -            PortletContainerServices.prepare("jetspeed"); 
  -            RequestContext context = (RequestContext) request.getAttribute("org.apache.jetspeed.request.RequestContext");
  -            PortletWindow portletWindow = getPortletWindow(fragment);
  -            HttpServletRequest servletRequest = context.getRequestForWindow(portletWindow);
  -            HttpServletResponse servletResponse = context.getResponseForWindow(portletWindow);
  +            PortletContainerServices.prepare("jetspeed");
  +            ContentDispatcherCtrl dispatcherCtrl = getDispatcherCtrl(requestContext, true);
               
  -            container.renderPortlet(portletWindow, servletRequest, servletResponse);
  +            HttpServletRequest servletRequest = requestContext.getRequestForWindow(portletWindow);
  +            HttpServletResponse servletResponse = dispatcherCtrl.getResponseForWindow(portletWindow, requestContext);
  +
  +            RenderingJob rJob = buildRenderingJob(fragment, servletRequest, servletResponse, requestContext);
  +            rJob.execute();
           }
           catch (Exception e)
  -        {            
  -            throw new FailedToRenderFragmentException("Unable to render fragment because: "+e.toString(), e);
  +        {
  +            fragment.setRenderedContent(e.toString());
  +            log.error(e.toString(), e);
           }
       }
   
  -    /** Render the specified Page fragment.
  -        The method returns before rendering is complete, rendered content can be
  -        accessed through the ContentDispatcher
  +    /**
  +     * Render the specified Page fragment. The method returns before rendering
  +     * is complete, rendered content can be accessed through the
  +     * ContentDispatcher
  +     * @throws FailedToRetrievePortletWindow
  +     * 
        * @throws UnknownPortletDefinitionException
        * @throws FailedToRetrievePortletWindow
  -    */
  -    public void render(Fragment fragment, RequestContext request) throws FailedToRenderFragmentException
  +     */
  +    public void render( Fragment fragment, RequestContext requestContext ) throws FailedToRenderFragmentException, FailedToRetrievePortletWindow
       {
  -        RenderingJob rJob = new RenderingJob();
  -        PortletContainerServices.prepare("jetspeed"); 
  +
  +        PortletContainerServices.prepare("jetspeed");
   
           PortletWindow portletWindow;
  +
  +        
  +
  +        ContentDispatcherCtrl dispatcherCtrl = getDispatcherCtrl(requestContext, true);
  +        ContentDispatcher dispatcher = getDispatcher(requestContext, true);
  +
  +        HttpServletRequest servletRequest =null;
  +        HttpServletResponse servletResponse = null;
  +
           try
           {
               portletWindow = getPortletWindow(fragment);
  +            servletRequest = requestContext.getRequestForWindow(portletWindow);
  +            servletResponse = dispatcherCtrl.getResponseForWindow(portletWindow, requestContext);
  +            
           }
  -        catch (FailedToRetrievePortletWindow e)
  +        catch (FailedToRetrievePortletWindow e1)
           {
  -           throw new FailedToRenderFragmentException("Unable to render fragment because: "+e.toString(), e);
  +            servletRequest = requestContext.getRequest();
  +            servletResponse = dispatcherCtrl.getResponseForFragment(fragment, requestContext);
  +            log.error("render() failed: " + e1.toString(), e1);
  +            fragment.setRenderedContent(e1.toString());            
  +        }
  +        finally
  +        {
  +            RenderingJob rJob = buildRenderingJob(fragment, servletRequest, servletResponse, requestContext);
  +            monitor.process(rJob);
           }
  -        ContentDispatcherCtrl dispatcher = getDispatcherCtrl(request,true);
  -
  -        HttpServletRequest servletRequest = request.getRequestForWindow(portletWindow);
  -        HttpServletResponse servletResponse = dispatcher.getResponseForWindow(portletWindow, request);
  -
  -        rJob.setWindow(portletWindow);
  -        rJob.setContainer(this.container);
  -        rJob.setRequest(servletRequest);
  -        rJob.setResponse(servletResponse);
  -        rJob.setDispatcher(dispatcher);
  -
  -        monitor.process(rJob);
       }
   
       /**
        * Retrieve the ContentDispatcher for the specified request
        */
  -    public ContentDispatcher getDispatcher(RequestContext request, boolean isParallel)
  +    public ContentDispatcher getDispatcher( RequestContext request, boolean isParallel )
       {
  -        return (ContentDispatcher)getDispatcherCtrl(request,isParallel);
  +        return (ContentDispatcher) getDispatcherCtrl(request, isParallel);
       }
   
       /**
        * Retrieve the ContentDispatcherCtrl for the specified request
        */
  -    protected ContentDispatcherCtrl getDispatcherCtrl(RequestContext request, boolean isParallel)
  +    protected ContentDispatcherCtrl getDispatcherCtrl( RequestContext request, boolean isParallel )
       {
           if (request.getContentDispatcher() == null)
           {
  -            request.setContentDispatcher(new ContentDispatcherImpl(isParallel, this));
  +            request.setContentDispatcher(new ContentDispatcherImpl(isParallel));
           }
   
  -        return (ContentDispatcherCtrl)request.getContentDispatcher();
  +        return (ContentDispatcherCtrl) request.getContentDispatcher();
       }
   
  -    protected PortletWindow getPortletWindow(Fragment fragment) throws  FailedToRetrievePortletWindow
  +    protected PortletWindow getPortletWindow( Fragment fragment ) throws FailedToRetrievePortletWindow
       {
  -        ObjectID oid = JetspeedObjectID.createFromString(fragment.getId());
  -                        
  -        PortletWindow portletWindow = windowAccessor.getPortletWindow(fragment);
  -        if (portletWindow == null)
  -        {
  -            throw new FailedToRetrievePortletWindow("Portlet Window creation failed for fragment: " + fragment.getId() + ", " + fragment.getName());
  -        }
  -        PortletEntity portletEntity = portletWindow.getPortletEntity();
   
  -        return portletWindow;
  +            ObjectID oid = JetspeedObjectID.createFromString(fragment.getId());
  +
  +            PortletWindow portletWindow = windowAccessor.getPortletWindow(fragment);
  +            if (portletWindow == null)
  +            {
  +                throw new FailedToRetrievePortletWindow("Portlet Window creation failed for fragment: "
  +                        + fragment.getId() + ", " + fragment.getName());
  +            }
  +            PortletEntity portletEntity = portletWindow.getPortletEntity();
  +
  +            return portletWindow;
  +
  +    }
  +
  +    protected RenderingJob buildRenderingJob( Fragment fragment, HttpServletRequest request,
  +            HttpServletResponse response, RequestContext requestContext ) throws FailedToRetrievePortletWindow,
  +            FailedToRenderFragmentException
  +    {
  +        ContentDispatcher dispatcher = null;
  +        RenderingJob rJob;
  +
  +        PortletContainerServices.prepare("jetspeed");
  +
  +        PortletWindow portletWindow = getPortletWindow(fragment);
  +        ContentDispatcherCtrl dispatcherCtrl = getDispatcherCtrl(requestContext, true);
  +        dispatcher = getDispatcher(requestContext, true);
  +        request = requestContext.getRequestForWindow(portletWindow);
  +        response = dispatcherCtrl.getResponseForWindow(portletWindow, requestContext);
  +
  +        request.setAttribute(PortalReservedParameters.PAGE_ATTRIBUTE, requestContext.getPage());
  +        request.setAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE, fragment);
  +        request.setAttribute(PortalReservedParameters.CONTENT_DISPATCHER_ATTRIBUTE, dispatcher);
  +        request.setAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE, request);
  +
  +        request.setAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE, fragment);
  +        return new RenderingJob(container, dispatcher, fragment, request, response, requestContext, portletWindow);
  +
       }
   }
  
  
  
  1.17      +155 -141  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java
  
  Index: PageAggregatorImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- PageAggregatorImpl.java	19 Nov 2004 03:07:43 -0000	1.16
  +++ PageAggregatorImpl.java	4 Jan 2005 16:05:45 -0000	1.17
  @@ -15,16 +15,18 @@
    */
   package org.apache.jetspeed.aggregator.impl;
   
  +import java.io.IOException;
   import java.util.ArrayList;
   import java.util.HashSet;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Set;
  -import java.util.Stack;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.jetspeed.PortalReservedParameters;
   import org.apache.jetspeed.aggregator.ContentDispatcher;
  +import org.apache.jetspeed.aggregator.FailedToRenderFragmentException;
   import org.apache.jetspeed.aggregator.PageAggregator;
   import org.apache.jetspeed.aggregator.PortletRenderer;
   import org.apache.jetspeed.container.state.NavigationalState;
  @@ -37,9 +39,9 @@
   
   /**
    * PageAggregator builds the content required to render a page of portlets.
  - *
  - * @author <a href="mailto:raphael@apache.org">RaphaŰl Luta</a>
  - * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  + * 
  + * @author <a href="mailto:raphael@apache.org">Rapha´┐Żl Luta </a>
  + * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
    * @version $Id$
    */
   public class PageAggregatorImpl implements PageAggregator
  @@ -54,57 +56,55 @@
   
       private List fallBackContentPathes;
   
  -    public PageAggregatorImpl(PortletRenderer renderer, int strategy, List fallBackContentPathes)
  +    public PageAggregatorImpl( PortletRenderer renderer, int strategy, List fallBackContentPathes )
       {
           this.renderer = renderer;
           this.strategy = strategy;
           this.fallBackContentPathes = fallBackContentPathes;
       }
   
  -    public PageAggregatorImpl(PortletRenderer renderer, List fallBackContentPathes)
  +    public PageAggregatorImpl( PortletRenderer renderer, List fallBackContentPathes )
       {
           this(renderer, STRATEGY_SEQUENTIAL, fallBackContentPathes);
       }
   
  -   
  -
       /**
        * Builds the portlet set defined in the context into a portlet tree.
  -     *
  +     * 
        * @return Unique Portlet Entity ID
        */
  -    public void build(RequestContext context) throws JetspeedException
  +    public void build( RequestContext context ) throws JetspeedException, IOException
       {
           Page page = context.getPage();
           if (null == page)
           {
               throw new JetspeedException("Failed to find PSML Pin PageAggregator.build");
           }
  -    
  -        // Initialize fragment
  -        Stack stack = new Stack();
  -        Fragment currentFragment = page.getRootFragment();
  -    
  -        if (currentFragment == null)
  +
  +        Fragment root = page.getRootFragment();
  +
  +        if (root == null)
           {
               throw new JetspeedException("No root Fragment found in Page");
           }
  -    
  -        String layoutDecorator = currentFragment.getDecorator();
  +
  +        String layoutDecorator = root.getDecorator();
           if (layoutDecorator == null)
           {
  -            layoutDecorator = page.getDefaultDecorator(currentFragment.getType());
  +            layoutDecorator = page.getDefaultDecorator(root.getType());
           }
  -        
  +
           String defaultPortletDecorator = page.getDefaultDecorator(Fragment.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        
  +        //      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);
  @@ -114,144 +114,105 @@
           if (contentPathes.size() < 1)
           {
               // define the lookup order
  -            
  -            contentPathes.add(currentFragment.getType() + "/"+mediaType+"/" + layoutDecorator);
  +
  +            contentPathes.add(root.getType() + "/" + mediaType + "/" + layoutDecorator);
               Iterator defaults = fallBackContentPathes.iterator();
  -            while(defaults.hasNext())
  +            while (defaults.hasNext())
               {
  -                String path = (String)defaults.next();
  +                String path = (String) defaults.next();
                   contentPathes.add(path.replaceAll("\\{mediaType\\}", mediaType));
               }
  -            
  -//            contentPathes.add("portlet/"+mediaType+"/jetspeed");
  -//            contentPathes.add("portlet/" + mediaType);
  -//            contentPathes.add("generic/" + mediaType);
  -//            contentPathes.add("/" + mediaType);
  +
  +            //            contentPathes.add("portlet/"+mediaType+"/jetspeed");
  +            //            contentPathes.add("portlet/" + mediaType);
  +            //            contentPathes.add("generic/" + mediaType);
  +            //            contentPathes.add("/" + mediaType);
           }
           else
           {
  -            contentPathes.set(0, currentFragment.getType() + "/"+mediaType+"/" + layoutDecorator);
  +            contentPathes.set(0, root.getType() + "/" + mediaType + "/" + layoutDecorator);
           }
  -        
  -        
  -        if(layoutDecorator != null)
  +
  +        if (layoutDecorator != null)
           {
  -            addStyle(context, layoutDecorator, Fragment.LAYOUT);	        
  +            addStyle(context, layoutDecorator, Fragment.LAYOUT);
           }
  -        
  -                      
  +
           ///////////////////////////////////////////////////////////////////////////////////////////////
  -    
  +        ContentDispatcher dispatcher = renderer.getDispatcher(context, (strategy == STRATEGY_PARALLEL));
           // handle maximized state
           NavigationalState nav = context.getPortalURL().getNavigationalState();
           PortletWindow window = nav.getMaximizedWindow();
           if (null != window)
           {
  -            Fragment fragment = page.getFragmentById(window.getId().toString());
  -            if (fragment != null)
  -            {
  -                context.getRequest().setAttribute("org.apache.jetspeed.maximized.Fragment", fragment);
  -                context.getRequest().setAttribute("org.apache.jetspeed.maximized.Layout", page.getRootFragment());
  -                
  -                if(fragment.getDecorator() != null)
  -                {
  -                    log.debug("decorator=" + currentFragment.getDecorator());
  -                    addStyle(context, fragment.getDecorator(), Fragment.PORTLET);
  -                } 
  -                else 
  -                {
  -                    log.debug("no decorator for defined for portlet fragement," + currentFragment.getId()+".  So using page default, "+defaultPortletDecorator);
  -                    addStyle(context, defaultPortletDecorator, Fragment.PORTLET);
  -                }
  -                renderer.renderNow(page.getRootFragment(), context);
  -                
  -                context.getRequest().removeAttribute("org.apache.jetspeed.maximized.Fragment");
  -                context.getRequest().removeAttribute("org.apache.jetspeed.maximized.Layout");
  -            }
  -            return;
  +            renderMaximizedWindow(context, page, root, window);
  +        }
  +        else
  +        {
  +            aggregateAndRender(root, context, page);
           }
           
  -        // initializes the rendering stack with root children
  -        // root fragement is always treated synchronously
  -        for (Iterator i = currentFragment.getFragments().iterator(); i.hasNext();)
  -        {
  -            Fragment f = (Fragment) i.next();
  -            
  -            if (!"hidden".equals(f.getState()))
  +        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);
  +        }
  +    }
  +
  +    /**
  +     * <p>
  +     * renderMaximizedWindow
  +     * </p>
  +     * 
  +     * @param context
  +     * @param page
  +     * @param layoutFragment
  +     * @param defaultPortletDecorator
  +     * @param dispatcher
  +     * @param window
  +     * @throws FailedToRenderFragmentException
  +     */
  +    protected void renderMaximizedWindow( RequestContext context, Page page, Fragment layoutFragment,
  +            PortletWindow window ) throws FailedToRenderFragmentException
  +    {
  +        String defaultPortletDecorator = page.getDefaultDecorator(Fragment.PORTLET);
  +        Fragment maxedFragment = page.getFragmentById(window.getId().toString());
  +        if (maxedFragment != null)
  +        {
  +            context.getRequest().setAttribute(PortalReservedParameters.MAXIMIZED_FRAGMENT_ATTRIBUTE, maxedFragment);
  +            context.getRequest().setAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE, maxedFragment);
  +            context.getRequest().setAttribute(PortalReservedParameters.MAXIMIZED_LAYOUT_ATTRIBUTE, page.getRootFragment());
  +
  +            if (maxedFragment.getDecorator() != null)
               {
  -                stack.push(f);
  +                log.debug("decorator=" + layoutFragment.getDecorator());
  +                addStyle(context, maxedFragment.getDecorator(), Fragment.PORTLET);
               }
  -        }
  -        
  -        // Walk through the Fragment tree, and start rendering "portlet" type
  -        // fragment
  -        while (!stack.isEmpty())
  -        {
  -            currentFragment = (Fragment) stack.pop();
  -            
  -            if (currentFragment.getType().equals("portlet"))
  -            {
  -                // make the page aggreator less fragile
  -                // by preventing failed rendering from screwing up the
  -                // whole process
  -                try
  -                {
  -                    if (log.isDebugEnabled())
  -                    {
  -                        log.debug(
  -                                  "Rendering portlet fragment: [[name, "
  -                                  + currentFragment.getName()
  -                                  + "], [id, "
  -                                  + currentFragment.getId()
  -                                  + "]]");
  -                    }
  -                    renderer.render(currentFragment, context);
  -                    if (strategy == STRATEGY_SEQUENTIAL)
  -                    {
  -                        ContentDispatcher dispatcher = renderer.getDispatcher(context, false);
  -                        dispatcher.sync(currentFragment);
  -                    }
  -                    
  -                    if(currentFragment.getDecorator() != null)
  -                    {
  -                        log.debug("decorator=" + currentFragment.getDecorator());
  -                        addStyle(context, currentFragment.getDecorator(), Fragment.PORTLET);
  -                    } 
  -                    else 
  -                    {
  -                        log.debug("no decorator for defined for portlet fragement," + currentFragment.getId()+".  So using page default, "+defaultPortletDecorator);
  -                        addStyle(context, defaultPortletDecorator, Fragment.PORTLET);
  -                    }
  -                    
  -                }
  -                catch (Exception e)
  -                {
  -                    log.error("Failed to render portlet \"" + currentFragment + "\": " + e.toString());
  -                }
  +            else
  +            {
  +                log.debug("no decorator for defined for portlet fragement," + layoutFragment.getId()
  +                        + ".  So using page default, " + defaultPortletDecorator);
  +                addStyle(context, defaultPortletDecorator, Fragment.PORTLET);
               }
  -            
  -            // push the children frgaments on the rendering stack
  -            for (Iterator i = currentFragment.getFragments().iterator(); i.hasNext();)
  +            try
               {
  -                Fragment f = (Fragment) i.next();
  -                
  -                if (!"hidden".equals(f.getState()))
  -                {
  -                    stack.push(f);
  -                }
  +                renderer.renderNow(maxedFragment, context);
  +                renderer.renderNow(layoutFragment, context);
  +            }
  +            catch (Exception e)
  +            {
  +                log.error(e.getMessage(), e);
  +                maxedFragment.setRenderedContent("Sorry, but we were unable access the requested portlet.  Send the following message to your portal admin:  "+  e.getMessage());
               }
  +
  +
           }
  -        
  -        // Retrieves the content dispatcher appropriate for sequential
  -        // or parallel rendering
  -        
  -        ContentDispatcher dispatcher = renderer.getDispatcher(context, (strategy == STRATEGY_PARALLEL));
  -        
  -        // Now synchronously trigger the rendering of the whole page
  -        renderer.renderNow(page.getRootFragment(), context);
       }
   
  -    private void addStyle(RequestContext context, String decoratorName, String decoratorType) 
  +    private void addStyle( RequestContext context, String decoratorName, String decoratorType )
       {
           Set cssUrls = (Set) context.getAttribute("cssUrls");
   
  @@ -260,14 +221,67 @@
               cssUrls = new HashSet();
               context.setAttribute("cssUrls", cssUrls);
           }
  -        
  -        if(decoratorType.equals(Fragment.LAYOUT))
  +
  +        if (decoratorType.equals(Fragment.LAYOUT))
           {
               cssUrls.add("content/css/styles.css");
           }
           else
           {
  -            cssUrls.add("content/"+decoratorName+"/css/styles.css");
  +            cssUrls.add("content/" + decoratorName + "/css/styles.css");
  +        }
  +    }
  +
  +    protected void aggregateAndRender( Fragment f, RequestContext context, Page page )
  +            throws FailedToRenderFragmentException
  +    {
  +
  +        if (f.getFragments() != null && f.getFragments().size() > 0)
  +        {
  +            Iterator children = f.getFragments().iterator();
  +            while (children.hasNext())
  +            {
  +                Fragment child = (Fragment) children.next();
  +                if (!"hidden".equals(f.getState()))
  +                {
  +                    aggregateAndRender(child, context, page);
  +                }
  +            }
  +        }
  +
  +        // Start the actual rendering process
  +        String defaultPortletDecorator = page.getDefaultDecorator(Fragment.PORTLET);
  +        if (log.isDebugEnabled())
  +        {
  +            log.debug("Rendering portlet fragment: [[name, " + f.getName() + "], [id, " + f.getId() + "]]");
  +        }
  +        
  +        try
  +        {
  +            renderer.render(f, context);
  +        }
  +        catch (Exception e)
  +        {
  +            log.error(e.getMessage(), e);
  +            f.setRenderedContent("Sorry, but we were unable access the requested portlet.  Send the following message to your portal admin:  "+  e.getMessage());
  +        }
  +        
  +        if (strategy == STRATEGY_SEQUENTIAL)
  +        {
  +            ContentDispatcher dispatcher = renderer.getDispatcher(context, false);
  +            dispatcher.sync(f);
  +        }
  +
  +        if (f.getDecorator() != null && f.getType().equals(Fragment.PORTLET))
  +        {
  +            log.debug("decorator=" + f.getDecorator());
  +            addStyle(context, f.getDecorator(), Fragment.PORTLET);
  +        }
  +        else if (f.getDecorator() == null && f.getType().equals(Fragment.PORTLET))
  +        {
  +            log.debug("no decorator for defined for portlet fragement," + f.getId() + ".  So using page default, "
  +                    + defaultPortletDecorator);
  +            addStyle(context, defaultPortletDecorator, Fragment.PORTLET);
           }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message