You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ra...@apache.org on 2001/07/22 22:31:11 UTC

cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/util/template JetspeedTemplateLink.java JetspeedTool.java

raphael     01/07/22 13:31:11

  Modified:    src/java/org/apache/jetspeed/modules/actions/controllers
                        MultiColumnControllerAction.java
                        PanedControllerAction.java
                        RowColumnControllerAction.java
                        VelocityControllerAction.java
               src/java/org/apache/jetspeed/modules/actions/controls
                        Close.java Customize.java Maximize.java
                        Restore.java
               src/java/org/apache/jetspeed/modules/actions/portlets
                        CustomizeAction.java CustomizeSetAction.java
                        VelocityPortletAction.java
               src/java/org/apache/jetspeed/modules/pages
                        JetspeedTemplatePage.java
               src/java/org/apache/jetspeed/om/profile
                        BasePSMLDocument.java
               src/java/org/apache/jetspeed/util/template
                        JetspeedTemplateLink.java JetspeedTool.java
  Log:
  Update customization features:
  - remove static PortalState class and refactor layout flow
  - upgrade functionalities for multicolumn and paned controller
  
  (Works only in Velocity mode right now)
  
  Revision  Changes    Path
  1.3       +65 -22    jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/MultiColumnControllerAction.java
  
  Index: MultiColumnControllerAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/MultiColumnControllerAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MultiColumnControllerAction.java	2001/07/11 09:36:26	1.2
  +++ MultiColumnControllerAction.java	2001/07/22 20:31:11	1.3
  @@ -59,9 +59,10 @@
   import org.apache.jetspeed.portal.PortletController;
   import org.apache.jetspeed.portal.PortletControllerConfig;
   import org.apache.jetspeed.portal.PanedPortletController;
  -import org.apache.jetspeed.portal.PortalState;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
  +import org.apache.jetspeed.services.Registry;
   import org.apache.jetspeed.om.profile.Profile;
  +import org.apache.jetspeed.om.newregistry.PortletEntry;
   import org.apache.jetspeed.xml.api.portletmarkup.Portlets;
   import org.apache.jetspeed.xml.api.portletmarkup.Entry;
   import org.apache.jetspeed.xml.api.portletmarkup.Metainfo;
  @@ -71,6 +72,7 @@
   // Turbine stuff
   import org.apache.turbine.util.Log;
   import org.apache.turbine.util.RunData;
  +import org.apache.turbine.services.template.TurbineTemplate;
   
   // Velocity Stuff
   import org.apache.velocity.context.Context;
  @@ -238,6 +240,8 @@
                                             Context context,
                                             RunData rundata )
       {
  +        JetspeedRunData jdata = (JetspeedRunData)rundata;
  +        
           super.buildCustomizeContext(controller,context,rundata);
   
           List[] columns = null;
  @@ -261,38 +265,71 @@
           context.put("sizes", getCellSizes(sizes));
   
           columns = (List[])rundata.getUser().getTemp("columns");
  +        PortletSet customizedSet = (PortletSet)jdata.getCustomized();
  +        Portlets set = jdata.getProfile()
  +                            .getDocument()
  +                            .getPortlets(customizedSet.getName());
   
  -        if (columns == null)
  -        {
  -            Portlets set = ((JetspeedRunData)rundata)
  -                                    .getProfile()
  -                                    .getDocument()
  -                                    .getPortlets((String)context.get("paneid"));
  -        
  +        Log.debug("MultiCol: columns "+columns+" set "+set);
   
  +        if ((columns != null)&&(columns.length==colNum))
  +        {
  +            int eCount = 0;
  +            for (int i=0; i < columns.length; i++)
  +            {
  +                eCount+=columns[i].size();
  +            }
  +            
  +            Log.debug("MultiCol: eCount "+eCount+" setCount"+ set.getEntryCount()+" "+set.getPortletsCount());
  +            if (eCount != set.getEntryCount()+set.getPortletsCount())
  +            {
  +                Log.debug("MultiCol: rebuilding columns ");
  +                columns = buildColumns(set,colNum);
  +            }
  +                
  +        }
  +        else
  +        {
  +            Log.debug("MultiCol: rebuilding columns ");
               columns = buildColumns(set,colNum);
  -            rundata.getUser().setTemp("columns",columns);
  -            rundata.getUser().setTemp("portlets",set);
           }
  -        
  +
  +        rundata.getUser().setTemp("columns",columns);
           context.put("portlets", columns);
           
           Map titles = new HashMap();
  -        Enumeration en = controller.getPortlets().getPortlets();
  -        while(en.hasMoreElements())
  +        for (int col=0; col < columns.length; col++)
           {
  -            Portlet p = (Portlet)en.nextElement();
  -            titles.put(p.getName(),p.getTitle());
  +            for(int row=0; row < columns[col].size(); row++)
  +            {
  +                Entry entry = (Entry)columns[col].get(row);
  +                if ((entry.getMetainfo()!=null)&&(entry.getMetainfo().getTitle()!=null))
  +                {
  +                    titles.put(entry.getParent(),entry.getMetainfo().getTitle());
  +                }
  +                else
  +                {
  +                    PortletEntry pentry = (PortletEntry)Registry.getEntry(Registry.PORTLET,entry.getParent());
  +                    if (pentry!=null)
  +                    {
  +                        titles.put(entry.getParent(),pentry.getTitle());
  +                    }
  +                }
  +            }
           }
  -        
  +                               
           context.put("titles", titles);
  +        context.put("action", "controllers.MultiColumnControllerAction");
       }
       
       public void doCancel(RunData data, Context context)
       {
           data.getUser().removeTemp("columns");
  -        data.getUser().removeTemp("portlets");
  -        PortalState.reset(data);
  +        ((JetspeedRunData)data).setCustomized(null);
  +        if (((JetspeedRunData)data).getCustomized()==null)
  +        {
  +            data.setScreenTemplate("Home");
  +        }
       }
   
       public void doSave(RunData data, Context context)
  @@ -323,6 +360,9 @@
   
       public void doDelete(RunData data, Context context)
       {
  +        JetspeedRunData jdata = (JetspeedRunData)data;
  +        PortletSet customizedSet = (PortletSet)jdata.getCustomized();
  +
           int col = data.getParameters().getInt("col",-1);
           int row = data.getParameters().getInt("row",-1);
           List[] columns = (List[])data.getUser().getTemp("columns");
  @@ -334,8 +374,10 @@
               {
                   Entry entry = (Entry)columns[col].get(row);
                   columns[col].remove(row);
  -                
  -                Portlets portlets = (Portlets)data.getUser().getTemp("portlets");
  +                    
  +                Portlets portlets = jdata.getProfile()
  +                                         .getDocument()
  +                                         .getPortlets(customizedSet.getName());
                   if (portlets != null)
                   {
                       for (int i=0; i < portlets.getEntryCount(); i++)
  @@ -529,13 +571,14 @@
               }
           }
   
  -        row = (int)Math.ceil(set.getEntryCount() / colNum);
  +        int sCount = set.getEntryCount();
  +        row = (sCount / colNum) +1;
           if (row > rowNum)
           {
               rowNum = row;
           }
   
  -        Log.debug("Controller customize colNum: "+colNum+ " rowNum: "+rowNum);        
  +        Log.debug("Controller customize colNum: "+colNum+ " rowNum: "+rowNum);    
           // initialize the result position table and the work list
           List[] table = new List[colNum];
           List filler = Collections.nCopies(rowNum+1,null);
  
  
  
  1.3       +125 -37   jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/PanedControllerAction.java
  
  Index: PanedControllerAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/PanedControllerAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PanedControllerAction.java	2001/07/08 20:54:36	1.2
  +++ PanedControllerAction.java	2001/07/22 20:31:11	1.3
  @@ -59,7 +59,6 @@
   import org.apache.jetspeed.portal.PortletController;
   import org.apache.jetspeed.portal.PortletControllerConfig;
   import org.apache.jetspeed.portal.PanedPortletController;
  -import org.apache.jetspeed.portal.PortalState;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
   import org.apache.jetspeed.om.profile.Profile;
   import org.apache.jetspeed.xml.api.portletmarkup.Portlets;
  @@ -75,6 +74,10 @@
   import org.apache.velocity.context.Context;
   
   import java.util.Enumeration;
  +import java.util.Iterator;
  +import java.util.ArrayList;
  +import java.util.List;
  +import java.util.Collections;
   
   /**
    * This action builds a context suitable for controllers portlets
  @@ -168,9 +171,114 @@
           cont.savePaneName(rundata,pane);
       }
   
  +    /** 
  +     * Adds a "pane" portlet object in the context which represents the
  +     * currently selected pane
  +     */
  +    protected void buildCustomizeContext( PortletController controller, 
  +                                       Context context,
  +                                       RunData rundata )
  +    {
  +        super.buildCustomizeContext(controller, context, rundata);
  +        
  +        JetspeedRunData jdata = (JetspeedRunData)rundata;
  +        PortletSet set = (PortletSet)jdata.getCustomized();
  +        
  +        Portlets portlets = jdata.getProfile()
  +                                 .getDocument()
  +                                 .getPortlets(set.getName());
  +
  +        List plist = new ArrayList();
  +        List work = new ArrayList();
  +        List filler = Collections.nCopies(set.size(),null);
  +        plist.addAll(filler);
  +        
  +        for (int i=0; i < portlets.getPortletsCount(); i++)
  +        {
  +            Portlets p = portlets.getPortlets(i);
  +            Layout layout = p.getLayout();
  +            if (layout!=null)
  +            {
  +                try
  +                {
  +                    int pos = Integer.parseInt(layout.getPosition());
  +                    if (pos>=0)
  +                    {
  +                        plist.set(pos,p);
  +                    }
  +                    else
  +                    {
  +                        work.add(p);
  +                    }
  +                }
  +                catch (Exception e)
  +                {
  +                    layout.setPosition(null);
  +                    work.add(p);                    
  +                }
  +            }
  +            else
  +            {
  +                work.add(p);
  +            }
  +        }
  +
  +        for (int i=0; i < portlets.getEntryCount(); i++)
  +        {
  +            Entry p = portlets.getEntry(i);
  +            Layout layout = p.getLayout();
  +            if (layout!=null)
  +            {
  +                try
  +                {
  +                    int pos = Integer.parseInt(layout.getPosition());
  +                    if (pos>=0)
  +                    {
  +                        plist.set(pos,p);
  +                    }
  +                    else
  +                    {
  +                        work.add(p);
  +                    }
  +                }
  +                catch (Exception e)
  +                {
  +                    layout.setPosition(null);
  +                    work.add(p);                    
  +                }
  +            }
  +            else
  +            {
  +                work.add(p);
  +            }
  +        }
  +        
  +        Iterator i = work.iterator();
  +        for(int idx=0;idx < plist.size(); idx++)
  +        {
  +            if (plist.get(idx)==null)
  +            {
  +                if (i.hasNext())
  +                {
  +                    plist.set(idx,i.next());
  +                }
  +                else
  +                {
  +                    plist.remove(idx);
  +                }
  +            }
  +        }
  +        
  +        context.put("portlets",plist);
  +    }
  +
       public void doCancel(RunData data, Context context)
       {
  -        PortalState.reset(data);
  +        ((JetspeedRunData)data).setCustomized(null);
  +        if (((JetspeedRunData)data).getCustomized()==null)
  +        {
  +            data.setScreenTemplate("Home");
  +        }
       }
   
       public void doSave(RunData data, Context context)
  @@ -193,33 +301,6 @@
           doCancel(data,context);
       }
   
  -    /** 
  -     * This method is used to add a new pane in the current controller
  -     * The pane is always added at the end of the current set.
  -     * This methods expects the following parameters to work:
  -     * - paneid: the id a the pane to modify within the current profile
  -     * - title: the title for the new pane to be included
  -     */
  -    public void doAdd(RunData data, Context context)
  -    {
  -        String paneid = data.getParameters().getString("paneid");
  -        String title = data.getParameters().getString("title");
  -        Profile profile = ((JetspeedRunData)data).getProfile();
  -        
  -        if ((paneid != null) && (title != null))
  -        {
  -            Portlets set = profile.getDocument().getPortlets(paneid);
  -            if (set != null)
  -            {
  -                Portlets newset = new Portlets();
  -                Metainfo meta = new Metainfo();
  -                meta.setTitle(title);
  -                newset.setMetainfo(meta);
  -                set.addPortlets(newset);
  -            }
  -        }
  -    }
  -    
       /** Remove a pane from the current set
        *  This method expects the following parameters
        * - paneid: the id a the pane to modify within the current profile
  @@ -227,13 +308,17 @@
        */
       public void doDelete(RunData data, Context context)
       {
  -        String paneid = data.getParameters().getString("paneid");
  +        JetspeedRunData jdata = (JetspeedRunData)data;
  +        PortletSet customizedSet = (PortletSet)jdata.getCustomized();
           int position = data.getParameters().getInt("position",-1);
  -        Profile profile = ((JetspeedRunData)data).getProfile();
  +        Profile profile = jdata.getProfile();
   
  -        if ((paneid != null) && (position > -1))
  +        if (customizedSet == null) return;
  +
  +        if (position > -1)
           {
  -            Portlets set = profile.getDocument().getPortlets(paneid);
  +            Portlets set = profile.getDocument()
  +                                  .getPortlets(customizedSet.getName());
               if (set != null)
               {
                   // first try explicit portlets position
  @@ -313,16 +398,19 @@
        */
       public void doMove(RunData data, Context context, boolean moveUp)
       {
  -        String paneid = data.getParameters().getString("paneid");
  +        JetspeedRunData jdata = (JetspeedRunData)data;
  +        PortletSet customizedSet = (PortletSet)jdata.getCustomized();
           int position = data.getParameters().getInt("position",-1);
  +        Profile profile = jdata.getProfile();
           
  -        Profile profile = ((JetspeedRunData)data).getProfile();
  +        if (customizedSet == null) return;
           
  -        if ((paneid != null) && (position > -1))
  +        if (position > -1)
           {
               int target = -1;
               
  -            Portlets set = profile.getDocument().getPortlets(paneid);
  +            Portlets set = profile.getDocument()
  +                                  .getPortlets(customizedSet.getName());
               Layout targetLayout = null;
               Layout baseLayout = null;
   
  
  
  
  1.3       +0 -1      jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/RowColumnControllerAction.java
  
  Index: RowColumnControllerAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/RowColumnControllerAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RowColumnControllerAction.java	2001/07/08 20:54:37	1.2
  +++ RowColumnControllerAction.java	2001/07/22 20:31:11	1.3
  @@ -57,7 +57,6 @@
   import org.apache.jetspeed.portal.PortletController;
   import org.apache.jetspeed.portal.PortletControllerConfig;
   import org.apache.jetspeed.portal.PanedPortletController;
  -import org.apache.jetspeed.portal.PortalState;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
   import org.apache.jetspeed.om.profile.Profile;
   import org.apache.jetspeed.xml.api.portletmarkup.Portlets;
  
  
  
  1.4       +3 -13     jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/VelocityControllerAction.java
  
  Index: VelocityControllerAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/VelocityControllerAction.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- VelocityControllerAction.java	2001/07/08 20:54:37	1.3
  +++ VelocityControllerAction.java	2001/07/22 20:31:11	1.4
  @@ -54,7 +54,6 @@
    
   package org.apache.jetspeed.modules.actions.controllers;
   
  -import org.apache.jetspeed.portal.PortalState;
   import org.apache.jetspeed.portal.PortletController;
   import org.apache.jetspeed.om.profile.PSMLDocument;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
  @@ -147,11 +146,9 @@
       {
           PortletController controller = (PortletController)context.get( "controller" );
   
  -        String name = controller.getPortlets().getName();
  -        
           // if we're in customization mode for the given set, handle 
           // customization
  -        if ( (name != null) && (name.equals(PortalState.getCustomized(rundata))) )
  +        if (((JetspeedRunData)rundata).getMode()==JetspeedRunData.CUSTOMIZE)
           {
               buildCustomizeContext( controller, context, rundata);
               return;
  @@ -168,13 +165,7 @@
                                             Context context,
                                             RunData rundata )
       {
  -        String name = controller.getPortlets().getName();
  -        String paneid = rundata.getParameters().getString("paneid");
  -        if (paneid == null)
  -        {
  -            paneid = name;
  -        }
  -            
  +        String name = controller.getPortlets().getName();            
           String template = (String)context.get("template");
   
           int dotIdx = template.lastIndexOf('.');
  @@ -191,7 +182,6 @@
           setTemplate(rundata, template);
           
           context.put( "action", controller.getConfig().getInitParameter("action"));
  -        context.put( "paneid", paneid );
       }
   
       /** 
  @@ -207,6 +197,6 @@
        */
       public void doCancel(RunData data, Context context)
       {
  -        PortalState.reset(data);
  +        // nothing to do
       }
   }
  
  
  
  1.4       +1 -5      jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Close.java
  
  Index: Close.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Close.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Close.java	2001/06/16 09:40:36	1.3
  +++ Close.java	2001/07/22 20:31:11	1.4
  @@ -60,7 +60,6 @@
   
   // Jetspeed stuff
   import org.apache.jetspeed.portal.Portlet;
  -import org.apache.jetspeed.portal.PortalState;
   import org.apache.jetspeed.portal.PortletState;
   import org.apache.jetspeed.services.PortletFactory;
   import org.apache.jetspeed.services.Registry;
  @@ -92,9 +91,6 @@
           if (( portlet != null )&&( portlet instanceof PortletState ))
           {
               ((PortletState)portlet).setClosed( true, rundata );
  -        }
  -        
  -        //make sure the portal reset its state
  -        PortalState.reset(rundata);
  +        }        
       }
   }
  
  
  
  1.4       +65 -6     jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Customize.java
  
  Index: Customize.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Customize.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Customize.java	2001/06/16 09:40:36	1.3
  +++ Customize.java	2001/07/22 20:31:11	1.4
  @@ -57,11 +57,17 @@
   // Turbine stuff
   import org.apache.turbine.modules.Action;
   import org.apache.turbine.util.RunData;
  +import org.apache.turbine.util.Log;
   
   // Jetspeed stuff
  -import org.apache.jetspeed.portal.PortalState;
  +import org.apache.jetspeed.portal.Portlet;
  +import org.apache.jetspeed.portal.PortletSet;
  +import org.apache.jetspeed.portal.PortletControl;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
   
  +import java.util.Enumeration;
  +import java.util.Stack;
  +
   /**
    * Handle Customization requests for the current portlet
    * 
  @@ -71,14 +77,67 @@
   {
       public void doPerform( RunData rundata ) throws Exception
       {
  -
  -        String name = ((JetspeedRunData)rundata).getPortlet();
  +        JetspeedRunData jdata = (JetspeedRunData)rundata;
  +        String name = jdata.getPortlet();
           if ( name == null )
           {
  -            return;
  +            //if no portlet specified, customized the default pane
  +            //of the profile
  +            name="0";
  +            jdata.setPortlet(name);
           }
   
  -        PortalState.setMaximized(name, rundata);
  -        PortalState.setCustomized(name, rundata);
  +        Portlet found = null;
  +        Stack sets = new Stack();
  +        sets.push(jdata.getProfile().getRootSet());
  +        
  +        while ((found==null) && (sets.size() > 0))
  +        {
  +            PortletSet set = (PortletSet)sets.pop();
  +            
  +            if (set.getName().equals(name))
  +            {
  +                found = set;
  +            }
  +            else
  +            {
  +                Enumeration en = set.getPortlets();
  +                while((found==null) && en.hasMoreElements())
  +                {
  +                    Portlet p = (Portlet)en.nextElement();
  +                        
  +                    // unstack the controls to find the real PortletSets
  +                    Portlet real = p;
  +                    while (real instanceof PortletControl)
  +                    {
  +                        real = ((PortletControl)p).getPortlet();
  +                    }
  +                        
  +                    if (real instanceof PortletSet)
  +                    {
  +                        if (real.getName().equals(name))
  +                        {
  +                            found=real;
  +                        }
  +                        else
  +                        {
  +                            // we'll explore this set afterwards
  +                            sets.push(real);
  +                        }
  +                    }
  +                    else if (p.getName().equals(name))
  +                    {                        
  +                        found = p;
  +                    }
  +                }
  +            }
  +        }
  +        
  +        if (found!=null)
  +        {
  +            jdata.setCustomized(found);
  +            jdata.setScreenTemplate("Customize");
  +        }
  +        
       }
   }
  
  
  
  1.5       +4 -3      jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Maximize.java
  
  Index: Maximize.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Maximize.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Maximize.java	2001/06/16 09:40:36	1.4
  +++ Maximize.java	2001/07/22 20:31:11	1.5
  @@ -59,7 +59,6 @@
   import org.apache.turbine.util.RunData;
   
   // Jetspeed stuff
  -import org.apache.jetspeed.portal.PortalState;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
   
   
  @@ -77,17 +76,19 @@
       public void doPerform( RunData rundata ) throws Exception
       {
   
  +        JetspeedRunData jdata = (JetspeedRunData)rundata;
  +        
           if( rundata.getUser() == null || !rundata.getUser().hasLoggedIn() )
           {
               return;
           }
   
  -        String name = ((JetspeedRunData)rundata).getPortlet();
  +        String name = jdata.getPortlet();
           if ( name == null )
           {
               return;
           }
   
  -        PortalState.setMaximized(name, rundata);
  +        jdata.setScreenTemplate("Maximize");
       }
   }
  
  
  
  1.7       +8 -5      jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Restore.java
  
  Index: Restore.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Restore.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Restore.java	2001/06/16 09:40:36	1.6
  +++ Restore.java	2001/07/22 20:31:11	1.7
  @@ -62,7 +62,6 @@
   // Jetspeed stuff
   import org.apache.jetspeed.portal.Portlet;
   import org.apache.jetspeed.portal.PortletState;
  -import org.apache.jetspeed.portal.PortalState;
   import org.apache.jetspeed.services.PortletFactory;
   import org.apache.jetspeed.services.Registry;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
  @@ -101,10 +100,14 @@
               // this is most likely a normal occurence, ie portlet was removed
               // from registry, portlet is actually a portlet set, etc...
               Log.debug("Exception occured while trying to get portlet "+name);
  -        }            
  -
  -        // if restore was called because of maximize, remove the maximize state
  -        PortalState.reset(rundata);
  +        }
  +        
  +        // make sure we use the default template
  +        while (((JetspeedRunData)rundata).getCustomized()!=null)
  +        {
  +            ((JetspeedRunData)rundata).setCustomized(null);
  +        }
  +        rundata.setScreenTemplate(null);
       }
   
   }
  
  
  
  1.2       +12 -13    jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeAction.java
  
  Index: CustomizeAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CustomizeAction.java	2001/05/31 17:10:38	1.1
  +++ CustomizeAction.java	2001/07/22 20:31:11	1.2
  @@ -55,19 +55,20 @@
   package org.apache.jetspeed.modules.actions.portlets;
   
   import org.apache.jetspeed.portal.Portlet;
  -import org.apache.jetspeed.portal.PortalState;
   import org.apache.jetspeed.portal.PortletException;
   import org.apache.jetspeed.portal.portlets.VelocityPortlet;
   import org.apache.jetspeed.portal.service.PersistenceService;
   import org.apache.jetspeed.portal.service.ServiceFactory;
   import org.apache.jetspeed.portal.service.ServiceException;
   import org.apache.jetspeed.services.Registry;
  +import org.apache.jetspeed.services.rundata.JetspeedRunData;
   import org.apache.jetspeed.om.newregistry.PortletEntry;
   import org.apache.jetspeed.om.newregistry.Parameter;
   
   // Turbine stuff
   import org.apache.turbine.util.Log;
   import org.apache.turbine.util.RunData;
  +import org.apache.turbine.services.template.TurbineTemplate;
   
   // Velocity Stuff
   import org.apache.velocity.context.Context;
  @@ -96,7 +97,7 @@
                                          RunData rundata )
       {
           // we should first retrieve the portlet to customize
  -        Portlet p = (Portlet)rundata.getSession().getAttribute("customize");
  +        Portlet p = ((JetspeedRunData)rundata).getCustomized();
           
           context.put("action", "portlets.CustomizeAction");
           
  @@ -134,9 +135,12 @@
       /** Clean up the customization state */
       public void doCancel(RunData rundata, Context context)
       {
  -        rundata.getSession().removeAttribute("customize");
           rundata.getSession().removeAttribute("parameters");
  -        PortalState.reset(rundata);
  +        ((JetspeedRunData)rundata).setCustomized(null);
  +        if (((JetspeedRunData)rundata).getCustomized()==null)
  +        {
  +            rundata.setScreenTemplate("Home");
  +        }
       }
   
       /** Updates the customized portlet entry */
  @@ -144,13 +148,12 @@
       {
           // we should first retrieve the portlet to customize and its parameters
           // definition
  -        Portlet p = (Portlet)rundata.getSession().getAttribute("customize");
  +        Portlet p = ((JetspeedRunData)rundata).getCustomized();
           List params = (List)rundata.getSession().getAttribute("parameters");
   
           if ((p==null)||(params==null))
           {
  -            //default to build normal
  -            buildNormalContext(null,context,rundata);
  +            doCancel(rundata, context);
               return;
           }
           
  @@ -183,7 +186,6 @@
                       // only update if the value changed
                       if (!newValue.equals(p.getPortletConfig().getInitParameter(name)))
                       {
  -                        Log.note("Changing attribute "+name+" to "+newValue);
                           page.setAttribute(name,newValue);
                           p.getPortletConfig().setInitParameter(name,newValue);
                       }
  @@ -206,14 +208,11 @@
   
               // we're done, make sure clean up the
               // session
  -            rundata.getSession().removeAttribute("customize");
  -            rundata.getSession().removeAttribute("parameters");
  -            PortalState.reset(rundata);
  +            doCancel(rundata, context);
           }
           catch (ServiceException e)
           {
               Log.error(e);
  -        }
  -        
  +        }        
       }
   }
  
  
  
  1.6       +156 -63   jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeSetAction.java
  
  Index: CustomizeSetAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeSetAction.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CustomizeSetAction.java	2001/07/11 09:36:27	1.5
  +++ CustomizeSetAction.java	2001/07/22 20:31:11	1.6
  @@ -58,10 +58,10 @@
   import org.apache.jetspeed.portal.PortletSkin;
   import org.apache.jetspeed.portal.PortletController;
   import org.apache.jetspeed.portal.PortletSetController;
  -import org.apache.jetspeed.portal.PortalState;
   import org.apache.jetspeed.portal.portlets.VelocityPortlet;
   import org.apache.jetspeed.services.Registry;
   import org.apache.jetspeed.services.PortalToolkit;
  +import org.apache.jetspeed.services.TemplateLocator;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
   import org.apache.jetspeed.om.profile.Profile;
   import org.apache.jetspeed.om.newregistry.PortletEntry;
  @@ -76,6 +76,7 @@
   // Turbine stuff
   import org.apache.turbine.util.Log;
   import org.apache.turbine.util.RunData;
  +import org.apache.turbine.services.template.TurbineTemplate;
   
   // Velocity Stuff
   import org.apache.velocity.context.Context;
  @@ -97,7 +98,6 @@
    */
   public class CustomizeSetAction extends VelocityPortletAction
   {
  -
       /** 
        * Subclasses must override this method to provide default behavior 
        * for the portlet action
  @@ -107,48 +107,134 @@
                                          RunData rundata )
       {
           // we should first retrieve the portlet to customize
  -        PortletSet set = (PortletSet)rundata.getSession().getAttribute("customize");
  -                
  -        if (set==null) return;
  +        PortletSet set = (PortletSet)((JetspeedRunData)rundata).getCustomized();
  +
  +        //identify the portlet submode and build the appropriate subt-template path
  +        String mode = rundata.getParameters().getString("mode");
  +        if (mode == null)
  +        {
  +            mode = (String)rundata.getUser().getTemp("mode");
  +            if (mode == null) mode = "layout";
  +        }
  +        else
  +        {
  +            rundata.getUser().setTemp("mode",mode);
  +        }
           
  -        // retrieve the portlet parameters
  +        String template = (String)context.get("template");
  +
  +        if (template!=null)
  +        {
  +            int idx=template.lastIndexOf(".");
  +            StringBuffer buffer = new StringBuffer(template);
  +            if (idx>0)
  +            {
  +                template = template.substring(0,idx);
  +            }
  +            buffer.append("-").append(mode).append(".vm");
  +            
  +            template = TemplateLocator.locatePortletTemplate(rundata, buffer.toString());
  +            context.put("feature",template);
  +        }
  +    
  +        if (set==null) return;
  +
  +        // generic context stuff
  +        context.put("skin", set.getPortletConfig().getPortletSkin());
  +        context.put("set", set);
  +        context.put("action","portlets.CustomizeSetAction");        
           context.put("controllers",Registry.get(Registry.PORTLET_CONTROLLER).toArray());
           context.put("skins",Registry.get(Registry.SKIN).toArray());
           context.put("currentController", set.getController().getConfig().getName());
           context.put("currentSkin", set.getPortletConfig().getPortletSkin().getName());
  -        context.put("skin", set.getPortletConfig().getPortletSkin());
  -        context.put("set", set);
  -        context.put("action","portlets.CustomizeSetAction");
  -        
  -        if (!(set.getController() instanceof PortletSetController))
  +
  +        if (set.getController() instanceof PortletSetController)
           {
  -            context.put("browser", buildPortletList(rundata,set));
  +            context.put("allowpane","true");
           }
  +        else
  +        {
  +            context.put("allowportlet", "true");
  +            context.put("allowpane","true");
  +        }
  +            
  +        if ("add".equals(mode)) // build context for add mode
  +        {
  +            List portlets  = buildPortletList(rundata,set);
  +            int start = rundata.getParameters().getInt("start",0);                
  +            int size = 15;
  +                
  +            try
  +            {
  +                size = Integer.parseInt(portlet.getPortletConfig()
  +                                               .getInitParameter("size"));
  +            }
  +            catch (Exception e)
  +            {
  +                // ignore
  +            }
  +                
  +            int end = Math.min(start+size, portlets.size());
  +                
  +            if (start > 0)
  +            {
  +                context.put("prev",String.valueOf(Math.max(start - size,0)));
  +            }
  +                
  +            if (start + size < portlets.size() )
  +            {
  +                context.put("next",String.valueOf(start + size));
  +            }
  +                
  +            context.put("browser", portlets.subList(start,end));
  +        }
  +        else                         // build context for layout mode
  +        {
  +            // nothing specific to do
  +        }
  +
       }
   
       /** Clean up the customization state */
       public void doCancel(RunData rundata, Context context)
       {
  -        rundata.getSession().removeAttribute("customize");
  -        PortalState.reset(rundata);
  +        ((JetspeedRunData)rundata).setCustomized(null);
  +        if (((JetspeedRunData)rundata).getCustomized()==null)
  +        {
  +            rundata.setScreenTemplate("Home");
  +        }
       }
   
  +    /** Save the general informations for this set */
       public void doSave(RunData rundata, Context context)
       {
  -        doLayout(rundata, context);
  -        doSkin(rundata, context);
  -        //doMetainfo(rundata, context);
  +        doMetainfo(rundata,context);
  +        doSkin(rundata,context);
  +        doLayout(rundata,context);
  +        
  +        Profile profile = ((JetspeedRunData)rundata).getProfile();
  +        try
  +        {
  +            profile.store();
  +        }
  +        catch (Exception e)
  +        {
  +            Log.error("Exception occured while saving PSML",e);
  +        }
  +
       }
       
  +    /** Save customizations and get out of customization state */
       public void doApply(RunData rundata, Context context)
       {
           doSave(rundata, context);
           doCancel(rundata, context);
       }
       
  +    /** Add a new portlets element in the customized set */
       public void doAddset(RunData rundata, Context context)
       {
  -        PortletSet set = (PortletSet)rundata.getSession().getAttribute("customize");
  +        PortletSet set = (PortletSet)((JetspeedRunData)rundata).getCustomized();
           String title = rundata.getParameters().getString("title","My Pane");
           
           if (set!=null)
  @@ -165,56 +251,85 @@
                   portlets.addPortlets(p);
               }
           }
  +
  +        rundata.getUser().setTemp("mode","layout");
       }
       
  +    /** Add new portlets in the customized set */
       public void doAdd(RunData rundata, Context context)
       {
  -        PortletSet set = (PortletSet)rundata.getSession().getAttribute("customize");
  -        String pname = rundata.getParameters().getString("pname");
  +        PortletSet set = (PortletSet)((JetspeedRunData)rundata).getCustomized();
  +        String[] pnames = rundata.getParameters().getStrings("pname");
           
  -        if ( (pname!=null) && (set!=null) )
  +        if ( (pnames!=null) && (set!=null) )
           {
               Portlets portlets = ((JetspeedRunData)rundata).getProfile()
                                               .getDocument()
                                               .getPortlets(set.getName());
  -            
  -            PortletEntry entry = (PortletEntry)Registry.getEntry(Registry.PORTLET, pname);
  -            if ((entry!=null) && (portlets != null))
  +            for(int i=0;i < pnames.length; i++)
               {
  -                Entry p = new Entry();
  -                p.setParent(pname);
  -                portlets.addEntry(p);
  +                PortletEntry entry = (PortletEntry)Registry.getEntry(Registry.PORTLET, pnames[i]);
  +                if ((entry!=null) && (portlets != null))
  +                {
  +                    Entry p = new Entry();
  +                    p.setParent(pnames[i]);
  +                    portlets.addEntry(p);
  +                }
               }
           }
  +        rundata.getUser().setTemp("mode","layout");
       }
       
  +    /** Sets the metainfo for this entry */
  +    public void doMetainfo(RunData rundata, Context context)
  +    {
  +        PortletSet set = (PortletSet)((JetspeedRunData)rundata).getCustomized();
  +        String title = rundata.getParameters().getString("title");
  +
  +        if ( set!=null )
  +        {
  +            Portlets portlets = ((JetspeedRunData)rundata).getProfile()
  +                                            .getDocument()
  +                                            .getPortlets(set.getName());
  +            
  +            if (portlets!=null)
  +            {
  +                Metainfo meta = portlets.getMetainfo();
  +                if (meta==null)
  +                {
  +                    meta = new Metainfo();
  +                    portlets.setMetainfo(meta);
  +                }
  +            
  +                if (title!=null)
  +                {
  +                    meta.setTitle(title);
  +                    set.setTitle(title);
  +                }
  +            }
  +        }
  +    }
  +
       /** Updates the customized portlet entry */
       public void doLayout(RunData rundata, Context context)
       {
           // we should first retrieve the portlet to customize and its parameters
           // definition
  -        PortletSet set = (PortletSet)rundata.getSession().getAttribute("customize");
  +        PortletSet set = (PortletSet)((JetspeedRunData)rundata).getCustomized();
           
  -        if (set==null)
  -        {
  -            //default to build normal
  -            buildNormalContext(null,context,rundata);
  -            return;
  -        }
  -        
           try
           {            
               String controller = rundata.getParameters().getString("controller");
               
               if (controller!=null)
               {
  +                Profile profile = ((JetspeedRunData)rundata).getProfile();
                   PortletController pc = PortalToolkit.getController(controller);
   
                   if (pc!=null)
                   {
                       set.setController(pc);
   
  -                    Profile profile = ((JetspeedRunData)rundata).getProfile();
                       Portlets portlets = profile.getDocument().getPortlets(set.getName());
   
                       Controller c = portlets.getController();
  @@ -224,15 +339,6 @@
                           portlets.setController(c);
                       }
                       c.setName(controller);                    
  -                    
  -                    try
  -                    {
  -                        profile.store();
  -                    }
  -                    catch (Exception e)
  -                    {
  -                        Log.error("Exception occured while saving PSML",e);
  -                    }
                   }
               }
           }
  @@ -248,14 +354,7 @@
       {
           // we should first retrieve the portlet to customize and its parameters
           // definition
  -        PortletSet set = (PortletSet)rundata.getSession().getAttribute("customize");
  -        
  -        if (set==null)
  -        {
  -            //default to build normal
  -            buildNormalContext(null,context,rundata);
  -            return;
  -        }
  +        PortletSet set = (PortletSet)((JetspeedRunData)rundata).getCustomized();
           
           try
           {            
  @@ -278,15 +377,6 @@
                           portlets.setSkin(new Skin());
                       }
                       portlets.getSkin().setName(skin);
  -                    
  -                    try
  -                    {
  -                        profile.store();
  -                    }
  -                    catch (Exception e)
  -                    {
  -                        Log.error("Exception occured while saving PSML",e);
  -                    }
                   }
               }
           }
  @@ -329,7 +419,10 @@
               PortletEntry entry = (PortletEntry)Registry.getEntry(Registry.PORTLET,
                                                                    (String)i.next());
               
  -            if ((!entry.isHidden()) && entry.hasMediaType(mediaName))
  +            //FIXME: we should add security testing
  +            if ((!entry.isHidden()) 
  +                && (!entry.getType().equals(PortletEntry.TYPE_ABSTRACT))
  +                && entry.hasMediaType(mediaName))
               {
                   list.add(entry);
               }
  
  
  
  1.8       +12 -4     jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/VelocityPortletAction.java
  
  Index: VelocityPortletAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/VelocityPortletAction.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- VelocityPortletAction.java	2001/07/11 09:36:27	1.7
  +++ VelocityPortletAction.java	2001/07/22 20:31:11	1.8
  @@ -55,7 +55,7 @@
   package org.apache.jetspeed.modules.actions.portlets;
   
   import org.apache.jetspeed.portal.portlets.VelocityPortlet;
  -import org.apache.jetspeed.portal.PortalState;
  +import org.apache.jetspeed.services.rundata.JetspeedRunData;
   
   // Turbine stuff
   import org.apache.turbine.util.Log;
  @@ -153,27 +153,35 @@
           throws Exception
       {
           VelocityPortlet portlet = null;
  +        JetspeedRunData jdata = (JetspeedRunData)rundata;
           
  +        Log.debug("VelocityAction: retrieved context: "+context);
           if (context != null)
               portlet = (VelocityPortlet)context.get( "portlet" );
   
  +        Log.debug("VelocityAction: retrieved portlet: "+portlet);
           if (portlet != null)
           {
               // we're bein configured
  -            if ( portlet.getName().equals( PortalState.getCustomized( rundata ) ) )
  +            if  ( ( jdata.getMode()==jdata.CUSTOMIZE ) 
  +                && (portlet.getName().equals(jdata.getCustomized().getName())) )
               {
  +                Log.debug("VelocityAction: building customize");
                   buildConfigureContext( portlet, context, rundata);
                   return;
               }
               
               // we're maximized
  -            if ( portlet.getName().equals( PortalState.getMaximized( rundata ) ) )
  +            if ( jdata.getMode()==jdata.MAXIMIZE )
               {
  +                Log.debug("VelocityAction: building maximize");
                   buildMaximizedContext( portlet, context, rundata);
                   return;
               }
  +
  +            Log.debug("VelocityAction: building normal");
  +            buildNormalContext( portlet, context, rundata);
           }        
  -        buildNormalContext( portlet, context, rundata);
       }
   
       /** 
  
  
  
  1.15      +5 -1      jakarta-jetspeed/src/java/org/apache/jetspeed/modules/pages/JetspeedTemplatePage.java
  
  Index: JetspeedTemplatePage.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/pages/JetspeedTemplatePage.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- JetspeedTemplatePage.java	2001/07/07 21:10:23	1.14
  +++ JetspeedTemplatePage.java	2001/07/22 20:31:11	1.15
  @@ -72,6 +72,7 @@
   import org.apache.jetspeed.capability.CapabilityMap;
   import org.apache.jetspeed.capability.CapabilityMapFactory;
   import org.apache.jetspeed.services.TemplateLocator;
  +import org.apache.jetspeed.services.rundata.JetspeedRunData;
   
   //<Temporary FIX: new turbine will make it obsolete>        
   import org.apache.turbine.services.localization.LocaleDetector;
  @@ -125,7 +126,7 @@
    *
    * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
    * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
  - * @version $Id: JetspeedTemplatePage.java,v 1.14 2001/07/07 21:10:23 taylor Exp $
  + * @version $Id: JetspeedTemplatePage.java,v 1.15 2001/07/22 20:31:11 raphael Exp $
    */
   public class JetspeedTemplatePage extends DefaultPage
   {
  @@ -159,6 +160,9 @@
               
               String template = data.getTemplateInfo().getScreenTemplate();
   
  +            //save the initial requested template before mangling it
  +            ((JetspeedRunData)data).setRequestedTemplate(template);
  +            
               if (template.lastIndexOf('.')<0)
               {
                   template=template+"."+ext;
  
  
  
  1.4       +2 -2      jakarta-jetspeed/src/java/org/apache/jetspeed/om/profile/BasePSMLDocument.java
  
  Index: BasePSMLDocument.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/profile/BasePSMLDocument.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BasePSMLDocument.java	2001/07/17 16:40:59	1.3
  +++ BasePSMLDocument.java	2001/07/22 20:31:11	1.4
  @@ -64,7 +64,7 @@
    * document.
    *
    * @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
  - * @version $Id: BasePSMLDocument.java,v 1.3 2001/07/17 16:40:59 taylor Exp $
  + * @version $Id: BasePSMLDocument.java,v 1.4 2001/07/22 20:31:11 raphael Exp $
    */
   public class BasePSMLDocument implements PSMLDocument
   {
  @@ -99,7 +99,7 @@
           this.name = name;
           this.portlets = portlets;
       }
  -
  +    
       /**
        * Return the name of this document
        */
  
  
  
  1.5       +90 -25    jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTemplateLink.java
  
  Index: JetspeedTemplateLink.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTemplateLink.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JetspeedTemplateLink.java	2001/06/11 07:06:27	1.4
  +++ JetspeedTemplateLink.java	2001/07/22 20:31:11	1.5
  @@ -55,32 +55,36 @@
   package org.apache.jetspeed.util.template;
   
   import org.apache.turbine.util.RunData;
  +import org.apache.turbine.util.Log;
   import org.apache.turbine.util.DynamicURI;
   import org.apache.turbine.util.template.TemplateLink;
   import org.apache.turbine.services.pull.ApplicationTool;
   
  +import org.apache.jetspeed.services.rundata.JetspeedRunData;
  +
  +
   /**
    * A customized version of the TemplateLink which can handle portlet
    * references.
    * It is inserted into the template context by the JetspeedVelocityPage.
    *
    * @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
  - * @version $Id: JetspeedTemplateLink.java,v 1.4 2001/06/11 07:06:27 taylor Exp $
  + * @version $Id: JetspeedTemplateLink.java,v 1.5 2001/07/22 20:31:11 raphael Exp $
    */
   public class JetspeedTemplateLink
  -    extends TemplateLink
  +    extends TemplateLink implements ApplicationTool
   {
           
  -    // The portlet name for this link
  -    private String portlet = null;
  -
       // parameter names for the Jetspeed framework elements    
  -    private static final String PORTLET_KEY = "portlet";
  -    private static final String ACTION_KEY = "action";
  -    private static final String SCREEN_KEY = "screen";
  -    private static final String TEMPLATE_KEY = "template";
  -    private static final String PANEL_KEY = "select-panel";        
  -
  +    public static final String PORTLET_KEY = "portlet";
  +    public static final String ACTION_KEY = "action";
  +    public static final String SCREEN_KEY = "screen";
  +    public static final String TEMPLATE_KEY = "template";
  +    public static final String PANEL_KEY = "select-panel";        
  +    
  +    private String portlet = null;
  +    private JetspeedRunData data = null;
  +    
       /**
        * Empty constructor.for introspection
        */
  @@ -96,53 +100,99 @@
       public JetspeedTemplateLink(RunData data)
       {
           super(data);
  +        this.data = (JetspeedRunData)data;
  +
  +        String tmpl = this.data.getRequestedTemplate();
  +        if (tmpl!=null)
  +        {
  +            setPage(tmpl);
  +        }
       }
   
  +    /**
  +     * This will initialise a JetspeedTool object that was
  +     * constructed with the default constructor (ApplicationTool
  +     * method).
  +     *
  +     * @param data assumed to be a RunData object
  +     */
  +    public void init(Object data)
  +    {
  +        super.init(data);
  +        this.data = (JetspeedRunData)data;
  +
  +        String tmpl = this.data.getRequestedTemplate();
  +        if (tmpl!=null)
  +        {
  +            setPage(tmpl);
  +        }
  +    }
  +
  +    /**
  +     * Refresh method - does nothing
  +     */
  +    public void refresh()
  +    {
  +        super.refresh();
  +
  +        String tmpl = this.data.getRequestedTemplate();
  +        if (tmpl!=null)
  +        {
  +            setPage(tmpl);
  +        }
  +    }
  +
       /** 
        * Add a portlet reference in the link
        *
        * @param portlet the name of the portlet to link to
        * @return a self reference for easy link construction in template
        */
  -    public DynamicURI setPortlet(String portlet) {
  -        this.portlet = portlet;
  +    public DynamicURI setPortlet(String portlet)
  +    {
  +        this.portlet=portlet;
  +        removePathInfo(getPortletKey());
  +        removeQueryData(getPortletKey());
           return addPathInfo(getPortletKey(), portlet);
       }
       
       /** 
  -     * Get the portlet reference for this link
  -     *
  -     * @return the portlet name for this link
  +     * @return the portlet parameter value
        */
  -    public String getPortlet() {
  +    public String getPortlet()
  +    {
           return this.portlet;
       }
  -
  +    
       /** 
        * @return the portlet parameter name
        */
  -    public String getPortletKey() {
  +    public String getPortletKey()
  +    {
           return PORTLET_KEY;
       }
       
       /** 
        * @return the action parameter name
        */
  -    public String getActionKey() {
  +    public String getActionKey()
  +    {
           return ACTION_KEY;
       }
       
       /** 
        * @return the screen parameter name
        */
  -    public String getScreenKey() {
  +    public String getScreenKey()
  +    {
           return SCREEN_KEY;
       }
       
       /** 
        * @return the template parameter name
        */
  -    public String getPageKey() {
  +    public String getPageKey()
  +    {
           return TEMPLATE_KEY;
       }
   
  @@ -152,15 +202,30 @@
        * @param portlet the name of the portlet to link to
        * @return a self reference for easy link construction in template
        */
  -    public DynamicURI setPanel(String panel) {
  +    public DynamicURI setPanel(String panel)
  +    {
  +        removePathInfo(getPanelKey());
  +        removeQueryData(getPanelKey());
           return addPathInfo(getPanelKey(), panel);
       }
       
        /** 
        * @return the panel parameter name
        */
  -    public String getPanelKey() {
  +    public String getPanelKey()
  +    {
           return PANEL_KEY;
  +    }    
  +    
  +    public String toString()
  +    {
  +        String buf = super.toString();
  +        String tmpl = this.data.getRequestedTemplate();
  +        if (tmpl!=null)
  +        {
  +            setPage(tmpl);
  +        }
  +        
  +        return buf;
       }
  -
   }
  
  
  
  1.10      +111 -13   jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTool.java
  
  Index: JetspeedTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTool.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JetspeedTool.java	2001/07/17 16:46:14	1.9
  +++ JetspeedTool.java	2001/07/22 20:31:11	1.10
  @@ -59,6 +59,10 @@
   import org.apache.turbine.util.Log;
   import org.apache.turbine.util.RunData;
   import org.apache.turbine.services.pull.ApplicationTool;
  +import org.apache.jetspeed.portal.Portlet;
  +import org.apache.jetspeed.portal.PortletSet;
  +import org.apache.jetspeed.portal.PortletControl;
  +import org.apache.jetspeed.portal.PortletCustomizer;
   import org.apache.jetspeed.services.PortalToolkit;
   import org.apache.jetspeed.services.PsmlManager;
   import org.apache.jetspeed.services.PortletFactory;
  @@ -70,6 +74,9 @@
   import org.apache.jetspeed.om.profile.ProfileException;
   import org.apache.jetspeed.xml.api.portletmarkup.Entry;
   
  +import java.util.Enumeration;
  +import java.util.Stack;
  +
   /**
    * Utility class for accessing Jetspeed in a "pull" mode
    * This class currently does not implement the ApplicationTool interface
  @@ -80,7 +87,7 @@
    * shared between threads and/or requests</strong>
    *
    * @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
  - * @version $Id: JetspeedTool.java,v 1.9 2001/07/17 16:46:14 taylor Exp $
  + * @version $Id: JetspeedTool.java,v 1.10 2001/07/22 20:31:11 raphael Exp $
    */
   public class JetspeedTool implements ApplicationTool
   {
  @@ -135,8 +142,8 @@
        */
       public ConcreteElement getPane(String name)
       {
  -        ConcreteElement result = new ConcreteElement();
  -
  +        ConcreteElement result = null;
  +        
           if (null != rundata)
           {
               Profile profile = rundata.getProfile();
  @@ -164,6 +171,11 @@
                   Log.error(e);
               }
           }
  +        
  +        if (result == null)
  +        {
  +            result = new ConcreteElement();
  +        }
   
           return result;
       }
  @@ -180,25 +192,111 @@
        */
       public ConcreteElement getPortlet(String name)
       {
  -        ConcreteElement result = new ConcreteElement();
  +        ConcreteElement result = null;
  +        Portlet found = null;
  +        Stack sets = new Stack();
  +        sets.push(rundata.getProfile().getRootSet());
           
  -        PSMLDocument doc = rundata.getProfile().getDocument();
  -
  -        try
  +        while ((sets.size() > 0) && (found==null))
           {
  -            Entry entry  = doc.getEntry(name);
  +            PortletSet set = (PortletSet)sets.pop();
               
  -            if (entry != null)
  +            if (set.getName().equals(name))
  +            {
  +                found = set;
  +            }
  +            else
               {
  -                result = PortletFactory.getPortlet(entry).getContent(rundata);
  +                Enumeration en = set.getPortlets();
  +                while((found==null) && en.hasMoreElements())
  +                {
  +                    Portlet p = (Portlet)en.nextElement();
  +                        
  +                    // unstack the controls to find the real PortletSets
  +                    Portlet real = p;
  +                    while (real instanceof PortletControl)
  +                    {
  +                        real = ((PortletControl)p).getPortlet();
  +                    }
  +                        
  +                    if (real instanceof PortletSet)
  +                    {
  +                        // we'll explore this set afterwards
  +                        sets.push(real);
  +                    }
  +                    else if (p.getName().equals(name))
  +                    {                        
  +                        found = p;
  +                    }
  +                }
               }
           }
  -        catch (Exception e)
  +        
  +        if (found!=null)
           {
  -            Log.error(e);
  -            return new StringElement( e.toString() );
  +            result = found.getContent(rundata);
           }
           
  +        if (result==null)
  +        {
  +            //the customizer already streamed its content, return a stub
  +            result = new ConcreteElement();
  +        }
  +
           return result;
  +    }
  +
  +    /** This method retrieves the appropriate customizer portlet for the 
  +     *  current portlet
  +     *
  +     *  @param p the portlet to customize
  +     *  @param data the RunData for this request
  +     *  @return the portlet object of the appropriate customizer
  +     */
  +    public static Portlet getCustomizer(Portlet p)
  +    {
  +        Portlet customizer = p;
  +
  +        while (p instanceof PortletControl)
  +        {
  +            p = ((PortletControl)p).getPortlet();
  +        }
  +        
  +        // if the portlet cannot customize itself...
  +        if (! (p instanceof PortletCustomizer) )
  +        {
  +
  +            //look for the customizer name in the portlet
  +            //config (from Registry definition)
  +        
  +            String name = p.getPortletConfig().getInitParameter("_customizer");
  +            
  +            if (name == null)
  +            {
  +                String key = (p instanceof PortletSet)?"PortletSet":"Portlet";            
  +
  +                name = JetspeedResources.getString("customizer."+key,key+"Customizer");
  +            }
  +        
  +            try
  +            {
  +                customizer = PortletFactory.getPortlet(name);
  +                customizer.getPortletConfig()
  +                          .setPortletSkin(p.getPortletConfig().getPortletSkin());
  +                PortletControl control = PortalToolkit.getControl((String)null);
  +                if (control!=null)
  +                {
  +                    control.setPortlet(customizer);
  +                    control.init();
  +                    return control;
  +                }
  +            }
  +            catch (Exception e)
  +            {
  +                Log.error(e);
  +            }
  +        }
  +            
  +        return customizer;
       }
   }
  
  
  

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