portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl FolderImpl.java
Date Wed, 18 Aug 2004 19:21:08 GMT
weaver      2004/08/18 12:21:08

  Modified:    components/page-manager/src/java/org/apache/jetspeed/profiler/rules/impl
                        PathSessionResolver.java PathResolver.java
               portal/src/webapp/WEB-INF/assembly pipelines.xml
               portal/src/java/org/apache/jetspeed/profiler/impl
                        ProfilerValveImpl.java
               portal/src/test/org/apache/jetspeed/pipeline
                        TestPipeline.java
               components/page-manager/src/java/org/apache/jetspeed/om/folder/impl
                        FolderImpl.java
  Removed:     portal/src/java/org/apache/jetspeed/pipeline/valve/impl
                        FolderNavigationValve.java
  Log:
  - Refactored folder valve into profiler valve
  - Folder implementation now plays better with the profiler
  - using RequestConext.getPath() instead of HttpServletRequest.getPathInfo() per David Taylor's
suggestion.
  
  Revision  Changes    Path
  1.2       +19 -7     jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/profiler/rules/impl/PathSessionResolver.java
  
  Index: PathSessionResolver.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/profiler/rules/impl/PathSessionResolver.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PathSessionResolver.java	28 May 2004 22:05:09 -0000	1.1
  +++ PathSessionResolver.java	18 Aug 2004 19:21:07 -0000	1.2
  @@ -15,6 +15,7 @@
    */
   package org.apache.jetspeed.profiler.rules.impl;
   
  +import org.apache.jetspeed.om.page.Page;
   import org.apache.jetspeed.profiler.rules.RuleCriterion;
   import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
   import org.apache.jetspeed.request.RequestContext;
  @@ -32,16 +33,27 @@
        */
       public String resolve(RequestContext context, RuleCriterion criterion)
       {        
  -        String value = context.getPath();
  -        if (value == null)
  +        String path = null;
  +        Page page = context.getPage();
  +        
  +        if(page != null)
  +        {
  +            path = page.getId();
  +        }
  +        else
  +        {
  +            path = context.getPath();
  +        }
  +        
  +        if (path == null)
           {
               String key = this.getClass() + "." + criterion.getName();
  -            value = (String)context.getSessionAttribute(key);
  -            if (value == null)
  +            path = (String)context.getSessionAttribute(key);
  +            if (path == null)
               {
  -                value = criterion.getValue();
  +                path = criterion.getValue();
               }
           }
  -        return value;            
  +        return path;            
       }
   }
  
  
  
  1.2       +15 -3     jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/profiler/rules/impl/PathResolver.java
  
  Index: PathResolver.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/profiler/rules/impl/PathResolver.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PathResolver.java	28 May 2004 22:05:09 -0000	1.1
  +++ PathResolver.java	18 Aug 2004 19:21:07 -0000	1.2
  @@ -15,6 +15,7 @@
    */
   package org.apache.jetspeed.profiler.rules.impl;
   
  +import org.apache.jetspeed.om.page.Page;
   import org.apache.jetspeed.profiler.rules.RuleCriterion;
   import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
   import org.apache.jetspeed.request.RequestContext;
  @@ -31,8 +32,19 @@
        * @see org.apache.jetspeed.profiler.rules.RuleCriterionResolver#resolve(org.apache.jetspeed.request.RequestContext,
org.apache.jetspeed.profiler.rules.RuleCriterion)
        */
       public String resolve(RequestContext context, RuleCriterion criterion)
  -    {
  -        String path = context.getPath();
  +    {        
  +        String path = null;
  +        Page page = context.getPage();
  +        
  +        if(page != null)
  +        {
  +            path = page.getId();
  +        }
  +        else
  +        {
  +            path = context.getPath();
  +        }
  +            
           if (path == null)
           {
               path = criterion.getValue();
  
  
  
  1.4       +0 -7      jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly/pipelines.xml
  
  Index: pipelines.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly/pipelines.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- pipelines.xml	18 Aug 2004 13:59:48 -0000	1.3
  +++ pipelines.xml	18 Aug 2004 19:21:07 -0000	1.4
  @@ -49,12 +49,6 @@
      <constructor-arg>
      	<ref bean="org.apache.jetspeed.profiler.Profiler" />
      </constructor-arg>
  -  </bean> 
  -  
  -  <bean id="folderValve"
  -        class="org.apache.jetspeed.pipeline.valve.impl.FolderNavigationValve"
  -        init-method="initialize"
  -  >
      <constructor-arg>
      	<ref bean="org.apache.jetspeed.page.PageManager" />
      </constructor-arg>
  @@ -113,7 +107,6 @@
       	<ref bean="localizationValve"/>
       	<ref bean="capabilityValve"/>
       	<ref bean="securityValve"/>
  -    	<ref bean="folderValve"/>
       	<ref bean="profilerValve"/>
       	<ref bean="containerValve"/>
       	<ref bean="actionValve"/>
  
  
  
  1.9       +90 -13    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
  
  Index: ProfilerValveImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ProfilerValveImpl.java	18 Aug 2004 13:57:58 -0000	1.8
  +++ ProfilerValveImpl.java	18 Aug 2004 19:21:07 -0000	1.9
  @@ -21,6 +21,8 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.jetspeed.om.folder.Folder;
  +import org.apache.jetspeed.page.PageManager;
   import org.apache.jetspeed.page.PageNotFoundException;
   import org.apache.jetspeed.pipeline.PipelineException;
   import org.apache.jetspeed.pipeline.valve.AbstractValve;
  @@ -42,13 +44,15 @@
       protected Log log = LogFactory.getLog(ProfilerValveImpl.class);
       private Profiler profiler;
       static final String LOCATOR_KEY = "org.apache.jetpeed.profileLocator";
  +    public static final String FOLDER_ATTR_KEY = "org.apache.jetspeed.folder";
  +    private PageManager pageManager;
   
  -    
  -    public ProfilerValveImpl(Profiler profiler)
  +    public ProfilerValveImpl( Profiler profiler, PageManager pageManager )
       {
           this.profiler = profiler;
  +        this.pageManager = pageManager;
       }
  -    
  +
       /*
        * (non-Javadoc)
        * 
  @@ -58,16 +62,17 @@
       public void invoke( RequestContext request, ValveContext context ) throws PipelineException
       {
           try
  -        {  
  -             
  +        {
  +
               HttpServletRequest httpRequest = request.getRequest();
               ProfileLocator locator = null;
  -            String pathInfo = httpRequest.getPathInfo();
  -            locator = profiler.getProfile(request);                 
  -            httpRequest.getSession().setAttribute(LOCATOR_KEY, locator);             
  -            
  +            Folder folder = getFolder(request);
  +            httpRequest.setAttribute(FOLDER_ATTR_KEY, folder);
  +            request.setPage(pageManager.getPage(getPageName(request, folder)));
  +
  +            locator = profiler.getProfile(request);
               request.setProfileLocator(locator);
  -            request.setPage(profiler.getPage(locator));
  +            // request.setPage(profiler.getPage(locator));
               context.invokeNext(request);
   
           }
  @@ -84,10 +89,82 @@
               }
               catch (IOException e1)
               {
  -                log.error("Failed to invoke HttpServletReponse.sendError: "+e1.getMessage(),
e1);
  +                log.error("Failed to invoke HttpServletReponse.sendError: " + e1.getMessage(),
e1);
  +            }
  +        }
  +    }
  +
  +
  +    protected Folder getFolder( RequestContext request )
  +    {
  +        HttpServletRequest httpRequest = request.getRequest();
  +        String folderInRequest = getFolderPath(request);
  +        Folder selectedFolder = null;
  +
  +        if (folderInRequest != null)
  +        {
  +            selectedFolder = pageManager.getFolder(folderInRequest);
  +        }
  +
  +        if (selectedFolder != null)
  +        {
  +            httpRequest.getSession().setAttribute(FOLDER_ATTR_KEY, selectedFolder);
  +        }
  +        else
  +        {
  +            selectedFolder = (Folder) httpRequest.getAttribute(FOLDER_ATTR_KEY);
  +            if (selectedFolder == null)
  +            {
  +                selectedFolder = pageManager.getFolder("/");
  +            }
  +        }
  +
  +        return selectedFolder;
  +
  +    }
  +
  +    protected String getFolderPath( RequestContext request )
  +    {
  +        String pathInfo = request.getPath();  
  +        
  +        String folder = null;
  +        if (pathInfo != null)
  +        {
  +            if (pathInfo.endsWith(PageManager.PAGE_SUFFIX))
  +            {
  +                int lastSlash = pathInfo.lastIndexOf("/");
  +                if(lastSlash > -1)
  +                {
  +                    return pathInfo.substring(0, lastSlash);
  +                }
  +                else
  +                {
  +                    return "/";
  +                }
  +            }
  +            else
  +            {
  +                return pathInfo;
               }
  -        }       
  +        }
  +        else
  +        {
  +            return "/";
  +        }
       }
  +
  +    protected String getPageName( RequestContext request, Folder currentFolder )
  +    {
  +        String pathInfo = request.getPath();
  +        if (pathInfo == null || !pathInfo.endsWith(".psml"))
  +        {
  +            return currentFolder.getDefaultPage();
  +        }
  +        else
  +        {
  +            return pathInfo;
  +        }
  +    }    
   
       public String toString()
       {
  
  
  
  1.14      +6 -7      jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/pipeline/TestPipeline.java
  
  Index: TestPipeline.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/pipeline/TestPipeline.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TestPipeline.java	18 Aug 2004 13:59:01 -0000	1.13
  +++ TestPipeline.java	18 Aug 2004 19:21:08 -0000	1.14
  @@ -80,12 +80,11 @@
           assertTrue(valves[0].toString().equals("LocalizationValve"));
           assertTrue(valves[1].toString().equals("CapabilityValveImpl"));
           assertTrue(valves[2].toString().equals("SecurityValve"));     
  -        assertTrue(valves[3].toString().equals("FolderValve"));    
  -        assertTrue(valves[4].toString().equals("ProfilerValve"));        
  -        assertTrue(valves[5].toString().equals("ContainerValve"));
  -        assertTrue(valves[6].toString().equals("ActionValveImpl"));     
  -        assertTrue(valves[7].toString().equals("AggregatorValve"));
  -        assertTrue(valves[8].toString().equals("CleanupValveImpl"));
  +        assertTrue(valves[3].toString().equals("ProfilerValve"));        
  +        assertTrue(valves[4].toString().equals("ContainerValve"));
  +        assertTrue(valves[5].toString().equals("ActionValveImpl"));     
  +        assertTrue(valves[6].toString().equals("AggregatorValve"));
  +        assertTrue(valves[7].toString().equals("CleanupValveImpl"));
           assertNotNull(engine.getPipeline("action-pipeline"));
           assertNotNull(engine.getPipeline("portlet-pipeline"));
       }
  
  
  
  1.7       +13 -6     jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java
  
  Index: FolderImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FolderImpl.java	18 Aug 2004 13:53:21 -0000	1.6
  +++ FolderImpl.java	18 Aug 2004 19:21:08 -0000	1.7
  @@ -38,7 +38,7 @@
       private int id;
       private String name;
       //TODO: need to grab this from metadata...once we have metadata
  -    private String defaultPage="default-page.psml";
  +    private String defaultPage = "default-page.psml";
       private String defaultTheme;
       private FolderSet folders;
       private PageSet pages;
  @@ -53,7 +53,14 @@
       {
   
           this.directory = directory;
  -        this.name = name;
  +        if (!name.startsWith("/"))
  +        {
  +            this.name = "/" + name;
  +        }
  +        else
  +        {
  +            this.name = name;
  +        }
           this.pageManager = pageManager;
       }
   
  @@ -70,11 +77,11 @@
        */
       public Folder getParent()
       {
  -        if(name.equals("/"))
  +        if (name.equals("/"))
           {
               return null;
           }
  -        
  +
           if (parent == null)
           {
               int lastSlash = name.lastIndexOf('/');
  @@ -156,7 +163,7 @@
                   return "page_not_found.psml";
               }
           }
  -        
  +
       }
   
       /*
  
  
  

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