portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r350066 [2/3] - in /portals/jetspeed-2/trunk: components/page-manager/ components/page-manager/src/java/JETSPEED-INF/castor/ components/page-manager/src/java/JETSPEED-INF/ojb/ components/page-manager/src/java/org/apache/jetspeed/om/folder/i...
Date Wed, 30 Nov 2005 22:53:59 GMT
Propchange: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceList.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceList.java?rev=350066&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceList.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceList.java Wed Nov 30 14:53:22 2005
@@ -0,0 +1,156 @@
+/*
+ * 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.AbstractList;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * FragmentPreferenceList
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+class FragmentPreferenceList extends AbstractList
+{
+    private FragmentImpl fragment;
+
+    private List removedPreferences;
+
+    FragmentPreferenceList(FragmentImpl fragment)
+    {
+        super();
+        this.fragment = fragment;
+    }
+
+    /**
+     * validatePreferenceForAdd
+     *
+     * Validates preference to be added to this list.
+     *
+     * @param preference preference to add
+     * @return list element to add
+     */
+    private FragmentPreferenceImpl validatePreferenceForAdd(FragmentPreferenceImpl preference)
+    {
+        // only non-null definitions supported
+        if (preference == null)
+        {
+            throw new NullPointerException("Unable to add null to list.");
+        }
+        // make sure element is unique
+        if (fragment.accessPreferences().contains(preference))
+        {
+            throw new IllegalArgumentException("Unable to add duplicate entry to list: " + preference.getName());
+        }
+        // retrieve from removed list to reuse
+        // previously removed element copying
+        // security constraint defs
+        if (removedPreferences != null)
+        {
+            int removedIndex = removedPreferences.indexOf(preference);
+            if (removedIndex >= 0)
+            {
+                FragmentPreferenceImpl addPreference = preference;
+                preference = (FragmentPreferenceImpl)removedPreferences.remove(removedIndex);
+                preference.setReadOnly(addPreference.isReadOnly());
+                preference.setValueList(addPreference.getValueList());
+            }
+        }
+        return preference;
+    }
+
+    /**
+     * getRemovedPreferences
+     *
+     * @return removed preferences tracking collection
+     */
+    private List getRemovedPreferences()
+    {
+        if (removedPreferences == null)
+        {
+            removedPreferences = new ArrayList(fragment.accessPreferences().size());
+        }
+        return removedPreferences;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(int,java.lang.Object)
+     */
+    public void add(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // validate index
+        if ((index < 0) || (index > fragment.accessPreferences().size()))
+        {
+            throw new IndexOutOfBoundsException("Unable to add to list at index: " + index);
+        }
+        // verify preference
+        FragmentPreferenceImpl preference = validatePreferenceForAdd((FragmentPreferenceImpl)element);
+        // add to underlying ordered list
+        fragment.accessPreferences().add(index, preference);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#get(int)
+     */
+    public Object get(int index)
+    {
+        // implement for modifiable AbstractList
+        return fragment.accessPreferences().get(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#remove(int)
+     */
+    public Object remove(int index)
+    {
+        // implement for modifiable AbstractList:
+        // save removed element 
+        FragmentPreferenceImpl removed = (FragmentPreferenceImpl)fragment.accessPreferences().remove(index);
+        if (removed != null)
+        {
+            getRemovedPreferences().add(removed);
+        }
+        return removed;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#set(int,java.lang.Object)
+     */
+    public Object set(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // verify preference
+        FragmentPreferenceImpl newPreference = validatePreferenceForAdd((FragmentPreferenceImpl)element);
+        // set in underlying ordered list
+        FragmentPreferenceImpl preference = (FragmentPreferenceImpl)fragment.accessPreferences().set(index, newPreference);
+        // save replaced element
+        getRemovedPreferences().add(preference);
+        // return constraints ref
+        return preference;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#size()
+     */
+    public int size()
+    {
+        // implement for modifiable AbstractList
+        return fragment.accessPreferences().size();
+    }
+}

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

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceValue.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceValue.java?rev=350066&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceValue.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceValue.java Wed Nov 30 14:53:22 2005
@@ -0,0 +1,69 @@
+/*
+ * 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;
+
+/**
+ * FragmentPreferenceValue
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class FragmentPreferenceValue
+{
+    private int id;
+    private int valueOrder;
+    private String value;
+
+    /**
+     * getValueOrder
+     *
+     * @return value order
+     */
+    public int getValueOrder()
+    {
+        return valueOrder;
+    }
+
+    /**
+     * setValueOrder
+     *
+     * @param order value order
+     */
+    public void setValueOrder(int order)
+    {
+        valueOrder = order;
+    }
+
+    /**
+     * getValue
+     *
+     * @return preference value
+     */
+    public String getValue()
+    {
+        return value;
+    }
+
+    /**
+     * setValue
+     *
+     * @param value preference value
+     */
+    public void setValue(String value)
+    {
+        this.value = value;
+    }
+}

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

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceValueList.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceValueList.java?rev=350066&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceValueList.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceValueList.java Wed Nov 30 14:53:22 2005
@@ -0,0 +1,145 @@
+/*
+ * 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.AbstractList;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * FragmentPreferenceValueList
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+class FragmentPreferenceValueList extends AbstractList
+{
+    private FragmentPreferenceImpl preference;
+
+    FragmentPreferenceValueList(FragmentPreferenceImpl preference)
+    {
+        super();
+        this.preference = preference;
+    }
+
+    /**
+     * wrapValueStringForAdd
+     *
+     * Wraps and validates preference value string
+     * to be added to this list.
+     *
+     * @param value preference value string to add
+     * @return list element to add
+     */
+    private FragmentPreferenceValue wrapValueStringForAdd(String value)
+    {
+        // only non-null values supported
+        if (value == null)
+        {
+            throw new NullPointerException("Unable to add null to list.");
+        }
+        // wrap preference value string
+        FragmentPreferenceValue preferenceValue = new FragmentPreferenceValue();
+        preferenceValue.setValue(value);
+        return preferenceValue;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(int,java.lang.Object)
+     */
+    public void add(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // validate index
+        if ((index < 0) || (index > preference.accessValues().size()))
+        {
+            throw new IndexOutOfBoundsException("Unable to add to list at index: " + index);
+        }
+        // wrap and verify preference value string
+        FragmentPreferenceValue preferenceValue = wrapValueStringForAdd((String)element);
+        // add to underlying ordered list
+        preference.accessValues().add(index, preferenceValue);
+        // set value order in added element
+        if (index > 0)
+        {
+            preferenceValue.setValueOrder(((FragmentPreferenceValue)preference.accessValues().get(index-1)).getValueOrder() + 1);
+        }
+        else
+        {
+            preferenceValue.setValueOrder(0);
+        }
+        // maintain value order in subsequent elements
+        for (int i = index, limit = preference.accessValues().size() - 1; (i < limit); i++)
+        {
+            FragmentPreferenceValue nextPreferenceValue = (FragmentPreferenceValue)preference.accessValues().get(i + 1);
+            if (nextPreferenceValue.getValueOrder() <= preferenceValue.getValueOrder())
+            {
+                // adjust value order for next element
+                nextPreferenceValue.setValueOrder(preferenceValue.getValueOrder() + 1);
+                preferenceValue = nextPreferenceValue;
+            }
+            else
+            {
+                // value order maintained for remaining list elements
+                break;
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#get(int)
+     */
+    public Object get(int index)
+    {
+        // implement for modifiable AbstractList:
+        // unwrap preference value string
+        return ((FragmentPreferenceValue)preference.accessValues().get(index)).getValue();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#remove(int)
+     */
+    public Object remove(int index)
+    {
+        // implement for modifiable AbstractList
+        return preference.accessValues().remove(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#set(int,java.lang.Object)
+     */
+    public Object set(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // wrap and verify preference value string
+        FragmentPreferenceValue newPreferenceValue = wrapValueStringForAdd((String)element);
+        // set in underlying ordered list
+        FragmentPreferenceValue preferenceValue = (FragmentPreferenceValue)preference.accessValues().set(index, newPreferenceValue);
+        // set value order in new element
+        newPreferenceValue.setValueOrder(preferenceValue.getValueOrder());
+        // return unwrapped preference value string
+        return preferenceValue.getValue();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#size()
+     */
+    public int size()
+    {
+        // implement for modifiable AbstractList
+        return preference.accessValues().size();
+    }
+}

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

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPropertyMap.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPropertyMap.java?rev=350066&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPropertyMap.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentPropertyMap.java Wed Nov 30 14:53:22 2005
@@ -0,0 +1,235 @@
+/*
+ * 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.AbstractMap;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.jetspeed.om.page.Fragment;
+
+/**
+ * FragmentPropertyMap
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+class FragmentPropertyMap extends AbstractMap
+{
+    private FragmentImpl fragment;
+    private FragmentPropertiesEntrySet entrySet;
+
+    FragmentPropertyMap(FragmentImpl fragment)
+    {
+        super();
+        this.fragment = fragment;
+        // populate fragment properties using property members
+        entrySet = new FragmentPropertiesEntrySet();
+        Iterator keyIter = fragment.getPropertyMemberKeys().iterator();
+        while (keyIter.hasNext())
+        {
+            String key = (String)keyIter.next();
+            entrySet.add(new FragmentPropertiesEntry(key, fragment.getPropertyMember(key)));
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.Map#put(java.lang.Object, java.lang.Object)
+     */
+    public Object put(Object key, Object value)
+    {
+        // implement for modifiable AbstractMap:
+        // set map entry value or add new map entry
+        // using iterator to find key entry
+        FragmentPropertiesEntry entry = new FragmentPropertiesEntry(key, value);
+        Iterator entryIter = entrySet.iterator();
+        while (entryIter.hasNext())
+        {
+            FragmentPropertiesEntry testEntry = (FragmentPropertiesEntry) entryIter.next();
+            if (testEntry.equals(entry))
+            {
+                Object oldValue = testEntry.getValue();
+                testEntry.setValue(entry.getValue());
+                return oldValue;
+            }
+        }
+        entrySet.add(entry);
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.Map#entrySet()
+     */
+    public Set entrySet()
+    {
+        // implement for modifiable AbstractMap
+        return entrySet;
+    }
+
+    private class FragmentPropertiesEntrySet extends AbstractSet
+    {
+        private Collection entries = new ArrayList(5);
+
+        /* (non-Javadoc)
+         * @see java.util.Set#add(java.lang.Object)
+         */
+        public boolean add(Object o)
+        {
+            // implement for modifiable AbstractSet:
+            FragmentPropertiesEntry entry = (FragmentPropertiesEntry)o;
+            if (!entries.contains(entry))
+            {
+                // set fragment explicit property member
+                fragment.setPropertyMember(entry.getKey().toString(), entry.getValue().toString());
+                // add entry to set
+                entries.add(o);
+                return true;
+            }
+            return false;
+        }
+
+        /* (non-Javadoc)
+         * @see java.util.Set#iterator()
+         */
+        public Iterator iterator()
+        {
+            // implement for modifiable AbstractSet:
+            return new Iterator()
+                {
+                    private Iterator iter = entries.iterator();
+                    private FragmentPropertiesEntry last;
+                    
+                    /* (non-Javadoc)
+                     * @see java.util.Iterator#hasNext()
+                     */
+                    public boolean hasNext()
+                    {
+                        // implement for modifiable AbstractSet:
+                        return iter.hasNext();
+                    }
+
+                    /* (non-Javadoc)
+                     * @see java.util.Iterator#next()
+                     */
+                    public Object next()
+                    {
+                        // implement for modifiable AbstractSet:
+                        last = (FragmentPropertiesEntry)iter.next();
+                        return last;
+                    }
+
+                    /* (non-Javadoc)
+                     * @see java.util.Iterator#remove()
+                     */
+                    public void remove()
+                    {
+                        // implement for modifiable AbstractSet:
+                        // clear fragment explicit property associated with entry
+                        if (last == null)
+                        {
+                            throw new IllegalStateException("No preceding call to next() or remove() already invoked");
+                        }
+                        FragmentPropertyMap.this.fragment.clearPropertyMember(last.getKey().toString());
+                        last = null;
+                        // remove entry using iterator
+                        iter.remove();
+                    }
+                };
+        }
+
+        /* (non-Javadoc)
+         * @see java.util.Set#size()
+         */
+        public int size()
+        {
+            // implement for modifiable AbstractSet:
+            return entries.size();
+        }
+    }
+
+    private class FragmentPropertiesEntry implements Map.Entry
+    {
+        private Object key;
+        private Object value;
+
+        public FragmentPropertiesEntry(Object key, Object value)
+        {
+            this.key = key;
+            this.value = value;
+        }
+
+        /* (non-Javadoc)
+         * @see java.util.Map.Entry#getKey()
+         */
+        public Object getKey()
+        {
+            return key;
+        }
+
+        /* (non-Javadoc)
+         * @see java.util.Map.Entry#getValue()
+         */
+        public Object getValue()
+        {
+            return value;
+        }
+    
+        /* (non-Javadoc)
+         * @see java.util.Map.Entry#setValue(java.lang.Object)
+         */
+        public Object setValue(Object newValue)
+        {
+            // set fragment explicit property associated with entry
+            FragmentPropertyMap.this.fragment.setPropertyMember(key.toString(), newValue.toString());
+            // set entry value
+            Object oldValue = value;
+            value = newValue;
+            return oldValue;
+        }
+
+        /* (non-Javadoc)
+         * @see java.lang.Object#equals(java.lang.Object)
+         */
+        public boolean equals(Object o)
+        {
+            if (o instanceof FragmentPropertiesEntry)
+            {
+                if (key != null)
+                {
+                    return key.equals(((FragmentPropertiesEntry)o).getKey());
+                }
+                return (((FragmentPropertiesEntry)o).getKey() == null);
+            }
+            return false;
+        }
+        
+        /* (non-Javadoc)
+         * @see java.lang.Object#hashCode()
+         */
+        public int hashCode()
+        {
+            if (key != null)
+            {
+                return key.hashCode();
+            }
+            return 0;
+        }
+    }
+}

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

Copied: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentSecurityConstraintImpl.java (from r345429, portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentSecurityConstraint.java)
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentSecurityConstraintImpl.java?p2=portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentSecurityConstraintImpl.java&p1=portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentSecurityConstraint.java&r1=345429&r2=350066&rev=350066&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentSecurityConstraint.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentSecurityConstraintImpl.java Wed Nov 30 14:53:22 2005
@@ -15,13 +15,15 @@
  */
 package org.apache.jetspeed.om.page.impl;
 
+import org.apache.jetspeed.om.page.SecurityConstraintImpl;
+
 /**
- * PageSecurityConstraint
+ * PageSecurityConstraintImpl
  *
  * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
  * @version $Id$
  */
-public class FragmentSecurityConstraint extends BaseSecurityConstraint
+public class FragmentSecurityConstraintImpl extends SecurityConstraintImpl
 {
     // new class defined only to facilitate OJB table/class mapping
 }

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentSecurityConstraintsImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentSecurityConstraintsImpl.java?rev=350066&r1=350065&r2=350066&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentSecurityConstraintsImpl.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/FragmentSecurityConstraintsImpl.java Wed Nov 30 14:53:22 2005
@@ -24,18 +24,18 @@
 public class FragmentSecurityConstraintsImpl extends SecurityConstraintsImpl
 {
     /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl#newSecurityConstraint()
+     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl#getSecurityConstraintClass()
      */
-    public BaseSecurityConstraint newSecurityConstraint()
+    public Class getSecurityConstraintClass()
     {
-        return new FragmentSecurityConstraint();
+        return FragmentSecurityConstraintImpl.class;
     }
 
     /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl#newSecurityConstraintsRef()
+     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl#getSecurityConstraintsRefClass()
      */
-    public BaseSecurityConstraintsRef newSecurityConstraintsRef()
+    public Class getSecurityConstraintsRefClass()
     {
-        return new FragmentSecurityConstraintsRef();
+        return FragmentSecurityConstraintsRef.class;
     }
 }

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=350066&r1=350065&r2=350066&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 Wed Nov 30 14:53:22 2005
@@ -24,8 +24,6 @@
 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
@@ -234,21 +232,5 @@
     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);
-        }
     }
 }

Copied: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintImpl.java (from r345429, portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraint.java)
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintImpl.java?p2=portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintImpl.java&p1=portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraint.java&r1=345429&r2=350066&rev=350066&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraint.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintImpl.java Wed Nov 30 14:53:22 2005
@@ -15,13 +15,15 @@
  */
 package org.apache.jetspeed.om.page.impl;
 
+import org.apache.jetspeed.om.page.SecurityConstraintImpl;
+
 /**
- * PageSecurityConstraint
+ * PageSecurityConstraintImpl
  *
  * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
  * @version $Id$
  */
-public class PageSecurityConstraint extends BaseSecurityConstraint
+public class PageSecurityConstraintImpl extends SecurityConstraintImpl
 {
     // new class defined only to facilitate OJB table/class mapping
 }

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsDefList.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsDefList.java?rev=350066&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsDefList.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsDefList.java Wed Nov 30 14:53:22 2005
@@ -0,0 +1,161 @@
+/*
+ * 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.AbstractList;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * PageSecurityConstraintsDefList
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+class PageSecurityConstraintsDefList extends AbstractList
+{
+    private PageSecurityImpl pageSecurity;
+
+    private List removedConstraintsDefs;
+
+    PageSecurityConstraintsDefList(PageSecurityImpl pageSecurity)
+    {
+        super();
+        this.pageSecurity = pageSecurity;
+    }
+
+    /**
+     * validateConstraintsDefForAdd
+     *
+     * Validates constraints def to be added to this list.
+     *
+     * @param constraintsDef constraints definition to add
+     * @return list element to add
+     */
+    private SecurityConstraintsDefImpl validateConstraintsDefForAdd(SecurityConstraintsDefImpl constraintsDef)
+    {
+        // only non-null definitions supported
+        if (constraintsDef == null)
+        {
+            throw new NullPointerException("Unable to add null to list.");
+        }
+        // make sure element is unique
+        if (pageSecurity.accessConstraintsDefs().contains(constraintsDef))
+        {
+            throw new IllegalArgumentException("Unable to add duplicate entry to list: " + constraintsDef.getName());
+        }
+        // retrieve from removed list to reuse
+        // previously removed element copying
+        // security constraint defs
+        if (removedConstraintsDefs != null)
+        {
+            int removedIndex = removedConstraintsDefs.indexOf(constraintsDef);
+            if (removedIndex >= 0)
+            {
+                SecurityConstraintsDefImpl addConstraintsDef = constraintsDef;
+                constraintsDef = (SecurityConstraintsDefImpl)removedConstraintsDefs.remove(removedIndex);
+                constraintsDef.setSecurityConstraints(addConstraintsDef.getSecurityConstraints());
+            }
+        }
+        return constraintsDef;
+    }
+
+    /**
+     * getRemovedConstraintsDefs
+     *
+     * @return removed constraints defs tracking collection
+     */
+    private List getRemovedConstraintsDefs()
+    {
+        if (removedConstraintsDefs == null)
+        {
+            removedConstraintsDefs = new ArrayList(pageSecurity.accessConstraintsDefs().size());
+        }
+        return removedConstraintsDefs;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(int,java.lang.Object)
+     */
+    public void add(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // validate index
+        if ((index < 0) || (index > pageSecurity.accessConstraintsDefs().size()))
+        {
+            throw new IndexOutOfBoundsException("Unable to add to list at index: " + index);
+        }
+        // verify constraints definition
+        SecurityConstraintsDefImpl constraintsDef = validateConstraintsDefForAdd((SecurityConstraintsDefImpl)element);
+        // add to underlying ordered list
+        pageSecurity.accessConstraintsDefs().add(index, constraintsDef);
+        // clear cached security constraints definition map
+        pageSecurity.clearSecurityConstraintsDefsMap();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#get(int)
+     */
+    public Object get(int index)
+    {
+        // implement for modifiable AbstractList
+        return pageSecurity.accessConstraintsDefs().get(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#remove(int)
+     */
+    public Object remove(int index)
+    {
+        // implement for modifiable AbstractList
+        SecurityConstraintsDefImpl removed = (SecurityConstraintsDefImpl)pageSecurity.accessConstraintsDefs().remove(index);
+        if (removed != null)
+        {
+            // save removed element 
+            getRemovedConstraintsDefs().add(removed);
+            // clear cached security constraints definition map
+            pageSecurity.clearSecurityConstraintsDefsMap();
+        }
+        return removed;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#set(int,java.lang.Object)
+     */
+    public Object set(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // verify constraints definition
+        SecurityConstraintsDefImpl newConstraintsDef = validateConstraintsDefForAdd((SecurityConstraintsDefImpl)element);
+        // set in underlying ordered list
+        SecurityConstraintsDefImpl constraintsDef = (SecurityConstraintsDefImpl)pageSecurity.accessConstraintsDefs().set(index, newConstraintsDef);
+        // save replaced element
+        getRemovedConstraintsDefs().add(constraintsDef);
+        // clear cached security constraints definition map
+        pageSecurity.clearSecurityConstraintsDefsMap();
+        // return constraints definition
+        return constraintsDef;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#size()
+     */
+    public int size()
+    {
+        // implement for modifiable AbstractList
+        return pageSecurity.accessConstraintsDefs().size();
+    }
+}

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

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsImpl.java?rev=350066&r1=350065&r2=350066&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsImpl.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsImpl.java Wed Nov 30 14:53:22 2005
@@ -24,18 +24,18 @@
 public class PageSecurityConstraintsImpl extends SecurityConstraintsImpl
 {
     /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl#newSecurityConstraint()
+     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl#getSecurityConstraintClass()
      */
-    public BaseSecurityConstraint newSecurityConstraint()
+    public Class getSecurityConstraintClass()
     {
-        return new PageSecurityConstraint();
+        return PageSecurityConstraintImpl.class;
     }
 
     /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl#newSecurityConstraintsRef()
+     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl#getSecurityConstraintsRefClass()
      */
-    public BaseSecurityConstraintsRef newSecurityConstraintsRef()
+    public Class getSecurityConstraintsRefClass()
     {
-        return new PageSecurityConstraintsRef();
+        return PageSecurityConstraintsRef.class;
     }
 }

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsRefList.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsRefList.java?rev=350066&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsRefList.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsRefList.java Wed Nov 30 14:53:22 2005
@@ -0,0 +1,184 @@
+/*
+ * 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.AbstractList;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * PageSecurityConstraintsRefList
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+class PageSecurityConstraintsRefList extends AbstractList
+{
+    private PageSecurityImpl pageSecurity;
+
+    private List removedConstraintsRefs;
+
+    PageSecurityConstraintsRefList(PageSecurityImpl pageSecurity)
+    {
+        super();
+        this.pageSecurity = pageSecurity;
+    }
+
+    /**
+     * wrapNameStringForAdd
+     *
+     * Wraps and validates constraints ref name string
+     * to be added to this list.
+     *
+     * @param name constraints ref name string to add
+     * @return list element to add
+     */
+    private PageSecurityGlobalSecurityConstraintsRef wrapNameStringForAdd(String name)
+    {
+        // only non-null names supported
+        if (name == null)
+        {
+            throw new NullPointerException("Unable to add null to list.");
+        }
+        // wrap constraints ref name string
+        PageSecurityGlobalSecurityConstraintsRef constraintsRef = new PageSecurityGlobalSecurityConstraintsRef();
+        constraintsRef.setName(name);
+        // make sure element is unique
+        if (pageSecurity.accessGlobalConstraintsRefs().contains(constraintsRef))
+        {
+            throw new IllegalArgumentException("Unable to add duplicate entry to list: " + constraintsRef.getName());
+        }
+        // retrieve from removed list to reuse
+        // previously removed element
+        if (removedConstraintsRefs != null)
+        {
+            int removedIndex = removedConstraintsRefs.indexOf(constraintsRef);
+            if (removedIndex >= 0)
+            {
+                constraintsRef = (PageSecurityGlobalSecurityConstraintsRef)removedConstraintsRefs.remove(removedIndex);
+            }
+        }
+        return constraintsRef;
+    }
+
+    /**
+     * getRemovedConstraintsRefs
+     *
+     * @return removed constraints refs tracking collection
+     */
+    private List getRemovedConstraintsRefs()
+    {
+        if (removedConstraintsRefs == null)
+        {
+            removedConstraintsRefs = new ArrayList(pageSecurity.accessGlobalConstraintsRefs().size());
+        }
+        return removedConstraintsRefs;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(int,java.lang.Object)
+     */
+    public void add(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // validate index
+        if ((index < 0) || (index > pageSecurity.accessGlobalConstraintsRefs().size()))
+        {
+            throw new IndexOutOfBoundsException("Unable to add to list at index: " + index);
+        }
+        // wrap and verify constraints ref name string
+        PageSecurityGlobalSecurityConstraintsRef constraintsRef = wrapNameStringForAdd((String)element);
+        // add to underlying ordered list
+        pageSecurity.accessGlobalConstraintsRefs().add(index, constraintsRef);
+        // set apply order in added element
+        if (index > 0)
+        {
+            constraintsRef.setApplyOrder(((PageSecurityGlobalSecurityConstraintsRef)pageSecurity.accessGlobalConstraintsRefs().get(index-1)).getApplyOrder() + 1);
+        }
+        else
+        {
+            constraintsRef.setApplyOrder(0);
+        }
+        // maintain apply order in subsequent elements
+        for (int i = index, limit = pageSecurity.accessGlobalConstraintsRefs().size() - 1; (i < limit); i++)
+        {
+            PageSecurityGlobalSecurityConstraintsRef nextConstraintsRef = (PageSecurityGlobalSecurityConstraintsRef)pageSecurity.accessGlobalConstraintsRefs().get(i + 1);
+            if (nextConstraintsRef.getApplyOrder() <= constraintsRef.getApplyOrder())
+            {
+                // adjust apply order for next element
+                nextConstraintsRef.setApplyOrder(constraintsRef.getApplyOrder() + 1);
+                constraintsRef = nextConstraintsRef;
+            }
+            else
+            {
+                // apply order maintained for remaining list elements
+                break;
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#get(int)
+     */
+    public Object get(int index)
+    {
+        // implement for modifiable AbstractList:
+        // unwrap constraints ref name string
+        return ((PageSecurityGlobalSecurityConstraintsRef)pageSecurity.accessGlobalConstraintsRefs().get(index)).getName();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#remove(int)
+     */
+    public Object remove(int index)
+    {
+        // implement for modifiable AbstractList:
+        // save removed element 
+        PageSecurityGlobalSecurityConstraintsRef removed = (PageSecurityGlobalSecurityConstraintsRef)pageSecurity.accessGlobalConstraintsRefs().remove(index);
+        if (removed != null)
+        {
+            getRemovedConstraintsRefs().add(removed);
+        }
+        return removed;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#set(int,java.lang.Object)
+     */
+    public Object set(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // wrap and verify constraints ref name string
+        PageSecurityGlobalSecurityConstraintsRef newConstraintsRef = wrapNameStringForAdd((String)element);
+        // set in underlying ordered list
+        PageSecurityGlobalSecurityConstraintsRef constraintsRef = (PageSecurityGlobalSecurityConstraintsRef)pageSecurity.accessGlobalConstraintsRefs().set(index, newConstraintsRef);
+        // set apply order in new element
+        newConstraintsRef.setApplyOrder(constraintsRef.getApplyOrder());
+        // save replaced element
+        getRemovedConstraintsRefs().add(constraintsRef);
+        // return unwrapped constraints ref name string
+        return constraintsRef.getName();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#size()
+     */
+    public int size()
+    {
+        // implement for modifiable AbstractList
+        return pageSecurity.accessGlobalConstraintsRefs().size();
+    }
+}

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

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityImpl.java?rev=350066&r1=350065&r2=350066&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityImpl.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecurityImpl.java Wed Nov 30 14:53:22 2005
@@ -20,16 +20,13 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.ListIterator;
 import java.util.Map;
 
 import org.apache.jetspeed.om.common.SecurityConstraint;
 import org.apache.jetspeed.om.page.PageSecurity;
-import org.apache.jetspeed.om.page.SecurityConstraintImpl;
 import org.apache.jetspeed.om.page.SecurityConstraintsDef;
-import org.apache.jetspeed.om.page.SecurityConstraintsDefImpl;
 import org.apache.jetspeed.page.document.impl.DocumentImpl;
-import org.apache.ojb.broker.PersistenceBroker;
-import org.apache.ojb.broker.PersistenceBrokerException;
 
 /**
  * PageSecurityImpl
@@ -42,20 +39,71 @@
     private List constraintsDefs;
     private List globalConstraintsRefs;
 
-    private List securityConstraintsDefs;
+    private PageSecurityConstraintsDefList securityConstraintsDefs;
     private Map securityConstraintsDefsMap;
-    private List globalSecurityConstraintsRefs;
+    private PageSecurityConstraintsRefList globalSecurityConstraintsRefs;
 
     public PageSecurityImpl()
     {
         super(null);
     }
 
+    /**
+     * accessConstraintsDefs
+     *
+     * Access mutable persistent collection member for List wrappers.
+     *
+     * @return persistent collection
+     */
+    List accessConstraintsDefs()
+    {
+        // create initial collection if necessary
+        if (constraintsDefs == null)
+        {
+            constraintsDefs = new ArrayList(4);
+        }
+        return constraintsDefs;
+    }
+
+    /**
+     * accessGlobalConstraintsRefs
+     *
+     * Access mutable persistent collection member for List wrappers.
+     *
+     * @return persistent collection
+     */
+    List accessGlobalConstraintsRefs()
+    {
+        // create initial collection if necessary
+        if (globalConstraintsRefs == null)
+        {
+            globalConstraintsRefs = new ArrayList(4);
+        }
+        return globalConstraintsRefs;
+    }
+
+    /**
+     * clearSecurityConstraintsDefsMap
+     *
+     * Clear previously cached security constraints definitions map.
+     */
+    synchronized void clearSecurityConstraintsDefsMap()
+    {
+        securityConstraintsDefsMap = null;
+    }
+
     /* (non-Javadoc)
      * @see org.apache.jetspeed.om.page.PageSecurity#getSecurityConstraintsDefs()
      */
     public List getSecurityConstraintsDefs()
     {
+        // return mutable constraints defs list
+        // by using list wrapper to manage
+        // element uniqueness
+        if (securityConstraintsDefs == null)
+        {
+            securityConstraintsDefs = new PageSecurityConstraintsDefList(this);
+        }
         return securityConstraintsDefs;
     }
     
@@ -64,19 +112,34 @@
      */
     public void setSecurityConstraintsDefs(List definitions)
     {
-        securityConstraintsDefs = definitions;
-        securityConstraintsDefsMap = null;
+        // set constraints defs by replacing existing
+        // entries with new elements if new collection
+        // is specified
+        List securityConstraintsDefs = getSecurityConstraintsDefs();
+        if (definitions != securityConstraintsDefs)
+        {
+            // replace all constraints definitions
+            securityConstraintsDefs.clear();
+            if (definitions != null)
+            {
+                securityConstraintsDefs.addAll(definitions);
+            }
+        }
+        // clear cached security constraints definition map
+        clearSecurityConstraintsDefsMap();
     }
 
     /* (non-Javadoc)
      * @see org.apache.jetspeed.om.page.PageSecurity#getSecurityConstraintsDef(java.lang.String)
      */
-    public SecurityConstraintsDef getSecurityConstraintsDef(String name)
+    public synchronized SecurityConstraintsDef getSecurityConstraintsDef(String name)
     {
-        if ((securityConstraintsDefs != null) && (securityConstraintsDefsMap == null))
+        // build and cache security constraints definitions
+        // map if necessary upon realization or after modification
+        if ((getSecurityConstraintsDefs() != null) && (securityConstraintsDefsMap == null))
         {
-            securityConstraintsDefsMap = new HashMap((securityConstraintsDefs.size() * 2) + 1);
-            Iterator definitionsIter = securityConstraintsDefs.iterator();
+            securityConstraintsDefsMap = new HashMap((getSecurityConstraintsDefs().size() * 2) + 1);
+            Iterator definitionsIter = getSecurityConstraintsDefs().iterator();
             while (definitionsIter.hasNext())
             {
                 SecurityConstraintsDef definition = (SecurityConstraintsDef)definitionsIter.next();
@@ -87,9 +150,10 @@
                 }
             }
         }
+        // lookup constraints definition using cached map 
         if (securityConstraintsDefsMap != null)
         {
-            return (SecurityConstraintsDef) securityConstraintsDefsMap.get(name);
+            return (SecurityConstraintsDef)securityConstraintsDefsMap.get(name);
         }
         return null;
     }
@@ -99,6 +163,13 @@
      */
     public List getGlobalSecurityConstraintsRefs()
     {
+        // return mutable constraints refs list
+        // by using list wrapper to manage apply
+        // order and element uniqueness
+        if (globalSecurityConstraintsRefs == null)
+        {
+            globalSecurityConstraintsRefs = new PageSecurityConstraintsRefList(this);
+        }
         return globalSecurityConstraintsRefs;
     }
     
@@ -107,213 +178,26 @@
      */
     public void setGlobalSecurityConstraintsRefs(List constraintsRefs)
     {
-        globalSecurityConstraintsRefs = constraintsRefs;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.page.document.Node#getType()
-     */
-    public String getType()
-    {
-        return DOCUMENT_TYPE;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ojb.broker.PersistenceBrokerAware#beforeUpdate(org.apache.ojb.broker.PersistenceBroker)
-     */
-    public void beforeUpdate(PersistenceBroker broker) throws PersistenceBrokerException
-    {
-        // propagate to super
-        super.beforeUpdate(broker);
-
-        // synchronize persistent constraints definitions
-        if ((securityConstraintsDefs != null) && !securityConstraintsDefs.isEmpty())
-        {
-            // get sorted list of definition names and required
-            // size of constraints definitions collection
-            List securityConstraintsDefNames = new ArrayList(securityConstraintsDefs.size());
-            int securityConstraintsDefsSize = 0;
-            Iterator definitionsIter = securityConstraintsDefs.iterator();
-            while (definitionsIter.hasNext())
-            {
-                SecurityConstraintsDef securityConstraintsDef = (SecurityConstraintsDef)definitionsIter.next();
-                String securityConstraintsDefName = securityConstraintsDef.getName();
-                if ((securityConstraintsDef.getSecurityConstraints() != null) &&
-                    (securityConstraintsDefName != null) &&
-                    !securityConstraintsDefNames.contains(securityConstraintsDefName))
-                {
-                    securityConstraintsDefsSize += securityConstraintsDef.getSecurityConstraints().size();
-                    securityConstraintsDefNames.add(securityConstraintsDefName);
-                }
-            }
-            Collections.sort(securityConstraintsDefNames);
-            // update constraints definitions collection size
-            if (constraintsDefs == null)
+        // set constraints refs using ordered ref
+        // names by replacing existing entries with
+        // new elements if new collection is specified
+        List globalSecurityConstraintsRefs = getGlobalSecurityConstraintsRefs();
+        if (constraintsRefs != globalSecurityConstraintsRefs)
+        {
+            // replace all constraints ref names
+            globalSecurityConstraintsRefs.clear();
+            if (constraintsRefs != null)
             {
-                constraintsDefs = new ArrayList(securityConstraintsDefsSize);
-            }
-            while (constraintsDefs.size() < securityConstraintsDefsSize)
-            {
-                constraintsDefs.add(new PageSecuritySecurityConstraintsDef());
-            }
-            while (constraintsDefs.size() > securityConstraintsDefsSize)
-            {
-                constraintsDefs.remove(constraintsDefs.size()-1);
-            }
-            // update constraints definitions
-            Iterator updateIter0 = securityConstraintsDefNames.iterator();
-            Iterator updateIter1 = constraintsDefs.iterator();
-            while (updateIter0.hasNext() && updateIter1.hasNext())
-            {
-                // update by definition name
-                String securityConstraintsDefName = (String)updateIter0.next();
-                // find named definition
-                SecurityConstraintsDef securityConstraintsDef = null;
-                Iterator findDefinitionIter = securityConstraintsDefs.iterator();
-                while ((securityConstraintsDef == null) && findDefinitionIter.hasNext())
-                {
-                    SecurityConstraintsDef testSecurityConstraintsDef = (SecurityConstraintsDef)findDefinitionIter.next();
-                    if (securityConstraintsDefName.equals(testSecurityConstraintsDef.getName()))
-                    {
-                        securityConstraintsDef = testSecurityConstraintsDef;
-                    }
-                }
-                // update constraints definition
-                if ((securityConstraintsDef != null) && (securityConstraintsDef.getSecurityConstraints() != null))
-                {
-                    Iterator updateIter2 = securityConstraintsDef.getSecurityConstraints().iterator();
-                    for (int i = 0; (updateIter1.hasNext() && updateIter2.hasNext()); i++)
-                    {
-                        SecurityConstraint securityConstraint = (SecurityConstraint)updateIter2.next();
-                        PageSecuritySecurityConstraintsDef constraintsDef = (PageSecuritySecurityConstraintsDef)updateIter1.next();
-                        constraintsDef.setName(securityConstraintsDefName);
-                        constraintsDef.setApplyOrder(i);
-                        constraintsDef.setUserPrincipals(securityConstraint.getUsersList());
-                        constraintsDef.setRolePrincipals(securityConstraint.getRolesList());
-                        constraintsDef.setGroupPrincipals(securityConstraint.getGroupsList());
-                        constraintsDef.setPermissions(securityConstraint.getPermissionsList());
-                    }
-                }
-            }
-        }
-        else
-        {
-            // empty constraints definitions collection
-            if (constraintsDefs != null)
-            {
-                constraintsDefs.clear();
-            }
-        }
-
-        // synchronize persistent global constraints references
-        if ((globalSecurityConstraintsRefs != null) && !globalSecurityConstraintsRefs.isEmpty())
-        {
-            // update global constraints references collection size
-            if (globalConstraintsRefs == null)
-            {
-                globalConstraintsRefs = new ArrayList(globalSecurityConstraintsRefs.size());
-            }
-            while (globalConstraintsRefs.size() < globalSecurityConstraintsRefs.size())
-            {
-                PageSecurityGlobalSecurityConstraintsRef globalConstraintsRef = new PageSecurityGlobalSecurityConstraintsRef();
-                globalConstraintsRef.setApplyOrder(globalConstraintsRefs.size());
-                globalConstraintsRefs.add(globalConstraintsRef);
-            }
-            while (globalConstraintsRefs.size() > globalSecurityConstraintsRefs.size())
-            {
-                globalConstraintsRefs.remove(globalConstraintsRefs.size()-1);
-            }
-            // update global constraints references
-            Iterator updateIter0 = globalSecurityConstraintsRefs.iterator();
-            Iterator updateIter1 = globalConstraintsRefs.iterator();
-            while (updateIter0.hasNext() && updateIter1.hasNext())
-            {
-                String securityConstraintsRef = (String)updateIter0.next();
-                PageSecurityGlobalSecurityConstraintsRef globalConstraintsRef = (PageSecurityGlobalSecurityConstraintsRef)updateIter1.next();
-                globalConstraintsRef.setName(securityConstraintsRef);
-            }
-        }
-        else
-        {
-            // empty global constraints references collection
-            if (globalConstraintsRefs != null)
-            {
-                globalConstraintsRefs.clear();
+                globalSecurityConstraintsRefs.addAll(constraintsRefs);
             }
         }
     }
 
     /* (non-Javadoc)
-     * @see org.apache.ojb.broker.PersistenceBrokerAware#afterLookup(org.apache.ojb.broker.PersistenceBroker)
+     * @see org.apache.jetspeed.page.document.Node#getType()
      */
-    public void afterLookup(PersistenceBroker broker) throws PersistenceBrokerException
+    public String getType()
     {
-        // propagate to super
-        super.afterLookup(broker);
-
-        // synchronize constraints definitions
-        if ((constraintsDefs != null) && !constraintsDefs.isEmpty())
-        {
-            // initialize security constraints definitions collection
-            if (securityConstraintsDefs == null)
-            {
-                securityConstraintsDefs = new ArrayList(4);
-            }
-            else
-            {
-                securityConstraintsDefs.clear();
-            }
-            // construct security constraints definitions
-            Iterator updateIter = constraintsDefs.iterator();
-            SecurityConstraintsDef securityConstraintsDef = null;
-            while (updateIter.hasNext())
-            {
-                PageSecuritySecurityConstraintsDef constraintsDef = (PageSecuritySecurityConstraintsDef)updateIter.next();
-                if ((securityConstraintsDef == null) || !securityConstraintsDef.getName().equals(constraintsDef.getName()))
-                {
-                    securityConstraintsDef = new SecurityConstraintsDefImpl();
-                    securityConstraintsDef.setName(constraintsDef.getName());
-                    securityConstraintsDef.setSecurityConstraints(new ArrayList(4));
-                    securityConstraintsDefs.add(securityConstraintsDef);
-                }
-                SecurityConstraint securityConstraint = new SecurityConstraintImpl();
-                securityConstraint.setUsers(constraintsDef.getUserPrincipals());
-                securityConstraint.setRoles(constraintsDef.getRolePrincipals());
-                securityConstraint.setGroups(constraintsDef.getGroupPrincipals());
-                securityConstraint.setPermissions(constraintsDef.getPermissions());
-                securityConstraintsDef.getSecurityConstraints().add(securityConstraint);
-            }
-        }
-        else
-        {
-            // remove security constraints collection
-            securityConstraintsDefs = null;
-        }
-        securityConstraintsDefsMap = null;
-
-        // synchronize global constraints references
-        if ((globalConstraintsRefs != null) && !globalConstraintsRefs.isEmpty())
-        {
-            // update global security constraints references
-            if (globalSecurityConstraintsRefs == null)
-            {
-                globalSecurityConstraintsRefs = new ArrayList(globalConstraintsRefs.size());
-            }
-            else
-            {
-                globalSecurityConstraintsRefs.clear();
-            }
-            Iterator updateIter = globalConstraintsRefs.iterator();
-            while (updateIter.hasNext())
-            {
-                PageSecurityGlobalSecurityConstraintsRef globalConstraintsRef = (PageSecurityGlobalSecurityConstraintsRef)updateIter.next();
-                globalSecurityConstraintsRefs.add(globalConstraintsRef.getName());
-            }
-        }
-        else
-        {
-            // remove global security constraints references collection
-            globalSecurityConstraintsRefs = null;
-        }
+        return DOCUMENT_TYPE;
     }
 }

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecuritySecurityConstraintImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecuritySecurityConstraintImpl.java?rev=350066&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecuritySecurityConstraintImpl.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecuritySecurityConstraintImpl.java Wed Nov 30 14:53:22 2005
@@ -0,0 +1,29 @@
+/*
+ * 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 org.apache.jetspeed.om.page.SecurityConstraintImpl;
+
+/**
+ * PageSecuritySecurityConstraintImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class PageSecuritySecurityConstraintImpl extends SecurityConstraintImpl
+{
+    // new class defined only to facilitate OJB table/class mapping
+}

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

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintDefList.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintDefList.java?rev=350066&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintDefList.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintDefList.java Wed Nov 30 14:53:22 2005
@@ -0,0 +1,153 @@
+/*
+ * 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.AbstractList;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.jetspeed.om.page.SecurityConstraintImpl;
+
+/**
+ * SecurityConstraintDefList
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+class SecurityConstraintDefList extends AbstractList
+{
+    private SecurityConstraintsDefImpl constraintsDef;
+
+    SecurityConstraintDefList(SecurityConstraintsDefImpl constraintsDef)
+    {
+        super();
+        this.constraintsDef = constraintsDef;
+    }
+
+    /**
+     * validateConstraintForAdd
+     *
+     * Validates constraint to be added to this list.
+     *
+     * @param constraint constraint to add
+     * @return list element to add
+     */
+    private PageSecuritySecurityConstraintImpl validateConstraintForAdd(SecurityConstraintImpl constraint)
+    {
+        // validate constraint instance class
+        if (constraint == null)
+        {
+            throw new NullPointerException("Unable to add null to list.");
+        }
+        if (!(constraint instanceof PageSecuritySecurityConstraintImpl))
+        {
+            // duplicate constraint from equivalent types                
+            SecurityConstraintImpl origConstraint = (SecurityConstraintImpl)constraint;
+            PageSecuritySecurityConstraintImpl dupConstraint = new PageSecuritySecurityConstraintImpl();
+            dupConstraint.setUsers(origConstraint.getUsers());
+            dupConstraint.setRoles(origConstraint.getRoles());
+            dupConstraint.setGroups(origConstraint.getGroups());
+            dupConstraint.setPermissions(origConstraint.getPermissions());
+            return dupConstraint;
+        }
+        return (PageSecuritySecurityConstraintImpl)constraint;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(int,java.lang.Object)
+     */
+    public void add(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // validate index
+        if ((index < 0) || (index > constraintsDef.accessConstraintDefs().size()))
+        {
+            throw new IndexOutOfBoundsException("Unable to add to list at index: " + index);
+        }
+        // verify constraint
+        PageSecuritySecurityConstraintImpl constraint = validateConstraintForAdd((SecurityConstraintImpl)element);
+        // add to underlying ordered list
+        constraintsDef.accessConstraintDefs().add(index, constraint);
+        // set apply order in added element
+        if (index > 0)
+        {
+            constraint.setApplyOrder(((PageSecuritySecurityConstraintImpl)constraintsDef.accessConstraintDefs().get(index-1)).getApplyOrder() + 1);
+        }
+        else
+        {
+            constraint.setApplyOrder(0);
+        }
+        // maintain apply order in subsequent elements
+        for (int i = index, limit = constraintsDef.accessConstraintDefs().size() - 1; (i < limit); i++)
+        {
+            PageSecuritySecurityConstraintImpl nextConstraint = (PageSecuritySecurityConstraintImpl)constraintsDef.accessConstraintDefs().get(i + 1);
+            if (nextConstraint.getApplyOrder() <= constraint.getApplyOrder())
+            {
+                // adjust apply order for next element
+                nextConstraint.setApplyOrder(constraint.getApplyOrder() + 1);
+                constraint = nextConstraint;
+            }
+            else
+            {
+                // apply order maintained for remaining list elements
+                break;
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#get(int)
+     */
+    public Object get(int index)
+    {
+        // implement for modifiable AbstractList
+        return constraintsDef.accessConstraintDefs().get(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#remove(int)
+     */
+    public Object remove(int index)
+    {
+        // implement for modifiable AbstractList
+        return constraintsDef.accessConstraintDefs().remove(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#set(int,java.lang.Object)
+     */
+    public Object set(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // verify constraint
+        PageSecuritySecurityConstraintImpl newConstraint = validateConstraintForAdd((SecurityConstraintImpl)element);
+        // set in underlying ordered list
+        PageSecuritySecurityConstraintImpl constraint = (PageSecuritySecurityConstraintImpl)constraintsDef.accessConstraintDefs().set(index, newConstraint);
+        // set apply order in new element
+        newConstraint.setApplyOrder(constraint.getApplyOrder());
+        // return constraint
+        return constraint;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#size()
+     */
+    public int size()
+    {
+        // implement for modifiable AbstractList
+        return constraintsDef.accessConstraintDefs().size();
+    }
+}

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

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintList.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintList.java?rev=350066&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintList.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintList.java Wed Nov 30 14:53:22 2005
@@ -0,0 +1,175 @@
+/*
+ * 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.AbstractList;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.jetspeed.om.page.SecurityConstraintImpl;
+
+/**
+ * SecurityConstraintList
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+class SecurityConstraintList extends AbstractList
+{
+    private SecurityConstraintsImpl constraints;
+
+    SecurityConstraintList(SecurityConstraintsImpl constraints)
+    {
+        super();
+        this.constraints = constraints;
+    }
+
+    /**
+     * validateConstraintForAdd
+     *
+     * Validates constraint to be added to this list.
+     *
+     * @param constraint to add
+     * @return list element to add
+     */
+    private SecurityConstraintImpl validateConstraintForAdd(SecurityConstraintImpl constraint)
+    {
+        // validate constraint instance class
+        if (constraint == null)
+        {
+            throw new NullPointerException("Unable to add null to list.");
+        }
+        if ((constraints.getSecurityConstraintClass() != null) &&
+            !constraints.getSecurityConstraintClass().isInstance(constraint))
+        {
+            // duplicate constraint from equivalent types                
+            try
+            {
+                SecurityConstraintImpl origConstraint = (SecurityConstraintImpl)constraint;
+                SecurityConstraintImpl dupConstraint = (SecurityConstraintImpl)constraints.getSecurityConstraintClass().newInstance();
+                dupConstraint.setUsers(origConstraint.getUsers());
+                dupConstraint.setRoles(origConstraint.getRoles());
+                dupConstraint.setGroups(origConstraint.getGroups());
+                dupConstraint.setPermissions(origConstraint.getPermissions());
+                return dupConstraint;
+            }
+            catch (InstantiationException ie)
+            {
+                throw new ClassCastException("Unable to create constraint list element instance: " + constraints.getSecurityConstraintClass().getName() + ", " + ie + ").");
+            }
+            catch (IllegalAccessException iae)
+            {
+                throw new ClassCastException("Unable to create constraint list element instance: " + constraints.getSecurityConstraintClass().getName() + ", " + iae + ").");
+            }
+        }
+        return constraint;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(int,java.lang.Object)
+     */
+    public void add(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // validate index
+        if ((index < 0) || (index > constraints.accessConstraints().size()))
+        {
+            throw new IndexOutOfBoundsException("Unable to add to list at index: " + index);
+        }
+        // verify constraint
+        SecurityConstraintImpl constraint = validateConstraintForAdd((SecurityConstraintImpl)element);
+        // add to underlying ordered list
+        constraints.accessConstraints().add(index, constraint);
+        // set apply order in added element
+        if (index > 0)
+        {
+            constraint.setApplyOrder(((SecurityConstraintImpl)constraints.accessConstraints().get(index-1)).getApplyOrder() + 1);
+        }
+        else
+        {
+            constraint.setApplyOrder(0);
+        }
+        // maintain apply order in subsequent elements
+        for (int i = index, limit = constraints.accessConstraints().size() - 1; (i < limit); i++)
+        {
+            SecurityConstraintImpl nextConstraint = (SecurityConstraintImpl)constraints.accessConstraints().get(i + 1);
+            if (nextConstraint.getApplyOrder() <= constraint.getApplyOrder())
+            {
+                // adjust apply order for next element
+                nextConstraint.setApplyOrder(constraint.getApplyOrder() + 1);
+                constraint = nextConstraint;
+            }
+            else
+            {
+                // apply order maintained for remaining list elements
+                break;
+            }
+        }
+        // clear all cached security constraints
+        constraints.clearAllSecurityConstraints();
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#get(int)
+     */
+    public Object get(int index)
+    {
+        // implement for modifiable AbstractList
+        return constraints.accessConstraints().get(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#remove(int)
+     */
+    public Object remove(int index)
+    {
+        // implement for modifiable AbstractList
+        Object removed = constraints.accessConstraints().remove(index);
+        if (removed != null)
+        {
+            // clear all cached security constraints
+            constraints.clearAllSecurityConstraints();
+        }
+        return removed;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#set(int,java.lang.Object)
+     */
+    public Object set(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // verify constraint
+        SecurityConstraintImpl newConstraint = validateConstraintForAdd((SecurityConstraintImpl)element);
+        // set in underlying ordered list
+        SecurityConstraintImpl constraint = (SecurityConstraintImpl)constraints.accessConstraints().set(index, newConstraint);
+        // set apply order in new element
+        newConstraint.setApplyOrder(constraint.getApplyOrder());
+        // clear all cached security constraints
+        constraints.clearAllSecurityConstraints();
+        // return constraint
+        return constraint;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#size()
+     */
+    public int size()
+    {
+        // implement for modifiable AbstractList
+        return constraints.accessConstraints().size();
+    }
+}

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

Copied: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsDefImpl.java (from r345429, portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecuritySecurityConstraintsDef.java)
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsDefImpl.java?p2=portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsDefImpl.java&p1=portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecuritySecurityConstraintsDef.java&r1=345429&r2=350066&rev=350066&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/PageSecuritySecurityConstraintsDef.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsDefImpl.java Wed Nov 30 14:53:22 2005
@@ -15,33 +15,117 @@
  */
 package org.apache.jetspeed.om.page.impl;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.jetspeed.om.page.SecurityConstraintsDef;
+
 /**
- * PageSecuritySecurityConstraintsDef
+ * SecurityConstraintsDefImpl
  *
  * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
  * @version $Id$
  */
-public class PageSecuritySecurityConstraintsDef extends BaseSecurityConstraint
+public class SecurityConstraintsDefImpl implements SecurityConstraintsDef
 {
+    private int id;
     private String name;
+    private List constraintDefs;
+
+    private SecurityConstraintDefList securityConstraintDefs;
 
     /**
-     * getName
+     * accessConstraintDefs
+     *
+     * Access mutable persistent collection member for List wrappers.
      *
-     * @return name of defined constraint
+     * @return persistent collection
+     */
+    List accessConstraintDefs()
+    {
+        // create initial collection if necessary
+        if (constraintDefs == null)
+        {
+            constraintDefs = new ArrayList(4);
+        }
+        return constraintDefs;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.SecurityConstraintsDef#getName()
      */
     public String getName()
     {
         return name;
     }
 
-    /**
-     * setName
-     *
-     * @param name name of defined constraint
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.SecurityConstraintsDef#setName(java.lang.String)
      */
     public void setName(String name)
     {
         this.name = name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.SecurityConstraintsDef#getSecurityConstraints()
+     */
+    public List getSecurityConstraints()
+    {
+        // return mutable constraint def list
+        // by using list wrapper to manage apply order
+        if (securityConstraintDefs == null)
+        {
+            securityConstraintDefs = new SecurityConstraintDefList(this);
+        }
+        return securityConstraintDefs;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.SecurityConstraintsDef#setSecurityConstraints(java.util.List)
+     */
+    public void setSecurityConstraints(List constraints)
+    {
+        // set constraint defs by replacing existing
+        // entries with new elements if new collection
+        // is specified
+        List securityConstraintDefs = getSecurityConstraints();
+        if (constraints != securityConstraintDefs)
+        {
+            // replace all constraints
+            securityConstraintDefs.clear();
+            if (constraints != null)
+            {
+                securityConstraintDefs.addAll(constraints);
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object o)
+    {
+        if (o instanceof SecurityConstraintsDefImpl)
+        {
+            if (name != null)
+            {
+                return name.equals(((SecurityConstraintsDefImpl)o).getName());
+            }
+            return (((SecurityConstraintsDefImpl)o).getName() == null);
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        if (name != null)
+        {
+            return name.hashCode();
+        }
+        return 0;
     }
 }



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