portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r1578680 - in /portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src: main/java/org/apache/jetspeed/om/folder/proxy/ main/java/org/apache/jetspeed/page/document/proxy/ main/java/org/apache/jetspeed/portalsite/impl/ main/java/o...
Date Tue, 18 Mar 2014 00:28:14 GMT
Author: rwatler
Date: Tue Mar 18 00:28:13 2014
New Revision: 1578680

URL: http://svn.apache.org/r1578680
Log:
JS2-874: Iterator/foreach conversions for portal site implementation

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/page/document/proxy/NodeProxy.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/page/document/proxy/NodeSetImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/MenuImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/AbstractSiteView.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SearchPathsSiteView.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewUtils.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java

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=1578680&r1=1578679&r2=1578680&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 Tue Mar 18 00:28:13 2014
@@ -49,7 +49,6 @@ import java.lang.reflect.Proxy;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 
@@ -805,11 +804,9 @@ public class FolderProxy extends NodePro
         try
         {
             // check access on concrete child in all search folders
-            Iterator foldersIter = getSearchFolders().iterator();
-            while (foldersIter.hasNext())
+            for (SearchFolder searchFolder : getSearchFolders())
             {
                 // test access against child in search folder
-                SearchFolder searchFolder = (SearchFolder)foldersIter.next();
                 Folder folder = searchFolder.folderReference.getFolder();
                 // ignore all folder access exceptions, (throws SecurityException on failed check access)
                 try
@@ -843,11 +840,9 @@ public class FolderProxy extends NodePro
         try
         {
             // check access on concrete child in all search folders
-            Iterator foldersIter = getSearchFolders().iterator();
-            while (foldersIter.hasNext())
+            for (SearchFolder searchFolder : getSearchFolders())
             {
                 // test access against child in search folder
-                SearchFolder searchFolder = (SearchFolder)foldersIter.next();
                 Folder folder = searchFolder.folderReference.getFolder();
                 // ignore all folder access exceptions, (throws SecurityException on failed check access)
                 try
@@ -899,12 +894,10 @@ public class FolderProxy extends NodePro
         // specific along inheritance folder graph by name
         try
         {
-            Iterator inheritanceFoldersIter = getInheritanceFolders().iterator();
-            while (inheritanceFoldersIter.hasNext())
+            for (InheritanceFolder inheritanceFolder : getInheritanceFolders())
             {
                 // get menu definitions from inheritance folders and
                 // merge into aggregate menu definition locators
-                InheritanceFolder inheritanceFolder = (InheritanceFolder)inheritanceFoldersIter.next();
                 Folder folder = inheritanceFolder.folderReference.getFolder();
                 String path = inheritanceFolder.path;
                 mergeMenuDefinitionLocators(folder.getMenuDefinitions(), folder, path, false);
@@ -955,10 +948,9 @@ public class FolderProxy extends NodePro
         // with a specified title, short title, or metadata
         try
         {
-            Iterator foldersIter = getSearchFolders().iterator();
-            while (foldersIter.hasNext())
+            for (SearchFolder searchFolder : getSearchFolders())
             {
-                FolderWeakReference folderReference = ((SearchFolder)foldersIter.next()).folderReference;
+                FolderWeakReference folderReference = searchFolder.folderReference;
                 Folder folder = folderReference.getFolder();
                 String name = folder.getName();
                 String title = folder.getTitle();
@@ -994,11 +986,10 @@ public class FolderProxy extends NodePro
         {
             // only test for fallback default page once
             boolean fallbackDefaultPageNotFound = false;
-            Iterator foldersIter = getSearchFolders().iterator();
-            while (foldersIter.hasNext())
+            for (SearchFolder searchFolder : getSearchFolders())
             {
                 // get folder default page name or look for fallback default name
-                Folder folder = ((SearchFolder)foldersIter.next()).folderReference.getFolder();
+                Folder folder = searchFolder.folderReference.getFolder();
                 String defaultPageName = folder.getDefaultPage();
                 if (defaultPageName != null)
                 {
@@ -1094,20 +1085,16 @@ public class FolderProxy extends NodePro
             // get children proxies
             List<Node> allChildren = new ArrayList<Node>();
             List<String> folderDocumentOrder = null;
-            Iterator foldersIter = getSearchFolders().iterator();
-            while (foldersIter.hasNext())
+            for (SearchFolder searchFolder : getSearchFolders())
             {
                 // aggregate folders
-                SearchFolder searchFolder = (SearchFolder)foldersIter.next();
                 Folder folder = searchFolder.folderReference.getFolder();
                 String locatorName = searchFolder.locatorName;
 
                 // create and save proxies for concrete children
                 NodeSet children = folder.getAll();
-                Iterator childrenIter = children.iterator();
-                while (childrenIter.hasNext())
+                for (Node child : children)
                 {
-                    Node child = (Node)childrenIter.next();
                     String childName = child.getName();
 
                     // filter profiling property folders unless forced; they are
@@ -1120,10 +1107,13 @@ public class FolderProxy extends NodePro
                     {
                         // test child name uniqueness
                         boolean childUnique = true ;
-                        Iterator allChildrenIter = allChildren.iterator();
-                        while (childUnique && allChildrenIter.hasNext())
+                        for (Node testChild : allChildren)
                         {
-                            childUnique = !childName.equals(((Node)allChildrenIter.next()).getName());                            
+                            if (childName.equals(testChild.getName()))
+                            {
+                                childUnique = false;
+                                break;
+                            }
                         }
 
                         // add uniquely named children proxies
@@ -1235,11 +1225,9 @@ public class FolderProxy extends NodePro
             // search for existing folders along search paths
             List<SiteViewSearchPath> searchPaths = getView().getSearchPaths();
             searchFolders = new ArrayList<SearchFolder>(searchPaths.size());
-            Iterator pathsIter = searchPaths.iterator();
-            while (pathsIter.hasNext())
+            for (SiteViewSearchPath searchPath : searchPaths)
             {
                 // construct folder paths
-                SiteViewSearchPath searchPath = (SiteViewSearchPath)pathsIter.next();
                 String path = searchPath.toString();
                 if (!path.equals(Folder.PATH_SEPARATOR))
                 {
@@ -1313,10 +1301,9 @@ public class FolderProxy extends NodePro
             {
                 // copy ordered search path folders into inheritance
                 // graph folders list
-                Iterator foldersIter = searchFolders.iterator();
-                while (foldersIter.hasNext())
+                for (SearchFolder searchFolder : searchFolders)
                 {
-                    inheritanceFolders.add(new InheritanceFolder(((SearchFolder)foldersIter.next()).folderReference, folder.getPath()));
+                    inheritanceFolders.add(new InheritanceFolder(searchFolder.folderReference, folder.getPath()));
                 }
 
                 // get super/parent search paths

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/page/document/proxy/NodeProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/page/document/proxy/NodeProxy.java?rev=1578680&r1=1578679&r2=1578680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/page/document/proxy/NodeProxy.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/page/document/proxy/NodeProxy.java Tue Mar 18 00:28:13 2014
@@ -30,7 +30,6 @@ import java.lang.reflect.Proxy;
 import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -210,10 +209,9 @@ public abstract class NodeProxy extends 
             if (locators != null)
             {
                 menuDefinitions = Collections.synchronizedList(new ArrayList<MenuDefinition>(locators.size()));
-                Iterator locatorsIter = locators.iterator();
-                while (locatorsIter.hasNext())
+                for (SiteViewMenuDefinitionLocator locator : locators)
                 {
-                    menuDefinitions.add(((SiteViewMenuDefinitionLocator)locatorsIter.next()).getMenuDefinition());
+                    menuDefinitions.add(locator.getMenuDefinition());
                 }
             }
             menuDefinitionsAggregated = true;

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/page/document/proxy/NodeSetImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/page/document/proxy/NodeSetImpl.java?rev=1578680&r1=1578679&r2=1578680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/page/document/proxy/NodeSetImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/page/document/proxy/NodeSetImpl.java Tue Mar 18 00:28:13 2014
@@ -58,10 +58,8 @@ public class NodeSetImpl implements Node
     public Node get(String name)
     {
         // search nodes for matching name or path
-        Iterator nodesIter = nodes.iterator();
-        while (nodesIter.hasNext())
+        for (Node node : this)
         {
-            Node node = (Node) nodesIter.next();
             if (node.getName().equals(name) || node.getPath().equals(name))
             {
                 return node;
@@ -75,9 +73,9 @@ public class NodeSetImpl implements Node
      *
      * @return proxy NodeSet list iterator
      */
-    public Iterator iterator()
+    public Iterator<Node> iterator()
     {
-        return nodes.listIterator();
+        return nodes.iterator();
     }
     
     /**
@@ -91,10 +89,8 @@ public class NodeSetImpl implements Node
     {
         // search for matching nodes
         List<Node> subsetNodes = null;
-        Iterator nodesIter = nodes.iterator();
-        while (nodesIter.hasNext())
+        for (Node node : this)
         {
-            Node node = (Node) nodesIter.next();
             if (node.getType().equals(type))
             {
                 if (subsetNodes == null)
@@ -124,10 +120,8 @@ public class NodeSetImpl implements Node
         // search for matching nodes
         List<Node> subsetNodes = null;
         Pattern pattern = Pattern.compile(regex);
-        Iterator nodesIter = nodes.iterator();
-        while (nodesIter.hasNext())
+        for (Node node : this)
         {
-            Node node = (Node) nodesIter.next();
             if (pattern.matcher(node.getName()).matches() || pattern.matcher(node.getPath()).matches())
             {
                 if (subsetNodes == null)
@@ -157,10 +151,8 @@ public class NodeSetImpl implements Node
         // search for matching nodes
         List<Node> subsetNodes = null;
         Pattern pattern = Pattern.compile(regex);
-        Iterator nodesIter = nodes.iterator();
-        while (nodesIter.hasNext())
+        for (Node node : this)
         {
-            Node node = (Node) nodesIter.next();
             if (!pattern.matcher(node.getName()).matches() && !pattern.matcher(node.getPath()).matches())
             {
                 if (subsetNodes == null)

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/MenuImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/MenuImpl.java?rev=1578680&r1=1578679&r2=1578680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/MenuImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/MenuImpl.java Tue Mar 18 00:28:13 2014
@@ -18,6 +18,7 @@ package org.apache.jetspeed.portalsite.i
 
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.folder.MenuDefinition;
+import org.apache.jetspeed.om.folder.MenuDefinitionElement;
 import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
 import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
 import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
@@ -38,7 +39,6 @@ import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.ListIterator;
 import java.util.Locale;
 import java.util.Set;
 import java.util.regex.Matcher;
@@ -221,10 +221,8 @@ public class MenuImpl extends MenuElemen
                 List<MenuElement> separatedElements = null;
 
                 // process each defined menu element
-                Iterator menuElementsIter = definition.getMenuElements().iterator();
-                while (menuElementsIter.hasNext())
+                for (MenuDefinitionElement menuElement : definition.getMenuElements())
                 {
-                    Object menuElement = menuElementsIter.next();
                     if (menuElement instanceof MenuOptionsDefinition)
                     {
                         // construct menu option elements from definition using
@@ -354,10 +352,9 @@ public class MenuImpl extends MenuElemen
                                     // include menu elements
                                     if (!includeMenu.isEmpty())
                                     {
-                                        Iterator elementsIter = includeMenu.getElements().iterator();
-                                        while (elementsIter.hasNext())
+                                        for (MenuElement includeMenuElement : includeMenu.getElements())
                                         {
-                                            MenuElementImpl includeElement = (MenuElementImpl)elementsIter.next();
+                                            MenuElementImpl includeElement = (MenuElementImpl)includeMenuElement;
                                             try
                                             {
                                                 // clone menu element and reparent
@@ -522,10 +519,9 @@ public class MenuImpl extends MenuElemen
         // add to menu element list
         if (appendMenuElements != null)
         {
-            Iterator elementsIter = appendMenuElements.iterator();
-            while (elementsIter.hasNext())
+            for (MenuElement appendMenuElement : appendMenuElements)
             {
-                appendMenuElement((MenuElementImpl)elementsIter.next(), menuElements);
+                appendMenuElement((MenuElementImpl)appendMenuElement, menuElements);
             }
         }
     }
@@ -603,10 +599,8 @@ public class MenuImpl extends MenuElemen
                             }
                             if (pathViews != null)
                             {
-                                Iterator pathViewsIter = pathViews.iterator();
-                                while (pathViewsIter.hasNext())
+                                for (Node pathView : pathViews)
                                 {
-                                    Node pathView = (Node)pathViewsIter.next();
                                     if ((locatorName == null) || locatorName.equals(MenuOptionsDefinition.ANY_PROFILE_LOCATOR) ||
                                         locatorName.equals(view.getProfileLocatorName(pathView)))
                                     {
@@ -685,8 +679,8 @@ public class MenuImpl extends MenuElemen
                         Iterator elementViewsIter = elementViews.iterator();
                         while (elementViewsIter.hasNext())
                         {
-                            Node elementView = (Node)elementViewsIter.next(); 
-                            
+                            Node elementView = (Node)elementViewsIter.next();
+
                             // get url or name to test ordering match against
                             String test = null;
                             if (ordering.charAt(0) == Folder.PATH_SEPARATOR_CHAR)
@@ -741,10 +735,8 @@ public class MenuImpl extends MenuElemen
             // convert elements views into menu elements
             List<MenuElement> menuElements = new ArrayList<MenuElement>(elementViews.size());
             DefaultMenuOptionsDefinition defaultMenuOptionsDefinition = null;
-            ListIterator elementViewsIter = elementViews.listIterator();
-            while (elementViewsIter.hasNext())
+            for (Node elementView : elementViews)
             {
-                Node elementView = (Node)elementViewsIter.next();
                 MenuElement menuElement = null;
 
                 // convert folders into nested menus if depth specified
@@ -808,11 +800,10 @@ public class MenuImpl extends MenuElemen
         // clone and reparent copy elements
         if (copy.elements != null)
         {
-            Iterator elementsIter = copy.elements.iterator();
             copy.elements = new ArrayList<MenuElement>(copy.elements.size());
-            while (elementsIter.hasNext())
+            for (MenuElement element : copy.elements)
             {
-                MenuElementImpl elementCopy = (MenuElementImpl)((MenuElementImpl)elementsIter.next()).clone();
+                MenuElementImpl elementCopy = (MenuElementImpl)((MenuElementImpl)element).clone();
                 elementCopy.setParentMenu(copy);
                 copy.elements.add(elementCopy);
             }
@@ -1048,11 +1039,8 @@ public class MenuImpl extends MenuElemen
         // elements for selected status
         if (elements != null)
         {
-            Iterator elementsIter = elements.iterator();
-            while (elementsIter.hasNext())
+            for (MenuElement element : elements)
             {
-                MenuElement element = (MenuElement)elementsIter.next();
-                
                 // test element selected
                 boolean selected = false;
                 if (element instanceof MenuOption)

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java?rev=1578680&r1=1578679&r2=1578680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java Tue Mar 18 00:28:13 2014
@@ -40,7 +40,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -535,10 +534,8 @@ public class PortalSiteRequestContextImp
                 // scan through site looking for each first matching fragment
                 // definition by reference/definition id up the folder hierarchy
                 // from the requested page
-                Iterator refIdsIter = refIds.iterator();
-                while (refIdsIter.hasNext())
+                for (String refId : refIds)
                 {
-                    String refId = (String)refIdsIter.next();
                     FragmentDefinition requestFragmentDefinition = null;
                     try
                     {
@@ -550,13 +547,13 @@ public class PortalSiteRequestContextImp
                             if ((fragmentDefinitions != null) && !fragmentDefinitions.isEmpty())
                             {
                                 // find fragment definition by matching reference/definition id
-                                Iterator fragmentDefinitionsIter = fragmentDefinitions.iterator();
-                                while (fragmentDefinitionsIter.hasNext() && (requestFragmentDefinition == null))
+                                for (Node fragmentDefinitionNode : fragmentDefinitions)
                                 {
-                                    FragmentDefinition fragmentDefinition = (FragmentDefinition)fragmentDefinitionsIter.next();
+                                    FragmentDefinition fragmentDefinition = (FragmentDefinition)fragmentDefinitionNode;
                                     if (fragmentDefinition.getDefId().equals(refId))
                                     {
                                         requestFragmentDefinition = fragmentDefinition;
+                                        break;
                                     }
                                 }
                             }
@@ -605,13 +602,12 @@ public class PortalSiteRequestContextImp
         // merge list of fragment reference reference ids 
         if ((fragmentReferences != null) && !fragmentReferences.isEmpty())
         {
-            Iterator fragmentReferencesIter = fragmentReferences.iterator();
-            while (fragmentReferencesIter.hasNext())
+            for (BaseFragmentElement fragmentReference : fragmentReferences)
             {
-                FragmentReference fragmentReference = (FragmentReference)fragmentReferencesIter.next();
-                if (fragmentReference.getRefId() != null)
+                String refId = ((FragmentReference)fragmentReference).getRefId();
+                if (refId != null)
                 {
-                    refIds.add(fragmentReference.getRefId());
+                    refIds.add(refId);
                 }
             }
         }        
@@ -853,10 +849,9 @@ public class PortalSiteRequestContextImp
         // merge menu definition locator names
         if (locators != null)
         {
-            Iterator locatorsIter = locators.iterator();
-            while (locatorsIter.hasNext())
+            for (SiteViewMenuDefinitionLocator locator : locators)
             {
-                String definitionName = ((SiteViewMenuDefinitionLocator)locatorsIter.next()).getName();
+                String definitionName = locator.getName();
                 if (!excludeNames.contains(definitionName))
                 {
                     names.add(definitionName);
@@ -1006,11 +1001,9 @@ public class PortalSiteRequestContextImp
         {
             // filter node views in node set
             List<Node> filteredNodes = null;
-            Iterator nodesIter = nodes.iterator();
-            while (nodesIter.hasNext())
+            for (Node node : nodes)
             {
                 // test hidden status of individual node views
-                Node node = (Node)nodesIter.next();
                 if (node.isHidden())
                 {
                     // if not copying, create new node set
@@ -1018,10 +1011,8 @@ public class PortalSiteRequestContextImp
                     if (filteredNodes == null)
                     {
                         filteredNodes = new ArrayList<Node>(nodes.size());
-                        Iterator copyIter = nodes.iterator();
-                        while (copyIter.hasNext())
+                        for (Node copyNode : nodes)
                         {
-                            Node copyNode = (Node)copyIter.next();
                             if (copyNode != node)
                             {
                                 filteredNodes.add(copyNode);

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java?rev=1578680&r1=1578679&r2=1578680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java Tue Mar 18 00:28:13 2014
@@ -835,13 +835,13 @@ public class PortalSiteSessionContextImp
                         if (requestPageId != null)
                         {
                             // find page by id in request folder pages
-                            Iterator requestFolderPagesIter = requestFolderPages.iterator();
-                            while ((requestPage == null) && (requestFolderPagesIter.hasNext()))
+                            for (Node requestFolderPageNode : requestFolderPages)
                             {
-                                Page requestFolderPage = (Page)requestFolderPagesIter.next();
+                                Page requestFolderPage = (Page)requestFolderPageNode;
                                 if (requestPageId.equals(requestFolderPage.getId()))
                                 {
                                     requestPage = requestFolderPage;
+                                    break;
                                 }
                             }
                             
@@ -1062,10 +1062,9 @@ public class PortalSiteSessionContextImp
                         DynamicPage matchingPage = null;
                         DynamicPage inheritableMatchingPage = null;
                         DynamicPage wildcardMatchingPage = null;
-                        Iterator dynamicPagesIter = dynamicPages.iterator();
-                        while (dynamicPagesIter.hasNext())
+                        for (Node dynamicPageNode : dynamicPages)
                         {
-                            DynamicPage dynamicPage = (DynamicPage)dynamicPagesIter.next();
+                            DynamicPage dynamicPage = (DynamicPage)dynamicPageNode;
                             if ((dynamicPage.getContentType() == null) || dynamicPage.getContentType().equals(DynamicPage.WILDCARD_CONTENT_TYPE))
                             {
                                 wildcardMatchingPage = dynamicPage;
@@ -1268,12 +1267,10 @@ public class PortalSiteSessionContextImp
                 if (requestProfileLocators != null)
                 {
                     boolean firstEntry = true;
-                    Iterator entriesIter = requestProfileLocators.entrySet().iterator();
-                    while (entriesIter.hasNext())
+                    for (Map.Entry<String,ProfileLocator> entry : requestProfileLocators.entrySet())
                     {
-                        Map.Entry entry = (Map.Entry)entriesIter.next();
-                        String locatorName = (String)entry.getKey();
-                        ProfileLocator locator = (ProfileLocator)entry.getValue();
+                        String locatorName = entry.getKey();
+                        ProfileLocator locator = entry.getValue();
                         if (!firstEntry)
                         {
                             debug.append(",");
@@ -1619,7 +1616,7 @@ public class PortalSiteSessionContextImp
      * @param locators1 request profile locator map
      * @return boolean flag indicating equivalence
      */
-    private static boolean locatorsEquals(Map locators0, Map locators1)
+    private static boolean locatorsEquals(Map<String,ProfileLocator> locators0, Map<String,ProfileLocator> locators1)
     {
         // trivial comparisons
         if (locators0 == locators1)
@@ -1638,12 +1635,10 @@ public class PortalSiteSessionContextImp
         }
 
         // compare locator map entries
-        Iterator entriesIter = locators0.entrySet().iterator();
-        if (entriesIter.hasNext())
+        for (Map.Entry<String,ProfileLocator> entry : locators0.entrySet())
         {
-            Map.Entry entry = (Map.Entry)entriesIter.next();
-            ProfileLocator locator0 = (ProfileLocator)entry.getValue();
-            ProfileLocator locator1 = (ProfileLocator)locators1.get(entry.getKey());
+            ProfileLocator locator0 = entry.getValue();
+            ProfileLocator locator1 = locators1.get(entry.getKey());
             if (locator1 == null)
             {
                 return false;

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/AbstractSiteView.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/AbstractSiteView.java?rev=1578680&r1=1578679&r2=1578680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/AbstractSiteView.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/AbstractSiteView.java Tue Mar 18 00:28:13 2014
@@ -35,7 +35,6 @@ import org.apache.jetspeed.portalsite.me
 
 import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -464,10 +463,9 @@ public abstract class AbstractSiteView
                                     {
                                         // recursively process matching sub-folders
                                         List<Node> views = null;
-                                        Iterator subfoldersIter = subfolders.iterator();
-                                        while (subfoldersIter.hasNext())
+                                        for (Node folderNode : subfolders)
                                         {
-                                            currentFolder = (Folder)subfoldersIter.next();
+                                            currentFolder = (Folder)folderNode;
                                             List<Node> subfolderViews = getNodeViews(currentRegexpPath, currentFolder, menuPath, onlyConcrete, onlyViewable, onlyVisible);
                                             if ((subfolderViews != null) && !subfolderViews.isEmpty())
                                             {
@@ -546,10 +544,8 @@ public abstract class AbstractSiteView
                             if ((children != null) && !children.isEmpty())
                             {
                                 List<Node> views = null;
-                                Iterator childrenIter = children.iterator();
-                                while (childrenIter.hasNext())
+                                for (Node child : children)
                                 {
-                                    Node child = (Node)childrenIter.next(); 
                                     if ((!onlyConcrete || isConcreteNode(child)) &&
                                         (!onlyVisible || isVisible(child, currentPage)) &&
                                         (!onlyViewable || isViewable(child, onlyVisible)))
@@ -848,10 +844,8 @@ public abstract class AbstractSiteView
                 NodeSet children = ((Folder) node).getAll();
                 if (children != null)
                 {
-                    Iterator childrenIter = children.iterator();
-                    while (childrenIter.hasNext())
+                    for (Node child : children)
                     {
-                        Node child = (Node)childrenIter.next();
                         if ((!onlyVisible || isVisible(child, null)) && isViewable(child, onlyVisible))
                         {
                             return true;

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SearchPathsSiteView.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SearchPathsSiteView.java?rev=1578680&r1=1578679&r2=1578680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SearchPathsSiteView.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SearchPathsSiteView.java Tue Mar 18 00:28:13 2014
@@ -95,11 +95,9 @@ public class SearchPathsSiteView extends
             this.searchPaths = new ArrayList<SiteViewSearchPath>(searchPaths.size());
             List<SiteViewSearchPath> allSearchPaths = new ArrayList<SiteViewSearchPath>(searchPaths.size());
             StringBuilder searchPathsStringBuilder = new StringBuilder();
-            Iterator pathsIter = searchPaths.iterator();
-            while (pathsIter.hasNext())
+            for (Object pathObject : searchPaths)
             {
                 // construct search paths if necessary
-                Object pathObject = pathsIter.next();
                 if (!(pathObject instanceof SiteViewSearchPath))
                 {
                     String path = pathObject.toString().trim();
@@ -158,10 +156,8 @@ public class SearchPathsSiteView extends
             }
             
             // find primary user search path, (may not exist: search against all paths) 
-            Iterator searchPathsIter = allSearchPaths.iterator();
-            while (searchPathsIter.hasNext())
+            for (SiteViewSearchPath searchPath : allSearchPaths)
             {
-                SiteViewSearchPath searchPath = (SiteViewSearchPath)searchPathsIter.next();
                 if (searchPath.isUserPath())
                 {
                     this.userSearchPath = searchPath;
@@ -185,10 +181,9 @@ public class SearchPathsSiteView extends
                 // scan for the search path that are common to all
                 // more specific search paths starting at the least
                 // specific search path
-                ListIterator baseSearchPathsIter = allSearchPaths.listIterator(allSearchPaths.size());
-                while (baseSearchPathsIter.hasPrevious())
+                for (ListIterator<SiteViewSearchPath> baseSearchPathsIter = allSearchPaths.listIterator(allSearchPaths.size()); baseSearchPathsIter.hasPrevious();)
                 {
-                    SiteViewSearchPath searchPath = (SiteViewSearchPath)baseSearchPathsIter.previous();
+                    SiteViewSearchPath searchPath = baseSearchPathsIter.previous();
                     int scanSearchPathsIndex = baseSearchPathsIter.previousIndex();
                     if (scanSearchPathsIndex == -1)
                     {
@@ -206,10 +201,9 @@ public class SearchPathsSiteView extends
                         // scan more specific search paths to test whether the
                         // current search path is common to all
                         boolean isCommonSearchPath = true;
-                        ListIterator scanBaseSearchPathsIter = allSearchPaths.listIterator(scanSearchPathsIndex+1);
-                        while (scanBaseSearchPathsIter.hasPrevious())
+                        for (ListIterator<SiteViewSearchPath> scanBaseSearchPathsIter = allSearchPaths.listIterator(scanSearchPathsIndex+1); scanBaseSearchPathsIter.hasPrevious();)
                         {
-                            SiteViewSearchPath scanSearchPath = (SiteViewSearchPath)scanBaseSearchPathsIter.previous();
+                            SiteViewSearchPath scanSearchPath = scanBaseSearchPathsIter.previous();
                             if (!scanSearchPath.toString().startsWith(searchPath.toString()))
                             {
                                 isCommonSearchPath = false;
@@ -368,10 +362,8 @@ public class SearchPathsSiteView extends
             }
             if ((pageLocator == null) || (locators.size() > 1))
             {
-                Iterator locatorNameIter = locators.keySet().iterator();
-                while (locatorNameIter.hasNext())
+                for (String locatorName : locators.keySet())
                 {
-                    String locatorName = (String)locatorNameIter.next();
                     if (!locatorName.equals(ProfileLocator.PAGE_LOCATOR))
                     {
                         // add alternate locator search paths
@@ -589,10 +581,8 @@ public class SearchPathsSiteView extends
                             // control value from each, appending new value, and adding new
                             // valued set to collection of paths
                             ArrayList<PathStringBuilder> multipleValuePaths = new ArrayList<PathStringBuilder>(lastPathsCount);
-                            Iterator pathsIter = paths.iterator();
-                            for (int count = 0; (pathsIter.hasNext() && (count < lastPathsCount)); count++)
+                            for (PathStringBuilder path : paths)
                             {
-                                PathStringBuilder path = (PathStringBuilder) pathsIter.next();
                                 PathStringBuilder multipleValuePath = new PathStringBuilder(path.toString());
                                 multipleValuePath.setLength(multipleValuePath.length() - lastPropertyValueLength - 1);
                                 multipleValuePath.append(propertyValue);
@@ -601,6 +591,10 @@ public class SearchPathsSiteView extends
                                 multipleValuePath.setPrincipalPath(path.isPrincipalPath() || principalPath);
                                 multipleValuePath.setPathDepth(path.getPathDepth()+1);
                                 multipleValuePaths.add(multipleValuePath);
+                                if (multipleValuePaths.size() == lastPathsCount)
+                                {
+                                    break;
+                                }
                             }
                             paths.addAll(multipleValuePaths);
 
@@ -612,10 +606,8 @@ public class SearchPathsSiteView extends
                         else
                         {
                             // construct locator path folders with control properties
-                            Iterator pathsIter = paths.iterator();
-                            while (pathsIter.hasNext())
+                            for (PathStringBuilder path : paths)
                             {
-                                PathStringBuilder path = (PathStringBuilder) pathsIter.next();
                                 path.append(Folder.RESERVED_FOLDER_PREFIX);
                                 path.append(propertyName);
                                 path.append(Folder.PATH_SEPARATOR_CHAR);
@@ -691,10 +683,8 @@ public class SearchPathsSiteView extends
                 // search order; move non-unique paths to end of search
                 // path list to favor more specific paths over common
                 // root paths, (i.e. '/' should be last)
-                Iterator locatorSearchPathsIter = locatorSearchPaths.iterator();
-                while (locatorSearchPathsIter.hasNext())
+                for (PathStringBuilder searchPathBuilder : locatorSearchPaths)
                 {
-                    PathStringBuilder searchPathBuilder = (PathStringBuilder)locatorSearchPathsIter.next();
                     SiteViewSearchPath searchPath = new SiteViewSearchPath(locatorName, searchPathBuilder.toString(), searchPathBuilder.isUserPath(), searchPathBuilder.isPrincipalPath(), searchPathBuilder.getPathDepth());
                     // test search path uniqueness
                     int existsAt = searchPaths.indexOf(searchPath);

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewUtils.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewUtils.java?rev=1578680&r1=1578679&r2=1578680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewUtils.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewUtils.java Tue Mar 18 00:28:13 2014
@@ -21,7 +21,6 @@ import org.apache.jetspeed.page.document
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -50,11 +49,9 @@ public class SiteViewUtils
         // locators if defined
         if (definitions != null)
         {
-            Iterator definitionsIter = definitions.iterator();
-            while (definitionsIter.hasNext())
+            for (MenuDefinition definition : definitions)
             {
                 // aggregate menu definition by valid name
-                MenuDefinition definition = (MenuDefinition)definitionsIter.next();
                 String definitionName = definition.getName();
                 if (definitionName != null)
                 {
@@ -93,11 +90,9 @@ public class SiteViewUtils
         // locators if defined
         if (locators != null)
         {
-            Iterator locatorsIter = locators.iterator();
-            while (locatorsIter.hasNext())
+            for (SiteViewMenuDefinitionLocator locator : locators)
             {
                 // aggregate menu definition by valid name
-                SiteViewMenuDefinitionLocator locator = (SiteViewMenuDefinitionLocator)locatorsIter.next();
                 String definitionName = locator.getName();
 
                 // add unique menu definition to end of
@@ -142,10 +137,8 @@ public class SiteViewUtils
         {
             synchronized (menuDefinitionLocators)
             {
-                Iterator locatorsIter = menuDefinitionLocators.iterator();
-                while (locatorsIter.hasNext())
+                for (SiteViewMenuDefinitionLocator locator : menuDefinitionLocators)
                 {
-                    SiteViewMenuDefinitionLocator locator = (SiteViewMenuDefinitionLocator)locatorsIter.next();
                     if (name.equals(locator.getName()))
                     {
                         return locator;

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=1578680&r1=1578679&r2=1578680&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 Tue Mar 18 00:28:13 2014
@@ -164,7 +164,7 @@ public class TestPortalSite extends Abst
         assertEquals("root", rootFolderView.getTitle());
         assertEquals("/", extractFileSystemPathFromId(rootFolderView.getId()));
         assertEquals(6, rootFolderView.getFolders().size());
-        Iterator foldersIter = rootFolderView.getFolders().iterator();
+        Iterator<Node> foldersIter = rootFolderView.getFolders().iterator();
         assertEquals("contentfolder", ((Folder)foldersIter.next()).getName());
         assertEquals("folder0", ((Folder)foldersIter.next()).getName());
         assertEquals("folder1", ((Folder)foldersIter.next()).getName());
@@ -172,17 +172,17 @@ public class TestPortalSite extends Abst
         assertEquals("folder3", ((Folder)foldersIter.next()).getName());
         assertEquals("folder4", ((Folder)foldersIter.next()).getName());
         assertEquals(4, rootFolderView.getPages().size());
-        Iterator pagesIter = rootFolderView.getPages().iterator();
+        Iterator<Node> pagesIter = rootFolderView.getPages().iterator();
         assertEquals("page2.psml", ((Page)pagesIter.next()).getName());
         assertEquals("page1.psml", ((Page)pagesIter.next()).getName());
         assertEquals("page0.psml", ((Page)pagesIter.next()).getName());
         assertEquals("hidden.psml", ((Page)pagesIter.next()).getName());
         assertEquals(2, rootFolderView.getLinks().size());
-        Iterator linksIter = rootFolderView.getLinks().iterator();
+        Iterator<Node> linksIter = rootFolderView.getLinks().iterator();
         assertEquals("link1.link", ((Link)linksIter.next()).getName());
         assertEquals("link0.link", ((Link)linksIter.next()).getName());
         assertEquals(2, rootFolderView.getDynamicPages().size());
-        Iterator dynamicPagesIter = rootFolderView.getDynamicPages().iterator();
+        Iterator<Node> dynamicPagesIter = rootFolderView.getDynamicPages().iterator();
         assertEquals("contentpage.dpsml", ((DynamicPage)dynamicPagesIter.next()).getName());
         assertEquals("docpage.dpsml", ((DynamicPage)dynamicPagesIter.next()).getName());
         Page rootPage0View = rootFolderView.getPage("page0.psml");
@@ -279,33 +279,33 @@ public class TestPortalSite extends Abst
         List<MenuDefinition> rootPage0ViewMenus = rootPage0View.getMenuDefinitions();
         assertNotNull(rootPage0ViewMenus);
         assertEquals(7 + aggregateView.getStandardMenuNames().size(), rootPage0ViewMenus.size());
-        Iterator menusIter = rootPage0ViewMenus.iterator();
-        MenuDefinition rootPage0ViewTemplateTestMenu = (MenuDefinition)menusIter.next();
+        Iterator<MenuDefinition> menusIter = rootPage0ViewMenus.iterator();
+        MenuDefinition rootPage0ViewTemplateTestMenu = menusIter.next();
         assertEquals("template-test", rootPage0ViewTemplateTestMenu.getName());
         assertEquals("/page2.psml", rootPage0ViewTemplateTestMenu.getOptions());
-        MenuDefinition rootPage0ViewTopMenu = (MenuDefinition)menusIter.next();
+        MenuDefinition rootPage0ViewTopMenu = menusIter.next();
         assertEquals("top", rootPage0ViewTopMenu.getName());
         assertEquals("/", rootPage0ViewTopMenu.getOptions());
         assertEquals(2, rootPage0ViewTopMenu.getDepth());
         assertEquals("dhtml-pull-down", rootPage0ViewTopMenu.getSkin());
-        MenuDefinition rootPage0ViewBreadCrumbMenu = (MenuDefinition)menusIter.next();
+        MenuDefinition rootPage0ViewBreadCrumbMenu = menusIter.next();
         assertEquals("bread-crumbs", rootPage0ViewBreadCrumbMenu.getName());
         assertEquals("./", rootPage0ViewBreadCrumbMenu.getOptions());
         assertEquals(true, rootPage0ViewBreadCrumbMenu.isPaths());
-        MenuDefinition rootPage0ViewCurrentPageTestMenu = (MenuDefinition)menusIter.next();
+        MenuDefinition rootPage0ViewCurrentPageTestMenu = menusIter.next();
         assertEquals("current-page-test", rootPage0ViewCurrentPageTestMenu.getName());
-        MenuDefinition rootPage0ViewCurrentPathTestMenu = (MenuDefinition)menusIter.next();
+        MenuDefinition rootPage0ViewCurrentPathTestMenu = menusIter.next();
         assertEquals("current-path-test", rootPage0ViewCurrentPathTestMenu.getName());        
-        MenuDefinition rootPage0SiteNavigationsMenu = (MenuDefinition)menusIter.next();
+        MenuDefinition rootPage0SiteNavigationsMenu = menusIter.next();
         assertEquals("site-navigations", rootPage0SiteNavigationsMenu.getName());        
         assertTrue(rootPage0SiteNavigationsMenu.isRegexp());        
         assertEquals("/*/,/*.psml", rootPage0SiteNavigationsMenu.getOptions());        
         assertEquals(-1, rootPage0SiteNavigationsMenu.getDepth());        
-        MenuDefinition rootPage0RootedNavigationsMenu = (MenuDefinition)menusIter.next();
+        MenuDefinition rootPage0RootedNavigationsMenu = menusIter.next();
         assertEquals("rooted-navigations", rootPage0RootedNavigationsMenu.getName());        
         for (int i = 0; (i < aggregateView.getStandardMenuNames().size()); i++)
         {
-            assertTrue(aggregateView.getStandardMenuNames().contains(((MenuDefinition)menusIter.next()).getName()));
+            assertTrue(aggregateView.getStandardMenuNames().contains((menusIter.next()).getName()));
         }
         Page rootPage2View = rootFolderView.getPage("page2.psml");
         assertNotNull(rootPage2View);
@@ -316,22 +316,22 @@ public class TestPortalSite extends Abst
         assertNotNull(rootPage2ViewMenus);
         assertEquals(7 + aggregateView.getStandardMenuNames().size(), rootPage2ViewMenus.size());
         menusIter = rootPage2ViewMenus.iterator();
-        MenuDefinition rootPage2ViewTopMenu = (MenuDefinition)menusIter.next();
+        MenuDefinition rootPage2ViewTopMenu = menusIter.next();
         assertEquals("top", rootPage2ViewTopMenu.getName());
         assertEquals("/", rootPage2ViewTopMenu.getOptions());
         assertEquals(1, rootPage2ViewTopMenu.getDepth());
-        MenuDefinition rootPage2ViewBreadCrumbMenu = (MenuDefinition)menusIter.next();
+        MenuDefinition rootPage2ViewBreadCrumbMenu = menusIter.next();
         assertEquals("bread-crumbs", rootPage2ViewBreadCrumbMenu.getName());
-        MenuDefinition rootPage2ViewTemplateTestMenu = (MenuDefinition)menusIter.next();
+        MenuDefinition rootPage2ViewTemplateTestMenu = menusIter.next();
         assertEquals("template-test", rootPage2ViewTemplateTestMenu.getName());
         assertEquals("/page0.psml", rootPage2ViewTemplateTestMenu.getOptions());
-        MenuDefinition rootPage2ViewCurrentPageTestMenu = (MenuDefinition)menusIter.next();
-        assertEquals("current-page-test", rootPage0ViewCurrentPageTestMenu.getName());
-        MenuDefinition rootPage2ViewCurrentPathTestMenu = (MenuDefinition)menusIter.next();
-        assertEquals("current-path-test", rootPage0ViewCurrentPathTestMenu.getName());        
-        MenuDefinition rootPage2SiteNavigationsMenu = (MenuDefinition)menusIter.next();
+        MenuDefinition rootPage2ViewCurrentPageTestMenu = menusIter.next();
+        assertEquals("current-page-test", rootPage2ViewCurrentPageTestMenu.getName());
+        MenuDefinition rootPage2ViewCurrentPathTestMenu = menusIter.next();
+        assertEquals("current-path-test", rootPage2ViewCurrentPathTestMenu.getName());
+        MenuDefinition rootPage2SiteNavigationsMenu = menusIter.next();
         assertEquals("site-navigations", rootPage2SiteNavigationsMenu.getName());        
-        MenuDefinition rootPage2RootedNavigationsMenu = (MenuDefinition)menusIter.next();
+        MenuDefinition rootPage2RootedNavigationsMenu = menusIter.next();
         assertEquals("rooted-navigations", rootPage2RootedNavigationsMenu.getName());        
         for (int i = 0; (i < aggregateView.getStandardMenuNames().size()); i++)
         {
@@ -970,10 +970,8 @@ public class TestPortalSite extends Abst
         List<MenuElement> topMenuElements = topMenu.getElements();
         assertNotNull(topMenuElements);
         assertEquals(8, topMenuElements.size());
-        Iterator menuElementsIter = topMenuElements.iterator();
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : topMenuElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) && element.getTitle().equals("folder0"))
             {
                 assertTrue(element instanceof Menu);
@@ -1133,10 +1131,8 @@ public class TestPortalSite extends Abst
         List<MenuElement> siteNavigationsElements = siteNavigationsMenu.getElements();
         assertNotNull(siteNavigationsElements);
         assertEquals(6, siteNavigationsElements.size());
-        menuElementsIter = siteNavigationsElements.iterator();
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : siteNavigationsElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) && element.getTitle().equals("folder0"))
             {
                 assertTrue(element instanceof Menu);
@@ -1241,10 +1237,8 @@ public class TestPortalSite extends Abst
         List<MenuElement> rootedElements = rootedMenu.getElements();
         assertNotNull(rootedElements);
         assertEquals(8, rootedElements.size());
-        menuElementsIter = rootedElements.iterator();
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : rootedElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if ((element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) && element.getTitle().equals("folder0")) ||
                 (element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) && element.getTitle().equals("group folder1")) ||
                 (element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) && element.getTitle().equals("Folder4")) ||
@@ -1369,10 +1363,8 @@ public class TestPortalSite extends Abst
         List<MenuElement> navigationsElements = navigationsMenu.getElements();
         assertNotNull(navigationsElements);
         assertEquals(7, navigationsElements.size());
-        menuElementsIter = navigationsElements.iterator();
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : navigationsElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.SEPARATOR_ELEMENT_TYPE) &&
                 (element instanceof MenuSeparator) &&
                 ((MenuSeparator)element).getText().equals("Folders"))
@@ -1442,10 +1434,8 @@ public class TestPortalSite extends Abst
         List<MenuElement> pagesElements = pagesMenu.getElements();
         assertNotNull(pagesElements);
         assertEquals(3, pagesElements.size());
-        menuElementsIter = pagesElements.iterator();
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : pagesElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) && element.getTitle().equals("/page2.psml"))
             {
                 assertTrue(element instanceof MenuOption);
@@ -1526,10 +1516,10 @@ public class TestPortalSite extends Abst
         assertEquals("custom", customMenu.getName());
         assertEquals("Top Menu", customMenu.getTitle());
         assertEquals("Haut", customMenu.getTitle(Locale.FRENCH));
-        menuElementsIter = customElements.iterator();        
+        Iterator<MenuElement> menuElementsIter = customElements.iterator();
         for (int i = 0; ((i < 2) && menuElementsIter.hasNext()); i++)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
+            MenuElement element = menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) && element.getTitle().equals("/link0.link"))
             {
                 assertTrue(element instanceof MenuOption);
@@ -1549,16 +1539,16 @@ public class TestPortalSite extends Abst
         }
         if (menuElementsIter.hasNext())
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
+            MenuElement element = menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) && element.getTitle().equals("user root"))
             {
                 assertFalse(((Menu)element).isEmpty());
                 List<MenuElement> nestedElements = ((Menu)element).getElements();
                 assertEquals(6, nestedElements.size());
-                Iterator nestedElementsIter = nestedElements.iterator();
+                Iterator<MenuElement> nestedElementsIter = nestedElements.iterator();
                 if (nestedElementsIter.hasNext())
                 {
-                    MenuElement nestedElement = (MenuElement)nestedElementsIter.next();
+                    MenuElement nestedElement = nestedElementsIter.next();
                     if (nestedElement.getElementType().equals(MenuElement.SEPARATOR_ELEMENT_TYPE) &&
                         (nestedElement instanceof MenuSeparator) &&
                         ((MenuSeparator)nestedElement).getText().equals("=== Current Page ==="))
@@ -1571,7 +1561,7 @@ public class TestPortalSite extends Abst
                 }
                 if (nestedElementsIter.hasNext())
                 {
-                    MenuElement nestedElement = (MenuElement)nestedElementsIter.next();
+                    MenuElement nestedElement = nestedElementsIter.next();
                     if (nestedElement.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) &&
                         nestedElement.getTitle().equals("/folder1/page1.psml"))
                     {
@@ -1586,7 +1576,7 @@ public class TestPortalSite extends Abst
                 }
                 if (nestedElementsIter.hasNext())
                 {
-                    MenuElement nestedElement = (MenuElement)nestedElementsIter.next();
+                    MenuElement nestedElement = nestedElementsIter.next();
                     if (nestedElement.getElementType().equals(MenuElement.SEPARATOR_ELEMENT_TYPE) &&
                         (nestedElement instanceof MenuSeparator) &&
                         ((MenuSeparator)nestedElement).getText().equals("=== Top Pages ==="))
@@ -1600,7 +1590,7 @@ public class TestPortalSite extends Abst
                 }
                 for (int i = 0; ((i < 3) && nestedElementsIter.hasNext()); i++)
                 {
-                    MenuElement nestedElement = (MenuElement)nestedElementsIter.next();
+                    MenuElement nestedElement = nestedElementsIter.next();
                     if (nestedElement.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) &&
                         nestedElement.getTitle().equals("/page2.psml"))
                     {
@@ -1635,7 +1625,7 @@ public class TestPortalSite extends Abst
         }
         if (menuElementsIter.hasNext())
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
+            MenuElement element = menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.SEPARATOR_ELEMENT_TYPE) &&
                 (element instanceof MenuSeparator) &&
                 ((MenuSeparator)element).getText().equals("=== More Options ==="))
@@ -1648,7 +1638,7 @@ public class TestPortalSite extends Abst
         }
         for (int i = 0; ((i < 4) && menuElementsIter.hasNext()); i++)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
+            MenuElement element = menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) && element.getTitle().equals("/link1.link"))
             {
                 assertTrue(element instanceof MenuOption);
@@ -1680,7 +1670,7 @@ public class TestPortalSite extends Abst
         }
         if (menuElementsIter.hasNext())
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
+            MenuElement element = menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.SEPARATOR_ELEMENT_TYPE) &&
                 (element instanceof MenuSeparator) &&
                 ((MenuSeparator)element).getText().equals("=== Standard Menus ==="))
@@ -1693,7 +1683,7 @@ public class TestPortalSite extends Abst
         }
         if (menuElementsIter.hasNext())
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
+            MenuElement element = menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) && element.getTitle().equals("user root"))
             {
                 assertTrue(element instanceof MenuOption);
@@ -1707,7 +1697,7 @@ public class TestPortalSite extends Abst
         }
         if (menuElementsIter.hasNext())
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
+            MenuElement element = menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) && element.getTitle().equals("navigations"))
             {
                 assertTrue(element instanceof Menu);
@@ -1720,7 +1710,7 @@ public class TestPortalSite extends Abst
         }
         if (menuElementsIter.hasNext())
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
+            MenuElement element = menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) && element.getTitle().equals("pages"))
             {
                 assertTrue(element instanceof Menu);
@@ -1737,10 +1727,8 @@ public class TestPortalSite extends Abst
         rootedElements = rootedMenu.getElements();
         assertNotNull(rootedElements);
         assertEquals(3, rootedElements.size());
-        menuElementsIter = rootedElements.iterator();        
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : rootedElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.MENU_ELEMENT_TYPE) && element.getTitle().equals("folder1/folder"))
             {
                 assertTrue(element instanceof Menu);
@@ -2056,11 +2044,9 @@ public class TestPortalSite extends Abst
         assertFalse(topMenu.isEmpty());
         List<MenuElement> topMenuElements = topMenu.getElements();
         assertNotNull(topMenuElements);
-        Iterator menuElementsIter = topMenuElements.iterator();
         boolean hiddenElement = false;
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : topMenuElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) && element.getTitle().equals("/hidden.psml"))
             {
                 hiddenElement = true;
@@ -2072,11 +2058,9 @@ public class TestPortalSite extends Abst
         assertFalse(pagesMenu.isEmpty());
         List<MenuElement> pagesElements = pagesMenu.getElements();
         assertNotNull(pagesElements);
-        menuElementsIter = pagesElements.iterator();
         hiddenElement = false;
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : pagesElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) && element.getTitle().equals("/hidden.psml"))
             {
                 hiddenElement = true;
@@ -2097,11 +2081,9 @@ public class TestPortalSite extends Abst
         assertFalse(topMenu.isEmpty());
         topMenuElements = topMenu.getElements();
         assertNotNull(topMenuElements);
-        menuElementsIter = topMenuElements.iterator();
         hiddenElement = false;
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : topMenuElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) && element.getTitle().equals("/hidden.psml"))
             {
                 hiddenElement = true;
@@ -2113,11 +2095,9 @@ public class TestPortalSite extends Abst
         assertFalse(pagesMenu.isEmpty());
         pagesElements = pagesMenu.getElements();
         assertNotNull(pagesElements);
-        menuElementsIter = pagesElements.iterator();
         hiddenElement = false;
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : pagesElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) && element.getTitle().equals("/hidden.psml"))
             {
                 hiddenElement = true;
@@ -2138,11 +2118,9 @@ public class TestPortalSite extends Abst
         assertFalse(topMenu.isEmpty());
         topMenuElements = topMenu.getElements();
         assertNotNull(topMenuElements);
-        menuElementsIter = topMenuElements.iterator();
         hiddenElement = false;
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : topMenuElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) && element.getTitle().equals("/hidden.psml"))
             {
                 hiddenElement = true;
@@ -2154,11 +2132,9 @@ public class TestPortalSite extends Abst
         assertFalse(pagesMenu.isEmpty());
         pagesElements = pagesMenu.getElements();
         assertNotNull(pagesElements);
-        menuElementsIter = pagesElements.iterator();
         hiddenElement = false;
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : pagesElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) && element.getTitle().equals("/hidden.psml"))
             {
                 hiddenElement = true;
@@ -2178,11 +2154,9 @@ public class TestPortalSite extends Abst
         assertFalse(pagesMenu.isEmpty());
         pagesElements = pagesMenu.getElements();
         assertNotNull(pagesElements);
-        menuElementsIter = pagesElements.iterator();
         hiddenElement = false;
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : pagesElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) && element.getTitle().equals("/hidden.psml"))
             {
                 hiddenElement = true;
@@ -2198,11 +2172,9 @@ public class TestPortalSite extends Abst
         assertFalse(pagesMenu.isEmpty());
         pagesElements = pagesMenu.getElements();
         assertNotNull(pagesElements);
-        menuElementsIter = pagesElements.iterator();
         hiddenElement = false;
-        while (menuElementsIter.hasNext())
+        for (MenuElement element : pagesElements)
         {
-            MenuElement element = (MenuElement)menuElementsIter.next();
             if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE) && element.getTitle().equals("/hidden.psml"))
             {
                 hiddenElement = 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