portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r923437 - in /portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src: main/java/org/apache/jetspeed/portalsite/view/SearchPathsSiteView.java test/java/org/apache/jetspeed/portalsite/TestPortalSite.java
Date Mon, 15 Mar 2010 20:59:59 GMT
Author: rwatler
Date: Mon Mar 15 20:59:59 2010
New Revision: 923437

URL: http://svn.apache.org/viewvc?rev=923437&view=rev
Log:
support calculation of profiled base and user paths against non-existent folders

Modified:
    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/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java

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=923437&r1=923436&r2=923437&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
Mon Mar 15 20:59:59 2010
@@ -93,10 +93,12 @@ public class SearchPathsSiteView extends
         {
             // validate search path format and existence
             this.searchPaths = new ArrayList(searchPaths.size());
+            List allSearchPaths = new ArrayList(searchPaths.size());
             StringBuilder searchPathsStringBuilder = new StringBuilder();
             Iterator pathsIter = searchPaths.iterator();
             while (pathsIter.hasNext())
             {
+                // construct search paths if necessary
                 Object pathObject = pathsIter.next();
                 if (!(pathObject instanceof SiteViewSearchPath))
                 {
@@ -107,6 +109,9 @@ public class SearchPathsSiteView extends
                     }
                 }
                 SiteViewSearchPath searchPath = (SiteViewSearchPath)pathObject;
+                allSearchPaths.add(searchPath);
+
+                // validate and filter final search paths
                 if (this.searchPaths.indexOf(searchPath) == -1)
                 {
                     try
@@ -150,26 +155,26 @@ public class SearchPathsSiteView extends
             else
             {
                 this.searchPathsString = searchPathsStringBuilder.toString();
-                
-                // find primary user search path
-                Iterator searchPathsIter = this.searchPaths.iterator();
-                while (searchPathsIter.hasNext())
+            }
+            
+            // find primary user search path, (may not exist: search against all paths) 
+            Iterator searchPathsIter = allSearchPaths.iterator();
+            while (searchPathsIter.hasNext())
+            {
+                SiteViewSearchPath searchPath = (SiteViewSearchPath)searchPathsIter.next();
+                if (searchPath.isUserPath())
                 {
-                    SiteViewSearchPath searchPath = (SiteViewSearchPath)searchPathsIter.next();
-                    if (searchPath.isUserPath())
-                    {
-                        this.userSearchPath = searchPath;
-                        break;
-                    }
+                    this.userSearchPath = searchPath;
+                    break;
                 }
             }
             
-            // find base search path
-            if (this.searchPaths.size() == 1)
+            // find base search path, (may not exist: search against all paths)
+            if (allSearchPaths.size() == 1)
             {
                 // single non-principal search path is the base
                 // search path
-                SiteViewSearchPath searchPath = (SiteViewSearchPath)this.searchPaths.get(0);
+                SiteViewSearchPath searchPath = (SiteViewSearchPath)allSearchPaths.get(0);
                 if (!searchPath.isPrincipalPath())
                 {
                     this.baseSearchPath = searchPath;
@@ -180,11 +185,11 @@ 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 searchPathsIter = this.searchPaths.listIterator(this.searchPaths.size());
-                while (searchPathsIter.hasPrevious())
+                ListIterator baseSearchPathsIter = allSearchPaths.listIterator(allSearchPaths.size());
+                while (baseSearchPathsIter.hasPrevious())
                 {
-                    SiteViewSearchPath searchPath = (SiteViewSearchPath)searchPathsIter.previous();
-                    int scanSearchPathsIndex = searchPathsIter.previousIndex();
+                    SiteViewSearchPath searchPath = (SiteViewSearchPath)baseSearchPathsIter.previous();
+                    int scanSearchPathsIndex = baseSearchPathsIter.previousIndex();
                     if (scanSearchPathsIndex == -1)
                     {
                         // most specific non-principal search path is the
@@ -201,10 +206,10 @@ public class SearchPathsSiteView extends
                         // scan more specific search paths to test whether the
                         // current search path is common to all
                         boolean isCommonSearchPath = true;
-                        ListIterator scanSearchPathsIter = this.searchPaths.listIterator(scanSearchPathsIndex+1);
-                        while (scanSearchPathsIter.hasPrevious())
+                        ListIterator scanBaseSearchPathsIter = allSearchPaths.listIterator(scanSearchPathsIndex+1);
+                        while (scanBaseSearchPathsIter.hasPrevious())
                         {
-                            SiteViewSearchPath scanSearchPath = (SiteViewSearchPath)scanSearchPathsIter.previous();
+                            SiteViewSearchPath scanSearchPath = (SiteViewSearchPath)scanBaseSearchPathsIter.previous();
                             if (!scanSearchPath.toString().startsWith(searchPath.toString()))
                             {
                                 isCommonSearchPath = false;

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=923437&r1=923436&r2=923437&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
Mon Mar 15 20:59:59 2010
@@ -556,7 +556,6 @@ public class TestPortalSite extends Abst
     public void testRelativeNavigations() throws Exception
     {
         JetspeedProfileLocator locator = new JetspeedProfileLocator();
-
         locator.init(null, "/");
         locator.add("hostname", true, false, "dash");
         locator.add("user", true, false, "joe");
@@ -568,6 +567,16 @@ public class TestPortalSite extends Abst
         
         locator = new JetspeedProfileLocator();
         locator.init(null, "/");
+        locator.add("hostname", true, false, "new-host");
+        locator.add("user", true, false, "new-user");
+        locator.add("page", false, false, "home");
+        profileView = new SearchPathsSiteView(pageManager, locator, false);
+        assertEquals("/", profileView.getSearchPathsString());
+        assertEquals("/_hostname/new-host/_user/new-user", profileView.getUserFolderPath());
+        assertEquals("/_hostname/new-host", profileView.getBaseFolderPath());
+        
+        locator = new JetspeedProfileLocator();
+        locator.init(null, "/");
         locator.add("hostname", true, false, "dash");
         locator.add("user", true, false, "joe");
         locator.add("navigation", false, 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