portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/containers window-accessor-container.groovy aggregator-container.groovy
Date Wed, 31 Mar 2004 06:19:08 GMT
taylor      2004/03/30 22:19:08

  Modified:    portal/src/java/org/apache/jetspeed/container/url/impl
                        PortalControlParameter.java PortalURLImpl.java
               portal/src/java/org/apache/jetspeed/container/session
                        NavigationalStateComponent.java
               portal/src/java/org/apache/jetspeed/container/url
                        PortalURL.java
               portal/src/java/org/apache/jetspeed/container/session/impl
                        PathNavigationalState.java
                        SessionNavigationalState.java
                        JetspeedNavigationalStateComponent.java
               portal/src/java/org/apache/jetspeed/request
                        JetspeedRequestContextComponent.java
               portal/src/java/org/apache/jetspeed/engine
                        JetspeedEngine.java
               portal/src/java/org/apache/jetspeed/containers
                        window-accessor-container.groovy
                        aggregator-container.groovy
  Log:
  made navigational state render parameter names configurable
  started second implmentation (session) of nav state
  continued decoupling/refactoring of Path Navigational state
  
  PR:
  Obtained from:
  Submitted by:	
  Reviewed by:	
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.2       +129 -135  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/url/impl/PortalControlParameter.java
  
  Index: PortalControlParameter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/url/impl/PortalControlParameter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PortalControlParameter.java	31 Mar 2004 01:19:24 -0000	1.1
  +++ PortalControlParameter.java	31 Mar 2004 06:19:08 -0000	1.2
  @@ -25,9 +25,8 @@
   import javax.portlet.WindowState;
   
   import org.apache.jetspeed.Jetspeed;
  -import org.apache.jetspeed.container.session.impl.*;
  +import org.apache.jetspeed.container.session.NavigationalStateComponent;
   import org.apache.jetspeed.container.url.*;
  -import org.apache.jetspeed.container.url.impl.*;
   import org.apache.jetspeed.container.window.PortletWindowAccessor;
   import org.apache.pluto.om.window.PortletWindow;
   import org.apache.pluto.util.StringUtils;
  @@ -43,135 +42,18 @@
    */
   public class PortalControlParameter
   {
  -    static public final String ACTION = "ac";
   
  -    static public final String MODE = "md";
  -    static public final String PREFIX = "_";
  -    static public final String PREV_MODE = "pm";
  -    static public final String PREV_STATE = "ps";
  -    static public final String RENDER_PARAM = "rp";
  -    static public final String STATE = "st";
  -    static public final String KEY_DELIMITER = ":";
  -    static public final String PORTLET_ID = "pid";
  -
  -    public static String decodeParameterName(String paramName)
  -    {
  -        return paramName.substring(PREFIX.length());
  -    }
  -
  -    public static String decodeParameterValue(String paramName, String paramValue)
  -    {
  -        return paramValue;
  -    }
  -
  -    private static String decodeRenderParamName(String encodedParamName)
  -    {
  -        StringTokenizer tokenizer = new StringTokenizer(encodedParamName, "_");
  -        if (!tokenizer.hasMoreTokens())
  -            return null;
  -        String constant = tokenizer.nextToken();
  -        if (!tokenizer.hasMoreTokens())
  -            return null;
  -        String objectId = tokenizer.nextToken();
  -        if (!tokenizer.hasMoreTokens())
  -            return null;
  -        String name = tokenizer.nextToken();
  -        return name;
  -    }
  -
  -    private static String[] decodeRenderParamValues(String encodedParamValues)
  -    {
  -        StringTokenizer tokenizer = new StringTokenizer(encodedParamValues, "_");
  -        if (!tokenizer.hasMoreTokens())
  -            return null;
  -        String _count = tokenizer.nextToken();
  -        int count = Integer.valueOf(_count).intValue();
  -        String[] values = new String[count];
  -        for (int i = 0; i < count; i++)
  -        {
  -            if (!tokenizer.hasMoreTokens())
  -                return null;
  -            values[i] = decodeValue(tokenizer.nextToken());
  -        }
  -        return values;
  -    }
  -
  -    private static String decodeValue(String value)
  -    {
  -        value = StringUtils.replace(value, "0x1", "_");
  -        value = StringUtils.replace(value, "0x2", ".");
  -        return value;
  -    }
  -
  -    public static String encodeParameter(String param)
  -    {
  -        return PREFIX + param;
  -    }
  -
  -    public static String encodeRenderParamName(PortletWindow window, String paramName)
  -    {
  -        StringBuffer returnvalue = new StringBuffer(50);
  -        returnvalue.append(RENDER_PARAM);
  -        returnvalue.append("_");
  -        returnvalue.append(window.getId().toString());
  -        returnvalue.append("_");
  -        returnvalue.append(paramName);
  -        return returnvalue.toString();
  -    }
  -
  -    public static String encodeRenderParamValues(String[] paramValues)
  -    {
  -        StringBuffer returnvalue = new StringBuffer(100);
  -        returnvalue.append(paramValues.length);
  -        for (int i = 0; i < paramValues.length; i++)
  -        {
  -            returnvalue.append("_");
  -            returnvalue.append(encodeValue(paramValues[i]));
  -        }
  -        return returnvalue.toString();
  -    }
  -
  -    private static String encodeValue(String value)
  -    {
  -        value = StringUtils.replace(value, "_", "0x1");
  -        value = StringUtils.replace(value, ".", "0x2");
  -        return value;
  -    }
  -
  -    public static String getRenderParamKey(PortletWindow window)
  -    {
  -        return RENDER_PARAM + "_" + window.getId().toString();
  -    }
  -
  -    public static boolean isControlParameter(String param)
  -    {
  -        return param.startsWith(PREFIX);
  -    }
  -
  -    public static boolean isStateFullParameter(String param)
  -    {
  -        if (isControlParameter(param))
  -        {
  -            if ((param.startsWith(PREFIX + MODE))
  -                || (param.startsWith(PREFIX + PREV_MODE))
  -                || (param.startsWith(PREFIX + STATE))
  -                || (param.startsWith(PREFIX + PREV_STATE))
  -                || (param.startsWith(PREFIX + RENDER_PARAM)))
  -            {
  -                return true;
  -            }
  -        }
  -        return false;
  -    }
       private Map requestParameter = new HashMap();
       private Map stateFullControlParameter = null;
       private Map stateLessControlParameter = null;
  -
  +    private NavigationalStateComponent nav;
       private PortalURL url;
   
  -    public PortalControlParameter(PortalURL url)
  +    public PortalControlParameter(PortalURL url, NavigationalStateComponent nav)
       {
  +        this.nav = nav;
           this.url = url;
  +        url.setControlParameter(this);        
           stateFullControlParameter = ((PortalURLImpl)this.url).getClonedStateFullControlParameter();
           stateLessControlParameter = ((PortalURLImpl) this.url).getClonedStateLessControlParameter();
       }
  @@ -192,8 +74,8 @@
       }
   
       private String getActionKey(PortletWindow window)
  -    {
  -        return ACTION + "_" + window.getId().toString();
  +    {        
  +        return nav.getNavigationKey(NavigationalStateComponent.ACTION) + "_" + window.getId().toString();
       }
   
       public PortletMode getMode(PortletWindow window)
  @@ -207,7 +89,7 @@
   
       private String getModeKey(PortletWindow window)
       {
  -        return MODE + "_" + window.getId().toString();
  +        return nav.getNavigationKey(NavigationalStateComponent.MODE) + "_" + window.getId().toString();
       }
   
       public PortletWindow getPortletWindowOfAction() 
  @@ -217,9 +99,9 @@
           while (iterator.hasNext())
           {
               String name = (String) iterator.next();
  -            if (name.startsWith(ACTION))
  +            if (name.startsWith(nav.getNavigationKey(NavigationalStateComponent.ACTION)))
               {
  -                String id = name.substring(ACTION.length() + 1);
  +                String id = name.substring(nav.getNavigationKey(NavigationalStateComponent.ACTION).length()
+ 1);
                   /*
                   
                   TODO: BROKEN: need to go the profiler to get the profile, psml, and then
window for an entity
  @@ -275,7 +157,7 @@
       }
       private String getPrevModeKey(PortletWindow window)
       {
  -        return PREV_MODE + "_" + window.getId().toString();
  +        return nav.getNavigationKey(NavigationalStateComponent.PREV_MODE) + "_" + window.getId().toString();
       }
   
       public WindowState getPrevState(PortletWindow window)
  @@ -288,7 +170,7 @@
       }
       private String getPrevStateKey(PortletWindow window)
       {
  -        return PREV_STATE + "_" + window.getId().toString();
  +        return nav.getNavigationKey(NavigationalStateComponent.PREV_STATE) + "_" + window.getId().toString();
       }
   
       public Iterator getRenderParamNames(PortletWindow window)
  @@ -337,7 +219,7 @@
   
       private String getStateKey(PortletWindow window)
       {
  -        return STATE + "_" + window.getId().toString();
  +        return nav.getNavigationKey(NavigationalStateComponent.STATE) + "_" + window.getId().toString();
       }
   
       public Map getStateLessControlParameter()
  @@ -351,7 +233,7 @@
           while (iterator.hasNext())
           {
               String name = (String) iterator.next();
  -            if (name.startsWith(STATE))
  +            if (name.startsWith(nav.getNavigationKey(NavigationalStateComponent.STATE)))
               {
                   if (stateFullControlParameter.get(name).equals(WindowState.MAXIMIZED.toString()))
                   {
  @@ -364,7 +246,7 @@
   
       public void setAction(PortletWindow window)
       {
  -        getStateFullControlParameter().put(getActionKey(window), ACTION.toUpperCase());
  +        getStateFullControlParameter().put(getActionKey(window), nav.getNavigationKey(NavigationalStateComponent.ACTION).toUpperCase());
       }
   
       public void setMode(PortletWindow window, PortletMode mode)
  @@ -411,7 +293,119 @@
   
       private String getPortletIdKey()
       {
  -        return PORTLET_ID;
  +        return nav.getNavigationKey(NavigationalStateComponent.ID);
  +    }
  +
  +    public boolean isControlParameter(String param)
  +    {
  +        return param.startsWith(nav.getNavigationKey(NavigationalStateComponent.PREFIX));
  +    }
  +
  +    public boolean isStateFullParameter(String param)
  +    {
  +        if (isControlParameter(param))
  +        {
  +            String prefix = nav.getNavigationKey(NavigationalStateComponent.PREFIX);  
         
  +            if ((param.startsWith(prefix + nav.getNavigationKey(NavigationalStateComponent.MODE)))
  +                || (param.startsWith(prefix + nav.getNavigationKey(NavigationalStateComponent.PREV_MODE)))
  +                || (param.startsWith(prefix + nav.getNavigationKey(NavigationalStateComponent.STATE)))
  +                || (param.startsWith(prefix + nav.getNavigationKey(NavigationalStateComponent.PREV_STATE)))
  +                || (param.startsWith(prefix + nav.getNavigationKey(NavigationalStateComponent.RENDER_PARAM))))
  +            {
  +                return true;
  +            }
  +        }
  +        return false;
  +    }
  +
  +    public String decodeParameterName(String paramName)
  +    {
  +        int length = nav.getNavigationKey(NavigationalStateComponent.PREFIX).length();
  +        return paramName.substring(length);
  +    }
  +    
  +    public String encodeParameter(String param)
  +    {
  +        return nav.getNavigationKey(NavigationalStateComponent.PREFIX) + param;
  +    }
  +
  +    public String encodeRenderParamName(PortletWindow window, String paramName)
  +    {
  +        StringBuffer returnvalue = new StringBuffer(50);
  +        returnvalue.append(nav.getNavigationKey(NavigationalStateComponent.RENDER_PARAM));
  +        returnvalue.append("_");
  +        returnvalue.append(window.getId().toString());
  +        returnvalue.append("_");
  +        returnvalue.append(paramName);
  +        return returnvalue.toString();
  +    }
  +
  +    public String getRenderParamKey(PortletWindow window)
  +    {
  +        return nav.getNavigationKey(NavigationalStateComponent.RENDER_PARAM) + "_" + window.getId().toString();
  +    }
  +
  +    public String encodeRenderParamValues(String[] paramValues)
  +    {
  +        StringBuffer returnvalue = new StringBuffer(100);
  +        returnvalue.append(paramValues.length);
  +        for (int i = 0; i < paramValues.length; i++)
  +        {
  +            returnvalue.append("_");
  +            returnvalue.append(encodeValue(paramValues[i]));
  +        }
  +        return returnvalue.toString();
  +    }
  +
  +    public String decodeParameterValue(String paramName, String paramValue)
  +    {
  +        return paramValue;
  +    }
  +
  +    private String decodeRenderParamName(String encodedParamName)
  +    {
  +        StringTokenizer tokenizer = new StringTokenizer(encodedParamName, "_");
  +        if (!tokenizer.hasMoreTokens())
  +            return null;
  +        String constant = tokenizer.nextToken();
  +        if (!tokenizer.hasMoreTokens())
  +            return null;
  +        String objectId = tokenizer.nextToken();
  +        if (!tokenizer.hasMoreTokens())
  +            return null;
  +        String name = tokenizer.nextToken();
  +        return name;
  +    }
  +
  +    private String[] decodeRenderParamValues(String encodedParamValues)
  +    {
  +        StringTokenizer tokenizer = new StringTokenizer(encodedParamValues, "_");
  +        if (!tokenizer.hasMoreTokens())
  +            return null;
  +        String _count = tokenizer.nextToken();
  +        int count = Integer.valueOf(_count).intValue();
  +        String[] values = new String[count];
  +        for (int i = 0; i < count; i++)
  +        {
  +            if (!tokenizer.hasMoreTokens())
  +                return null;
  +            values[i] = decodeValue(tokenizer.nextToken());
  +        }
  +        return values;
  +    }
  +
  +    private String decodeValue(String value)
  +    {
  +        value = StringUtils.replace(value, "0x1", "_");
  +        value = StringUtils.replace(value, "0x2", ".");
  +        return value;
       }
   
  +    private String encodeValue(String value)
  +    {
  +        value = StringUtils.replace(value, "_", "0x1");
  +        value = StringUtils.replace(value, ".", "0x2");
  +        return value;
  +    }
  +    
   }
  
  
  
  1.2       +24 -12    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/url/impl/PortalURLImpl.java
  
  Index: PortalURLImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/url/impl/PortalURLImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PortalURLImpl.java	31 Mar 2004 01:19:24 -0000	1.1
  +++ PortalURLImpl.java	31 Mar 2004 06:19:08 -0000	1.2
  @@ -28,7 +28,6 @@
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.jetspeed.Jetspeed;
  -import org.apache.jetspeed.container.session.impl.*;
   import org.apache.jetspeed.container.url.*;
   import org.apache.jetspeed.request.RequestContext;
   import org.apache.jetspeed.request.RequestContextComponent;
  @@ -56,6 +55,7 @@
       private HashMap startStateLessControlParameter = new HashMap();
       private boolean analyzed = false;
       private boolean secure;
  +    private PortalControlParameter pcp;
   
       private String serverName;
       private String serverScheme;
  @@ -74,6 +74,17 @@
           init(context);
       }
   
  +    public void setControlParameter(PortalControlParameter pcp)
  +    {
  +        this.pcp = pcp;
  +    }
  +    
  +    public PortalControlParameter getControlParameter()
  +    {
  +        return this.pcp;
  +    }
  +    
  +    
       public void init(RequestContext context)
       {
           if (null != context.getRequest())
  @@ -201,7 +212,7 @@
               if (iterator.hasNext())
                   result.append("/");
               String name = (String) iterator.next();
  -            result.append(PortalControlParameter.encodeParameter(name));
  +            result.append(pcp.encodeParameter(name));
               result.append("/");
               result.append((String) stateFullParams.get(name));
           }
  @@ -337,7 +348,8 @@
               while (tokenizer.hasMoreTokens())
               {
                   String token = tokenizer.nextToken();
  -                if (PortalControlParameter.isControlParameter(token))
  +                
  +                if (pcp.isControlParameter(token))
                   {
                       mode = 1;
                       name = token;
  @@ -348,17 +360,17 @@
                   }
                   else if (mode == 1)
                   {
  -                    if ((PortalControlParameter.isStateFullParameter(name)))
  +                    if ((pcp.isStateFullParameter(name)))
                       {
                           startControlParameter.put(
  -                            PortalControlParameter.decodeParameterName(name),
  -                            PortalControlParameter.decodeParameterValue(name, token));
  +                            pcp.decodeParameterName(name),
  +                            pcp.decodeParameterValue(name, token));
                       }
                       else
                       {
                           startStateLessControlParameter.put(
  -                            PortalControlParameter.decodeParameterName(name),
  -                            PortalControlParameter.decodeParameterValue(name, token));
  +                            pcp.decodeParameterName(name),
  +                            pcp.decodeParameterValue(name, token));
                       }
                       mode = 0;
                   }
  @@ -371,14 +383,14 @@
       public void setRenderParameter(PortletWindow portletWindow, String name, String[] values)
       {
           startControlParameter.put(
  -            PortalControlParameter.encodeRenderParamName(portletWindow, name),
  -            PortalControlParameter.encodeRenderParamValues(values));
  +            pcp.encodeRenderParamName(portletWindow, name),
  +            pcp.encodeRenderParamValues(values));
   
       }
   
       public void clearRenderParameters(PortletWindow portletWindow)
       {
  -        String prefix = PortalControlParameter.getRenderParamKey(portletWindow);
  +        String prefix = pcp.getRenderParamKey(portletWindow);
           Iterator keyIterator = startControlParameter.keySet().iterator();
   
           while (keyIterator.hasNext())
  
  
  
  1.2       +13 -7     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/NavigationalStateComponent.java
  
  Index: NavigationalStateComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/NavigationalStateComponent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NavigationalStateComponent.java	30 Mar 2004 22:00:19 -0000	1.1
  +++ NavigationalStateComponent.java	31 Mar 2004 06:19:08 -0000	1.2
  @@ -55,11 +55,17 @@
        * Keys for URL encoding
        * @return
        */
  -    String getActionKey();
  -    String getRenderParamKey();    
  -    String getModeKey();    
  -    String getPreviousModeKey();        
  -    String getStateKey();    
  -    String getPreviousStateKey();
  +    static public final int PREFIX = 0;    
  +    static public final int ACTION = 1;
  +    static public final int MODE = 2;
  +    static public final int STATE = 3;
  +    static public final int RENDER_PARAM = 4;
  +    static public final int ID = 5;
  +    static public final int PREV_MODE = 6;
  +    static public final int PREV_STATE = 7;
  +    static public final int KEY_DELIM = 8;
  +    static public final int NAV_MAX = 9;        
  +    
  +    String getNavigationKey(int key);
       
   }
  
  
  
  1.2       +5 -1      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/url/PortalURL.java
  
  Index: PortalURL.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/url/PortalURL.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PortalURL.java	31 Mar 2004 01:19:24 -0000	1.1
  +++ PortalURL.java	31 Mar 2004 06:19:08 -0000	1.2
  @@ -26,6 +26,10 @@
       /** HTTPS protocol. */
       public static final String HTTPS = "https";
   
  +    void setControlParameter(PortalControlParameter pcp);
  +    
  +    PortalControlParameter getControlParameter();
  +    
       public abstract void init(RequestContext context);
       /**
        * Adds a navigational information pointing to a portal part, e.g. PageGroups
  
  
  
  1.6       +11 -8     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/PathNavigationalState.java
  
  Index: PathNavigationalState.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/PathNavigationalState.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PathNavigationalState.java	31 Mar 2004 01:19:24 -0000	1.5
  +++ PathNavigationalState.java	31 Mar 2004 06:19:08 -0000	1.6
  @@ -21,6 +21,7 @@
   import javax.portlet.WindowState;
   
   import org.apache.jetspeed.container.session.NavigationalState;
  +import org.apache.jetspeed.container.session.NavigationalStateComponent;
   import org.apache.jetspeed.container.url.PortalURL;
   import org.apache.jetspeed.container.url.impl.PortalControlParameter;
   import org.apache.jetspeed.container.url.impl.PortalURLImpl;
  @@ -38,20 +39,22 @@
    */
   public class PathNavigationalState implements NavigationalState 
   {
  -    RequestContext context;
  -    PortalURL url;
  -    PortalControlParameter pcp;
  +    private RequestContext context;
  +    private PortalURL url;
  +    private PortalControlParameter pcp;
  +    private NavigationalStateComponent nav;
       
  -    public PathNavigationalState(RequestContext context)
  +    public PathNavigationalState(RequestContext context, NavigationalStateComponent nav)
       {
  +        this.nav = nav;        
           init(context);
       }
       
       public void init(RequestContext context)
       {
           this.context = context;
  -        this.url = new PortalURLImpl(context);
  -        this.pcp = new PortalControlParameter(url);        
  +        this.url = new PortalURLImpl(context);               
  +        this.pcp = new PortalControlParameter(url, nav);        
       }
       
       public WindowState getState(PortletWindow window) 
  @@ -86,7 +89,7 @@
       
       public boolean isNavigationalParameter(String token)
       {
  -        return PortalControlParameter.isControlParameter(token);
  +        return pcp.isControlParameter(token);
       }
       
       public Iterator getRenderParamNames(PortletWindow window)
  
  
  
  1.6       +176 -8    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/SessionNavigationalState.java
  
  Index: SessionNavigationalState.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/SessionNavigationalState.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SessionNavigationalState.java	31 Mar 2004 01:19:24 -0000	1.5
  +++ SessionNavigationalState.java	31 Mar 2004 06:19:08 -0000	1.6
  @@ -15,28 +15,196 @@
    */
   package org.apache.jetspeed.container.session.impl;
   
  +import java.util.HashMap;
  +import java.util.Iterator;
  +import java.util.Map;
  +
  +import javax.portlet.PortletMode;
  +import javax.portlet.WindowState;
  +import javax.servlet.http.HttpSession;
  +
   import org.apache.jetspeed.container.session.NavigationalState;
  +import org.apache.jetspeed.container.session.NavigationalStateComponent;
   import org.apache.jetspeed.request.RequestContext;
  +import org.apache.pluto.om.window.PortletWindow;
   
   /**
  - * SessionNavigationalStateContext
  + * SessionNavigationalState, stores nav state in the session, not on URL
    *
    * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
    * @version $Id$
    */
   public class SessionNavigationalState
  -        extends
  -            PathNavigationalState // for now until we implement it
           implements
               NavigationalState 
  -{
  -    RequestContext context;
  +{    
  +    private static final String STATES_KEY = "org.apache.jetspeed.container.session.impl.states";
  +    private static final String MODES_KEY = "org.apache.jetspeed.container.session.impl.modes";
  +    private static final String PSTATES_KEY = "org.apache.jetspeed.container.session.impl.pstates";
  +    private static final String PMODES_KEY = "org.apache.jetspeed.container.session.impl.pmodes";
  +    
  +    private static Object lock = new Object();
  +    
  +    private HttpSession session;
  +    private RequestContext context;
  +    private Map states;
  +    private Map modes;
  +    private Map pstates;
  +    private Map pmodes;
  +    private NavigationalStateComponent nav;
  +    
  +    public SessionNavigationalState(RequestContext context, NavigationalStateComponent
nav)
  +    {
  +        this.context = context;
  +        this.nav = nav;
  +        session = context.getRequest().getSession();
  +        states = (Map)session.getAttribute(STATES_KEY);
  +        if (null == states)
  +        {
  +            synchronized (lock)
  +            {
  +                states = new HashMap();
  +                session.setAttribute(STATES_KEY, states);
  +            }
  +        }
  +        
  +        modes = (Map)session.getAttribute(MODES_KEY);
  +        if (null == modes)
  +        {
  +            synchronized (lock)
  +            {            
  +                modes = new HashMap();
  +                session.setAttribute(MODES_KEY, modes);
  +            }
  +        }
  +        
  +        pstates = (Map)session.getAttribute(PSTATES_KEY);
  +        if (null == pstates)
  +        {
  +            synchronized (lock)
  +            {
  +                pstates = new HashMap();
  +                session.setAttribute(PSTATES_KEY, pstates);
  +            }
  +        }
  +        
  +        pmodes = (Map)session.getAttribute(PMODES_KEY);
  +        if (null == pmodes)
  +        {
  +            synchronized (lock)
  +            {            
  +                pmodes = new HashMap();
  +                session.setAttribute(PMODES_KEY, pmodes);
  +            }
  +        }               
  +    }
  +        
  +    public WindowState getState(PortletWindow window) 
  +    {
  +        WindowState state = (WindowState)states.get(window.getId().toString());
  +        if (state == null)
  +        {
  +            // optimize, no need to add it if its default            
  +            return WindowState.NORMAL;
  +        }
  +        return state;
  +    }
  +
  +    public void setState(PortletWindow window, WindowState state) 
  +    {
  +        states.put(window.getId().toString(), state);
  +    }
  +    
  +    public PortletMode getMode(PortletWindow window) 
  +    {
  +        PortletMode mode = (PortletMode)modes.get(window.getId().toString());
  +        if (mode == null)
  +        {
  +            // optimize, no need to add it if its default
  +            return PortletMode.VIEW;
  +        }
  +        return mode;
  +    }
  +
  +    public void setMode(PortletWindow window, PortletMode mode) 
  +    {
  +        modes.put(window.getId().toString(), mode);        
  +    }
  +    
  +    public PortletMode getPreviousMode(PortletWindow window)
  +    {
  +        PortletMode mode = (PortletMode)pmodes.get(window.getId().toString());
  +        if (mode == null)
  +        {
  +            // optimize, no need to add it if its default
  +            return PortletMode.VIEW;
  +        }
  +        return mode;        
  +    }
  +    
  +    public WindowState getPreviousState(PortletWindow window)
  +    {
  +        WindowState state = (WindowState)pstates.get(window.getId().toString());
  +        if (state == null)
  +        {
  +            // optimize, no need to add it if its default            
  +            return WindowState.NORMAL;
  +        }
  +        return state;        
  +    }
  +    
  +    ///////////////////////////////////////////////////////////
  +    
  +    public boolean isNavigationalParameter(String token)
  +    {
  +        return token.startsWith(nav.getNavigationKey(NavigationalStateComponent.PREFIX));
  +    }
  +
  +    public Iterator getRenderParamNames(PortletWindow window)
  +    {
  +        return null;
  +    }
  +    
  +    public String[] getRenderParamValues(PortletWindow window, String paramName)
  +    {
  +        return null;
  +    }
  +
  +    public PortletWindow getPortletWindowOfAction()
  +    {
  +        return null;
  +    }
  +    
  +    public void clearRenderParameters(PortletWindow portletWindow)
  +    {
  +    }
  +    
  +    public void setAction(PortletWindow window)
  +    {        
  +    }
       
  -    public SessionNavigationalState(RequestContext context)
  +    public void setRequestParam(String name, String[] values)
       {
  -        super(context);
       }
       
  +    public void setRenderParam(PortletWindow window, String name, String[] values)
  +    {
  +    }
  +    
  +    public String toString()
  +    {
  +        return toString(false);
  +    }
  +
  +    public String toString(boolean secure)
  +    {        
  +        return "";
  +    }
  +    
  +    public String getBaseURL()
  +    {
  +        return "";
  +    }
       
       
   }
  
  
  
  1.2       +39 -39    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/JetspeedNavigationalStateComponent.java
  
  Index: JetspeedNavigationalStateComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/JetspeedNavigationalStateComponent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JetspeedNavigationalStateComponent.java	30 Mar 2004 22:00:20 -0000	1.1
  +++ JetspeedNavigationalStateComponent.java	31 Mar 2004 06:19:08 -0000	1.2
  @@ -16,12 +16,14 @@
   package org.apache.jetspeed.container.session.impl;
   
   import java.lang.reflect.Constructor;
  +import java.util.StringTokenizer;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.jetspeed.container.session.NavigationalState;
   import org.apache.jetspeed.container.session.NavigationalStateComponent;
   import org.apache.jetspeed.request.RequestContext;
  +import org.picocontainer.Startable;
   
   /**
    * JetspeedNavigationalStateComponent
  @@ -29,29 +31,48 @@
    * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
    * @version $Id$
    */
  -public class JetspeedNavigationalStateComponent implements NavigationalStateComponent 
  +public class JetspeedNavigationalStateComponent implements NavigationalStateComponent,
Startable 
   {
  +    static private final String PREFIX = "_";    
       static private final String ACTION = "ac";
       static private final String MODE = "md";
  -    static private final String PREFIX = "_";
  +    static private final String STATE = "st";
  +    static private final String RENDER_PARAM = "rp";
  +    static private final String PORTLET_ID = "pid";    
       static private final String PREV_MODE = "pm";
       static private final String PREV_STATE = "ps";
  -    static private final String RENDER_PARAM = "rp";
  -    static private final String STATE = "st";
       static private final String KEY_DELIMITER = ":";
  -    static private final String PORTLET_ID = "pid";
       
       private String contextClassName = null;
       private Class contextClass = null;
  +    private String navigationKeys;
  +    private String navigationKeyNames[] = new String[]
  +    {
  +            PREFIX, ACTION, MODE, STATE, RENDER_PARAM, PORTLET_ID, PREV_MODE, PREV_STATE,
KEY_DELIMITER
  +    };
  +    
       private final static Log log = LogFactory.getLog(JetspeedNavigationalStateComponent.class);
  +
  +    
       
  -    public JetspeedNavigationalStateComponent(String contextClassName)
  +    /**
  +     * @param contextClassName  name of the class implementing Navigational State instances
  +     * @param navigationsKeys comma-separated list of navigation keys
  +     */
  +    public JetspeedNavigationalStateComponent(String contextClassName, String navigationKeys)
       {
           this.contextClassName = contextClassName;
  +        this.navigationKeys = navigationKeys;
       }
               
       public void start()
  -    {
  +    {        
  +        StringTokenizer tokenizer = new StringTokenizer(navigationKeys, ", ");
  +        for (int ix = 0; tokenizer.hasMoreTokens() && ix < NavigationalStateComponent.NAV_MAX;
ix++)
  +        {
  +            String token = tokenizer.nextToken();
  +            navigationKeyNames[ix] = token;
  +        }
       }
       
       public void stop()
  @@ -69,14 +90,14 @@
               }
   
               // TODO: we could use a pooled object implementation here
  -            Constructor constructor = contextClass.getConstructor(new Class[] {RequestContext.class});
  +            Constructor constructor = contextClass.getConstructor(new Class[] {RequestContext.class,
NavigationalStateComponent.class});
               
  -            state = (NavigationalState) constructor.newInstance(new Object[] {context});
  +            state = (NavigationalState) constructor.newInstance(new Object[] {context,
this});
               
           }
           catch(Exception e)
           {
  -            String msg = "RequestContextFactory: Failed to create a Class object for RequestContext:
" + e.toString();
  +            String msg = "JetspeedNavigationalStateComponent: Failed to create a Class
object for: " + e.toString();            
               log.error(msg);
           }
           return state;
  @@ -91,35 +112,14 @@
       {
           
       }
  -
  -    public String getActionKey()
  -    {
  -        return ACTION;
  -    }
  -
  -    public String getRenderParamKey()
  -    {
  -        return RENDER_PARAM;
  -    }
  -    
  -    public String getModeKey()
  -    {
  -        return MODE;
  -    }
       
  -    public String getPreviousModeKey()
  +    public String getNavigationKey(int key)
       {
  -        return PREV_MODE;
  -    }
  -    
  -    
  -    public String getStateKey()
  -    {
  -        return STATE;
  -    }
  -    
  -    public String getPreviousStateKey()
  -    {
  -        return PREV_STATE;
  +        if (key < NavigationalStateComponent.NAV_MAX && key >= 0)
  +        {
  +            return navigationKeyNames[key];
  +        }
  +        return "";        
       }
  +
   }
  
  
  
  1.3       +2 -4      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java
  
  Index: JetspeedRequestContextComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JetspeedRequestContextComponent.java	31 Mar 2004 01:19:24 -0000	1.2
  +++ JetspeedRequestContextComponent.java	31 Mar 2004 06:19:08 -0000	1.3
  @@ -67,9 +67,7 @@
           }
           catch(Exception e)
           {
  -            e.printStackTrace();
  -            
  -            String msg = "RequestContextFactory: Failed to create a Class object for RequestContext:
" + e.toString();
  +            String msg = "JetspeedRequestContextComponent: Failed to create a Class object
for RequestContext: " + e.toString();
               log.error(msg);
           }
   
  
  
  
  1.21      +2 -1      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/engine/JetspeedEngine.java
  
  Index: JetspeedEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/engine/JetspeedEngine.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- JetspeedEngine.java	17 Mar 2004 01:50:13 -0000	1.20
  +++ JetspeedEngine.java	31 Mar 2004 06:19:08 -0000	1.21
  @@ -279,6 +279,7 @@
           }
           return base.concat(path);
       }
  +    
       private void initComponents(Configuration configuration) throws IOException, ClassNotFoundException,
NamingException
       {
           String applicationRoot = getRealPath("/");
  
  
  
  1.2       +8 -8      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/containers/window-accessor-container.groovy
  
  Index: window-accessor-container.groovy
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/containers/window-accessor-container.groovy,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- window-accessor-container.groovy	17 Mar 2004 22:19:53 -0000	1.1
  +++ window-accessor-container.groovy	31 Mar 2004 06:19:08 -0000	1.2
  @@ -28,20 +28,20 @@
   if(parent != null)
   {
       container = new DefaultPicoContainer(parent)
  -	parent.registerComponentImplementation(PortletWindowAccessor, 
  -	                                       PortletWindowAccessorImpl, 
  -          	    new Parameter[] {new ComponentParameter(PortletEntityAccessComponent), 
  -          	                     new ComponentParameter(PortletRegistryComponent)} )
  +    parent.registerComponentImplementation(PortletWindowAccessor, 
  +                                           PortletWindowAccessorImpl, 
  +                  new Parameter[] {new ComponentParameter(PortletEntityAccessComponent),

  +                                   new ComponentParameter(PortletRegistryComponent)} )
                                             
   
   }
   else
   {
       container = new DefaultPicoContainer()
  -	container.registerComponentImplementation(PortletWindowAccessor, 
  -	                                       PortletWindowAccessorImpl, 
  -          	    new Parameter[] {new ComponentParameter(PortletEntityAccessComponent), 
  -                           	    new ComponentParameter(PortletRegistryComponent)} )
  +    container.registerComponentImplementation(PortletWindowAccessor, 
  +                                           PortletWindowAccessorImpl, 
  +                  new Parameter[] {new ComponentParameter(PortletEntityAccessComponent),

  +                                   new ComponentParameter(PortletRegistryComponent)} )
   
   }
   
  
  
  
  1.2       +4 -4      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/containers/aggregator-container.groovy
  
  Index: aggregator-container.groovy
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/containers/aggregator-container.groovy,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- aggregator-container.groovy	17 Mar 2004 22:19:53 -0000	1.1
  +++ aggregator-container.groovy	31 Mar 2004 06:19:08 -0000	1.2
  @@ -32,11 +32,11 @@
   if(parent != null)
   {
       container = new DefaultPicoContainer(parent)
  -	parent.registerComponentImplementation(PageAggregator, 
  +    parent.registerComponentImplementation(PageAggregator, 
                                              PageAggregatorImpl,
                                 new Parameter[] {new ComponentParameter(PortletRenderer),

                                                  new ConstantParameter(strategy)} )     
                     	    
  -	parent.registerComponentImplementation(PortletAggregator, 
  +    parent.registerComponentImplementation(PortletAggregator, 
                                              PortletAggregatorImpl,
                                 new Parameter[] {new ComponentParameter(PortletRenderer)})
                                             
  @@ -44,11 +44,11 @@
   else
   {
       container = new DefaultPicoContainer()                           	    
  -	container.registerComponentImplementation(PageAggregator, 
  +    container.registerComponentImplementation(PageAggregator, 
                                              PageAggregatorImpl,
                                 new Parameter[] {new ComponentParameter(PortletRenderer),

                                                  new ConstantParameter(strategy)} )     
                     	    
  -	container.registerComponentImplementation(PortletAggregator, 
  +    container.registerComponentImplementation(PortletAggregator, 
                                              PortletAggregatorImpl,
                                 new Parameter[] {new ComponentParameter(PortletRenderer)})
                               
  
  
  

---------------------------------------------------------------------
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