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/services/information PortletURLProviderImpl.java
Date Thu, 01 Apr 2004 17:18:46 GMT
taylor      2004/04/01 09:18:46

  Modified:    portal/src/java/org/apache/jetspeed/container/url/impl
                        PortalControlParameter.java PortalURLImpl.java
               portal/src/java/org/apache/jetspeed/container/session/impl
                        PathNavigationalState.java
                        SessionNavigationalState.java
               portal/src/java/org/apache/jetspeed/container/session
                        NavigationalState.java
               portal/src/java/org/apache/jetspeed/services/information
                        PortletURLProviderImpl.java
  Added:       portal/src/java/org/apache/jetspeed/container/session/impl
                        AbstractNavigationalState.java
  Log:
  - abstracting inteface between navigational state components
  - fixed bug in PortletURLProvider as reported by Ate Douma
  - continuing test cases an implementation of SessionNavigationalState and PathNavigationalState
  
  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.3       +25 -24    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PortalControlParameter.java	31 Mar 2004 06:19:08 -0000	1.2
  +++ PortalControlParameter.java	1 Apr 2004 17:18:44 -0000	1.3
  @@ -18,6 +18,7 @@
   import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Iterator;
  +import java.util.List;
   import java.util.Map;
   import java.util.StringTokenizer;
   
  @@ -175,7 +176,7 @@
   
       public Iterator getRenderParamNames(PortletWindow window)
       {
  -        ArrayList returnvalue = new ArrayList();
  +        List returnvalue = new ArrayList();
           String prefix = getRenderParamKey(window);
           Iterator keyIterator = stateFullControlParameter.keySet().iterator();
   
  @@ -296,28 +297,6 @@
           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();
  @@ -406,6 +385,28 @@
           value = StringUtils.replace(value, "_", "0x1");
           value = StringUtils.replace(value, ".", "0x2");
           return value;
  +    }
  +
  +    public boolean isNavigationalParameter(String token)
  +    {
  +        return token.startsWith(nav.getNavigationKey(NavigationalStateComponent.PREFIX));
  +    }
  +    
  +    public boolean isStateFullParameter(String param)
  +    {
  +        if (isNavigationalParameter(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;
       }
       
   }
  
  
  
  1.3       +2 -2      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PortalURLImpl.java	31 Mar 2004 06:19:08 -0000	1.2
  +++ PortalURLImpl.java	1 Apr 2004 17:18:44 -0000	1.3
  @@ -349,7 +349,7 @@
               {
                   String token = tokenizer.nextToken();
                   
  -                if (pcp.isControlParameter(token))
  +                if (pcp.isNavigationalParameter(token))
                   {
                       mode = 1;
                       name = token;
  
  
  
  1.7       +8 -12     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PathNavigationalState.java	31 Mar 2004 06:19:08 -0000	1.6
  +++ PathNavigationalState.java	1 Apr 2004 17:18:45 -0000	1.7
  @@ -37,22 +37,23 @@
    * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
    * @version $Id$
    */
  -public class PathNavigationalState implements NavigationalState 
  +public class PathNavigationalState
  +    extends
  +        AbstractNavigationalState
  +    implements 
  +        NavigationalState 
   {
  -    private RequestContext context;
       private PortalURL url;
       private PortalControlParameter pcp;
  -    private NavigationalStateComponent nav;
       
       public PathNavigationalState(RequestContext context, NavigationalStateComponent nav)
       {
  -        this.nav = nav;        
  +        super(context, nav);
           init(context);
       }
       
       public void init(RequestContext context)
       {
  -        this.context = context;
           this.url = new PortalURLImpl(context);               
           this.pcp = new PortalControlParameter(url, nav);        
       }
  @@ -86,12 +87,7 @@
       {
           return pcp.getPrevState(window);
       }
  -    
  -    public boolean isNavigationalParameter(String token)
  -    {
  -        return pcp.isControlParameter(token);
  -    }
  -    
  +        
       public Iterator getRenderParamNames(PortletWindow window)
       {
           return pcp.getRenderParamNames(window);
  
  
  
  1.7       +66 -11    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SessionNavigationalState.java	31 Mar 2004 06:19:08 -0000	1.6
  +++ SessionNavigationalState.java	1 Apr 2004 17:18:45 -0000	1.7
  @@ -15,9 +15,12 @@
    */
   package org.apache.jetspeed.container.session.impl;
   
  +import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Iterator;
  +import java.util.List;
   import java.util.Map;
  +import java.util.StringTokenizer;
   
   import javax.portlet.PortletMode;
   import javax.portlet.WindowState;
  @@ -35,8 +38,10 @@
    * @version $Id$
    */
   public class SessionNavigationalState
  -        implements
  -            NavigationalState 
  +    extends
  +        AbstractNavigationalState
  +    implements 
  +        NavigationalState 
   {    
       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";
  @@ -46,17 +51,15 @@
       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;
  +    private List renderParams = null;
       
       public SessionNavigationalState(RequestContext context, NavigationalStateComponent
nav)
       {
  -        this.context = context;
  -        this.nav = nav;
  +        super(context, nav);
           session = context.getRequest().getSession();
           states = (Map)session.getAttribute(STATES_KEY);
           if (null == states)
  @@ -155,15 +158,67 @@
       
       ///////////////////////////////////////////////////////////
       
  -    public boolean isNavigationalParameter(String token)
  +    public Iterator getRenderParamNames(PortletWindow window)
       {
  -        return token.startsWith(nav.getNavigationKey(NavigationalStateComponent.PREFIX));
  +        if (null != renderParams)
  +        {
  +            return renderParams.iterator();
  +        }
  +
  +        renderParams = new ArrayList();       
  +        analyzeNavigationalParameters(context.getRequest().getPathInfo());
  +        return renderParams.iterator();
       }
  +    
   
  -    public Iterator getRenderParamNames(PortletWindow window)
  +    private void analyzeNavigationalParameters(String pathInfo)
       {
  -        return null;
  +        if (pathInfo != null)
  +        {
  +            StringTokenizer tokenizer = new StringTokenizer(pathInfo, "/.");
  +
  +            int mode = 0; // 0=navigation, 1=control information
  +            String name = null;
  +            while (tokenizer.hasMoreTokens())
  +            {
  +                String token = tokenizer.nextToken();
  +                
  +                if (isNavigationalParameter(token))
  +                {
  +                    mode = 1;
  +                    name = token;
  +                }
  +                else if (mode == 0)
  +                {
  +                    if (null == renderParams)
  +                    {
  +                        renderParams = new ArrayList();
  +                    }
  +                    renderParams.add(token);
  +                }
  +                else if (mode == 1)
  +                {
  +                    /*
  +                    if ((isStateFullParameter(name)))
  +                    {
  +                        startControlParameter.put(
  +                            pcp.decodeParameterName(name),
  +                            pcp.decodeParameterValue(name, token));
  +                    }
  +                    else
  +                    {
  +                        startStateLessControlParameter.put(
  +                            pcp.decodeParameterName(name),
  +                            pcp.decodeParameterValue(name, token));
  +                    }
  +                    */
  +                    mode = 0;
  +                }
  +            }
  +        }
  +        
       }
  +    
       
       public String[] getRenderParamValues(PortletWindow window, String paramName)
       {
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/AbstractNavigationalState.java
  
  Index: AbstractNavigationalState.java
  ===================================================================
  /*
   * Copyright 2000-2001,2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.jetspeed.container.session.impl;
  
  import org.apache.jetspeed.container.session.NavigationalStateComponent;
  import org.apache.jetspeed.request.RequestContext;
  
  /**
   * BaseNavigationalState
   *
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: AbstractNavigationalState.java,v 1.1 2004/04/01 17:18:45 taylor Exp $
   */
  public abstract class AbstractNavigationalState 
  {
      protected RequestContext context;
      protected NavigationalStateComponent nav;
      
      public AbstractNavigationalState(RequestContext context, NavigationalStateComponent
nav)
      {
          this.context = context;
          this.nav = nav;        
      }
              
      public boolean isNavigationalParameter(String token)
      {
          return token.startsWith(nav.getNavigationKey(NavigationalStateComponent.PREFIX));
      }
      
      public boolean isStateFullParameter(String param)
      {
          if (isNavigationalParameter(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;
      }
      
      
      
  }
  
  
  
  1.6       +2 -2      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/NavigationalState.java
  
  Index: NavigationalState.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/NavigationalState.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NavigationalState.java	31 Mar 2004 01:19:24 -0000	1.5
  +++ NavigationalState.java	1 Apr 2004 17:18:46 -0000	1.6
  @@ -45,7 +45,7 @@
       ///////////////////////////////////////////////
       
       boolean isNavigationalParameter(String token);
  -    
  +        
       Iterator getRenderParamNames(PortletWindow window);
       
       String[] getRenderParamValues(PortletWindow window, String paramName);
  
  
  
  1.6       +5 -6      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/information/PortletURLProviderImpl.java
  
  Index: PortletURLProviderImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/information/PortletURLProviderImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PortletURLProviderImpl.java	31 Mar 2004 01:19:24 -0000	1.5
  +++ PortletURLProviderImpl.java	1 Apr 2004 17:18:46 -0000	1.6
  @@ -28,7 +28,6 @@
   import org.apache.jetspeed.request.RequestContextComponent;
   import org.apache.pluto.om.window.PortletWindow;
   import org.apache.pluto.services.information.PortletURLProvider;
  -import org.apache.pluto.util.NamespaceMapperAccess;
   
   /**
    * Provides access to the Portal URL manipulation 
  @@ -130,10 +129,10 @@
                   : (String[]) value;
                   if (action)
                   {
  -                    nav.setRequestParam(
  -                        NamespaceMapperAccess.getNamespaceMapper().encode(portletWindow.getId(),
name),
  -                        values);
  -
  +                    //nav.setRequestParam(
  +                    //    NamespaceMapperAccess.getNamespaceMapper().encode(portletWindow.getId(),
name),
  +                    //    values);
  +                    nav.setRequestParam(name, values);
                   }
                   else
                   {
  
  
  

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