portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r344154 - in /portals/jetspeed-2/trunk: components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/ components/page-manager/src/java/org/apache/jetspeed/om/page/ components/page-manager/src/java/org/apache/jetspeed/om/page/impl/ co...
Date Mon, 14 Nov 2005 16:44:58 GMT
Author: rwatler
Date: Mon Nov 14 08:44:30 2005
New Revision: 344154

URL: http://svn.apache.org/viewcvs?rev=344154&view=rev
Log:
- add and implement Page.getFragmentsByName() API
- complete Fragment view security constraint/permissions checking
- implement Page/Folder logical paths computation, (i.e. request path), for permissions security checks
- implement DB PageManagerEventListener notifications for DB PageManager
- add operation to allow cached security constraints to be reset in cached Page/Folder instances if PageSecurity updated


Added:
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentList.java   (with props)
Modified:
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/ContentPageImpl.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsImpl.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/PageImpl.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/SecurityConstraintsImpl.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/impl/NodeImpl.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/psml/AbstractNode.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java
    portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java
    portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java
    portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/common/SecurityConstraints.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/page/ContentPage.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/page/Page.java

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java Mon Nov 14 08:44:30 2005
@@ -509,7 +509,7 @@
      * @param nodes node set containing nodes to check
      * @return checked subset of nodes
      */
-    private static NodeSet filterNodeSetByAccess(NodeSet nodes)
+    static NodeSet filterNodeSetByAccess(NodeSet nodes)
     {
         if ((nodes != null) && !nodes.isEmpty())
         {

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/ContentPageImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/ContentPageImpl.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/ContentPageImpl.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/ContentPageImpl.java Mon Nov 14 08:44:30 2005
@@ -2,6 +2,7 @@
 
 import java.util.HashMap;
 import java.util.List;
+import java.util.ListIterator;
 import java.util.Locale;
 import java.util.Map;
 
@@ -54,6 +55,43 @@
     public Fragment getFragmentById(String id)
     {
         return getContentFragmentById(id);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentPage#getContentFragmentsByName(java.lang.String)
+     */
+    public List getContentFragmentsByName(String name)
+    {
+        // get list of fragments by name
+        List fragments = page.getFragmentsByName(name);
+        if (fragments == null)
+        {
+            return null;
+        }
+
+        // convert list elements to content fragments
+        ListIterator fragmentsIter = fragments.listIterator();
+        while (fragmentsIter.hasNext())
+        {
+            Fragment fragment = (Fragment)fragmentsIter.next();
+            String fragmentId = fragment.getId();
+            ContentFragment contentFragment = (ContentFragment)cachedFragments.get(fragmentId);
+            if (contentFragment == null)
+            {
+                contentFragment = new ContentFragmentImpl(fragment, cachedFragments);
+                cachedFragments.put(fragmentId, contentFragment);
+            }
+            fragmentsIter.set(contentFragment);
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentPage#getFragmentsByName(java.lang.String)
+     */
+    public List getFragmentsByName(String name)
+    {
+        return getContentFragmentsByName(name);
     }
 
     /* (non-Javadoc)

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.java Mon Nov 14 08:44:30 2005
@@ -138,8 +138,7 @@
     public void checkConstraints(List actions, List userPrincipals, List rolePrincipals, List groupPrincipals, boolean checkNodeOnly, boolean checkParentsOnly) throws SecurityException
     {
         // check node constraints if available
-        SecurityConstraints constraints = getSecurityConstraints();
-        if (constraints != null)
+        if ((constraints != null) && !constraints.isEmpty())
         {
             ((SecurityConstraintsImpl)constraints).checkConstraints(actions, userPrincipals, rolePrincipals, groupPrincipals, getEffectivePageSecurity());
         }
@@ -347,6 +346,18 @@
         if (otherActionsList != null)
         {
             checkConstraints(otherActionsList, userPrincipals, rolePrincipals, groupPrincipals, true, false);
+        }
+    }
+
+    /**
+     * resetCachedSecurityConstraints
+     */
+    public void resetCachedSecurityConstraints()
+    {
+        // propagate to constraints
+        if (constraints != null)
+        {
+            constraints.resetCachedSecurityConstraints();
         }
     }
 

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java Mon Nov 14 08:44:30 2005
@@ -22,7 +22,9 @@
 import java.util.Map;
 
 import org.apache.jetspeed.om.common.SecuredResource;
+import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.PageSecurity;
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.PersistenceBrokerException;
 
@@ -35,6 +37,7 @@
 public class FragmentImpl extends BaseElementImpl implements Fragment
 {
     private List fragments;
+    private FragmentList fragmentsList;
     private String type;
     private String skin;
     private String decorator;
@@ -48,21 +51,217 @@
     private String extendedPropertyValue2;
 
     private Map properties;
+    private PageImpl page;
 
     public FragmentImpl()
     {
         super(new FragmentSecurityConstraintsImpl());
     }
 
+    /**
+     * getPage
+     *
+     * Get page implementation that owns fragment.
+     *
+     * @return owning page implementation
+     */
+    PageImpl getPage()
+    {
+        return page;
+    }
+
+    /**
+     * setPage
+     *
+     * Set page implementation that owns fragment and
+     * propagate to all child fragments.
+     *
+     * @param page owning page implementation
+     */
+    void setPage(PageImpl page)
+    {
+        // set page implementation
+        this.page = page;
+        // propagate to children
+        if (fragments != null)
+        {
+            Iterator fragmentsIter = fragments.iterator();
+            while (fragmentsIter.hasNext())
+            {
+                ((FragmentImpl)fragmentsIter.next()).setPage(page);
+            }
+        }
+    }
+
+    /**
+     * getFragmentById
+     *
+     * Retrieve fragment with matching id from
+     * this or child fragments.
+     *
+     * @param id fragment id to retrieve.
+     * @return matched fragment
+     */
+    Fragment getFragmentById(String id)
+    {
+        // check for match
+        if (getId().equals(id))
+        {
+            return this;
+        }
+        // match children
+        if (fragments != null)
+        {
+            Iterator fragmentsIter = fragments.iterator();
+            while (fragmentsIter.hasNext())
+            {
+                Fragment matchedFragment = ((FragmentImpl)fragmentsIter.next()).getFragmentById(id);
+                if (matchedFragment != null)
+                {
+                    return matchedFragment;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * getFragmentsByName
+     *
+     * Retrieve fragments with matching name including
+     * this and child fragments.
+     *
+     * @param name fragment name to retrieve.
+     * @return list of matched fragments
+     */
+    List getFragmentsByName(String name)
+    {
+        List matchedFragments = null;
+        // check for match
+        if ((getName() != null) && getName().equals(name))
+        {
+            if (matchedFragments == null)
+            {
+                matchedFragments = new ArrayList(1);
+            }
+            matchedFragments.add(this);
+        }
+        // match children
+        if (fragments != null)
+        {
+            Iterator fragmentsIter = fragments.iterator();
+            while (fragmentsIter.hasNext())
+            {
+                List matchedChildFragments = ((FragmentImpl)fragmentsIter.next()).getFragmentsByName(name);
+                if (matchedChildFragments != null)
+                {
+                    if (matchedFragments == null)
+                    {
+                        matchedFragments = matchedChildFragments;
+                    }
+                    else
+                    {
+                        matchedFragments.addAll(matchedChildFragments);
+                    }
+                }
+            }
+        }
+        return matchedFragments;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#getEffectivePageSecurity()
+     */
+    public PageSecurity getEffectivePageSecurity()
+    {
+        // delegate to page implementation
+        if (page != null)
+        {
+            return page.getEffectivePageSecurity();
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#getLogicalPermissionPath()
+     */
+    public String getLogicalPermissionPath()
+    {
+        // use page implementation path as base and append name
+        if ((page != null) && (getName() != null))
+        {
+            return page.getLogicalPermissionPath() + Folder.PATH_SEPARATOR + getName();
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#getPhysicalPermissionPath()
+     */
+    public String getPhysicalPermissionPath()
+    {
+        // use page implementation path as base and append name
+        if ((page != null) && (getName() != null))
+        {
+            return page.getPhysicalPermissionPath() + Folder.PATH_SEPARATOR + getName();
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#resetCachedSecurityConstraints()
+     */
+    public void resetCachedSecurityConstraints()
+    {
+        // propagate to super and sub fragments
+        super.resetCachedSecurityConstraints();
+        if (fragments != null)
+        {
+            Iterator fragmentsIter = fragments.iterator();
+            while (fragmentsIter.hasNext())
+            {
+                ((FragmentImpl)fragmentsIter.next()).resetCachedSecurityConstraints();
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#getConstraintsEnabled()
+     */
+    public boolean getConstraintsEnabled()
+    {
+        if (page != null)
+        {
+            return page.getConstraintsEnabled();
+        }
+        return false;
+    }
+    
     /* (non-Javadoc)
      * @see org.apache.jetspeed.om.common.SecuredResource#getPermissionsEnabled()
      */
     public boolean getPermissionsEnabled()
     {
-        // permission support disabled since path addressing
-        // not supported yet at the fragment level within pages
+        if (page != null)
+        {
+            return page.getPermissionsEnabled();
+        }
         return false;
     }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#checkAccess(java.lang.String)
+     */
+    public void checkAccess(String actions) throws SecurityException
+    {
+        // check access permissions and constraints only
+        // for view access: all other permissions granted
+        // implicitly via access to page
+        if ((actions != null) && (actions.indexOf(SecuredResource.VIEW_ACTION) != -1))
+        {
+            super.checkAccess(SecuredResource.VIEW_ACTION);
+        }
+    }
     
     /* (non-Javadoc)
      * @see org.apache.jetspeed.om.page.Fragment#getType()
@@ -140,9 +339,13 @@
         // set of fragments in the collection will not be preserved
         if (fragments == null)
         {
-            fragments = new ArrayList();
+            fragments = new ArrayList(4);
+        }
+        if (fragmentsList == null)
+        {
+            fragmentsList = new FragmentList(this, fragments);
         }
-        return filterFragmentsByAccess(fragments);
+        return filterFragmentsByAccess(fragmentsList);
     }
     
     /* (non-Javadoc)
@@ -254,7 +457,7 @@
         if (sizes != null)
         {
             getProperties().put(SIZES_PROPERTY_NAME, sizes);
-    }
+        }
         else if (properties != null)
         {
             properties.remove(SIZES_PROPERTY_NAME);
@@ -375,9 +578,10 @@
      * Filter fragments list for view access.
      *
      * @param nodes list containing fragments to check
-     * @return checked subset of nodes
+     * @return original list if all elements viewable, a filtered
+     *         partial list, or null if all filtered for view access
      */
-    private static List filterFragmentsByAccess(List fragments)
+    static List filterFragmentsByAccess(List fragments)
     {
         if ((fragments != null) && !fragments.isEmpty())
         {
@@ -427,7 +631,14 @@
             // return filteredFragments fragments if generated
             if (filteredFragments != null)
             {
-                return filteredFragments;
+                if (!filteredFragments.isEmpty())
+                {
+                    return filteredFragments;
+                }
+                else
+                {
+                    return null;
+                }
             }
         }
         return fragments;

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentList.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentList.java?rev=344154&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentList.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentList.java Mon Nov 14 08:44:30 2005
@@ -0,0 +1,382 @@
+/*
+ * 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.
+ */
+package org.apache.jetspeed.om.page.impl;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * FragmentList
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class FragmentList implements List
+{
+    private FragmentImpl fragment;
+    private List fragments;
+
+    FragmentList(FragmentImpl fragment, List fragments)
+    {
+        this.fragment = fragment;
+        this.fragments = fragments;
+    }
+
+    /**
+     * getFragment
+     *
+     * Returns fragment implementation associated with this list.
+     *
+     * @return fragment implementation
+     */
+    FragmentImpl getFragment()
+    {
+        return fragment;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(java.lang.Object)
+     */
+    public boolean add(Object o)
+    {
+        // add and maintain page implementation reference
+        boolean added = fragments.add(o);
+        if (added && (fragment.getPage() != null) && (o instanceof FragmentImpl))
+        {
+            ((FragmentImpl)o).setPage(fragment.getPage());
+        }
+        return added;
+    }
+    
+    /* (non-Javadoc)
+     * @see java.util.List#add(int,java.lang.Object)
+     */
+    public void add(int index, Object element)
+    {
+        // add and maintain page implementation reference
+        fragments.add(index, element);
+        if ((fragment.getPage() != null) && (element instanceof FragmentImpl))
+        {
+            ((FragmentImpl)element).setPage(fragment.getPage());
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(java.util.Collection)
+     */
+    public boolean addAll(Collection c)
+    {
+        // add and maintain page implementation reference
+        boolean added = fragments.addAll(c);
+        if (added && (fragment.getPage() != null))
+        {
+            Iterator addedIter = c.iterator();
+            while (addedIter.hasNext())
+            {
+                Object o = addedIter.next();
+                if (fragments.contains(o) && (o instanceof FragmentImpl))
+                {
+                    ((FragmentImpl)o).setPage(fragment.getPage());
+                }
+            }
+        }
+        return added;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(int,java.util.Collection)
+     */
+    public boolean addAll(int index, Collection c)
+    {
+        // add and maintain page implementation reference
+        boolean added = fragments.addAll(index, c);
+        if (added && (fragment.getPage() != null))
+        {
+            Iterator addedIter = c.iterator();
+            while (addedIter.hasNext())
+            {
+                Object o = addedIter.next();
+                if (fragments.contains(o) && (o instanceof FragmentImpl))
+                {
+                    ((FragmentImpl)o).setPage(fragment.getPage());
+                }
+            }
+        }
+        return added;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#clear()
+     */
+    public void clear()
+    {
+        fragments.clear();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#contains(java.lang.Object)
+     */
+    public boolean contains(Object o)
+    {
+        return fragments.contains(o);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.ListcontainsAll#(java.util.Collection)
+     */
+    public boolean containsAll(Collection c)
+    {
+        return fragments.containsAll(c);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#equals(java.lang.Object)
+     */
+    public boolean equals(Object o)
+    {
+        return fragments.equals(o);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#get(int)
+     */
+    public Object get(int index)
+    {
+        return fragments.get(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#hashCode()
+     */
+    public int hashCode()
+    {
+        return fragments.hashCode();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#indexOf(java.lang.Object)
+     */
+    public int indexOf(Object o)
+    {
+        return fragments.indexOf(o);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#isEmpty()
+     */
+    public boolean isEmpty()
+    {
+        return fragments.isEmpty();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#iterator()
+     */
+    public Iterator iterator()
+    {
+        return fragments.iterator();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#lastIndexOf(java.lang.Object)
+     */
+    public int lastIndexOf(Object o)
+    {
+        return fragments.lastIndexOf(o);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#listIterator()
+     */
+    public ListIterator listIterator()
+    {
+        return listIterator(0);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#listIterator(int)
+     */
+    public ListIterator listIterator(final int index)
+    {
+        // return new iterator
+        return new ListIterator()
+            {
+                ListIterator iter = FragmentList.this.fragments.listIterator(index);
+
+                /* (non-Javadoc)
+                 * @see java.util.ListIterator#add(java.lang.Object)
+                 */
+                public void add(Object o)
+                {
+                    // add and maintain page implementation reference
+                    iter.add(o);
+                    if ((FragmentList.this.fragment.getPage() != null) && (o instanceof FragmentImpl))
+                    {
+                        ((FragmentImpl)o).setPage(FragmentList.this.fragment.getPage());
+                    }
+                }
+
+                /* (non-Javadoc)
+                 * @see java.util.ListIterator#hasNext()
+                 */
+                public boolean hasNext()
+                {
+                    return iter.hasNext();
+                }
+
+                /* (non-Javadoc)
+                 * @see java.util.ListIterator#hasPrevious()
+                 */
+                public boolean hasPrevious()
+                {
+                    return iter.hasPrevious();                    
+                }
+
+                /* (non-Javadoc)
+                 * @see java.util.ListIterator#next()
+                 */
+                public Object next()
+                {
+                    return iter.next();
+                }
+
+                /* (non-Javadoc)
+                 * @see java.util.ListIterator#nextIndex()
+                 */
+                public int nextIndex()
+                {
+                    return iter.nextIndex();
+                }
+
+                /* (non-Javadoc)
+                 * @see java.util.ListIterator#previous()
+                 */
+                public Object previous()
+                {
+                    return iter.previous();
+                }
+
+                /* (non-Javadoc)
+                 * @see java.util.ListIterator#previousIndex()
+                 */
+                public int previousIndex()
+                {
+                    return iter.previousIndex();
+                }
+
+                /* (non-Javadoc)
+                 * @see java.util.ListIterator#remove()
+                 */
+                public void remove()
+                {
+                    iter.remove();
+                }
+
+                /* (non-Javadoc)
+                 * @see java.util.ListIterator#set(java.lang.Object)
+                 */
+                public void set(Object o)
+                {
+                    // set and maintain page implementation reference
+                    iter.set(o);
+                    if ((FragmentList.this.fragment.getPage() != null) && (o instanceof FragmentImpl))
+                    {
+                        ((FragmentImpl)o).setPage(FragmentList.this.fragment.getPage());
+                    }
+                }
+            };
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#remove(int)
+     */
+    public Object remove(int index)
+    {
+        return fragments.remove(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#remove(java.lang.Object)
+     */
+    public boolean remove(Object o)
+    {
+        return fragments.remove(o);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#removeAll(java.util.Collection)
+     */
+    public boolean removeAll(Collection c)
+    {
+        return fragments.removeAll(c);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#retainAll(java.util.Collection)
+     */
+    public boolean retainAll(Collection c)
+    {
+        return fragments.retainAll(c);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#set(int,java.lang.Object)
+     */
+    public Object set(int index, Object element)
+    {
+        // set and maintain page implementation reference
+        Object o = fragments.set(index, element);
+        if ((fragment.getPage() != null) && (element instanceof FragmentImpl))
+        {
+            ((FragmentImpl)element).setPage(fragment.getPage());
+        }
+        return o;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#size()
+     */
+    public int size()
+    {
+        return fragments.size();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#subList(int, int)
+     */
+    public List subList(int fromIndex, int toIndex)
+    {
+        return fragments.subList(fromIndex, toIndex);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#toArray()
+     */
+    public Object[] toArray()
+    {
+        return fragments.toArray();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#toArray(java.lang.Object[])
+     */
+    public Object[] toArray(Object[] a) 
+    {
+        return fragments.toArray(a);
+    }
+}

Propchange: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentList.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageImpl.java Mon Nov 14 08:44:30 2005
@@ -17,14 +17,15 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Stack;
 
+import org.apache.jetspeed.om.common.SecuredResource;
 import org.apache.jetspeed.om.page.Fragment;
 import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.om.page.PageMetadataImpl;
 import org.apache.jetspeed.page.document.impl.DocumentImpl;
+import org.apache.ojb.broker.PersistenceBroker;
+import org.apache.ojb.broker.PersistenceBrokerException;
 
 /**
  * PageImpl
@@ -45,6 +46,20 @@
     }
 
     /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#resetCachedSecurityConstraints()
+     */
+    public void resetCachedSecurityConstraints()
+    {
+        // propagate to super and fragments
+        super.resetCachedSecurityConstraints();
+        FragmentImpl rootFragment = (FragmentImpl)getRootFragment();
+        if (rootFragment != null)
+        {
+            rootFragment.resetCachedSecurityConstraints();
+        }
+    }
+
+    /* (non-Javadoc)
      * @see org.apache.jetspeed.page.document.impl.NodeImpl#newPageMetadata(java.util.Collection)
      */
     public PageMetadataImpl newPageMetadata(Collection fields)
@@ -135,13 +150,17 @@
         }
 
         // add new singleton fragment
-        if (fragment != null)
+        if (fragment instanceof FragmentImpl)
         {
+            // add fragment to singleton collection
             if (this.fragment == null)
             {
                 this.fragment = new ArrayList(1);
             }
             this.fragment.add(fragment);
+
+            // set page implementation in root and children fragments
+            ((FragmentImpl)fragment).setPage(this);
         }
     }
 
@@ -150,35 +169,39 @@
      */
     public Fragment getFragmentById(String id)
     {
-        // search for fragment recursively from
-        // root singleton fragment using a local stack
-        Stack stack = new Stack();
-        Fragment fragment = getRootFragment();
-        while ((fragment != null) && !fragment.getId().equals(id))
-        {
-            // push any fragment fragments onto the local stack;
-            // note that this set is already filtered for access
-            List fragments = fragment.getFragments();
-            if (!fragments.isEmpty())
+        // get fragment by id and check access
+        FragmentImpl rootFragment = (FragmentImpl)getRootFragment();
+        if (rootFragment != null)
+        {
+            Fragment fragment = rootFragment.getFragmentById(id);
+            if (fragment != null)
             {
-                Iterator pushIter = fragments.iterator();
-                while (pushIter.hasNext())
+                try
+                {
+                    fragment.checkAccess(SecuredResource.VIEW_ACTION);
+                }
+                catch (SecurityException se)
                 {
-                    stack.push(pushIter.next());
+                    fragment = null;
                 }
             }
+            return fragment;
+        }
+        return null;
+    }
 
-            // pop next fragment from local stack if available
-            if (stack.size() > 0)
-            {
-                fragment = (Fragment) stack.pop();
-            }
-            else
-            {
-                fragment = null;
-            }
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#getFragmentsByName(java.lang.String)
+     */
+    public List getFragmentsByName(String name)
+    {
+        // get fragments by name and filter by access
+        FragmentImpl rootFragment = (FragmentImpl)getRootFragment();
+        if (rootFragment != null)
+        {
+            return FragmentImpl.filterFragmentsByAccess(rootFragment.getFragmentsByName(name));
         }
-        return fragment;
+        return null;
     }
 
     /* (non-Javadoc)
@@ -211,5 +234,21 @@
     public String getType()
     {
         return DOCUMENT_TYPE;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.ojb.broker.PersistenceBrokerAware#afterLookup(org.apache.ojb.broker.PersistenceBroker)
+     */
+    public void afterLookup(PersistenceBroker broker) throws PersistenceBrokerException
+    {
+        // propagate
+        super.afterLookup(broker);
+
+        // set page implementation in root and children fragments
+        FragmentImpl rootFragment = (FragmentImpl)getRootFragment();
+        if (rootFragment != null)
+        {
+            rootFragment.setPage(this);
+        }
     }
 }

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsImpl.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsImpl.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsImpl.java Mon Nov 14 08:44:30 2005
@@ -39,6 +39,7 @@
 
     private List securityConstraints;
     private List securityConstraintsRefs;
+
     private List allConstraints;
 
     /**
@@ -290,15 +291,23 @@
     }
 
     /**
+     * resetCachedSecurityConstraints
+     */
+    public void resetCachedSecurityConstraints()
+    {
+        // clear previously cached security constraints
+        clearAllSecurityConstraints();
+    }
+
+    /**
      * getAllSecurityConstraints
      *
      * @param pageSecurity page security definitions
      * @return all security constraints
      */
-    private List getAllSecurityConstraints(PageSecurity pageSecurity)
+    private synchronized List getAllSecurityConstraints(PageSecurity pageSecurity)
     {
-        // return previously cached security constraints; note that
-        // cache is assumed valid until owning document is evicted
+        // return previously cached security constraints
         if (allConstraints != null)
         {
             return allConstraints;
@@ -341,9 +350,16 @@
     }
 
     /**
-     * <p>
+     * clearAllSecurityConstraints
+     */
+    private synchronized void clearAllSecurityConstraints()
+    {
+        // clear previously cached security constraints
+        allConstraints = null;
+    }
+
+    /**
      * dereferenceSecurityConstraintsRefs
-     * </p>
      *
      * @param constraintsRefs contstraints references to be dereferenced
      * @param pageSecurity page security definitions
@@ -386,7 +402,9 @@
      */
     public void setOwner(String owner)
     {
+        // save new setting and reset cached security constraints
         this.owner = owner;
+        clearAllSecurityConstraints();
     }
 
     /* (non-Javadoc)
@@ -402,7 +420,9 @@
      */
     public void setSecurityConstraints(List constraints)
     {
+        // save new setting and reset cached security constraints
         securityConstraints = constraints;
+        clearAllSecurityConstraints();
     }
 
     /* (non-Javadoc)
@@ -418,6 +438,16 @@
      */
     public void setSecurityConstraintsRefs(List constraintsRefs)
     {
+        // save new setting and reset cached security constraints
         securityConstraintsRefs = constraintsRefs;
+        clearAllSecurityConstraints();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraints#isEmpty()
+     */
+    public boolean isEmpty()
+    {
+        return ((owner == null) && (securityConstraints == null) && (securityConstraintsRefs == null));
     }
 }

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java Mon Nov 14 08:44:30 2005
@@ -295,8 +295,7 @@
     public void checkConstraints(List actions, List userPrincipals, List rolePrincipals, List groupPrincipals, boolean checkNodeOnly, boolean checkParentsOnly) throws SecurityException
     {
         // check node constraints if available
-        SecurityConstraints constraints = getSecurityConstraints();
-        if (constraints != null)
+        if ((constraints != null) && !constraints.isEmpty())
         {
             ((SecurityConstraintsImpl)constraints).checkConstraints(actions, userPrincipals, rolePrincipals, groupPrincipals, handlerFactory);
         }

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/PageImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/PageImpl.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/PageImpl.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/PageImpl.java Mon Nov 14 08:44:30 2005
@@ -16,6 +16,7 @@
 
 package org.apache.jetspeed.om.page.psml;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Stack;
@@ -158,6 +159,49 @@
         }
 
         return f;
+    }
+
+    public List getFragmentsByName( String name )
+    {
+        List fragments = null;
+
+        Stack stack = new Stack();
+        if (getRootFragment() != null)
+        {
+            stack.push(getRootFragment());
+        }
+
+        Fragment f = (Fragment) stack.pop();
+
+        while (f != null)
+        {
+            if ((f.getName() != null) && f.getName().equals(name))
+            {
+                if (fragments == null)
+                {
+                    fragments = new ArrayList(1);
+                }
+                fragments.add(f);
+            }
+
+            Iterator i = f.getFragments().iterator();
+
+            while (i.hasNext())
+            {
+                stack.push(i.next());
+            }
+
+            if (stack.size() > 0)
+            {
+                f = (Fragment) stack.pop();
+            }
+            else
+            {
+                f = null;
+            }
+        }
+
+        return fragments;
     }
 
     public DefaultsImpl getDefaults()

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/SecurityConstraintsImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/SecurityConstraintsImpl.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/SecurityConstraintsImpl.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/SecurityConstraintsImpl.java Mon Nov 14 08:44:30 2005
@@ -133,6 +133,19 @@
 
     /**
      * <p>
+     * isEmpty
+     * </p>
+     *
+     * @see org.apache.jetspeed.om.common.SecurityConstraints#isEmpty()
+     * @return flag indicating whether there are constraints or owner set
+     */
+    public boolean isEmpty()
+    {
+        return ((owner == null) && (constraints == null) && (constraintsRefs == null));
+    }
+
+    /**
+     * <p>
      * checkConstraints
      * </p>
      *

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java Mon Nov 14 08:44:30 2005
@@ -473,7 +473,7 @@
      *
      * @param node new managed node if known
      */
-    protected void notifyNewNode(Node node)
+    public void notifyNewNode(Node node)
     {
         Iterator listenersIter = listeners.iterator();
         while (listenersIter.hasNext())
@@ -496,7 +496,7 @@
      *
      * @param node updated managed node if known
      */
-    protected void notifyUpdatedNode(Node node)
+    public void notifyUpdatedNode(Node node)
     {
         Iterator listenersIter = listeners.iterator();
         while (listenersIter.hasNext())
@@ -519,7 +519,7 @@
      *
      * @param node removed managed node if known
      */
-    protected void notifyRemovedNode(Node node)
+    public void notifyRemovedNode(Node node)
     {
         Iterator listenersIter = listeners.iterator();
         while (listenersIter.hasNext())
@@ -547,7 +547,7 @@
         
         // copy security constraints
         SecurityConstraints srcSecurity = source.getSecurityConstraints();        
-        if (srcSecurity != null)
+        if ((srcSecurity != null) && !srcSecurity.isEmpty())
         {
             SecurityConstraints copiedSecurity = copySecurityConstraints(srcSecurity);
             folder.setSecurityConstraints(copiedSecurity);
@@ -582,7 +582,7 @@
         
         // copy security constraints
         SecurityConstraints srcSecurity = source.getSecurityConstraints();        
-        if (srcSecurity != null)
+        if ((srcSecurity != null) && !srcSecurity.isEmpty())
         {
             SecurityConstraints copiedSecurity = copySecurityConstraints(srcSecurity);
             page.setSecurityConstraints(copiedSecurity);
@@ -610,6 +610,14 @@
         copy.setType(source.getType());
         copy.setState(source.getState());
 
+        // copy security constraints
+        SecurityConstraints srcSecurity = source.getSecurityConstraints();        
+        if ((srcSecurity != null) && !srcSecurity.isEmpty())
+        {
+            SecurityConstraints copiedSecurity = copySecurityConstraints(srcSecurity);
+            copy.setSecurityConstraints(copiedSecurity);
+        }    
+        
         // recursively copy fragments
         Iterator fragments = source.getFragments().iterator();
         while (fragments.hasNext())
@@ -748,26 +756,8 @@
         copy.setGlobalSecurityConstraintsRefs(new ArrayList());
         copy.setSecurityConstraintsDefs(new ArrayList());                
         
-        
-//        private List constraintsDefs;
-//        private List globalConstraintsRefs;
-//
-//        private List securityConstraintsDefs;
-//        private Map securityConstraintsDefsMap;
-//        private List globalSecurityConstraintsRefs;
-        
-        
-        copy.setHidden(source.isHidden());
         copy.setPath(source.getPath());
-//        copy.setShortTitle(source.getTitle());        
-//        copy.setTitle(source.getTitle());
         copy.setVersion(source.getVersion());        
-        
-        if (source.getSecurityConstraints() != null)
-        {
-            SecurityConstraints constraints = copySecurityConstraints(source.getSecurityConstraints());
-            copy.setSecurityConstraints(constraints);
-        }            
         
         Iterator defs = source.getSecurityConstraintsDefs().iterator();
         while (defs.hasNext())

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/impl/NodeImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/impl/NodeImpl.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/impl/NodeImpl.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/impl/NodeImpl.java Mon Nov 14 08:44:30 2005
@@ -52,6 +52,7 @@
     private String extendedAttributeValue;
 
     private PageMetadataImpl pageMetadata;
+    private String logicalPath;
 
     public NodeImpl(SecurityConstraintsImpl constraints)
     {
@@ -153,6 +154,7 @@
         {
             if (path != null)
             {
+                // set path
                 if (!name.equals(Folder.PATH_SEPARATOR))
                 {
                     path = path.substring(0, path.lastIndexOf(Folder.PATH_SEPARATOR) + 1) + name;
@@ -161,6 +163,9 @@
                 {
                     path = Folder.PATH_SEPARATOR;
                 }
+
+                // reset logicalPath
+                logicalPath = null;
             }
             super.setName(name);
         }
@@ -192,7 +197,7 @@
             // recursively check parent constraints until
             // default constraints for node are checked
             SecurityConstraintsImpl constraintsImpl = (SecurityConstraintsImpl)getSecurityConstraints();
-            if (constraintsImpl != null)
+            if ((constraintsImpl != null) && !constraintsImpl.isEmpty())
             {
                 constraintsImpl.checkConstraints(actions, userPrincipals, rolePrincipals, groupPrincipals, getEffectivePageSecurity());
             }
@@ -212,7 +217,7 @@
             if (!checkParentsOnly)
             {
                 SecurityConstraintsImpl constraintsImpl = (SecurityConstraintsImpl)getSecurityConstraints();
-                if (constraintsImpl != null)
+                if ((constraintsImpl != null) && !constraintsImpl.isEmpty())
                 {
                     constraintsImpl.checkConstraints(actions, userPrincipals, rolePrincipals, groupPrincipals, getEffectivePageSecurity());
                 }
@@ -256,8 +261,63 @@
      */
     public String getLogicalPermissionPath()
     {
-        // NYI
-        return super.getLogicalPermissionPath();
+        // compute logical path if required
+        if (logicalPath == null)
+        {
+            // check for path attributes
+            if ((subsite != null) || (user != null) || (role != null) || (group != null) || (mediatype != null) ||
+                (locale != null) || (extendedAttributeName != null) || (extendedAttributeValue != null))
+            {
+                // parse path, stripping reserved folders from path
+                boolean skipAttribute = false;
+                StringBuffer logicalPathBuffer = new StringBuffer();
+                StringTokenizer pathElements = new StringTokenizer(path, Folder.PATH_SEPARATOR);
+                while (pathElements.hasMoreTokens())
+                {
+                    // classify path element
+                    String pathElement = pathElements.nextToken();
+                    if (!skipAttribute)
+                    {
+                        if (!pathElement.startsWith(Folder.RESERVED_SUBSITE_FOLDER_PREFIX))
+                        {
+                            if (!pathElement.startsWith(Folder.RESERVED_FOLDER_PREFIX))
+                            {
+                                // append to logical path
+                                logicalPathBuffer.append(Folder.PATH_SEPARATOR);
+                                logicalPathBuffer.append(pathElement);
+                            }
+                            else
+                            {
+                                // skip next attribute path element
+                                skipAttribute = true;
+                            }
+                        }
+                    }
+                    else
+                    {
+                        // attribute path element skipped
+                        skipAttribute = false;
+                    }
+                }
+                
+                // set logical path
+                if (logicalPathBuffer.length() > 0)
+                {
+                    logicalPath = logicalPathBuffer.toString();
+                }
+                else
+                {
+                    logicalPath = Folder.PATH_SEPARATOR;
+                }
+            }
+            else
+            {
+                // no path attributes: logical path and physical path equivalent
+                logicalPath = path;
+            }
+        }
+
+        return logicalPath;
     }
 
     /* (non-Javadoc)
@@ -265,6 +325,7 @@
      */
     public String getPhysicalPermissionPath()
     {
+        // return path
         return path;
     }
 
@@ -293,7 +354,11 @@
                 (!parentPath.equals(Folder.PATH_SEPARATOR) &&
                  !parentPath.equals(path.substring(0, path.lastIndexOf(Folder.PATH_SEPARATOR)))))
             {
+                // set path
                 path = parentPath + Folder.PATH_SEPARATOR + getName();
+
+                // reset logicalPath
+                logicalPath = null;
             }
         }
     }
@@ -314,6 +379,9 @@
     {
         // set canonical node path
         this.path = getCanonicalNodePath(path);
+
+        // reset logical path
+        logicalPath = null;
 
         // parse and set informational attributes from path
         String attributeName = null;

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/psml/AbstractNode.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/psml/AbstractNode.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/psml/AbstractNode.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/document/psml/AbstractNode.java Mon Nov 14 08:44:30 2005
@@ -384,7 +384,7 @@
             // recursively check parent constraints until
             // default constraints for node are checked
             SecurityConstraints constraints = getSecurityConstraints();
-            if (constraints != null)
+            if ((constraints != null) && !constraints.isEmpty())
             {
                 ((SecurityConstraintsImpl)constraints).checkConstraints(actions, userPrincipals, rolePrincipals, groupPrincipals, getHandlerFactory());
             }
@@ -400,7 +400,7 @@
             if (!checkParentsOnly)
             {
                 SecurityConstraints constraints = getSecurityConstraints();
-                if (constraints != null)
+                if ((constraints != null) && !constraints.isEmpty())
                 {
                     ((SecurityConstraintsImpl)constraints).checkConstraints(actions, userPrincipals, rolePrincipals, groupPrincipals, getHandlerFactory());
                 }

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java Mon Nov 14 08:44:30 2005
@@ -495,6 +495,9 @@
                     parent.removePage((PageImpl)page);
                     throw e;
                 }
+
+                // notify page manager listeners
+                delegator.notifyNewNode(page);
             }
             else
             {
@@ -503,6 +506,9 @@
 
                 // update page
                 getPersistenceBrokerTemplate().store(page);
+
+                // notify page manager listeners
+                delegator.notifyUpdatedNode(page);
             }
         }
         catch (PageNotUpdatedException pnue)
@@ -549,6 +555,9 @@
                 // delete page
                 getPersistenceBrokerTemplate().delete(page);
             }
+
+            // notify page manager listeners
+            delegator.notifyRemovedNode(page);
         }
         catch (SecurityException se)
         {
@@ -607,14 +616,29 @@
                     parent.removeFolder((FolderImpl)folder);
                     throw e;
                 }
+
+                // notify page manager listeners
+                delegator.notifyNewNode(folder);
             }
             else
             {
                 // check for edit access on folder and parent folder
                 folder.checkAccess(SecuredResource.EDIT_ACTION);
 
-                // update folder
+                // create root folder or update folder
+                boolean newFolder = folder.getId().equals("0");
                 getPersistenceBrokerTemplate().store(folder);
+                newFolder = (newFolder && !folder.getId().equals("0"));
+
+                // notify page manager listeners
+                if (newFolder)
+                {
+                    delegator.notifyNewNode(folder);
+                }
+                else
+                {
+                    delegator.notifyUpdatedNode(folder);
+                }
             }
         }
         catch (FolderNotUpdatedException fnue)
@@ -657,6 +681,9 @@
                 // deep delete folder
                 getPersistenceBrokerTemplate().delete(folder);
             }
+
+            // notify page manager listeners
+            delegator.notifyRemovedNode(folder);
         }
         catch (SecurityException se)
         {
@@ -747,6 +774,9 @@
                 {
                     throw new FailedToUpdateDocumentException("Parent folder page security exists: " + parentPath);
                 }
+
+                // notify page manager listeners
+                delegator.notifyNewNode(pageSecurity);
             }
             else
             {
@@ -755,7 +785,13 @@
 
                 // update document
                 getPersistenceBrokerTemplate().store(pageSecurity);
+
+                // notify page manager listeners
+                delegator.notifyUpdatedNode(pageSecurity);
             }
+
+            // reset all cached security constraints
+            DatabasePageManagerCache.resetCachedSecurityConstraints();
         }
         catch (FailedToUpdateDocumentException fude)
         {
@@ -797,6 +833,12 @@
                 // delete document
                 getPersistenceBrokerTemplate().delete(pageSecurity);
             }
+
+            // reset all cached security constraints
+            DatabasePageManagerCache.resetCachedSecurityConstraints();
+
+            // notify page manager listeners
+            delegator.notifyRemovedNode(pageSecurity);
         }
         catch (SecurityException se)
         {

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java Mon Nov 14 08:44:30 2005
@@ -16,6 +16,7 @@
 package org.apache.jetspeed.page.impl;
 
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Properties;
 import java.util.Map;
 
@@ -130,6 +131,25 @@
         {
             NodeImpl node = (NodeImpl)obj;
             cacheByPath.remove(node.getPath());
+        }
+    }
+
+    /**
+     * resetCachedSecurityConstraints
+     *
+     * Reset cached security constraints in all cached node objects.
+     */
+    public synchronized static void resetCachedSecurityConstraints()
+    {
+        // reset cached objects
+        Iterator objectsIter = cacheByOID.values().iterator();
+        while (objectsIter.hasNext())
+        {
+            Object obj = objectsIter.next();
+            if (obj instanceof NodeImpl)
+            {
+                ((NodeImpl)obj).resetCachedSecurityConstraints();
+            }
         }
     }
 

Modified: portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java Mon Nov 14 08:44:30 2005
@@ -261,6 +261,13 @@
         assertTrue(f.getDecorator().equals("Tab"));
         assertNotNull(f.getFragments());
         assertTrue(f.getFragments().size() == 2);
+
+        List fragments = testpage.getFragmentsByName("JMXPortlet");
+        assertNotNull(fragments);
+        assertEquals(1, fragments.size());
+        assertTrue(((Fragment)fragments.get(0)).getId().equals("pe002"));
+        assertTrue(((Fragment)fragments.get(0)).getName().equals("JMXPortlet"));
+        assertTrue(((Fragment)fragments.get(0)).getType().equals(Fragment.PORTLET));
     }
 
     public void testCreatePage() throws Exception

Modified: portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java Mon Nov 14 08:44:30 2005
@@ -31,6 +31,7 @@
 import org.apache.jetspeed.om.page.SecurityConstraintsDef;
 import org.apache.jetspeed.page.document.DocumentNotFoundException;
 import org.apache.jetspeed.page.document.FailedToUpdateDocumentException;
+import org.apache.jetspeed.page.document.Node;
 
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
@@ -44,15 +45,19 @@
  * @version $Id: $
  *          
  */
-public class TestDatabasePageManager extends AbstractSpringTestCase
+public class TestDatabasePageManager extends AbstractSpringTestCase implements PageManagerEventListener
 {
     private String deepFolderPath = "/__subsite-rootx/_user/userx/_role/rolex/_group/groupx/_mediatype/xhtml/_language/en/_country/us/_custom/customx";
     private String deepPagePath = deepFolderPath + "/default-page.psml";
 
     private static ClassPathXmlApplicationContext context;
 
-    private PageManager pageManager;
-    
+    private static PageManager pageManager;
+
+    private static int newNodeCount;
+    private static int updatedNodeCount;
+    private static int removedNodeCount;
+
     public static void main(String args[])
     {
         junit.awtui.TestRunner.main(new String[]
@@ -66,16 +71,20 @@
         // super class setUp() implementation
         if (context == null)
         {
+            // new context
             super.setUp();
             context = ctx;
+
+            // lookup page manager in context
+            pageManager = (PageManager)context.getBean("pageManager");
+            pageManager.addListener(this);
         }
         else
         {
+            // recycle context
             ctx = context;
             super.setUp();
         }
-        // lookup page manager in context
-        pageManager = (PageManager)context.getBean("pageManager");
     }
 
     protected void tearDown() throws Exception
@@ -101,6 +110,30 @@
         { "test-repository-datasource-spring.xml" };
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.PageManagerEventListener#newNode(org.apache.jetspeed.page.document.Node)
+     */
+    public void newNode(Node node)
+    {
+        newNodeCount++;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.PageManagerEventListener#newNode(org.apache.jetspeed.page.document.Node)
+     */
+    public void updatedNode(Node node)
+    {
+        updatedNodeCount++;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.PageManagerEventListener#newNode(org.apache.jetspeed.page.document.Node)
+     */
+    public void removedNode(Node node)
+    {
+        removedNodeCount++;
+    }
+
     public void testCreates() throws Exception
     {
         // reset page manager cache
@@ -367,6 +400,9 @@
             assertEquals(11, ((Fragment)check.getRootFragment().getFragments().get(1)).getLayoutColumn());
             assertNotNull(((Fragment)check.getRootFragment().getFragments().get(1)).getSecurityConstraints());
             assertEquals("user", ((Fragment)check.getRootFragment().getFragments().get(1)).getSecurityConstraints().getOwner());
+            assertNotNull(check.getFragmentById(((Fragment)check.getRootFragment().getFragments().get(0)).getId()));
+            assertNotNull(check.getFragmentsByName("some-app::SomePortlet"));
+            assertEquals(1, check.getFragmentsByName("some-app::SomePortlet").size());
             assertNotNull(check.getParent());
         }
         catch (PageNotFoundException e)
@@ -426,6 +462,28 @@
         }
     }
 
+    public void testUpdates() throws Exception
+    {
+        // reset page manager cache
+        pageManager.reset();
+        
+        // update documents and folders in persisted store
+        PageSecurity pageSecurity = pageManager.getPageSecurity();
+        assertEquals("/page.security", pageSecurity.getPath());
+        pageSecurity.getGlobalSecurityConstraintsRefs().add("UPDATED");
+        pageManager.updatePageSecurity(pageSecurity);
+
+        Page page = pageManager.getPage("/default-page.psml");
+        assertEquals("/default-page.psml", page.getPath());
+        page.setTitle("UPDATED");
+        pageManager.updatePage(page);
+
+        Folder folder = pageManager.getFolder("/");
+        assertEquals("/", folder.getPath());
+        folder.setTitle("UPDATED");
+        pageManager.updateFolder(folder);
+    }
+
     public void testRemoves() throws Exception
     {
         // reset page manager cache
@@ -495,5 +553,13 @@
         catch (PageNotFoundException e)
         {
         }
+    }
+
+    public void testEvents() throws Exception
+    {
+        // verify listener functionality and operation counts
+        assertEquals(19, newNodeCount);
+        assertEquals(3, updatedNodeCount);
+        assertEquals(1, removedNodeCount);
     }
 }

Modified: portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java Mon Nov 14 08:44:30 2005
@@ -52,6 +52,8 @@
 public class TestSecureDatabasePageManager extends AbstractSpringTestCase
 {
     private PageManager pageManager;
+
+    private String somePortletId;
     
     public static void main(String args[])
     {
@@ -181,7 +183,13 @@
                         portlet.setSecurityConstraints(fragmentConstraints);
                         root.getFragments().add(portlet);
                         pageManager.updatePage(page);
-
+                        assertNotNull(page.getRootFragment());
+                        assertNotNull(page.getRootFragment().getFragments());
+                        assertEquals(2, page.getRootFragment().getFragments().size());
+                        assertEquals("some-app::SomePortlet", ((Fragment)page.getRootFragment().getFragments().get(1)).getName());
+                        assertFalse("0".equals(((Fragment)page.getRootFragment().getFragments().get(1)).getId()));
+                        TestSecureDatabasePageManager.this.somePortletId = ((Fragment)page.getRootFragment().getFragments().get(1)).getId();
+                        
                         page = pageManager.newPage("/user-page.psml");
                         constraints = pageManager.newSecurityConstraints();
                         inlineConstraints = new ArrayList(1);
@@ -192,7 +200,7 @@
                         constraints.setSecurityConstraints(inlineConstraints);
                         page.setSecurityConstraints(constraints);
                         pageManager.updatePage(page);
-                        
+
                         return null;
                     }
                     catch (Exception e)
@@ -223,6 +231,9 @@
                         assertNotNull(page0.getRootFragment());
                         assertNotNull(page0.getRootFragment().getFragments());
                         assertEquals(2, page0.getRootFragment().getFragments().size());
+                        assertNotNull(page0.getFragmentById(TestSecureDatabasePageManager.this.somePortletId));
+                        assertNotNull(page0.getFragmentsByName("some-app::SomePortlet"));
+                        assertEquals(1, page0.getFragmentsByName("some-app::SomePortlet").size());
                         Page page1 = pageManager.getPage("/user-page.psml");
                         // test edit access
                         pageManager.updateFolder(folder);
@@ -259,6 +270,9 @@
                         assertNotNull(page0.getRootFragment());
                         assertNotNull(page0.getRootFragment().getFragments());
                         assertEquals(2, page0.getRootFragment().getFragments().size());
+                        assertNotNull(page0.getFragmentById(TestSecureDatabasePageManager.this.somePortletId));
+                        assertNotNull(page0.getFragmentsByName("some-app::SomePortlet"));
+                        assertEquals(1, page0.getFragmentsByName("some-app::SomePortlet").size());
                         Page page1 = pageManager.getPage("/user-page.psml");
                         // test edit access
                         try
@@ -315,8 +329,9 @@
                         Page page0 = pageManager.getPage("/default-page.psml");
                         assertNotNull(page0.getRootFragment());
                         assertNotNull(page0.getRootFragment().getFragments());
-                        // Fragment access bug: assertEquals(1, page0.getRootFragment().getFragments().size());
-                        assertEquals(2, page0.getRootFragment().getFragments().size());
+                        assertEquals(1, page0.getRootFragment().getFragments().size());
+                        assertNull(page0.getFragmentById(TestSecureDatabasePageManager.this.somePortletId));
+                        assertNull(page0.getFragmentsByName("some-app::SomePortlet"));
                         try
                         {
                             Page page1 = pageManager.getPage("/user-page.psml");
@@ -372,8 +387,9 @@
                         Page page0 = pageManager.getPage("/default-page.psml");
                         assertNotNull(page0.getRootFragment());
                         assertNotNull(page0.getRootFragment().getFragments());
-                        // Fragment access bug: assertEquals(1, page0.getRootFragment().getFragments().size());
-                        assertEquals(2, page0.getRootFragment().getFragments().size());
+                        assertEquals(1, page0.getRootFragment().getFragments().size());
+                        assertNull(page0.getFragmentById(TestSecureDatabasePageManager.this.somePortletId));
+                        assertNull(page0.getFragmentsByName("some-app::SomePortlet"));
                         try
                         {
                             Page page1 = pageManager.getPage("/user-page.psml");

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/common/SecurityConstraints.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/common/SecurityConstraints.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/common/SecurityConstraints.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/common/SecurityConstraints.java Mon Nov 14 08:44:30 2005
@@ -84,4 +84,13 @@
      * @param constraintsRefs security constraints references for resource
      */
     void setSecurityConstraintsRefs(List constraintsRefs);
+
+    /**
+     * <p>
+     * isEmpty
+     * </p>
+     *
+     * @return flag indicating whether there are constraints or owner set
+     */
+    boolean isEmpty();
 }

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/page/ContentPage.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/page/ContentPage.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/page/ContentPage.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/page/ContentPage.java Mon Nov 14 08:44:30 2005
@@ -1,5 +1,6 @@
 package org.apache.jetspeed.om.page;
 
+import java.util.List;
 
 /**
  * PageFragment is a volatile wrapper around a 
@@ -39,6 +40,16 @@
 
 
 
+  /**
+   * Returns a list of ContentFragment that wrap the actual
+   * Fragment metadata represented by the name argument.
+   * @param name name of the Fragments we want to retrieve.
+   * @return
+   */
+  List getContentFragmentsByName(String name);
+
+
+
 /**
  * Overridden to to indicate that the {@link Fragment} returned
  * must also be an instance of ContentFragment.
@@ -47,6 +58,17 @@
  * @return the found ContentFragment object or null if not found
  */
  Fragment getFragmentById(String id);
+
+
+
+/**
+ * Overridden to to indicate that the list of {@link Fragment}
+ * instances returned must also be instances of ContentFragment.
+ *
+ * @param name the fragments name to look for
+ * @return the list of found ContentFragment object or null if not found
+ */
+ List getFragmentsByName(String name);
 
 
 

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/page/Page.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/page/Page.java?rev=344154&r1=344153&r2=344154&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/page/Page.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/om/page/Page.java Mon Nov 14 08:44:30 2005
@@ -90,6 +90,15 @@
     Fragment getFragmentById(String id);
 
     /**
+     * Retrieves the fragments contained within this page, with the
+     * specified name.
+     *
+     * @param name the fragment name to look for
+     * @return the list of found Fragment objects or null if not found
+     */
+    List getFragmentsByName(String name);
+
+    /**
      * Create a clone of this object
      */
     Object clone() throws java.lang.CloneNotSupportedException;



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