You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by rw...@apache.org on 2009/01/05 07:04:18 UTC

svn commit: r731466 [5/12] - in /portals/jetspeed-2/portal/branches/JPA_BRANCH: ./ components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/ components/jetspeed-cm/src/main/java/org/apache/jetspeed/test/ components/jetspeed-page-manager/ com...

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentImpl.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,1398 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jpa;
+
+import java.security.AccessController;
+import java.security.Permission;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderBy;
+import javax.persistence.PostLoad;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.om.common.SecurityConstraint;
+import org.apache.jetspeed.om.common.SecurityConstraintsContext;
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.PageSecurity;
+import org.apache.jetspeed.page.jpa.DatabasePageManager;
+import org.apache.jetspeed.page.jpa.DatabasePageManagerUtils;
+import org.apache.jetspeed.security.PermissionFactory;
+
+/**
+ * FragmentImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="Fragment")
+@Inheritance (strategy=InheritanceType.TABLE_PER_CLASS)
+@Table (name="FRAGMENT")
+@AttributeOverrides ({@AttributeOverride (name="id", column=@Column(name="FRAGMENT_ID"))})
+public class FragmentImpl extends BaseElementImpl implements Fragment
+{
+    @Basic
+    @Column (name="TITLE")
+    private String title;
+    @Basic
+    @Column (name="SHORT_TITLE")
+    private String shortTitle;
+    
+    @ManyToOne (targetEntity=PageImpl.class, fetch=FetchType.LAZY, optional=true)
+    @JoinColumn (name="PAGE_ID", referencedColumnName="PAGE_ID")
+    private PageImpl page;
+    @ManyToOne (targetEntity=FragmentImpl.class, fetch=FetchType.LAZY, optional=true, cascade=CascadeType.PERSIST)
+    @JoinColumn (name="PARENT_ID", referencedColumnName="FRAGMENT_ID")
+    private FragmentImpl parent;
+    @OneToMany (targetEntity=FragmentImpl.class, mappedBy="parent", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    @OrderBy (value="id ASC")
+    private List fragments;
+    @Basic
+    @Column (name="TYPE")
+    private String type;
+    @Basic
+    @Column (name="SKIN")
+    private String skin;
+    @Basic
+    @Column (name="DECORATOR")
+    private String decorator;
+    @Basic
+    @Column (name="STATE")
+    private String state;
+    @Basic
+    @Column (name="PMODE")
+    private String mode;
+    @Basic
+    @Column (name="LAYOUT_ROW")
+    private int layoutRowProperty;
+    @Basic
+    @Column (name="LAYOUT_COLUMN")
+    private int layoutColumnProperty;
+    @Basic
+    @Column (name="LAYOUT_SIZES")
+    private String layoutSizesProperty;
+    @Basic
+    @Column (name="LAYOUT_X")
+    private float layoutXProperty;
+    @Basic
+    @Column (name="LAYOUT_Y")
+    private float layoutYProperty;
+    @Basic
+    @Column (name="LAYOUT_Z")
+    private float layoutZProperty;
+    @Basic
+    @Column (name="LAYOUT_WIDTH")
+    private float layoutWidthProperty;
+    @Basic
+    @Column (name="LAYOUT_HEIGHT")
+    private float layoutHeightProperty;
+    @Basic
+    @Column (name="EXT_PROP_NAME_1")
+    private String extendedPropertyName1;
+    @Basic
+    @Column (name="EXT_PROP_VALUE_1")
+    private String extendedPropertyValue1;
+    @Basic
+    @Column (name="EXT_PROP_NAME_2")
+    private String extendedPropertyName2;
+    @Basic
+    @Column (name="EXT_PROP_VALUE_2")
+    private String extendedPropertyValue2;
+    @OneToMany (targetEntity=FragmentPreferenceImpl.class, mappedBy="fragment", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    @OrderBy (value="name ASC")
+    private List preferences;
+
+    @PostLoad
+    private void eagerFetchCollections()
+    {
+        if (fragments != null)
+        {
+            fragments.size();
+        }
+        if (preferences != null)
+        {
+            preferences.size();
+        }
+        eagerFetchEmbeddedCollections();
+    }
+
+    @Transient
+    private FragmentList fragmentsList;
+    @Transient
+    private FragmentPropertyMap propertiesMap;
+    @Transient
+    private FragmentPreferenceList fragmentPreferences;
+    @Transient
+    private PageImpl fragmentsPage;
+
+    private static PermissionFactory pf;
+    
+    public static void setPermissionsFactory(PermissionFactory pf)
+    {
+        FragmentImpl.pf = pf;
+    }
+    
+    /**
+     * Default constructor.
+     */
+    public FragmentImpl()
+    {
+        layoutRowProperty = -1;
+        layoutColumnProperty = -1;
+        layoutXProperty = -1.0F;
+        layoutYProperty = -1.0F;
+        layoutZProperty = -1.0F;
+        layoutWidthProperty = -1.0F;
+        layoutHeightProperty = -1.0F;
+    }
+
+    /**
+     * Explicitly set inverse relationship when this object
+     * is added to a one-to-many collection. JPA does not
+     * manage bidirectional relationships.
+     * 
+     * @param inverse inverse relationship owning object.
+     */
+    public void setInverseTopLevelRelationship(Object inverse)
+    {
+        page = (PageImpl)inverse;
+    }
+    
+    /**
+     * Explicitly set inverse relationship when this object
+     * is added to a one-to-many collection. JPA does not
+     * manage bidirectional relationships.
+     * 
+     * @param inverse inverse relationship owning object.
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        parent = (FragmentImpl)inverse;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#newSecurityConstraintsContext()
+     */
+    public SecurityConstraintsContext newSecurityConstraintsContext()
+    {
+        // return generic security constraints context instance
+        // since the context is embedded in this, (see below).
+        return new GenericSecurityConstraintsContextImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#newSecurityConstraint()
+     */
+    public SecurityConstraint newSecurityConstraint()
+    {
+        // return constraints specific security constraint instance
+        return new FragmentSecurityConstraintImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.BaseElementImpl#accessSecurityConstraintsContext()
+     */
+    protected SecurityConstraintsContextImpl accessSecurityConstraintsContext()
+    {
+        // return this since the context is embedded in this, (see below).
+        return this;
+    }
+    
+    /**
+     * accessFragments
+     *
+     * Access mutable persistent collection member for List wrappers.
+     *
+     * @return persistent collection
+     */
+    List accessFragments()
+    {
+        // create initial collection if necessary
+        if (fragments == null)
+        {
+            fragments = DatabasePageManagerUtils.createList();
+        }
+        return fragments;
+    }
+
+    /**
+     * accessPreferences
+     *
+     * Access mutable persistent collection member for List wrappers.
+     *
+     * @return persistent collection
+     */
+    List accessPreferences()
+    {
+        // create initial collection if necessary
+        if (preferences == null)
+        {
+            preferences = DatabasePageManagerUtils.createList();
+        }
+        return preferences;
+    }
+
+    /**
+     * Get page implementation that owns fragment.
+     *
+     * @return fragments page implementation
+     */
+    PageImpl getFragmentsPage()
+    {
+        return fragmentsPage;
+    }
+
+    /**
+     * Set page implementation that owns fragment and
+     * propagate to all child fragments.
+     *
+     * @param fragmentsPage fragments page implementation
+     */
+    void setFragmentsPage(PageImpl fragmentsPage)
+    {
+        // set page implementation
+        this.fragmentsPage = fragmentsPage;
+        // propagate to children
+        if (fragments != null)
+        {
+            Iterator fragmentsIter = fragments.iterator();
+            while (fragmentsIter.hasNext())
+            {
+                ((FragmentImpl)fragmentsIter.next()).setFragmentsPage(fragmentsPage);
+            }
+        }
+    }
+
+    /**
+     * 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;
+    }
+
+    /**
+     * removeFragmentById
+     *
+     * Remove fragment with matching id from
+     * child fragments.
+     *
+     * @param id fragment id to remove.
+     * @return removed fragment
+     */
+    Fragment removeFragmentById(String id)
+    {
+        // remove from deep children
+        if (fragments != null)
+        {
+            Iterator fragmentsIter = fragments.iterator();
+            while (fragmentsIter.hasNext())
+            {
+                FragmentImpl fragment = (FragmentImpl)fragmentsIter.next();
+                if (!fragment.getId().equals(id))
+                {
+                    Fragment removed = fragment.removeFragmentById(id);
+                    if (removed != null)
+                    {
+                        return removed;
+                    }
+                }
+                else
+                {
+                    fragmentsIter.remove();
+                    return fragment;
+                }
+            }
+        }
+        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();
+            }
+            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;
+    }
+
+    /**
+     * getPropertyMemberKeys
+     *
+     * Get valid explicit property member keys.
+     *
+     * @return list of property member keys with values
+     */
+    List getPropertyMemberKeys()
+    {
+        List keys = new ArrayList();
+        if (layoutRowProperty >= 0)
+        {
+            keys.add(ROW_PROPERTY_NAME);
+        }
+        if (layoutColumnProperty >= 0)
+        {
+            keys.add(COLUMN_PROPERTY_NAME);
+        }
+        if (layoutSizesProperty != null)
+        {
+            keys.add(SIZES_PROPERTY_NAME);
+        }
+        if (layoutXProperty >= 0.0F)
+        {
+            keys.add(X_PROPERTY_NAME);
+        }
+        if (layoutYProperty >= 0.0F)
+        {
+            keys.add(Y_PROPERTY_NAME);
+        }
+        if (layoutZProperty >= 0.0F)
+        {
+            keys.add(Z_PROPERTY_NAME);
+        }
+        if (layoutWidthProperty >= 0.0F)
+        {
+            keys.add(WIDTH_PROPERTY_NAME);
+        }
+        if (layoutHeightProperty >= 0.0F)
+        {
+            keys.add(HEIGHT_PROPERTY_NAME);
+        }
+        if ((extendedPropertyName1 != null) && (extendedPropertyValue1 != null))
+        {
+            keys.add(extendedPropertyName1);
+        }
+        if ((extendedPropertyName2 != null) && (extendedPropertyValue2 != null))
+        {
+            keys.add(extendedPropertyName2);
+        }
+        return keys;
+    }
+
+    /**
+     * getPropertyMember
+     *
+     * Get explicit property member.
+     *
+     * @param key property name
+     * @return property setting
+     */
+    String getPropertyMember(String key)
+    {
+        // set fragment explicit property member
+        if (key.equals(ROW_PROPERTY_NAME))
+        {
+            if (layoutRowProperty >= 0)
+            {
+                return String.valueOf(layoutRowProperty);
+            }
+        }
+        else if (key.equals(COLUMN_PROPERTY_NAME))
+        {
+            if (layoutColumnProperty >= 0)
+            {
+                return String.valueOf(layoutColumnProperty);
+            }
+        }
+        else if (key.equals(SIZES_PROPERTY_NAME))
+        {
+            return layoutSizesProperty;
+        }
+        else if (key.equals(X_PROPERTY_NAME))
+        {
+            if (layoutXProperty >= 0.0F)
+            {
+                return String.valueOf(layoutXProperty);
+            }
+        }
+        else if (key.equals(Y_PROPERTY_NAME))
+        {
+            if (layoutYProperty >= 0.0F)
+            {
+                return String.valueOf(layoutYProperty);
+            }
+        }
+        else if (key.equals(Z_PROPERTY_NAME))
+        {
+            if (layoutZProperty >= 0.0F)
+            {
+                return String.valueOf(layoutZProperty);
+            }
+        }
+        else if (key.equals(WIDTH_PROPERTY_NAME))
+        {
+            if (layoutWidthProperty >= 0.0F)
+            {
+                return String.valueOf(layoutWidthProperty);
+            }
+        }
+        else if (key.equals(HEIGHT_PROPERTY_NAME))
+        {
+            if (layoutHeightProperty >= 0.0F)
+            {
+                return String.valueOf(layoutHeightProperty);
+            }
+        }
+        else if (key.equals(extendedPropertyName1))
+        {
+            return extendedPropertyValue1;
+        }
+        else if (key.equals(extendedPropertyName2))
+        {
+            return extendedPropertyValue2;
+        }
+        return null;
+    }
+
+    /**
+     * setPropertyMember
+     *
+     * Set explicit property member.
+     *
+     * @param key property name
+     * @param value property setting
+     */
+    void setPropertyMember(String key, String value)
+    {
+        // set fragment explicit property member
+        if (key.equals(ROW_PROPERTY_NAME))
+        {
+            layoutRowProperty = Integer.parseInt(value);
+        }
+        else if (key.equals(COLUMN_PROPERTY_NAME))
+        {
+            layoutColumnProperty = Integer.parseInt(value);
+        }
+        else if (key.equals(SIZES_PROPERTY_NAME))
+        {
+            layoutSizesProperty = value;
+        }
+        else if (key.equals(X_PROPERTY_NAME))
+        {
+            layoutXProperty = Float.parseFloat(value);
+        }
+        else if (key.equals(Y_PROPERTY_NAME))
+        {
+            layoutYProperty = Float.parseFloat(value);
+        }
+        else if (key.equals(Z_PROPERTY_NAME))
+        {
+            layoutZProperty = Float.parseFloat(value);
+        }
+        else if (key.equals(WIDTH_PROPERTY_NAME))
+        {
+            layoutWidthProperty = Float.parseFloat(value);
+        }
+        else if (key.equals(HEIGHT_PROPERTY_NAME))
+        {
+            layoutHeightProperty = Float.parseFloat(value);
+        }
+        else if (key.equals(extendedPropertyName1))
+        {
+            extendedPropertyValue1 = value;
+        }
+        else if (key.equals(extendedPropertyName2))
+        {
+            extendedPropertyValue2 = value;
+        }
+        else if (extendedPropertyName1 == null)
+        {
+            extendedPropertyName1 = key;
+            extendedPropertyValue1 = value;
+        }
+        else if (extendedPropertyName2 == null)
+        {
+            extendedPropertyName2 = key;
+            extendedPropertyValue2 = value;
+        }
+        else
+        {
+            throw new RuntimeException("Unable to set fragment property " + key + ", extended properties already used.");
+        }
+    }
+
+    /**
+     * clearPropertyMember
+     *
+     * Clear explicit property member.
+     *
+     * @param key property name
+     */
+    void clearPropertyMember(String key)
+    {
+        if (key.equals(ROW_PROPERTY_NAME))
+        {
+            layoutRowProperty = -1;
+        }
+        else if (key.equals(COLUMN_PROPERTY_NAME))
+        {
+            layoutColumnProperty = -1;
+        }
+        else if (key.equals(SIZES_PROPERTY_NAME))
+        {
+            layoutSizesProperty = null;
+        }
+        else if (key.equals(X_PROPERTY_NAME))
+        {
+            layoutXProperty = -1.0F;
+        }
+        else if (key.equals(Y_PROPERTY_NAME))
+        {
+            layoutYProperty = -1.0F;
+        }
+        else if (key.equals(Z_PROPERTY_NAME))
+        {
+            layoutZProperty = -1.0F;
+        }
+        else if (key.equals(WIDTH_PROPERTY_NAME))
+        {
+            layoutWidthProperty = -1.0F;
+        }
+        else if (key.equals(HEIGHT_PROPERTY_NAME))
+        {
+            layoutHeightProperty = -1.0F;
+        }
+        else if (key.equals(extendedPropertyName1))
+        {
+            extendedPropertyName1 = null;
+            extendedPropertyValue1 = null;
+        }
+        else if (key.equals(extendedPropertyName2))
+        {
+            extendedPropertyName2 = null;
+            extendedPropertyValue2 = null;
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.BaseElementImpl#getEffectivePageSecurity()
+     */
+    public PageSecurity getEffectivePageSecurity()
+    {
+        // delegate to page implementation
+        if (fragmentsPage != null)
+        {
+            return fragmentsPage.getEffectivePageSecurity();
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.BaseElementImpl#getLogicalPermissionPath()
+     */
+    public String getLogicalPermissionPath()
+    {
+        // use page implementation path as base and append name
+        if ((fragmentsPage != null) && (getName() != null))
+        {
+            return fragmentsPage.getLogicalPermissionPath() + Folder.PATH_SEPARATOR + getName();
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.BaseElementImpl#getPhysicalPermissionPath()
+     */
+    public String getPhysicalPermissionPath()
+    {
+        // use page implementation path as base and append name
+        if ((fragmentsPage != null) && (getName() != null))
+        {
+            return fragmentsPage.getPhysicalPermissionPath() + Folder.PATH_SEPARATOR + getName();
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.BaseElementImpl#setPageManager(org.apache.jetspeed.page.jpa.DatabasePageManager)
+     */
+    public void setPageManager(DatabasePageManager pageManager)
+    {
+        // propagate to super and sub fragments
+        super.setPageManager(pageManager);
+        if (fragments != null)
+        {
+            Iterator fragmentsIter = fragments.iterator();
+            while (fragmentsIter.hasNext())
+            {
+                ((FragmentImpl)fragmentsIter.next()).setPageManager(pageManager);
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.BaseElementImpl#setConstraintsEnabled(boolean)
+     */
+    public void setConstraintsEnabled(boolean enabled)
+    {
+        // propagate to super and sub fragments
+        super.setConstraintsEnabled(enabled);
+        if (fragments != null)
+        {
+            Iterator fragmentsIter = fragments.iterator();
+            while (fragmentsIter.hasNext())
+            {
+                ((FragmentImpl)fragmentsIter.next()).setConstraintsEnabled(enabled);
+            }
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.BaseElementImpl#setPermissionsEnabled(boolean)
+     */
+    public void setPermissionsEnabled(boolean enabled)
+    {
+        // propagate to super and sub fragments
+        super.setPermissionsEnabled(enabled);
+        if (fragments != null)
+        {
+            Iterator fragmentsIter = fragments.iterator();
+            while (fragmentsIter.hasNext())
+            {
+                ((FragmentImpl)fragmentsIter.next()).setPermissionsEnabled(enabled);
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.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.page.jpa.BaseElementImpl#checkPermissions(java.lang.String, int, boolean, boolean)
+     */
+    public void checkPermissions(String path, int mask, boolean checkNodeOnly, boolean checkParentsOnly) throws SecurityException
+    {
+        // always check for granted fragment permissions
+        AccessController.checkPermission((Permission)pf.newPermission(pf.FRAGMENT_PERMISSION,path, mask));
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#getConstraintsEnabled()
+     */
+    public boolean getConstraintsEnabled()
+    {
+        if (fragmentsPage != null)
+        {
+            return fragmentsPage.getConstraintsEnabled();
+        }
+        return false;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#getPermissionsEnabled()
+     */
+    public boolean getPermissionsEnabled()
+    {
+        if (fragmentsPage != null)
+        {
+            return fragmentsPage.getPermissionsEnabled();
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getType()
+     */
+    public String getType()
+    {
+        return type;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setType(java.lang.String)
+     */
+    public void setType(String type)
+    {
+        this.type = type;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getSkin()
+     */
+    public String getSkin()
+    {
+        return skin;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setSkin(java.lang.String)
+     */
+    public void setSkin(String skinName)
+    {
+        this.skin = skinName;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getDecorator()
+     */
+    public String getDecorator()
+    {
+        return decorator;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setDecorator(java.lang.String)
+     */
+    public void setDecorator(String decoratorName)
+    {
+        this.decorator = decoratorName;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getState()
+     */
+    public String getState()
+    {
+        return state;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setState(java.lang.String)
+     */
+    public void setState(String state)
+    {
+        this.state = state;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getMode()
+     */
+    public String getMode()
+    {
+        return mode;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setMode(java.lang.String)
+     */
+    public void setMode(String mode)
+    {
+        this.mode = mode;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getFragments()
+     */
+    public List getFragments()
+    {
+        // create and return mutable fragments collection
+        // filtered by view access
+        if (fragmentsList == null)
+        {
+            fragmentsList = new FragmentList(this);
+        }
+        return filterFragmentsByAccess(fragmentsList, true);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getProperty(java.lang.String)
+     */
+    public String getProperty(String propName)
+    {
+        return (String)getProperties().get(propName);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getIntProperty(java.lang.String)
+     */
+    public int getIntProperty(String propName)
+    {
+        String propValue = (String)getProperties().get(propName);
+        if (propValue != null)
+        {
+            return Integer.parseInt(propValue);
+        }
+        return -1;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getFloatProperty(java.lang.String)
+     */
+    public float getFloatProperty(String propName)
+    {
+        String propValue = (String)getProperties().get(propName);
+        if (propValue != null)
+        {
+            return Float.parseFloat(propValue);
+        }
+        return -1.0F;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getProperties()
+     */
+    public Map getProperties()
+    {
+        // initialize and return writable properties map
+        if (propertiesMap == null)
+        {
+            propertiesMap = new FragmentPropertyMap(this);
+        }
+        return propertiesMap;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getLayoutRow()
+     */
+    public int getLayoutRow()
+    {
+        // get standard int property
+        return getIntProperty(ROW_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setLayoutRow(int)
+     */
+    public void setLayoutRow(int row)
+    {
+        // set standard int property
+        if (row >= 0)
+        {
+            getProperties().put(ROW_PROPERTY_NAME, String.valueOf(row));
+        }
+        else
+        {
+            getProperties().remove(ROW_PROPERTY_NAME);
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getLayoutColumn()
+     */
+    public int getLayoutColumn()
+    {
+        // get standard int property
+        return getIntProperty(COLUMN_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setLayoutColumn(int)
+     */
+    public void setLayoutColumn(int column)
+    {
+        // set standard int property
+        if (column >= 0)
+        {
+            getProperties().put(COLUMN_PROPERTY_NAME, String.valueOf(column));
+        }
+        else
+        {
+            getProperties().remove(COLUMN_PROPERTY_NAME);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getLayoutSizes()
+     */
+    public String getLayoutSizes()
+    {
+        // get standard string property
+        return getProperty(SIZES_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setLayoutSizes(java.lang.String)
+     */
+    public void setLayoutSizes(String sizes)
+    {
+        // set standard string property
+        if (sizes != null)
+        {
+            getProperties().put(SIZES_PROPERTY_NAME, sizes);
+        }
+        else
+        {
+            getProperties().remove(SIZES_PROPERTY_NAME);
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getLayoutX()
+     */
+    public float getLayoutX()
+    {
+        // get standard float property
+        return getFloatProperty(X_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setLayoutX(float)
+     */
+    public void setLayoutX(float x)
+    {
+        // set standard float property
+        if (x >= 0.0F)
+        {
+            getProperties().put(X_PROPERTY_NAME, String.valueOf(x));
+        }
+        else
+        {
+            getProperties().remove(X_PROPERTY_NAME);
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getLayoutY()
+     */
+    public float getLayoutY()
+    {
+        // get standard float property
+        return getFloatProperty(Y_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setLayoutY(float)
+     */
+    public void setLayoutY(float y)
+    {
+        // set standard float property
+        if (y >= 0.0F)
+        {
+            getProperties().put(Y_PROPERTY_NAME, String.valueOf(y));
+        }
+        else
+        {
+            getProperties().remove(Y_PROPERTY_NAME);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getLayoutZ()
+     */
+    public float getLayoutZ()
+    {
+        // get standard float property
+        return getFloatProperty(Z_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setLayoutZ(float)
+     */
+    public void setLayoutZ(float z)
+    {
+        // set standard float property
+        if (z >= 0.0F)
+        {
+            getProperties().put(Z_PROPERTY_NAME, String.valueOf(z));
+        }
+        else
+        {
+            getProperties().remove(Z_PROPERTY_NAME);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getLayoutWidth()
+     */
+    public float getLayoutWidth()
+    {
+        // get standard float property
+        return getFloatProperty(WIDTH_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setLayoutWidth(float)
+     */
+    public void setLayoutWidth(float width)
+    {
+        // set standard float property
+        if (width >= 0.0F)
+        {
+            getProperties().put(WIDTH_PROPERTY_NAME, String.valueOf(width));
+        }
+        else
+        {
+            getProperties().remove(WIDTH_PROPERTY_NAME);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getLayoutHeight()
+     */
+    public float getLayoutHeight()
+    {
+        // get standard float property
+        return getFloatProperty(HEIGHT_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setLayoutHeight(float)
+     */
+    public void setLayoutHeight(float height)
+    {
+        // set standard float property
+        if (height >= 0.0F)
+        {
+            getProperties().put(HEIGHT_PROPERTY_NAME, String.valueOf(height));
+        }
+        else
+        {
+            getProperties().remove(HEIGHT_PROPERTY_NAME);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#isReference()
+     */
+    public boolean isReference()
+    {
+        return false; // NYI
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getPreferences()
+     */
+    public List getPreferences()
+    {
+        // return mutable preferences list
+        // by using list wrapper to manage
+        // element uniqueness
+        if (fragmentPreferences == null)
+        {
+            fragmentPreferences = new FragmentPreferenceList(this);
+        }
+        return fragmentPreferences;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#setPreferences(java.util.List)
+     */
+    public void setPreferences(List preferences)
+    {
+        // set preferences by replacing existing
+        // entries with new elements if new collection
+        // is specified
+        List fragmentPreferences = getPreferences();
+        if (preferences != fragmentPreferences)
+        {
+            // replace all preferences
+            fragmentPreferences.clear();
+            if (preferences != null)
+            {
+                fragmentPreferences.addAll(preferences);
+            }
+        }
+    }
+    
+    /**
+     * filterFragmentsByAccess
+     *
+     * Filter fragments list for view access.
+     *
+     * @param nodes list containing fragments to check
+     * @param mutable make returned list mutable
+     * @return original list if all elements viewable, a filtered
+     *         partial list, or null if all filtered for view access
+     */
+    List filterFragmentsByAccess(List fragments, boolean mutable)
+    {
+        if ((fragments != null) && !fragments.isEmpty())
+        {
+            // check permissions and constraints, filter fragments as required
+            List filteredFragments = null;
+            Iterator checkAccessIter = fragments.iterator();
+            while (checkAccessIter.hasNext())
+            {
+                Fragment fragment = (Fragment)checkAccessIter.next();
+                try
+                {
+                    // check access
+                    fragment.checkAccess(JetspeedActions.VIEW);
+
+                    // add to filteredFragments fragments if copying
+                    if (filteredFragments != null)
+                    {
+                        // permitted, add to filteredFragments fragments
+                        filteredFragments.add(fragment);
+                    }
+                }
+                catch (SecurityException se)
+                {
+                    // create filteredFragments fragments if not already copying
+                    if (filteredFragments == null)
+                    {
+                        // not permitted, copy previously permitted fragments
+                        // to new filteredFragments node set with same comparator
+                        filteredFragments = new ArrayList();
+                        Iterator copyIter = fragments.iterator();
+                        while (copyIter.hasNext())
+                        {
+                            Fragment copyFragment = (Fragment)copyIter.next();
+                            if (copyFragment != fragment)
+                            {
+                                filteredFragments.add(copyFragment);
+                            }
+                            else
+                            {
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+
+            // return filteredFragments fragments if generated
+            if (filteredFragments != null)
+            {
+                if (!filteredFragments.isEmpty())
+                {
+                    if (mutable)
+                    {
+                        return new FilteredFragmentList(this, filteredFragments);
+                    }
+                    else
+                    {
+                        return filteredFragments;
+                    }
+                }
+                else
+                {
+                    return new FilteredFragmentList(this, filteredFragments);
+                }
+            }
+        }
+        return fragments;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseElement#getTitle()
+     */
+    public String getTitle()
+    {
+        return title;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseElement#setTitle(java.lang.String)
+     */
+    public void setTitle(String title)
+    {
+        this.title = title;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseElement#getShortTitle()
+     */
+    public String getShortTitle()
+    {
+        return shortTitle;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseElement#setShortTitle(java.lang.String)
+     */
+    public void setShortTitle(String shortTitle)
+    {
+        this.shortTitle = shortTitle;
+    }
+
+    // **************************************************************************
+    // Begin Embedded SecurityConstraintsContextImpl
+    //
+    // Embeddable/Embedded with relationships not supported in JPA 1.0;
+    // otherwise, this should have been implemented as an embedded type
+    // derived from SecurityConstraintsContextImpl. Instead, BaseElementImpl
+    // derives from SecurityConstraintsContextImpl and the context
+    // protocol is implemented on this object.
+
+    @Basic
+    @Column (name="OWNER_PRINCIPAL")
+    private String owner;
+    @OneToMany (targetEntity=FragmentSecurityConstraintImpl.class, mappedBy="fragment", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    @OrderBy (value="applyOrder ASC")
+    private List constraints;
+    @OneToMany (targetEntity=FragmentSecurityConstraintsRef.class, mappedBy="fragment", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    @OrderBy (value="applyOrder ASC")
+    private List constraintsRefs;
+
+    private void eagerFetchEmbeddedCollections()
+    {
+        if (constraints != null)
+        {
+            constraints.size();
+        }
+        if (constraintsRefs != null)
+        {
+            constraintsRefs.size();
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraints#getOwner()
+     */
+    public String getOwner()
+    {
+        return owner;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraints#setOwner(java.lang.String)
+     */
+    public void setOwner(String owner)
+    {
+        // save new setting and reset cached security constraints
+        this.owner = owner;
+        clearAllSecurityConstraints();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl#accessConstraintsRefs()
+     */
+    protected List accessConstraintsRefs()
+    {
+        // create initial collection if necessary
+        if (constraintsRefs == null)
+        {
+            constraintsRefs = DatabasePageManagerUtils.createList();
+        }
+        return constraintsRefs;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl#accessConstraints()
+     */
+    protected List accessConstraints()
+    {
+        // create initial collection if necessary
+        if (constraints == null)
+        {
+            constraints = DatabasePageManagerUtils.createList();
+        }
+        return constraints;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl#getSecurityConstraintClass()
+     */
+    protected Class getSecurityConstraintClass()
+    {
+        return FragmentSecurityConstraintImpl.class;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl#getSecurityConstraintsRefClass()
+     */
+    protected Class getSecurityConstraintsRefClass()
+    {
+        return FragmentSecurityConstraintsRef.class;        
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraints#isEmpty()
+     */
+    public boolean isEmpty()
+    {
+        // test only persistent members for any specified constraints
+        return ((owner == null) &&
+                ((constraints == null) || constraints.isEmpty()) &&
+                ((constraintsRefs == null) || constraintsRefs.isEmpty()));
+    }
+
+    // End Embedded SecurityConstraintsContextImpl
+    // **************************************************************************
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentList.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentList.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentList.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jpa;
+
+import java.util.AbstractList;
+
+/**
+ * FragmentList
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+class FragmentList extends AbstractList
+{
+    private FragmentImpl fragment;
+
+    FragmentList(FragmentImpl fragment)
+    {
+        super();
+        this.fragment = fragment;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(int,java.lang.Object)
+     */
+    public synchronized void add(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // add and maintain page implementation reference
+        FragmentImpl newFragment = (FragmentImpl)element;
+        newFragment.setInverseRelationship(fragment);
+        fragment.accessFragments().add(index, element);
+        if (fragment.getFragmentsPage() != null)
+        {
+            newFragment.setFragmentsPage(fragment.getFragmentsPage());
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#get(int)
+     */
+    public synchronized Object get(int index)
+    {
+        // implement for modifiable AbstractList
+        return fragment.accessFragments().get(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#remove(int)
+     */
+    public synchronized Object remove(int index)
+    {
+        // implement for modifiable AbstractList
+        FragmentImpl removed = (FragmentImpl)fragment.accessFragments().remove(index);
+        if (removed != null)
+        {
+            removed.setInverseRelationship(null);
+        }
+        return removed;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#set(int,java.lang.Object)
+     */
+    public synchronized Object set(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // set and maintain page implementation reference
+        FragmentImpl newFragment = (FragmentImpl)element;
+        newFragment.setInverseRelationship(fragment);
+        FragmentImpl oldFragment = (FragmentImpl)fragment.accessFragments().set(index, element);
+        oldFragment.setInverseRelationship(null);
+        if (fragment.getFragmentsPage() != null)
+        {
+            newFragment.setFragmentsPage(fragment.getFragmentsPage());
+        }
+        return oldFragment;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#size()
+     */
+    public synchronized int size()
+    {
+        // implement for modifiable AbstractList
+        return fragment.accessFragments().size();
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceImpl.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jpa;
+
+import java.util.List;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderBy;
+import javax.persistence.PostLoad;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.om.preference.FragmentPreference;
+import org.apache.jetspeed.page.jpa.DatabasePageManagerUtils;
+
+/**
+ * FragmentPreferenceImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="FragmentPref")
+@Table (name="FRAGMENT_PREF")
+public class FragmentPreferenceImpl implements FragmentPreference
+{
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="PREF_ID")
+    private int id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @ManyToOne (targetEntity=FragmentImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="FRAGMENT_ID", referencedColumnName="FRAGMENT_ID")
+    private FragmentImpl fragment;
+    @Basic
+    @Column (name="NAME")
+    private String name;
+    @Basic
+    @Column (name="IS_READ_ONLY")
+    private boolean readOnly;
+    @OneToMany (targetEntity=FragmentPreferenceValue.class, mappedBy="pref", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    @OrderBy (value="valueOrder ASC")
+    private List values;
+
+    @PostLoad
+    private void eagerFetchCollections()
+    {
+        if (values != null)
+        {
+            values.size();
+        }
+    }
+
+    @Transient
+    private FragmentPreferenceValueList preferenceValues;
+
+    /**
+     * Explicitly set inverse relationship when this object
+     * is added to a one-to-many collection. JPA does not
+     * manage bidirectional relationships.
+     * 
+     * @param inverse inverse relationship owning object.
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        fragment = (FragmentImpl)inverse;
+    }
+    
+    /**
+     * accessValues
+     *
+     * Access mutable persistent collection member for List wrappers.
+     *
+     * @return persistent collection
+     */
+    List accessValues()
+    {
+        // create initial collection if necessary
+        if (values == null)
+        {
+            values = DatabasePageManagerUtils.createList();
+        }
+        return values;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.preference.FragmentPreference#getName()
+     * @see org.apache.pluto.om.common.Preference#getName()
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.preference.FragmentPreference#setName(java.lang.String)
+     * @see org.apache.pluto.om.common.PreferenceCtrl#setName(java.lang.String)
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.preference.FragmentPreference#isReadOnly()
+     * @see org.apache.pluto.om.common.Preference#isReadOnly()
+     */
+    public boolean isReadOnly()
+    {
+        return readOnly;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.preference.FragmentPreference#setReadOnly(boolean)
+     */
+    public void setReadOnly(boolean readOnly)
+    {
+        this.readOnly = readOnly;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.preference.FragmentPreference#getValueList()
+     */
+    public List getValueList()
+    {
+        // return mutable preference value list
+        // using list wrapper to manage value order
+        if (preferenceValues == null)
+        {
+            preferenceValues = new FragmentPreferenceValueList(this);
+        }
+        return preferenceValues;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.preference.FragmentPreference#setValueList(java.util.List)
+     */
+    public void setValueList(List values)
+    {
+        // set preference values by replacing existing
+        // entries with new elements if new collection
+        // is specified
+        List preferenceValues = getValueList();
+        if (values != preferenceValues)
+        {
+            // replace all values
+            preferenceValues.clear();
+            if (values != null)
+            {
+                preferenceValues.addAll(values);
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object o)
+    {
+        if (o instanceof FragmentPreferenceImpl)
+        {
+            if (name != null)
+            {
+                return name.equals(((FragmentPreferenceImpl)o).getName());
+            }
+            return (((FragmentPreferenceImpl)o).getName() == null);
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        if (name != null)
+        {
+            return name.hashCode();
+        }
+        return 0;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceList.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceList.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceList.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jpa;
+
+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);
+                // TODO: move this logic to copy methods on implementations
+                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();
+        }
+        return removedPreferences;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(int,java.lang.Object)
+     */
+    public synchronized 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
+        preference.setInverseRelationship(fragment);
+        fragment.accessPreferences().add(index, preference);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#get(int)
+     */
+    public synchronized Object get(int index)
+    {
+        // implement for modifiable AbstractList
+        return fragment.accessPreferences().get(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#remove(int)
+     */
+    public synchronized Object remove(int index)
+    {
+        // implement for modifiable AbstractList:
+        // save removed element 
+        FragmentPreferenceImpl removed = (FragmentPreferenceImpl)fragment.accessPreferences().remove(index);
+        if (removed != null)
+        {
+            removed.setInverseRelationship(null);
+            getRemovedPreferences().add(removed);
+        }
+        return removed;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#set(int,java.lang.Object)
+     */
+    public synchronized Object set(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // verify preference
+        FragmentPreferenceImpl newPreference = validatePreferenceForAdd((FragmentPreferenceImpl)element);
+        // set in underlying ordered list
+        newPreference.setInverseRelationship(fragment);
+        FragmentPreferenceImpl preference = (FragmentPreferenceImpl)fragment.accessPreferences().set(index, newPreference);
+        preference.setInverseRelationship(null);
+        // save replaced element
+        getRemovedPreferences().add(preference);
+        // return constraints ref
+        return preference;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#size()
+     */
+    public synchronized int size()
+    {
+        // implement for modifiable AbstractList
+        return fragment.accessPreferences().size();
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceValue.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceValue.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceValue.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceValue.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jpa;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+/**
+ * FragmentPreferenceValue
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="FragmentPrefValue")
+@Table (name="FRAGMENT_PREF_VALUE")
+public class FragmentPreferenceValue
+{
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="PREF_VALUE_ID")
+    private int id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @ManyToOne (targetEntity=FragmentPreferenceImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="PREF_ID", referencedColumnName="PREF_ID")
+    private FragmentPreferenceImpl pref;
+    @Basic
+    @Column (name="VALUE_ORDER")
+    private int valueOrder;
+    @Basic
+    @Column (name="VALUE")
+    private String value;
+
+    /**
+     * Explicitly set inverse relationship when this object
+     * is added to a one-to-many collection. JPA does not
+     * manage bidirectional relationships.
+     * 
+     * @param inverse inverse relationship owning object.
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        pref = (FragmentPreferenceImpl)inverse;
+    }
+    
+    /**
+     * 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;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceValueList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceValueList.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceValueList.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPreferenceValueList.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jpa;
+
+import java.util.AbstractList;
+
+/**
+ * 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 synchronized 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
+        preferenceValue.setInverseRelationship(preference);
+        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 synchronized 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 synchronized Object remove(int index)
+    {
+        // implement for modifiable AbstractList
+        FragmentPreferenceValue preferenceValue = (FragmentPreferenceValue)preference.accessValues().remove(index);
+        if (preferenceValue != null)
+        {
+            preferenceValue.setInverseRelationship(null);            
+        }
+        return preferenceValue;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#set(int,java.lang.Object)
+     */
+    public synchronized 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
+        newPreferenceValue.setInverseRelationship(preference);
+        FragmentPreferenceValue preferenceValue = (FragmentPreferenceValue)preference.accessValues().set(index, newPreferenceValue);
+        preferenceValue.setInverseRelationship(null);
+        // 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 synchronized int size()
+    {
+        // implement for modifiable AbstractList
+        return preference.accessValues().size();
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPropertyMap.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPropertyMap.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPropertyMap.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentPropertyMap.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jpa;
+
+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;
+
+/**
+ * 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 synchronized 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 synchronized Set entrySet()
+    {
+        // implement for modifiable AbstractMap
+        return entrySet;
+    }
+
+    private class FragmentPropertiesEntrySet extends AbstractSet
+    {
+        private Collection entries = new ArrayList();
+
+        /* (non-Javadoc)
+         * @see java.util.Set#add(java.lang.Object)
+         */
+        public synchronized 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 synchronized 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 synchronized 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;
+        }
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentSecurityConstraintImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentSecurityConstraintImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentSecurityConstraintImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentSecurityConstraintImpl.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jpa;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * PageSecurityConstraintImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="FragmentConstraint")
+@Inheritance (strategy=InheritanceType.TABLE_PER_CLASS)
+@Table (name="FRAGMENT_CONSTRAINT")
+@AttributeOverrides ({@AttributeOverride (name="id", column=@Column(name="CONSTRAINT_ID"))})
+public class FragmentSecurityConstraintImpl extends BaseSecurityConstraintImpl
+{
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=FragmentImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="FRAGMENT_ID", referencedColumnName="FRAGMENT_ID")
+    private FragmentImpl fragment;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.BaseSecurityConstraintImpl#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        fragment = (FragmentImpl)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentSecurityConstraintsRef.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentSecurityConstraintsRef.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentSecurityConstraintsRef.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FragmentSecurityConstraintsRef.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jpa;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * FragmentSecurityConstraintsRef
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="FragmentConstraintsRef")
+@Inheritance (strategy=InheritanceType.TABLE_PER_CLASS)
+@Table (name="FRAGMENT_CONSTRAINTS_REF")
+@AttributeOverrides ({@AttributeOverride (name="id", column=@Column(name="CONSTRAINTS_REF_ID"))})
+public class FragmentSecurityConstraintsRef extends BaseSecurityConstraintsRef
+{
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=FragmentImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="FRAGMENT_ID", referencedColumnName="FRAGMENT_ID")
+    private FragmentImpl fragment;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.BaseSecurityConstraintsRef#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        fragment = (FragmentImpl)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/GenericSecurityConstraintsContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/GenericSecurityConstraintsContextImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/GenericSecurityConstraintsContextImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/GenericSecurityConstraintsContextImpl.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jpa;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * GenericSecurityConstraintsContextImpl
+ * 
+ * Transient utility security constraints context implementation. 
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class GenericSecurityConstraintsContextImpl extends SecurityConstraintsContextImpl
+{
+    private String owner;
+    private List constraints;
+    private List constraintsRefs;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraints#getOwner()
+     */
+    public String getOwner()
+    {
+        return owner;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraints#setOwner(java.lang.String)
+     */
+    public void setOwner(String owner)
+    {
+        this.owner = owner;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl#accessConstraintsRefs()
+     */
+    protected List accessConstraintsRefs()
+    {
+        // create initial collection if necessary
+        if (constraintsRefs == null)
+        {
+            constraintsRefs = new ArrayList();
+        }
+        return constraintsRefs;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl#accessConstraints()
+     */
+    protected List accessConstraints()
+    {
+        // create initial collection if necessary
+        if (constraints == null)
+        {
+            constraints = new ArrayList();
+        }
+        return constraints;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl#getSecurityConstraintClass()
+     */
+    protected Class getSecurityConstraintClass()
+    {
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl#getSecurityConstraintsRefClass()
+     */
+    protected Class getSecurityConstraintsRefClass()
+    {
+        return null;        
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraints#isEmpty()
+     */
+    public boolean isEmpty()
+    {
+        return ((owner == null) &&
+                ((constraints == null) || constraints.isEmpty()) &&
+                ((constraintsRefs == null) || constraintsRefs.isEmpty()));
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org