portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r925414 - in /portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src: main/java/org/apache/jetspeed/om/folder/proxy/ main/java/org/apache/jetspeed/portalsite/view/ test/java/org/apache/jetspeed/portalsite/ test/resources/webapp...
Date Fri, 19 Mar 2010 20:47:17 GMT
Author: rwatler
Date: Fri Mar 19 20:47:17 2010
New Revision: 925414

URL: http://svn.apache.org/viewvc?rev=925414&view=rev
Log:
JS2-1134: correct computation of inherited rooted folder paths

Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/folder/
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/folder/folder.metadata
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/folder/page0.psml
Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/PhysicalSiteView.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/page0.psml

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java?rev=925414&r1=925413&r2=925414&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
Fri Mar 19 20:47:17 2010
@@ -195,6 +195,22 @@ public class FolderProxy extends NodePro
     private List searchFolders;
 
     /**
+     * InheritanceFolder - data object used hold aggregated concrete search
+     *                     folders and view path to folder 
+     */
+    private class InheritanceFolder
+    {
+        public Folder folder;
+        public String path;
+
+        public InheritanceFolder(Folder folder, String path)
+        {
+            this.folder = folder;
+            this.path = path;
+        }
+    }
+
+    /**
      * inheritanceFolders - inheritance graph folder list in most to
      *                      least specific order
      */
@@ -882,13 +898,15 @@ public class FolderProxy extends NodePro
         // specific along inheritance folder graph by name
         try
         {
-            Iterator foldersIter = getInheritanceFolders().iterator();
-            while (foldersIter.hasNext())
+            Iterator inheritanceFoldersIter = getInheritanceFolders().iterator();
+            while (inheritanceFoldersIter.hasNext())
             {
                 // get menu definitions from inheritance folders and
                 // merge into aggregate menu definition locators
-                Folder folder = (Folder)foldersIter.next();
-                mergeMenuDefinitionLocators(folder.getMenuDefinitions(), folder, getPath(),
false);
+                InheritanceFolder inheritanceFolder = (InheritanceFolder)inheritanceFoldersIter.next();
+                Folder folder = inheritanceFolder.folder;
+                String path = inheritanceFolder.path;
+                mergeMenuDefinitionLocators(folder.getMenuDefinitions(), folder, path, false);
             }
         }
         catch (FolderNotFoundException fnfe)
@@ -1295,7 +1313,7 @@ public class FolderProxy extends NodePro
                 Iterator foldersIter = searchFolders.iterator();
                 while (foldersIter.hasNext())
                 {
-                    inheritanceFolders.add(((SearchFolder)foldersIter.next()).folder);
+                    inheritanceFolders.add(new InheritanceFolder(((SearchFolder)foldersIter.next()).folder,
folder.getPath()));
                 }
 
                 // get super/parent search paths

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/PhysicalSiteView.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/PhysicalSiteView.java?rev=925414&r1=925413&r2=925414&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/PhysicalSiteView.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/PhysicalSiteView.java
Fri Mar 19 20:47:17 2010
@@ -127,7 +127,7 @@ public class PhysicalSiteView extends Ab
                 {
                     // get menu definitions from inheritance folders and
                     // merge into menu definition locators
-                    locators = SiteViewUtils.mergeMenuDefinitionLocators(folder.getMenuDefinitions(),
folder, path, false, locators);
+                    locators = SiteViewUtils.mergeMenuDefinitionLocators(folder.getMenuDefinitions(),
folder, folder.getPath(), false, locators);
                     folder = (Folder)folder.getParent();
                 }
                 // merge standard menu definition locator defaults

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java?rev=925414&r1=925413&r2=925414&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java
Fri Mar 19 20:47:17 2010
@@ -360,7 +360,8 @@ public class TestPortalSite extends Abst
         assertEquals(rootFolderView, rootFolder1View.getParent());
         assertEquals(2, rootFolder1View.getPages().size());
         assertNull(rootFolder1View.getLinks());
-        assertNull(rootFolder1View.getFolders());
+        assertNotNull(rootFolder1View.getFolders());
+        assertEquals(1, rootFolder1View.getFolders().size());
         assertEquals("folder1", rootFolder1View.getName());
         assertEquals("group folder1", rootFolder1View.getTitle());
         assertEquals("/_user/user/folder1", extractFileSystemPathFromId(rootFolder1View.getId()));
@@ -979,11 +980,13 @@ public class TestPortalSite extends Abst
                 assertFalse(((Menu)element).isEmpty());
                 List elements = ((Menu)element).getElements();
                 assertNotNull(elements);
-                assertEquals(2, elements.size());
+                assertEquals(3, elements.size());
                 assertTrue(elements.get(0) instanceof MenuOption);
-                assertEquals("/folder1/page0.psml", ((MenuOption)elements.get(0)).getTitle());
+                assertEquals("folder1/folder", ((MenuOption)elements.get(0)).getTitle());
                 assertTrue(elements.get(1) instanceof MenuOption);
-                assertEquals("/folder1/page1.psml", ((MenuOption)elements.get(1)).getTitle());
+                assertEquals("/folder1/page0.psml", ((MenuOption)elements.get(1)).getTitle());
+                assertTrue(elements.get(2) instanceof MenuOption);
+                assertEquals("/folder1/page1.psml", ((MenuOption)elements.get(2)).getTitle());
             }
             else if (element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) &&
element.getTitle().equals("Folder4"))
             {
@@ -1139,11 +1142,13 @@ public class TestPortalSite extends Abst
                 assertFalse(((Menu)element).isEmpty());
                 List elements = ((Menu)element).getElements();
                 assertNotNull(elements);
-                assertEquals(2, elements.size());
-                assertTrue(elements.get(0) instanceof MenuOption);
-                assertEquals("/folder1/page0.psml", ((MenuOption)elements.get(0)).getTitle());
+                assertEquals(3, elements.size());
+                assertTrue(elements.get(0) instanceof Menu);
+                assertEquals("folder1/folder", ((Menu)elements.get(0)).getTitle());
                 assertTrue(elements.get(1) instanceof MenuOption);
-                assertEquals("/folder1/page1.psml", ((MenuOption)elements.get(1)).getTitle());
+                assertEquals("/folder1/page0.psml", ((MenuOption)elements.get(1)).getTitle());
+                assertTrue(elements.get(2) instanceof MenuOption);
+                assertEquals("/folder1/page1.psml", ((MenuOption)elements.get(2)).getTitle());
             }
             else if (element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) &&
element.getTitle().equals("Folder4"))
             {
@@ -1708,12 +1713,17 @@ public class TestPortalSite extends Abst
         assertFalse(rootedMenu.isEmpty());
         rootedElements = rootedMenu.getElements();
         assertNotNull(rootedElements);
-        assertEquals(2, rootedElements.size());
+        assertEquals(3, rootedElements.size());
         menuElementsIter = rootedElements.iterator();        
         while (menuElementsIter.hasNext())
         {
             MenuElement element = (MenuElement)menuElementsIter.next();
-            if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) &&
element.getTitle().equals("/folder1/page0.psml"))
+            if (element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) &&
element.getTitle().equals("folder1/folder"))
+            {
+                assertTrue(element instanceof Menu);
+                assertEquals("/folder1/folder", ((Menu)element).getUrl());
+            }
+            else if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) &&
element.getTitle().equals("/folder1/page0.psml"))
             {
                 assertTrue(element instanceof MenuOption);
                 assertEquals("/folder1/page0.psml", ((MenuOption)element).getUrl());
@@ -1731,6 +1741,40 @@ public class TestPortalSite extends Abst
             }            
         }
 
+        // new request at /folder1/folder/page0.psml
+        locator = new JetspeedProfileLocator();
+        locator.init(null, "/folder1/folder/page0.psml");
+        locator.add("user", true, false, "user");
+        locator.add("mediatype", true, false, "html");
+        locators = new HashMap();
+        locators.put(ProfileLocator.PAGE_LOCATOR, locator);
+        locator = new JetspeedProfileLocator();
+        locator.init(null, "/folder1");
+        locator.add("group", true, false, "group");
+        locators.put("group", locator);
+        requestContext = sessionContext.newRequestContext(locators, "user");
+        assertNotNull(requestContext);
+        rootedMenu = requestContext.getMenu("rooted-navigations");
+        assertNotNull(rootedMenu);
+        assertFalse(rootedMenu.isEmpty());
+        rootedElements = rootedMenu.getElements();
+        assertNotNull(rootedElements);
+        assertEquals(3, rootedElements.size());
+        menuElementsIter = rootedElements.iterator();        
+        while (menuElementsIter.hasNext())
+        {
+            MenuElement element = (MenuElement)menuElementsIter.next();
+            if ((element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) &&
element.getTitle().equals("folder1/folder")) ||
+                (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) &&
element.getTitle().equals("/folder1/page0.psml")) ||
+                (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) &&
element.getTitle().equals("/folder1/page1.psml")))
+            {
+            }
+            else
+            {
+                fail("Unexpected menu element type/title: "+element.getElementType()+"/"+element.getTitle());
+            }            
+        }
+
         // physical site menus
         sessionContext = portalSite.newSessionContext();
         assertNotNull(sessionContext);
@@ -1920,12 +1964,17 @@ public class TestPortalSite extends Abst
         assertFalse(rootedMenu.isEmpty());
         rootedElements = rootedMenu.getElements();
         assertNotNull(rootedElements);
-        assertEquals(1, rootedElements.size());
+        assertEquals(2, rootedElements.size());
         menuElementsIter = rootedElements.iterator();        
         while (menuElementsIter.hasNext())
         {
             MenuElement element = (MenuElement)menuElementsIter.next();
-            if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) &&
element.getTitle().equals("/folder1/page0.psml"))
+            if (element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) &&
element.getTitle().equals("folder1/folder"))
+            {
+                assertTrue(element instanceof Menu);
+                assertEquals("/folder1/folder", ((Menu)element).getUrl());
+            }
+            else if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) &&
element.getTitle().equals("/folder1/page0.psml"))
             {
                 assertTrue(element instanceof MenuOption);
                 assertEquals("/folder1/page0.psml", ((MenuOption)element).getUrl());
@@ -1936,6 +1985,28 @@ public class TestPortalSite extends Abst
                 fail("Unexpected menu element type/title: "+element.getElementType()+"/"+element.getTitle());
             }            
         }
+
+        requestContext = sessionContext.newRequestContext("/folder1/folder/page0.psml", null,
"user");
+        assertNotNull(requestContext);
+        rootedMenu = requestContext.getMenu("rooted-navigations");
+        assertNotNull(rootedMenu);
+        assertFalse(rootedMenu.isEmpty());
+        rootedElements = rootedMenu.getElements();
+        assertNotNull(rootedElements);
+        assertEquals(2, rootedElements.size());
+        menuElementsIter = rootedElements.iterator();        
+        while (menuElementsIter.hasNext())
+        {
+            MenuElement element = (MenuElement)menuElementsIter.next();
+            if ((element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) &&
element.getTitle().equals("folder1/folder")) ||
+                (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) &&
element.getTitle().equals("/folder1/page0.psml")))
+            {
+            }
+            else
+            {
+                fail("Unexpected menu element type/title: "+element.getElementType()+"/"+element.getTitle());
+            }            
+        }
     }
 
     /**

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/folder/folder.metadata
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/folder/folder.metadata?rev=925414&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/folder/folder.metadata
(added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/folder/folder.metadata
Fri Mar 19 20:47:17 2010
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+-->
+
+<folder
+    xmlns="http://portals.apache.org/jetspeed"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://portals.apache.org/jetspeed http://portals.apache.org/jetspeed-2/2.1/schemas/folder-metadata.xsd">
+
+  <title>folder1/folder</title>  
+  <short-title>folder1/folder</short-title>  
+
+  <default-page>page0.psml</default-page>
+</folder>

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/folder/page0.psml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/folder/page0.psml?rev=925414&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/folder/page0.psml
(added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/folder/page0.psml
Fri Mar 19 20:47:17 2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+-->
+
+<page id="folder1-folder-page0"
+    xmlns="http://portals.apache.org/jetspeed"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+    xsi:schemaLocation="http://portals.apache.org/jetspeed http://portals.apache.org/jetspeed-2/2.1/schemas/psml.xsd">
+
+  <title>/folder1/folder/page0.psml</title>
+  <fragment id="fake" name="fake" type="fake"/>
+
+</page>

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/page0.psml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/page0.psml?rev=925414&r1=925413&r2=925414&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/page0.psml
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/resources/webapp/WEB-INF/pages/folder1/page0.psml
Fri Mar 19 20:47:17 2010
@@ -17,7 +17,7 @@ See the License for the specific languag
 limitations under the License.
 -->
 
-<page id="folder-page0"
+<page id="folder1-page0"
     xmlns="http://portals.apache.org/jetspeed"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://portals.apache.org/jetspeed http://portals.apache.org/jetspeed-2/2.1/schemas/psml.xsd">



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message