portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r306996 - in /portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite: impl/MenuImpl.java view/SiteView.java
Date Fri, 07 Oct 2005 04:14:31 GMT
Author: rwatler
Date: Thu Oct  6 21:14:26 2005
New Revision: 306996

URL: http://svn.apache.org/viewcvs?rev=306996&view=rev
Log:
- correct recursion bug when nested menu was constructed for empty folder
- extend folder view test to include visibility, (i.e. hidden), test on children
  to prevent empty folders to be returned as valid children when forming
  site views for menu construction


Modified:
    portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/MenuImpl.java
    portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/view/SiteView.java

Modified: portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/MenuImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/MenuImpl.java?rev=306996&r1=306995&r2=306996&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/MenuImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/MenuImpl.java
Thu Oct  6 21:14:26 2005
@@ -136,6 +136,7 @@
                         }
 
                         // override menu options with visible folder contents
+                        // or create empty menu if no contents exist
                         List folderChildren = null;
                         try
                         {
@@ -151,6 +152,10 @@
                         {
                             overrideOptionProxies = folderChildren;
                         }
+                        else
+                        {
+                            return;
+                        }
                     }
                     else
                     {
@@ -159,11 +164,8 @@
                         overrideOptionProxies.add(optionProxy);
                     }
                     
-                    if (overrideOptionProxies != null)
-                    {
-                        // set relative element flag if options path is relative
-                        elementRelative = (elementRelative || !options.startsWith(Folder.PATH_SEPARATOR));
-                    }
+                    // set relative element flag if options path is relative
+                    this.elementRelative = (this.elementRelative || !options.startsWith(Folder.PATH_SEPARATOR));
                 }
 
                 // menu defined only with menu definition options
@@ -273,7 +275,7 @@
                         appendMenuElement(nestedMenu, separatedElements);
 
                         // set relative element flag if nested menu is relative
-                        elementRelative = (elementRelative || nestedMenu.isElementRelative());
+                        this.elementRelative = (this.elementRelative || nestedMenu.isElementRelative());
                     }
                     else if (menuElement instanceof MenuIncludeDefinition)
                     {
@@ -383,7 +385,7 @@
                                 }
 
                                 // set relative element flag if included menu is relative
-                                elementRelative = (elementRelative || includeMenu.isElementRelative());
+                                this.elementRelative = (this.elementRelative || includeMenu.isElementRelative());
                             }
                         }
                     }
@@ -418,7 +420,7 @@
                                     removeMenuElements(excludeMenu.getElements(), separatedElements);
 
                                     // set relative element flag if excluded menu is relative
-                                    elementRelative = (elementRelative || excludeMenu.isElementRelative());
+                                    this.elementRelative = (this.elementRelative || excludeMenu.isElementRelative());
                                 }
                             }
                         }
@@ -633,7 +635,7 @@
                     }
                 }
 
-                // retrun if no proxies available
+                // return if no proxies available
                 if (elementProxies == null)
                 {
                     return null;

Modified: portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/view/SiteView.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/view/SiteView.java?rev=306996&r1=306995&r2=306996&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/view/SiteView.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/view/SiteView.java
Thu Oct  6 21:14:26 2005
@@ -751,8 +751,8 @@
                     if (children != null)
                     {
                         Node node = children.get(currentPath);
-                        if ((node != null) && (!onlyViewable || isProxyViewable(node))
&&
-                            (!onlyVisible || !node.isHidden() || (node == currentPage)))
+                        if ((node != null) && (!onlyVisible || !node.isHidden() ||
(node == currentPage)) &&
+                            (!onlyViewable || isProxyViewable(node, onlyVisible)))
                         {
                             return node;
                         }
@@ -770,7 +770,8 @@
 
         // path maps to current folder; return if viewable/visible
         // or visibility not required
-        if ((!onlyViewable || isProxyViewable(currentFolder)) && (!onlyVisible ||
!currentFolder.isHidden()))
+        if ((!onlyVisible || !currentFolder.isHidden()) &&
+            (!onlyViewable || isProxyViewable(currentFolder, onlyVisible)))
         {
             return currentFolder;
         }
@@ -970,8 +971,8 @@
                                 while (childrenIter.hasNext())
                                 {
                                     Node child = (Node)childrenIter.next(); 
-                                    if ((!onlyViewable || isProxyViewable(child)) &&
-                                        (!onlyVisible || !child.isHidden() || (child == currentPage)))
+                                    if ((!onlyVisible || !child.isHidden() || (child == currentPage))
&&
+                                        (!onlyViewable || isProxyViewable(child, onlyVisible)))
                                     {
                                         if (proxies == null)
                                         {
@@ -989,8 +990,8 @@
                             // node proxy; return null if not found or not
                             // viewable and visiblity is required
                             Node child = children.get(currentRegexpPath);
-                            if ((child != null) && (!onlyViewable || isProxyViewable(child))
&&
-                                (!onlyVisible || !child.isHidden() || (child == currentPage)))
+                            if ((child != null) && (!onlyVisible || !child.isHidden()
|| (child == currentPage)) &&
+                                (!onlyViewable || isProxyViewable(child, onlyVisible)))
                             {
                                 List proxies = new ArrayList(1);
                                 proxies.add(currentFolder);
@@ -1014,7 +1015,8 @@
 
         // path maps to current folder; return if viewable/visible
         // or visibility not required
-        if ((!onlyViewable || isProxyViewable(currentFolder)) && (!onlyVisible ||
!currentFolder.isHidden()))
+        if ((!onlyVisible || !currentFolder.isHidden()) &&
+            (!onlyViewable || isProxyViewable(currentFolder, onlyVisible)))
         {
             List proxies = new ArrayList(1);
             proxies.add(currentFolder);
@@ -1081,15 +1083,17 @@
     }
 
     /**
-     * isProxyViewable - tests for node proxy visibilty in view
+     * isProxyViewable - tests for node proxy visibility in view
      *
      * @param nodeProxy test node proxy
+     * @param onlyVisible nodes required to be visible
      * @return - viewable flag
      */
-    private static boolean isProxyViewable(Node nodeProxy)
+    private static boolean isProxyViewable(Node nodeProxy, boolean onlyVisible)
     {
         // pages and links are always considered viewable;
-        // folders must be tested for viewable child nodes
+        // folders must be tested for viewable and visibile
+        // child nodes
         if (nodeProxy instanceof Folder)
         {
             try
@@ -1100,7 +1104,8 @@
                     Iterator childrenIter = children.iterator();
                     while (childrenIter.hasNext())
                     {
-                        if (isProxyViewable((Node)childrenIter.next()))
+                        Node child = (Node)childrenIter.next();
+                        if ((!onlyVisible || !child.isHidden()) && isProxyViewable(child,
onlyVisible))
                         {
                             return true;
                         }



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