portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r354482 - in /portals/jetspeed-2/trunk/components/portal-site: src/java/org/apache/jetspeed/om/folder/proxy/ src/java/org/apache/jetspeed/portalsite/impl/ src/test/org/apache/jetspeed/portalsite/ testdata/pages/folder3/ testdata/pages/folde...
Date Tue, 06 Dec 2005 18:03:23 GMT
Author: rwatler
Date: Tue Dec  6 10:03:15 2005
New Revision: 354482

URL: http://svn.apache.org/viewcvs?rev=354482&view=rev
Log:
allow default page to reference subfolder or '..'

Added:
    portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/
    portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder0/
    portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder0/folder.metadata
  (with props)
    portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/
    portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/folder.metadata
  (with props)
    portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/page0.psml
  (with props)
    portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/page1.psml
  (with props)
    portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/folder.metadata
  (with props)
Modified:
    portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
    portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
    portals/jetspeed-2/trunk/components/portal-site/src/test/org/apache/jetspeed/portalsite/TestPortalSite.java

Modified: portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java?rev=354482&r1=354481&r2=354482&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
Tue Dec  6 10:03:15 2005
@@ -321,14 +321,7 @@
     public String getDefaultPage(Object proxy)
     {
         // attempt to get explicitly specified default page
-        Page defaultPage = selectDefaultPageFromAggregateFolders(proxy);
-        if (defaultPage != null)
-        {
-            return defaultPage.getName();
-        }
-
-        // no default page available
-        return null;
+        return selectDefaultPageFromAggregateFolders(proxy);
     }
 
     /**
@@ -645,9 +638,9 @@
      *                                         proxy folder view path
      *
      * @param proxy this folder proxy
-     * @return selected default page proxy
+     * @return selected default page name
      */
-    private Page selectDefaultPageFromAggregateFolders(Object proxy)
+    private String selectDefaultPageFromAggregateFolders(Object proxy)
     {
         // select most specific specified default page
         // along search paths
@@ -663,17 +656,45 @@
                 String defaultPageName = folder.getDefaultPage();
                 if (defaultPageName != null)
                 {
-                    // validate and return default page if it exists
-                    // as child in this folder
-                    try
-                    {
-                        return getPage(proxy, defaultPageName);
-                    }
-                    catch (NodeException ne)
+                    // validate and return default page or folder
+                    // if it exists as child in this folder
+                    if (defaultPageName.equals(".."))
                     {
+                        // default parent folder
+                        if (getParent() != null)
+                        {
+                            return defaultPageName;
+                        }
                     }
-                    catch (SecurityException se)
+                    else
                     {
+                        // default page
+                        try
+                        {
+                            getPage(proxy, defaultPageName);
+                            return defaultPageName;
+                        }
+                        catch (NodeException ne)
+                        {
+                        }
+                        catch (SecurityException se)
+                        {
+                        }
+                        // default folder
+                        if (!defaultPageName.endsWith(Page.DOCUMENT_TYPE))
+                        {
+                            try
+                            {
+                                getFolder(proxy, defaultPageName);
+                                return defaultPageName;
+                            }
+                            catch (NodeException ne)
+                            {
+                            }
+                            catch (SecurityException se)
+                            {
+                            }
+                        }
                     }
                 }
                 else if (!fallbackDefaultPageNotFound)
@@ -682,7 +703,8 @@
                     // it exists as child in this folder
                     try
                     {
-                        return getPage(proxy, Folder.FALLBACK_DEFAULT_PAGE);
+                        getPage(proxy, Folder.FALLBACK_DEFAULT_PAGE);
+                        return Folder.FALLBACK_DEFAULT_PAGE;
                     }
                     catch (NodeException ne)
                     {

Modified: portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java?rev=354482&r1=354481&r2=354482&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
Tue Dec  6 10:03:15 2005
@@ -320,11 +320,12 @@
 
             // lookup request path in view for viewable page or folder
             // nodes; note: directly requested pages/folders may be hidden
+            // or not viewable
             Node requestNode = null;
             try
             {
                 // try page or folder request url
-                requestNode = view.getNodeProxy(requestPath, null, true, false);
+                requestNode = view.getNodeProxy(requestPath, null, false, false);
             }
             catch (NodeNotFoundException nnfe)
             {
@@ -348,30 +349,80 @@
             {
                 Folder requestFolder = (Folder)requestNode;
                 
-                // only request folders with pages can be
-                // selected by request; otherwise, fall back to
-                // parent folders assuming that immediate parents
-                // will have the most appropriate default page
-                NodeSet requestFolderPages = null;
+                // support subfolders specified as default pages;
+                // find highest subfolder with a default page that
+                // specifies a default folder, (not a default page).
                 try
                 {
-                    requestFolderPages = requestFolder.getPages();
-                    while (((requestFolderPages == null) || requestFolderPages.isEmpty())
&& (requestFolder.getParent() != null))
+                    String defaultFolderName = requestFolder.getDefaultPage();
+                    if (defaultFolderName != null)
                     {
-                        requestFolder = (Folder)requestFolder.getParent();
-                        requestFolderPages = requestFolder.getPages();
+                        // do not follow broken default folders
+                        Folder defaultRequestFolder = requestFolder;
+                        // follow default folders to parent folders
+                        while ((defaultRequestFolder != null) && (defaultFolderName
!= null) &&
+                               defaultFolderName.equals(".."))
+                        {
+                            defaultRequestFolder = (Folder)defaultRequestFolder.getParent();
+                            if (defaultRequestFolder != null)
+                            {
+                                defaultFolderName = defaultRequestFolder.getDefaultPage();
+                            }
+                            else
+                            {
+                                defaultFolderName = null;
+                            }
+                        }
+                        // follow default folders to subfolders
+                        while ((defaultRequestFolder != null) && (defaultFolderName
!= null) &&
+                               !defaultFolderName.endsWith(Page.DOCUMENT_TYPE) &&
!defaultFolderName.equals(".."))
+                        {
+                            defaultRequestFolder = defaultRequestFolder.getFolder(defaultFolderName);
+                            defaultFolderName = defaultRequestFolder.getDefaultPage();
+                        }
+                        // use default request folder
+                        if (defaultRequestFolder != null)
+                        {
+                            requestFolder = defaultRequestFolder;
+                        }
                     }
                 }
                 catch (NodeException ne)
                 {
-                    requestFolderPages = null;
                 }
                 catch (SecurityException se)
                 {
-                    requestFolderPages = null;
+                    requestFolder = null;
                     accessException = se;
                 }
-                if ((requestFolderPages != null) && !requestFolderPages.isEmpty())
+
+                // only request folders with pages can be
+                // selected by request; otherwise, fall back to
+                // parent folders assuming that immediate parents
+                // will have the most appropriate default page
+                NodeSet requestFolderPages = null;
+                if (requestFolder != null)
+                {
+                    try
+                    {
+                        requestFolderPages = requestFolder.getPages();
+                        while (((requestFolderPages == null) || requestFolderPages.isEmpty())
&& (requestFolder.getParent() != null))
+                        {
+                            requestFolder = (Folder)requestFolder.getParent();
+                            requestFolderPages = requestFolder.getPages();
+                        }
+                    }
+                    catch (NodeException ne)
+                    {
+                        requestFolderPages = null;
+                    }
+                    catch (SecurityException se)
+                    {
+                        requestFolderPages = null;
+                        accessException = se;
+                    }
+                }
+                if ((requestFolder != null) && (requestFolderPages != null) &&
!requestFolderPages.isEmpty())
                 {
                     // attempt to lookup last visited page by folder proxy
                     // path, (proxies are hashed by their path), contains

Modified: portals/jetspeed-2/trunk/components/portal-site/src/test/org/apache/jetspeed/portalsite/TestPortalSite.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/src/test/org/apache/jetspeed/portalsite/TestPortalSite.java?rev=354482&r1=354481&r2=354482&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/test/org/apache/jetspeed/portalsite/TestPortalSite.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/test/org/apache/jetspeed/portalsite/TestPortalSite.java
Tue Dec  6 10:03:15 2005
@@ -139,11 +139,12 @@
         assertEquals("/", rootFolderProxy.getName());
         assertEquals("root", rootFolderProxy.getTitle());
         assertEquals("/", extractFileSystemPathFromId(rootFolderProxy.getId()));
-        assertEquals(3, rootFolderProxy.getFolders().size());
+        assertEquals(4, rootFolderProxy.getFolders().size());
         Iterator foldersIter = rootFolderProxy.getFolders().iterator();
         assertEquals("folder0", ((Folder)foldersIter.next()).getName());
         assertEquals("folder1", ((Folder)foldersIter.next()).getName());
         assertEquals("folder2", ((Folder)foldersIter.next()).getName());
+        assertEquals("folder3", ((Folder)foldersIter.next()).getName());
         assertEquals(4, rootFolderProxy.getPages().size());
         Iterator pagesIter = rootFolderProxy.getPages().iterator();
         assertEquals("page2.psml", ((Page)pagesIter.next()).getName());
@@ -200,7 +201,7 @@
         assertTrue(rootPageProxiesByPath.contains(rootPage0Proxy));
         List rootFolderProxiesByPath = baseView.getNodeProxies("/*/", null, false, false);
         assertNotNull(rootFolderProxiesByPath);
-        assertEquals(3,rootFolderProxiesByPath.size());
+        assertEquals(4,rootFolderProxiesByPath.size());
         assertTrue(rootFolderProxiesByPath.contains(rootFolder0Proxy));
         List folderPageProxiesByPath = baseView.getNodeProxies("*/p*[0-9].psml", rootFolderProxy,
false, false);
         assertNotNull(folderPageProxiesByPath);
@@ -215,7 +216,7 @@
         assertEquals("/", rootFolderProxy.getName());
         assertEquals("user root", rootFolderProxy.getTitle());
         assertEquals("/_user/user", extractFileSystemPathFromId(rootFolderProxy.getId()));
-        assertEquals(3, rootFolderProxy.getFolders().size());
+        assertEquals(4, rootFolderProxy.getFolders().size());
         assertEquals(4, rootFolderProxy.getPages().size());
         assertEquals(2, rootFolderProxy.getLinks().size());
         rootPage0Proxy = rootFolderProxy.getPage("page0.psml");
@@ -517,6 +518,17 @@
         assertNotNull(requestPageProxy);
         assertEquals("page0.psml", requestPageProxy.getName());
         assertEquals("/folder0/page0.psml", extractFileSystemPathFromId(requestPageProxy.getId()));
+
+        locator = new JetspeedProfileLocator();
+        locator.init(null, "/");
+        locator.add("page", false, false, "/folder3/default-folder0/");
+        locators.put(ProfileLocator.PAGE_LOCATOR, locator);
+        requestContext = sessionContext.newRequestContext(locators);
+        assertNotNull(requestContext);
+        requestPageProxy = requestContext.getPage();
+        assertNotNull(requestPageProxy);
+        assertEquals("page1.psml", requestPageProxy.getName());
+        assertEquals("/folder3/default-folder1/page1.psml", extractFileSystemPathFromId(requestPageProxy.getId()));
     }
 
     /**

Added: portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder0/folder.metadata
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder0/folder.metadata?rev=354482&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder0/folder.metadata
(added)
+++ portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder0/folder.metadata
Tue Dec  6 10:03:15 2005
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Copyright 2005 The Apache Software Foundation
+
+Licensed 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>
+
+  <title>default-folder0</title>  
+  <short-title>default-folder0</short-title>  
+
+  <default-page>..</default-page>
+
+</folder>

Propchange: portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder0/folder.metadata
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/folder.metadata
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/folder.metadata?rev=354482&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/folder.metadata
(added)
+++ portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/folder.metadata
Tue Dec  6 10:03:15 2005
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Copyright 2005 The Apache Software Foundation
+
+Licensed 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 hidden="true">
+
+  <title>default-folder1</title>  
+  <short-title>default-folder1</short-title>  
+
+  <default-page>page1.psml</default-page>
+
+</folder>

Propchange: portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/folder.metadata
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/page0.psml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/page0.psml?rev=354482&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/page0.psml
(added)
+++ portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/page0.psml
Tue Dec  6 10:03:15 2005
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Copyright 2005 The Apache Software Foundation
+
+Licensed 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>
+
+  <title>/folder3/default-folder1/page0.psml</title>
+
+</page>

Propchange: portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/page0.psml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/page1.psml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/page1.psml?rev=354482&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/page1.psml
(added)
+++ portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/page1.psml
Tue Dec  6 10:03:15 2005
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Copyright 2005 The Apache Software Foundation
+
+Licensed 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>
+
+  <title>/folder3/default-folder1/page0.psml</title>
+
+</page>

Propchange: portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/default-folder1/page1.psml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/folder.metadata
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/folder.metadata?rev=354482&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/folder.metadata
(added)
+++ portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/folder.metadata
Tue Dec  6 10:03:15 2005
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Copyright 2005 The Apache Software Foundation
+
+Licensed 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 hidden="true">
+
+  <title>folder3</title>  
+  <short-title>folder3</short-title>  
+
+  <default-page>default-folder1</default-page>
+
+</folder>

Propchange: portals/jetspeed-2/trunk/components/portal-site/testdata/pages/folder3/folder.metadata
------------------------------------------------------------------------------
    svn:eol-style = native



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