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/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl FolderImpl.java
Date Fri, 26 Nov 2004 18:52:38 GMT
taylor      2004/11/26 10:52:38

  Modified:    components/locator/src/java/org/apache/jetspeed/profiler/impl
                        JetspeedProfiledPageContext.java
               components/page-manager/src/test/org/apache/jetspeed/page
                        TestCastorXmlPageManager.java
               components/page-manager/src/java/org/apache/jetspeed/page/impl
                        CastorXmlPageManager.java AbstractPageManager.java
               components/page-manager/src/java/org/apache/jetspeed/page/document
                        NodeSetImpl.java
               components/page-manager/src/java/org/apache/jetspeed/om/folder/impl
                        FolderImpl.java
  Log:
  Nested Document Sets implementation in page manager, decorators, templates, and demo site.
  
  - Addition of getAll() method to jetspeed API Folder interface.
  - Changes to CastorXmlPageManager/FolderImpl implementation and associated unit tests for
updating and removing PSML pages.
  
  - Improved indenting in left menu pane for Tigris layout.
  
  Note that an updated profiler/page manager design document is contained in the "new" zip
file.
  
  To test nested document sets:
  
  Login as user/user and validate nested document set named "More Pages" appears within "Top
Pages" and contains a new page and link to the Tigris sample page.
  
  patch from Randy Watler
  
  Reviewed by:	taylor@apache.org
  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       +20 -7     jakarta-jetspeed-2/components/locator/src/java/org/apache/jetspeed/profiler/impl/JetspeedProfiledPageContext.java
  
  Index: JetspeedProfiledPageContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/locator/src/java/org/apache/jetspeed/profiler/impl/JetspeedProfiledPageContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JetspeedProfiledPageContext.java	15 Oct 2004 06:49:43 -0000	1.2
  +++ JetspeedProfiledPageContext.java	26 Nov 2004 18:52:37 -0000	1.3
  @@ -150,14 +150,27 @@
       {
           if ((name != null) && (documentSet != null) && (nodes != null))
           {
  -            if (this.documentSets == null)
  -            {
  -                this.documentSetNames = new ArrayList(12);
  -                this.documentSets = new HashMap(12);
  -            }
  +            addDocumentSet(name, documentSet, nodes);
               this.documentSetNames.add(name);
  -            this.documentSets.put(name, new DocumentSetEntry(documentSet, nodes));
           }
  +    }
  +
  +    public void setNestedDocumentSet(String name, DocumentSet documentSet, NodeSet nodes)
  +    {
  +        if ((name != null) && (documentSet != null) && (nodes != null))
  +        {
  +            addDocumentSet(name, documentSet, nodes);
  +        }
  +    }
  +
  +    private void addDocumentSet(String name, DocumentSet documentSet, NodeSet nodes)
  +    {
  +        if (this.documentSets == null)
  +        {
  +            this.documentSetNames = new ArrayList(12);
  +            this.documentSets = new HashMap(12);
  +        }
  +        this.documentSets.put(name, new DocumentSetEntry(documentSet, nodes));
       }
   
       private class DocumentSetEntry
  
  
  
  1.17      +20 -21    jakarta-jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java
  
  Index: TestCastorXmlPageManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- TestCastorXmlPageManager.java	19 Nov 2004 03:06:44 -0000	1.16
  +++ TestCastorXmlPageManager.java	26 Nov 2004 18:52:37 -0000	1.17
  @@ -58,7 +58,7 @@
    */
   public class TestCastorXmlPageManager extends TestCase
   {
  -    private String testId = "test002";
  +    private String testId = "/test002.psml";
       protected CastorXmlPageManager pageManager;
       protected DirectoryHelper dirHelper;
   
  @@ -174,9 +174,9 @@
   
       public void testGetPage() throws Exception
       {
  -        Page testpage = pageManager.getPage("test001");
  +        Page testpage = pageManager.getPage("/test001.psml");
           assertNotNull(testpage);
  -        assertTrue(testpage.getId().equals("test001"));
  +        assertTrue(testpage.getId().equals("/test001.psml"));
           assertTrue(testpage.getTitle().equals("Test Page"));
           assertTrue(testpage.getDefaultSkin().equals("test-skin"));
           assertTrue(testpage.getDefaultDecorator(Fragment.LAYOUT).equals("test-layout"));
  @@ -332,13 +332,12 @@
               exceptionFound = true;
           }
           assertTrue(exceptionFound);
  -
       }
   
       public void testFolders() throws Exception
       {
   
  -        Folder folder1 = pageManager.getFolder("folder1");
  +        Folder folder1 = pageManager.getFolder("/folder1");
           assertNotNull(folder1);
                   
           assertEquals(2, folder1.getFolders().size());
  @@ -346,17 +345,17 @@
           // Test that the folders are naturally orderd
           Folder folder2 = (Folder) childItr.next();
           assertEquals("default-page.psml", folder2.getDefaultPage(true));
  -        assertEquals("folder1/folder2", folder2.getPath());
  +        assertEquals("/folder1/folder2", folder2.getPath());
           assertEquals("folder2", folder2.getName());
           Folder folder3 = (Folder) childItr.next();
  -        assertEquals("folder1/folder3", folder3.getPath());
  +        assertEquals("/folder1/folder3", folder3.getPath());
           assertEquals("test001.psml", folder3.getDefaultPage(true));
   
           assertEquals(1, folder2.getPages().size());
           assertEquals(2, folder3.getPages().size());
           
           // Check link order
  -        Iterator linkItr = folder3.getAllNodes().iterator();
  +        Iterator linkItr = folder3.getAll().iterator();
           assertEquals("Jetspeed2Wiki.link", ((Link)linkItr.next()).getName());
           assertEquals("Jetspeed2.link", ((Link)linkItr.next()).getName());        
           assertEquals("apache_portals.link", ((Link)linkItr.next()).getName());
  @@ -366,41 +365,41 @@
           
   
           //Test FolderSet with both absolute and relative names
  -        assertNotNull(folder1.getFolders().get("folder1/folder2"));
  +        assertNotNull(folder1.getFolders().get("/folder1/folder2"));
           assertNotNull(folder1.getFolders().get("folder2"));
  -        assertEquals(folder1.getFolders().get("folder1/folder2"), folder1.getFolders().get("folder2"));
  +        assertEquals(folder1.getFolders().get("/folder1/folder2"), folder1.getFolders().get("folder2"));
   
           //Test PageSet with both absolute and relative names
  -        assertNotNull(folder3.getPages().get("folder1/folder3/test001.psml"));
  +        assertNotNull(folder3.getPages().get("/folder1/folder3/test001.psml"));
           assertNotNull(folder3.getPages().get("test001.psml"));
  -        assertEquals("test001.psml", folder3.getPages().get("folder1/folder3/test001.psml").getName());
  +        assertEquals("test001.psml", folder3.getPages().get("/folder1/folder3/test001.psml").getName());
           
           assertTrue(folder3.isHidden());
           assertTrue(folder3.getPage("default-page.psml").isHidden());
           assertTrue(folder3.getLinks().get("Jetspeed2.link").isHidden());
           assertFalse(folder3.getLinks().get("apache.link").isHidden());
           
  -        assertNotNull(folder3.getAllNodes().get("Jetspeed2.link"));
  -        assertNull(folder3.getAllNodes().exclusiveSubset("Jetspeed2\\.link").get("Jetspeed2.link"));
  -        assertNull(folder3.getAllNodes().inclusiveSubset("apache\\.link").get("Jetspeed2.link"));
  -        assertNotNull(folder3.getAllNodes().inclusiveSubset("apache\\.link").get("apache.link"));
  +        assertNotNull(folder3.getAll().get("Jetspeed2.link"));
  +        assertNull(folder3.getAll().exclusiveSubset("Jetspeed2\\.link").get("Jetspeed2.link"));
  +        assertNull(folder3.getAll().inclusiveSubset("apache\\.link").get("Jetspeed2.link"));
  +        assertNotNull(folder3.getAll().inclusiveSubset("apache\\.link").get("apache.link"));
           
   
       }
   
       public void testFolderMetaData() throws Exception
       {
  -        Folder folder1French = pageManager.getFolder("folder1");        
  +        Folder folder1French = pageManager.getFolder("/folder1");        
   ;
           assertEquals("Titre francais pour la chemise 1", folder1French.getTitle(Locale.FRENCH));
           assertEquals("Titre francais pour la chemise 1", folder1French.getTitle(Locale.FRANCE));
   
  -        Folder folder1English = pageManager.getFolder("folder1");
  +        Folder folder1English = pageManager.getFolder("/folder1");
   
           assertEquals("English Title for Folder 1", folder1English.getTitle(Locale.ENGLISH));
   
           // check that default works
  -        Folder folder1German = pageManager.getFolder("folder1");
  +        Folder folder1German = pageManager.getFolder("/folder1");
          
           assertEquals("Default Title for Folder 1", folder1German.getTitle(Locale.GERMAN));
           
  @@ -413,7 +412,7 @@
   
       public void testPageMetaData() throws Exception
       {
  -        Page page = pageManager.getPage("default-page.psml");
  +        Page page = pageManager.getPage("/default-page.psml");
           assertNotNull(page);
           String frenchTitle = page.getTitle(Locale.FRENCH);
           assertNotNull(frenchTitle);
  @@ -425,7 +424,7 @@
   
       public void testLinks() throws Exception
       {
  -        Link link = pageManager.getLink("apache_portals.link");
  +        Link link = pageManager.getLink("/apache_portals.link");
           assertNotNull(link);
           assertEquals("http://portals.apache.org", link.getUrl());
           assertEquals("Apache Portals Website", link.getTitle());
  
  
  
  1.24      +173 -47   jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/CastorXmlPageManager.java
  
  Index: CastorXmlPageManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/CastorXmlPageManager.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- CastorXmlPageManager.java	23 Nov 2004 00:01:31 -0000	1.23
  +++ CastorXmlPageManager.java	26 Nov 2004 18:52:37 -0000	1.24
  @@ -325,13 +325,10 @@
                       {
                           // expand and profile each document set
                           DocumentSet documentSet = (DocumentSet) documentSetsIter.next();
  -                        NodeSetImpl documentSetNodes = null;
  -                        documentSetNodes = expandAndProfileDocumentSet(pageContext.getLocators(),
documentSet, documentSetNodes);
  +                        NodeSetImpl documentSetNodes = expandAndProfileDocumentSet(pageContext.getLocators(),
documentSet, null, "", documentSetNames, documentSetNodeSets);
                           if (documentSetNodes != null)
                           {
                               documentSets.add(documentSet);
  -                            documentSetNames.put(documentSet, documentSet.getUrl());
  -                            documentSetNodeSets.put(documentSet, documentSetNodes);
                           }
                       }
                   }
  @@ -478,12 +475,10 @@
   
                                   // expand document set using default document set order
                                   NodeSetImpl documentSetNodes = new NodeSetImpl(null, documentComparator);
  -                                documentSetNodes = expandDocumentSet(documentSet, documentSetNodes);
  +                                documentSetNodes = expandDocumentSet(documentSet, documentSetNodes,
"", documentSetNames, documentSetNodeSets);
                                   if (documentSetNodes != null)
                                   {
                                       documentSets.add(documentSet);
  -                                    documentSetNames.put(documentSet, documentSetPath);
  -                                    documentSetNodeSets.put(documentSet, documentSetNodes);
                                   }
                               }
                           }
  @@ -512,7 +507,7 @@
           populateProfiledPageContext(cachedPageContext, pageContext);
       }
   
  -    private NodeSetImpl expandAndProfileDocumentSet(Map profileLocators, DocumentSet documentSet,
NodeSetImpl expandedNodes)
  +    private NodeSetImpl expandAndProfileDocumentSet(Map profileLocators, DocumentSet documentSet,
NodeSetImpl expandedNodes, String documentSetNamePrefix, Map documentSetNames, Map documentSetNodeSets)
       {
           // expand and profile document set using document set or default
           // navigation profile locator
  @@ -534,38 +529,101 @@
               }
           }
   
  -        // initialized expanded nodes collection with profiled document/folder ordering
  +        // prepare expanded nodes set with profiled document/folder ordering
           if (expandedNodes == null)
           {
               // get document/folder ordering
               List documentOrder = null;
  -            Iterator pathsIter = searchPaths.iterator();
  -            while ((documentOrder == null) && pathsIter.hasNext())
  -            {
  -                String folderPath = (String) pathsIter.next();
  -                if (folderPath.endsWith(Folder.PATH_SEPARATOR) && (folderPath.length()
> 1))
  -                {
  -                    folderPath = folderPath.substring(0, folderPath.length()-1);
  -                }
  -                try
  -                {
  -                    FolderImpl folder = (FolderImpl) setProfiledNodePathAndUrl((AbstractNode)
folderHandler.getFolder(folderPath));
  -                    if ((folder.getMetaData() != null) && (folder.getMetaData().getDocumentOrder()
!= null) &&
  -                        ! folder.getMetaData().getDocumentOrder().isEmpty())
  +
  +            // if document set is composed of a single path and might match
  +            // more than one document, attempt to use path to determine
  +            // document ordering if it is not root relative
  +            List documentPaths = documentSet.getDefaultedDocumentPaths();
  +            if (documentPaths.size() == 1)
  +            {
  +                DocumentSetPath documentSetPath = (DocumentSetPath) documentPaths.get(0);
  +                if (documentSetPath.isRegexp())
  +                {
  +                    // enforce assumption that document set paths are absolute
  +                    // and extract folder
  +                    String documentFolderPath = forceAbsoluteDocumentSetPath(documentSetPath.getPath());
  +                    int lastSlashIndex = documentFolderPath.lastIndexOf(Folder.PATH_SEPARATOR_CHAR);
  +                    if (lastSlashIndex > 2)
                       {
  -                        documentOrder = folder.getMetaData().getDocumentOrder();
  +                        // non-root document path
  +                        documentFolderPath = documentFolderPath.substring(0, lastSlashIndex);
  +                        
  +                        // iterate over search paths formed with document path
  +                        Iterator pathsIter = searchPaths.iterator();
  +                        while ((documentOrder == null) && pathsIter.hasNext())
  +                        {
  +                            // search folder path
  +                            String folderPath = (String) pathsIter.next();
  +                            if (folderPath.endsWith(Folder.PATH_SEPARATOR))
  +                            {
  +                                folderPath = folderPath.substring(0, folderPath.length()-1)
+ documentFolderPath;
  +                            }
  +                            else
  +                            {
  +                                folderPath = folderPath + documentFolderPath;
  +                            }
  +                            
  +                            // check folder for document order
  +                            try
  +                            {
  +                                FolderImpl folder = (FolderImpl) setProfiledNodePathAndUrl((AbstractNode)
folderHandler.getFolder(folderPath));
  +                                if ((folder.getMetaData() != null) && (folder.getMetaData().getDocumentOrder()
!= null) &&
  +                                    ! folder.getMetaData().getDocumentOrder().isEmpty())
  +                                {
  +                                    documentOrder = folder.getMetaData().getDocumentOrder();
  +                                }                
  +                            }
  +                            catch (NodeException ne)
  +                            {
  +                            }
  +                        }
                       }
                   }
  -                catch (NodeException ne)
  +            }
  +
  +            // fallback to root search paths to determine document ordering
  +            if (documentOrder == null)
  +            {
  +                Iterator pathsIter = searchPaths.iterator();
  +                while ((documentOrder == null) && pathsIter.hasNext())
                   {
  +                    // root search folder path
  +                    String folderPath = (String) pathsIter.next();
  +                    if (folderPath.endsWith(Folder.PATH_SEPARATOR) && (folderPath.length()
> 1))
  +                    {
  +                        folderPath = folderPath.substring(0, folderPath.length()-1);
  +                    }
  +
  +                    // check folder for document order
  +                    try
  +                    {
  +                        FolderImpl folder = (FolderImpl) setProfiledNodePathAndUrl((AbstractNode)
folderHandler.getFolder(folderPath));
  +                        if ((folder.getMetaData() != null) && (folder.getMetaData().getDocumentOrder()
!= null) &&
  +                            ! folder.getMetaData().getDocumentOrder().isEmpty())
  +                        {
  +                            documentOrder = folder.getMetaData().getDocumentOrder();
  +                        }
  +                    }
  +                    catch (NodeException ne)
  +                    {
  +                    }
                   }
               }
  -            Comparator documentComparator = new DocumentOrderComparator(documentOrder);
   
               // create ordered node set
  +            Comparator documentComparator = new DocumentOrderComparator(documentOrder);
               expandedNodes = new NodeSetImpl(null, documentComparator);
           }
   
  +        // save doucument set name, (limits recursive expansion)
  +        String name = documentSetNamePrefix + documentSet.getUrl();
  +        documentSetNames.put(documentSet, name);
  +
           // profile each document path using profile locator search paths
           Iterator documentSetPathsIter = documentSet.getDefaultedDocumentPaths().iterator();
           while (documentSetPathsIter.hasNext())
  @@ -607,15 +665,31 @@
                       Iterator pathNodesIter = filterDocumentSet(folderHandler.getNodes(searchPath,
regexp, null)).iterator();
                       while (pathNodesIter.hasNext())
                       {
  -                        expandedNodes = addUniqueOrDescribedUrlNode(expandedNodes, setProfiledNodePathAndUrl((AbstractNode)
pathNodesIter.next()));
  +                        AbstractNode pathNode = setProfiledNodePathAndUrl((AbstractNode)
pathNodesIter.next());
  +                        if (!(pathNode instanceof DocumentSet))
  +                        {
  +                            // add expanded document
  +                            expandedNodes = addUniqueOrDescribedUrlNode(expandedNodes,
pathNode);
  +                        }
  +                        else if (!documentSetNames.containsKey(pathNode))
  +                        {
  +                            // expand unique nested document set
  +                            if (expandAndProfileDocumentSet(profileLocators, (DocumentSet)pathNode,
null, name, documentSetNames, documentSetNodeSets) != null)
  +                            {
  +                                // add expanded document set
  +                                expandedNodes = addUniqueOrDescribedUrlNode(expandedNodes,
pathNode);
  +                            }
  +                        }
                       }
                   }
                   catch (NodeException ne)
                   {
                   }
               }
  -
           }
  +
  +        // save and return expanded nodes
  +        documentSetNodeSets.put(documentSet, expandedNodes);
           return expandedNodes;
       }
   
  @@ -1274,7 +1348,7 @@
           }
       }
   
  -    private NodeSetImpl expandDocumentSet(DocumentSet documentSet, NodeSetImpl expandedNodes)
  +    private NodeSetImpl expandDocumentSet(DocumentSet documentSet, NodeSetImpl expandedNodes,
String documentSetNamePrefix, Map documentSetNames, Map documentSetNodeSets)
       {
           // ignore document sets with profiling locator specified
           if (documentSet.getProfileLocatorName() != null)
  @@ -1283,12 +1357,18 @@
               return null;
           }
   
  -        // expand document set against managed repository only without
  -        // profiling; ignores document set profiling rules as well
  +        // prepare expanded nodes set
           if (expandedNodes == null)
           {
               expandedNodes = new NodeSetImpl(null);        
           }
  +
  +        // save doucument set name, (limits recursive expansion)
  +        String name = documentSetNamePrefix + documentSet.getUrl();
  +        documentSetNames.put(documentSet, name);
  +
  +        // expand document set against managed repository only without
  +        // profiling; ignores document set profiling rules as well
           Iterator documentSetPathsIter = documentSet.getDefaultedDocumentPaths().iterator();
           while (documentSetPathsIter.hasNext())
           {
  @@ -1310,12 +1390,32 @@
               {
                   Iterator pathNodesIter = filterDocumentSet(folderHandler.getNodes(path,
regexp, null)).iterator();
                   while (pathNodesIter.hasNext())
  -                    expandedNodes.add((AbstractNode) pathNodesIter.next());
  +                {
  +                    AbstractNode pathNode = (AbstractNode) pathNodesIter.next();
  +                    if (!(pathNode instanceof DocumentSet))
  +                    {
  +                        // add expanded document
  +                        expandedNodes.add(pathNode);
  +                    }
  +                    else if (!documentSetNames.containsKey(pathNode))
  +                    {
  +                        // expand unique nested document set
  +                        NodeSetImpl nodes = new NodeSetImpl(null, expandedNodes.getComparator());
  +                        if (expandDocumentSet((DocumentSet)pathNode, nodes, name, documentSetNames,
documentSetNodeSets) != null)
  +                        {
  +                            // add expanded document set
  +                            expandedNodes.add(pathNode);
  +                        }
  +                    }
  +                }
               }
               catch (NodeException ne)
               {
               }
           }
  +
  +        // save and return expanded nodes
  +        documentSetNodeSets.put(documentSet, expandedNodes);
           return expandedNodes;
       }
   
  @@ -1361,20 +1461,20 @@
           while (!filterRequired && setIter.hasNext())
           {
               AbstractNode node = (AbstractNode) setIter.next();
  -            filterRequired = (! (node instanceof Page) && ! (node instanceof Folder)
&& ! (node instanceof Link));
  +            filterRequired = (! (node instanceof Page) && ! (node instanceof Folder)
&& ! (node instanceof Link) && ! (node instanceof DocumentSet));
           }
           if (! filterRequired)
           {
               return set;
           }
   
  -        // filter expanded document set for pages, folders, and links
  +        // filter expanded document set for pages, folders, links, and document sets
           NodeSet filteredSet = new NodeSetImpl(null);        
           setIter = set.iterator();
           while (setIter.hasNext())
           {
               AbstractNode node = (AbstractNode) setIter.next();
  -            if ((node instanceof Page) || (node instanceof Folder) || (node instanceof
Link))
  +            if ((node instanceof Page) || (node instanceof Folder) || (node instanceof
Link) || (node instanceof DocumentSet))
               {
                   filteredSet.add(node);
               }
  @@ -1397,7 +1497,7 @@
       public Page getPage(String path) throws PageNotFoundException, FolderNotFoundException,
NodeException
       {
           // get page via folder, (access checked in Folder.getPage())
  -        Folder folder = getNodeFolder(path);
  +        FolderImpl folder = getNodeFolder(path);
           return folder.getPage(getNodeName(path));
       }
   
  @@ -1411,9 +1511,19 @@
       public void registerPage(Page page) throws JetspeedException
       {
           // make sure path and related members are set
  -        if (page.getPath() == null)
  +        if ((page.getPath() == null) && (page.getId() != null))
           {
  -            page.setPath(page.getId());
  +            String path = page.getId();
  +            if (!path.startsWith(Folder.PATH_SEPARATOR))
  +            {
  +                path = Folder.PATH_SEPARATOR + path;
  +            }
  +            if (!path.endsWith(Page.DOCUMENT_TYPE))
  +            {
  +                path += Page.DOCUMENT_TYPE;
  +            }
  +            page.setId(path);
  +            page.setPath(path);
           }
           if (page.getPath() != null)
           {
  @@ -1422,16 +1532,27 @@
                   log.error("Page paths and ids must match!");
                   return;
               }
  -            setProfiledNodePathAndUrl((AbstractNode)page);
  -            Folder folder = getNodeFolder(page.getPath());
  -            page.setParent(folder);
           }
  +        else
  +        {
  +            log.error("Page paths and ids must be set!");
  +            return;
  +        }
  +        setProfiledNodePathAndUrl((AbstractNode)page);
   
           // check for edit access
           page.checkAccess(SecuredResource.EDIT_ACTION);
   
           // register page
           handlerFactory.getDocumentHandler(Page.DOCUMENT_TYPE).updateDocument(page);
  +
  +        // update folder
  +        FolderImpl folder = getNodeFolder(page.getPath());
  +        if (!folder.getAllNodes().contains(page))
  +        {
  +            folder.getAllNodes().add(page);
  +        }
  +        page.setParent(folder);
       }
   
       /**
  @@ -1460,6 +1581,11 @@
   
           // remove page
           handlerFactory.getDocumentHandler(Page.DOCUMENT_TYPE).removeDocument(page);
  +
  +        // update folder
  +        FolderImpl folder = getNodeFolder(page.getPath());
  +        ((NodeSetImpl)folder.getAllNodes()).remove(page);
  +        page.setParent(null);
       }
   
       /**
  @@ -1478,7 +1604,7 @@
       public Link getLink(String path) throws DocumentNotFoundException, UnsupportedDocumentTypeException,
FolderNotFoundException, NodeException
       {
           // get link via folder, (access checked in Folder.getLink())
  -        Folder folder = getNodeFolder(path);
  +        FolderImpl folder = getNodeFolder(path);
           return folder.getLink(getNodeName(path));
       }
   
  @@ -1498,7 +1624,7 @@
       public DocumentSet getDocumentSet(String path) throws DocumentNotFoundException, UnsupportedDocumentTypeException,
FolderNotFoundException, NodeException
       {
           // get document set via folder, (access checked in Folder.getDocumentSet())
  -        Folder folder = getNodeFolder(path);
  +        FolderImpl folder = getNodeFolder(path);
           return folder.getDocumentSet(getNodeName(path));
       }
   
  @@ -1517,7 +1643,7 @@
       public PageSecurity getPageSecurity() throws DocumentNotFoundException, UnsupportedDocumentTypeException,
FolderNotFoundException, NodeException
       {
           // get page security via folder, (always allow access)
  -        Folder folder = getNodeFolder(Folder.PATH_SEPARATOR);
  +        FolderImpl folder = getNodeFolder(Folder.PATH_SEPARATOR);
           return folder.getPageSecurity();
       }
   
  @@ -1542,14 +1668,14 @@
           return folderHandler.getFolder(folderPath);
       }
   
  -    private Folder getNodeFolder(String nodePath) throws NodeException, InvalidFolderException
  +    private FolderImpl getNodeFolder(String nodePath) throws NodeException, InvalidFolderException
       {
           int folderIndex = nodePath.lastIndexOf(Folder.PATH_SEPARATOR);
           if (folderIndex > 0)
           {
  -            return folderHandler.getFolder(nodePath.substring(0, folderIndex));
  +            return (FolderImpl) folderHandler.getFolder(nodePath.substring(0, folderIndex));
           }
  -        return folderHandler.getFolder(Folder.PATH_SEPARATOR);
  +        return (FolderImpl) folderHandler.getFolder(Folder.PATH_SEPARATOR);
       }
   
       private String getNodeName(String nodePath)
  
  
  
  1.10      +64 -17    jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/AbstractPageManager.java
  
  Index: AbstractPageManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/AbstractPageManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AbstractPageManager.java	23 Nov 2004 00:01:32 -0000	1.9
  +++ AbstractPageManager.java	26 Nov 2004 18:52:37 -0000	1.10
  @@ -208,6 +208,7 @@
           public NodeSet documentSets;
           public Map documentSetNames;
           public Map documentSetNodeSets;
  +        public NodeSet nestedDocumentSets;
   
           public CacheablePageContext(Page page, Folder folder, NodeSet siblingPages, Folder
parentFolder, NodeSet siblingFolders, NodeSet rootLinks, NodeSet documentSets, Map documentSetNames,
Map documentSetNodeSets)
           {
  @@ -221,6 +222,27 @@
               this.documentSetNames = documentSetNames;
               this.documentSetNodeSets = documentSetNodeSets;
   
  +            // compute nested document sets nodes set: these
  +            // do not appear in the document set but are mapped
  +            // in docuemnt set names/node sets
  +            if ((this.documentSetNames != null) && (this.documentSets != null)
&& (this.documentSetNames.size() > this.documentSets.size()))
  +            {
  +                Iterator mappedIter = this.documentSetNames.entrySet().iterator();
  +                while (mappedIter.hasNext())
  +                {
  +                    Map.Entry mappedEntry = (Map.Entry)mappedIter.next();
  +                    DocumentSet documentSet = (DocumentSet)mappedEntry.getKey();
  +                    if (!this.documentSets.contains(documentSet))
  +                    {
  +                        if (this.nestedDocumentSets == null)
  +                        {
  +                            this.nestedDocumentSets = new NodeSetImpl(null);
  +                        }
  +                        this.nestedDocumentSets.add(documentSet);
  +                    }
  +                }
  +            }
  +
               // debug profiled page context elements
               if (log.isDebugEnabled())
               {
  @@ -267,27 +289,39 @@
                       Iterator debugIter = this.documentSets.iterator();
                       while (debugIter.hasNext())
                       {
  -                        DocumentSet debug = (DocumentSet) debugIter.next();
  -                        String debugName = (String) this.documentSetNames.get(debug);
  -                        NodeSet debugNodes = (NodeSet) this.documentSetNodeSets.get(debug);
  -                        String debugMessage = "document set " + debug + ", name = " + debugName
+ ", nodes = {";
  -                        Iterator nodesIter = debugNodes.iterator();
  -                        if (nodesIter.hasNext())
  -                        {
  -                            debugMessage += ((Node) nodesIter.next()).getUrl();
  -                        }
  -                        while (nodesIter.hasNext())
  +                        log.debug("CacheablePageContext(), " + debugDocumentSetMessage((DocumentSet)debugIter.next()));
  +                    }
  +                    if ((this.nestedDocumentSets != null) && (this.nestedDocumentSets.size()
> 0))
  +                    {
  +                        debugIter = this.nestedDocumentSets.iterator();
  +                        while (debugIter.hasNext())
                           {
  -                            debugMessage += ", " + ((Node) nodesIter.next()).getUrl();
  +                            log.debug("CacheablePageContext(), nested " + debugDocumentSetMessage((DocumentSet)debugIter.next()));
                           }
  -                        debugMessage += "}, url = " + debug.getUrl();
  -                        log.debug("CacheablePageContext(), " + debugMessage);
                       }
                   }
                   else
                       log.debug("CacheablePageContext(), documentSets/documentSetNames/documentSetNodeSets
= null/empty");
               }
           }
  +
  +        private String debugDocumentSetMessage(DocumentSet debug)
  +        {
  +            String debugName = (String) this.documentSetNames.get(debug);
  +            NodeSet debugNodes = (NodeSet) this.documentSetNodeSets.get(debug);
  +            String debugMessage = "document set " + debug + ", name = " + debugName + ",
nodes = {";
  +            Iterator nodesIter = debugNodes.iterator();
  +            if (nodesIter.hasNext())
  +            {
  +                debugMessage += ((Node) nodesIter.next()).getUrl();
  +            }
  +            while (nodesIter.hasNext())
  +            {
  +                debugMessage += ", " + ((Node) nodesIter.next()).getUrl();
  +            }
  +            debugMessage += "}, url = " + debug.getUrl();
  +            return debugMessage;
  +        }
       }
   
       protected void populateProfiledPageContext(CacheablePageContext cachedPageContext,
ProfiledPageContext pageContext)
  @@ -305,10 +339,23 @@
               Iterator documentSetIter = checkAccess(cachedPageContext.documentSets, SecuredResource.VIEW_ACTION).iterator();
               while (documentSetIter.hasNext())
               {
  -                DocumentSet documentSet = (DocumentSet) documentSetIter.next();
  -                String documentSetName = (String) cachedPageContext.documentSetNames.get(documentSet);
  -                NodeSet documentSetNodes = checkAccess((NodeSet) cachedPageContext.documentSetNodeSets.get(documentSet),
SecuredResource.VIEW_ACTION);
  +                // populate root document set
  +                DocumentSet documentSet = (DocumentSet)documentSetIter.next();
  +                String documentSetName = (String)cachedPageContext.documentSetNames.get(documentSet);
  +                NodeSet documentSetNodes = checkAccess((NodeSet)cachedPageContext.documentSetNodeSets.get(documentSet),
SecuredResource.VIEW_ACTION);
                   pageContext.setDocumentSet(documentSetName, documentSet, documentSetNodes);
  +            }
  +            if (cachedPageContext.nestedDocumentSets != null)
  +            {
  +                Iterator nestedDocumentSetIter = checkAccess(cachedPageContext.nestedDocumentSets,
SecuredResource.VIEW_ACTION).iterator();
  +                while (nestedDocumentSetIter.hasNext())
  +                {
  +                    // populate nested document set
  +                    DocumentSet documentSet = (DocumentSet)nestedDocumentSetIter.next();
  +                    String documentSetName = (String)cachedPageContext.documentSetNames.get(documentSet);
  +                    NodeSet documentSetNodes = checkAccess((NodeSet)cachedPageContext.documentSetNodeSets.get(documentSet),
SecuredResource.VIEW_ACTION);
  +                    pageContext.setNestedDocumentSet(documentSetName, documentSet, documentSetNodes);
  +                }
               }
           }
       }
  
  
  
  1.7       +38 -4     jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/document/NodeSetImpl.java
  
  Index: NodeSetImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/document/NodeSetImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- NodeSetImpl.java	21 Oct 2004 02:28:07 -0000	1.6
  +++ NodeSetImpl.java	26 Nov 2004 18:52:37 -0000	1.7
  @@ -105,13 +105,12 @@
        */
       public void add( Node node )
       {
  -        nodes.put(node.getPath(), node);
           String path = node.getPath();
  +        nodes.put(path, node);
           if (subsets.containsKey(node.getType()))
           {
               ((NodeSet) subsets.get(node.getType())).add(node);
           }
  -
       }
   
       /**
  @@ -119,7 +118,7 @@
        * size
        * </p>
        * 
  -     * @see org.apache.jetspeed.om.page.DocumentSet#size()
  +     * @see org.apache.jetspeed.page.document.NodeSet#size()
        * @return
        */
       public int size()
  @@ -277,5 +276,40 @@
               patternCache.put(regex, pattern);
               return pattern;
           }       
  +    }
  +
  +    /**
  +     * <p>
  +     * contains
  +     * </p>
  +     * 
  +     * @see org.apache.jetspeed.page.document.NodeSet#contains()
  +     * @return
  +     */
  +    public boolean contains( Node node )
  +    {
  +        return nodes.values().contains(node);
  +    }
  +
  +    /**
  +     * <p>
  +     * remove
  +     * </p>
  +     * 
  +     * @param node to remove
  +     * @return removed node
  +     */
  +    public Node remove(Node node)
  +    {
  +        String path = node.getPath();
  +        if (nodes.get(path) == node)
  +        {
  +            nodes.remove(path);
  +            if (subsets.containsKey(node.getType()))
  +            {
  +                ((NodeSetImpl) subsets.get(node.getType())).remove(node);
  +            }
  +        }
  +        return null;
       }
   }
  
  
  
  1.21      +61 -9     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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- FolderImpl.java	23 Nov 2004 00:01:31 -0000	1.20
  +++ FolderImpl.java	26 Nov 2004 18:52:38 -0000	1.21
  @@ -494,17 +494,56 @@
           return getPageSecurity(false);
       }
   
  -    /**
  -     * <p>
  -     * getMetaData
  -     * </p>
  +    /*
  +     * (non-Javadoc)
        * 
  -     * @see org.apache.jetspeed.om.folder.Folder#getMetaData()
  -     * @return
  +     * @see org.apache.jetspeed.om.folder.Folder#getAll()
        */
  -    public FolderMetaData getMetaData()
  +    public NodeSet getAll() throws FolderNotFoundException, DocumentException
       {
  -        return metadata;
  +        // return secure set of all nodes: disable access checks on
  +        // folders to facilitate navigation, but enforce on documents
  +        // while creating filtered nodes
  +        NodeSet nodes = getAllNodes();
  +        NodeSet filteredNodes = null;
  +        Iterator checkAccessIter = nodes.iterator();
  +        while (checkAccessIter.hasNext())
  +        {
  +            Node node = (Node)checkAccessIter.next();
  +            try
  +            {
  +                ((AbstractNode) node).checkAccess(SecuredResource.VIEW_ACTION);
  +                if (filteredNodes != null)
  +                {
  +                    filteredNodes.add(node);
  +                }
  +            }
  +            catch (SecurityException se)
  +            {
  +                if (filteredNodes == null)
  +                {
  +                    filteredNodes = new NodeSetImpl(getPath(), ((NodeSetImpl) nodes).getComparator());
  +                    Iterator copyIter = nodes.iterator();
  +                    while (copyIter.hasNext())
  +                    {
  +                        Node copyNode = (Node)copyIter.next();
  +                        if (copyNode != node)
  +                        {
  +                            filteredNodes.add(copyNode);
  +                        }
  +                        else
  +                        {
  +                            break;
  +                        }
  +                    }
  +                }
  +            }
  +        }
  +        if (filteredNodes != null)
  +        {
  +            return filteredNodes;
  +        }
  +        return nodes;
       }
   
       /**
  @@ -584,6 +623,19 @@
           }
           
           return allNodes;
  +    }
  +
  +    /**
  +     * <p>
  +     * getMetaData
  +     * </p>
  +     * 
  +     * @see org.apache.jetspeed.om.folder.Folder#getMetaData()
  +     * @return
  +     */
  +    public FolderMetaData getMetaData()
  +    {
  +        return metadata;
       }
       /**
        * <p>
  
  
  

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