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 13:53:21 GMT
weaver      2004/08/18 06:53:21

  Modified:    components/page-manager/src/java/org/apache/jetspeed/om/folder/impl
                        FolderImpl.java
  Log:
  Improved dafault page logic.
  
  Revision  Changes    Path
  1.6       +51 -14    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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FolderImpl.java	21 Jul 2004 13:38:21 -0000	1.5
  +++ FolderImpl.java	18 Aug 2004 13:53:21 -0000	1.6
  @@ -37,7 +37,8 @@
   
       private int id;
       private String name;
  -    private String defaultPage;
  +    //TODO: need to grab this from metadata...once we have metadata
  +    private String defaultPage="default-page.psml";
       private String defaultTheme;
       private FolderSet folders;
       private PageSet pages;
  @@ -69,15 +70,20 @@
        */
       public Folder getParent()
       {
  -        if(parent == null)
  +        if(name.equals("/"))
  +        {
  +            return null;
  +        }
  +        
  +        if (parent == null)
           {
               int lastSlash = name.lastIndexOf('/');
  -            if(lastSlash != -1)
  +            if (lastSlash != -1)
               {
                   parent = pageManager.getFolder(name.substring(0, lastSlash));
  -            }            
  +            }
           }
  -        
  +
           return parent;
       }
   
  @@ -134,7 +140,23 @@
        */
       public String getDefaultPage()
       {
  -        return defaultPage;
  +        try
  +        {
  +            getPage(defaultPage);
  +            return defaultPage;
  +        }
  +        catch (PageNotFoundException e)
  +        {
  +            try
  +            {
  +                return ((Page) getPages().iterator().next()).getId();
  +            }
  +            catch (PageNotFoundException e1)
  +            {
  +                return "page_not_found.psml";
  +            }
  +        }
  +        
       }
   
       /*
  @@ -180,9 +202,17 @@
               File[] children = getDirectory().listFiles();
               for (int i = 0; i < children.length; i++)
               {
  +                String folderName = null;
                   if (children[i].isDirectory())
                   {
  -                    String folderName = name + "/" + children[i].getName();
  +                    if (name.equals("/"))
  +                    {
  +                        folderName = name + children[i].getName();
  +                    }
  +                    else
  +                    {
  +                        folderName = name + "/" + children[i].getName();
  +                    }
   
                       folders.add(pageManager.getFolder(folderName));
                   }
  @@ -217,7 +247,14 @@
               {
                   if (children[i].isFile())
                   {
  -                    pages.add(pageManager.getPage(name + "/" + children[i].getName()));
  +                    if (name.equals("/"))
  +                    {
  +                        pages.add(pageManager.getPage(name + children[i].getName()));
  +                    }
  +                    else
  +                    {
  +                        pages.add(pageManager.getPage(name + "/" + children[i].getName()));
  +                    }
                   }
   
               }
  @@ -225,13 +262,13 @@
   
           return pages;
       }
  -    
  -    public Page getPage(String name) throws PageNotFoundException
  +
  +    public Page getPage( String name ) throws PageNotFoundException
       {
  -        Page page = pages.get(name);
  -        if(page == null)
  +        Page page = getPages().get(name);
  +        if (page == null)
           {
  -            throw new PageNotFoundException("Jetspeed PSML page not found: "+name);
  +            throw new PageNotFoundException("Jetspeed PSML page not found: " + name);
           }
           return page;
       }
  
  
  

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