portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r881862 [6/16] - in /portals/jetspeed-2/portal/trunk: ./ applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/ applications/jetspeed/src/main/webapp/WEB-INF/templates/ applications/jetspeed/src/main/webapp/decorations/layout/greenearth/ ...
Date Wed, 18 Nov 2009 18:24:53 GMT
Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseFragmentElementImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseFragmentElementImpl.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseFragmentElementImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseFragmentElementImpl.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,824 @@
+/*
+ * 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.impl;
+
+import java.security.AccessController;
+import java.security.Permission;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.jetspeed.om.page.BaseFragmentElement;
+import org.apache.jetspeed.om.page.BaseFragmentValidationListener;
+import org.apache.jetspeed.om.page.PageSecurity;
+import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
+
+/**
+ * BaseFragmentElementImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public abstract class BaseFragmentElementImpl extends BaseElementImpl implements BaseFragmentElement
+{
+    private String ojbConcreteClass = getClass().getName();
+    private String fragmentId;
+    private String skin;
+    private String decorator;
+    private String state;
+    private String mode;
+    private int layoutRowProperty = -1;
+    private int layoutColumnProperty = -1;
+    private String layoutSizesProperty;
+    private float layoutXProperty = -1.0F;
+    private float layoutYProperty = -1.0F;
+    private float layoutZProperty = -1.0F;
+    private float layoutWidthProperty = -1.0F;
+    private float layoutHeightProperty = -1.0F;
+    private String extendedPropertyName1;
+    private String extendedPropertyValue1;
+    private String extendedPropertyName2;
+    private String extendedPropertyValue2;
+    private List preferences;
+
+    private FragmentPropertyMap propertiesMap;
+    private FragmentPreferenceList fragmentPreferences;
+    private BaseFragmentsElementImpl baseFragmentsElement;
+
+    public BaseFragmentElementImpl()
+    {
+        super(new FragmentSecurityConstraintsImpl());
+    }
+    
+    /**
+     * 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;
+    }
+
+    /**
+     * getBaseFragmentsElement
+     *
+     * Get base fragments implementation that owns fragment.
+     *
+     * @return owning base fragments implementation
+     */
+    BaseFragmentsElementImpl getBaseFragmentsElement()
+    {
+        return baseFragmentsElement;
+    }
+
+    /**
+     * setBaseFragmentsElement
+     *
+     * Set base fragments implementation that owns fragment.
+     *
+     * @param baseFragmentsElement owning base fragments implementation
+     */
+    void setBaseFragmentsElement(BaseFragmentsElementImpl baseFragmentsElement)
+    {
+        // set base fragments implementation
+        this.baseFragmentsElement = baseFragmentsElement;
+    }
+
+    /**
+     * getFragmentById
+     *
+     * Retrieve fragment with matching id from
+     * this or child fragments.
+     *
+     * @param id fragment id to retrieve.
+     * @return matched fragment
+     */
+    public BaseFragmentElement getFragmentById(String id)
+    {
+        // check for match
+        if (getId().equals(id))
+        {
+            return this;
+        }
+        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 = DatabasePageManagerUtils.createList();
+            }
+            matchedFragments.add(this);
+        }
+        return matchedFragments;
+    }
+
+    /**
+     * getPropertyMemberKeys
+     *
+     * Get valid explicit property member keys.
+     *
+     * @return list of property member keys with values
+     */
+    List getPropertyMemberKeys()
+    {
+        List keys = DatabasePageManagerUtils.createList();
+        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.impl.BaseElementImpl#getEffectivePageSecurity()
+     */
+    public PageSecurity getEffectivePageSecurity()
+    {
+        // delegate to base fragments implementation
+        if (baseFragmentsElement != null)
+        {
+            return baseFragmentsElement.getEffectivePageSecurity();
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.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()
+    {
+        // delegate to base fragments implementation
+        if (baseFragmentsElement != null)
+        {
+            return baseFragmentsElement.getConstraintsEnabled();
+        }
+        return false;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#getPermissionsEnabled()
+     */
+    public boolean getPermissionsEnabled()
+    {
+        // delegate to base fragments implementation
+        if (baseFragmentsElement != null)
+        {
+            return baseFragmentsElement.getPermissionsEnabled();
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#getId()
+     */
+    public String getId()
+    {
+        if (fragmentId != null)
+        {
+            return fragmentId;
+        }
+        return super.getId();
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#setId(java.lang.String)
+     */
+    public void setId(String fragmentId)
+    {
+        this.fragmentId = fragmentId;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getSkin()
+     */
+    public String getSkin()
+    {
+        return skin;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#setSkin(java.lang.String)
+     */
+    public void setSkin(String skinName)
+    {
+        this.skin = skinName;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getDecorator()
+     */
+    public String getDecorator()
+    {
+        return decorator;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#setDecorator(java.lang.String)
+     */
+    public void setDecorator(String decoratorName)
+    {
+        this.decorator = decoratorName;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getState()
+     */
+    public String getState()
+    {
+        return state;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#setState(java.lang.String)
+     */
+    public void setState(String state)
+    {
+        this.state = state;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getMode()
+     */
+    public String getMode()
+    {
+        return mode;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#setMode(java.lang.String)
+     */
+    public void setMode(String mode)
+    {
+        this.mode = mode;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getProperty(java.lang.String)
+     */
+    public String getProperty(String propName)
+    {
+        return (String)getProperties().get(propName);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#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.BaseFragmentElement#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.BaseFragmentElement#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.BaseFragmentElement#getLayoutRow()
+     */
+    public int getLayoutRow()
+    {
+        // get standard int property
+        return getIntProperty(ROW_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#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.BaseFragmentElement#getLayoutColumn()
+     */
+    public int getLayoutColumn()
+    {
+        // get standard int property
+        return getIntProperty(COLUMN_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#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.BaseFragmentElement#getLayoutSizes()
+     */
+    public String getLayoutSizes()
+    {
+        // get standard string property
+        return getProperty(SIZES_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#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.BaseFragmentElement#getLayoutX()
+     */
+    public float getLayoutX()
+    {
+        // get standard float property
+        return getFloatProperty(X_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#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.BaseFragmentElement#getLayoutY()
+     */
+    public float getLayoutY()
+    {
+        // get standard float property
+        return getFloatProperty(Y_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#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.BaseFragmentElement#getLayoutZ()
+     */
+    public float getLayoutZ()
+    {
+        // get standard float property
+        return getFloatProperty(Z_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#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.BaseFragmentElement#getLayoutWidth()
+     */
+    public float getLayoutWidth()
+    {
+        // get standard float property
+        return getFloatProperty(WIDTH_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#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.BaseFragmentElement#getLayoutHeight()
+     */
+    public float getLayoutHeight()
+    {
+        // get standard float property
+        return getFloatProperty(HEIGHT_PROPERTY_NAME);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#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.BaseFragmentElement#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.BaseFragmentElement#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);
+            }
+        }
+    }
+    
+    /**
+     * Validate fragment using specified validation listener.
+     * 
+     * @param validationListener validation listener
+     * @return validated flag
+     */
+    protected boolean validateFragments(BaseFragmentValidationListener validationListener)
+    {
+        // validate fragment using validation listener
+        return validationListener.validate(this);
+    }
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseFragmentsElementImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseFragmentsElementImpl.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseFragmentsElementImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseFragmentsElementImpl.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,257 @@
+/*
+ * 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.impl;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.om.page.BaseFragmentElement;
+import org.apache.jetspeed.om.page.BaseFragmentValidationListener;
+import org.apache.jetspeed.om.page.BaseFragmentsElement;
+import org.apache.jetspeed.page.document.impl.DocumentImpl;
+import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
+
+/**
+ * BaseFragmentsElementImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public abstract class BaseFragmentsElementImpl extends DocumentImpl implements BaseFragmentsElement
+{
+    private String ojbConcreteClass = getClass().getName();
+    private Collection fragment;
+
+    private BaseFragmentElementImpl removedFragment;
+
+    /**
+     * Default constructor to specify security constraints
+     */
+    public BaseFragmentsElementImpl()
+    {
+        super(new PageSecurityConstraintsImpl());
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#getRootFragment()
+     */
+    public BaseFragmentElement getRootFragment()
+    {
+        // get singleton fragment; no access checks to
+        // be made for root fragment
+        if ((fragment != null) && !fragment.isEmpty())
+        {
+            BaseFragmentElementImpl rootFragment = (BaseFragmentElementImpl)fragment.iterator().next();
+            if (rootFragment.getBaseFragmentsElement() != this)
+            {
+                // set base fragments implementation in root and children fragments
+                rootFragment.setBaseFragmentsElement(this);
+            }
+            return rootFragment;
+        }
+        return null;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#setRootFragment(org.apache.jetspeed.om.page.BaseFragmentElement)
+     */
+    public void setRootFragment(BaseFragmentElement fragment)
+    {
+        // create singleton collection or remove existing
+        // root fragment and save for reuse
+        if (fragment instanceof BaseFragmentElementImpl)
+        {
+            BaseFragmentElementImpl baseFragmentImpl = (BaseFragmentElementImpl)fragment;
+            if (this.fragment == null)
+            {
+                this.fragment = DatabasePageManagerUtils.createList();
+            }
+            else if (!this.fragment.isEmpty())
+            {
+                removedFragment = (BaseFragmentElementImpl)this.fragment.iterator().next();
+                this.fragment.clear();
+            }
+
+            // add new or reuse singleton fragment
+            BaseFragmentElementImpl addFragment = (BaseFragmentElementImpl)fragment;
+            BaseFragmentElementImpl reuseFragment = null;
+            if (fragment instanceof FragmentImpl)
+            {
+                // add new fragment or copy configuration
+                // from previously removed fragment
+                if (removedFragment instanceof FragmentImpl)
+                {
+                    // reuse previously removed fragment
+                    reuseFragment = removedFragment;
+                    addFragment = reuseFragment;
+                    removedFragment = null;
+                    // TODO: move this logic to copy methods on implementations
+                    FragmentImpl fragmentImpl = (FragmentImpl)fragment;
+                    FragmentImpl reuseFragmentImpl = (FragmentImpl)reuseFragment;
+                    reuseFragmentImpl.setName(fragmentImpl.getName());                
+                    reuseFragmentImpl.setType(fragmentImpl.getType());
+                    reuseFragmentImpl.getFragments().clear();
+                    reuseFragmentImpl.getFragments().addAll(fragmentImpl.getFragments());
+                }
+            }
+            else if (fragment instanceof FragmentReferenceImpl)
+            {
+                // add new fragment or copy configuration
+                // from previously removed fragment
+                if (removedFragment instanceof FragmentReferenceImpl)
+                {
+                    // reuse previously removed fragment
+                    reuseFragment = removedFragment;
+                    addFragment = reuseFragment;
+                    removedFragment = null;
+                    // TODO: move this logic to copy methods on implementations
+                    FragmentReferenceImpl fragmentImpl = (FragmentReferenceImpl)fragment;
+                    FragmentReferenceImpl reuseFragmentImpl = (FragmentReferenceImpl)reuseFragment;
+                    reuseFragmentImpl.setRefId(fragmentImpl.getRefId());                
+                }
+            }
+            else if (fragment instanceof PageFragmentImpl)
+            {
+                // add new fragment or copy configuration
+                // from previously removed fragment
+                if (removedFragment instanceof FragmentReferenceImpl)
+                {
+                    // reuse previously removed fragment
+                    reuseFragment = removedFragment;
+                    addFragment = reuseFragment;
+                    removedFragment = null;
+                }
+            }
+            if (reuseFragment != null)
+            {
+                // TODO: move this logic to copy methods on implementations
+                reuseFragment.setTitle(baseFragmentImpl.getTitle());
+                reuseFragment.setShortTitle(baseFragmentImpl.getShortTitle());
+                reuseFragment.setSkin(baseFragmentImpl.getSkin());
+                reuseFragment.setDecorator(baseFragmentImpl.getDecorator());
+                reuseFragment.setState(baseFragmentImpl.getState());
+                reuseFragment.setSecurityConstraints(baseFragmentImpl.getSecurityConstraints());
+                reuseFragment.getProperties().clear();
+                reuseFragment.getProperties().putAll(baseFragmentImpl.getProperties());
+                reuseFragment.setPreferences(baseFragmentImpl.getPreferences());
+            }
+            this.fragment.add(addFragment);
+
+            // set base fragments implementation in root and children fragments
+            addFragment.setBaseFragmentsElement(this);
+        }
+        else if (fragment == null)
+        {
+            // delete existing fragment if required, saving
+            // removed fragment for later reuse
+            if ((this.fragment != null) && !this.fragment.isEmpty())
+            {
+                removedFragment = (BaseFragmentElementImpl)this.fragment.iterator().next();
+                this.fragment.clear();
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#getFragmentById(java.lang.String)
+     */
+    public BaseFragmentElement getFragmentById(String id)
+    {
+        // get fragment by id and check access
+        BaseFragmentElementImpl rootFragment = (BaseFragmentElementImpl)getRootFragment();
+        if (rootFragment != null)
+        {
+            BaseFragmentElementImpl fragment = (BaseFragmentElementImpl)rootFragment.getFragmentById(id);
+            if (fragment != null)
+            {
+                try
+                {
+                    fragment.checkAccess(JetspeedActions.VIEW);
+                }
+                catch (SecurityException se)
+                {
+                    fragment = null;
+                }
+            }
+            return fragment;
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#removeFragmentById(java.lang.String)
+     */
+    public BaseFragmentElement removeFragmentById(String id)
+    {
+        // remove fragment by id
+        BaseFragmentElementImpl rootFragment = (BaseFragmentElementImpl)getRootFragment();
+        if (rootFragment != null)
+        {
+            if (rootFragment.getId().equals(id))
+            {
+                setRootFragment(null);
+                return rootFragment;
+            }
+            else if (rootFragment instanceof FragmentImpl)
+            {
+                return ((FragmentImpl)rootFragment).removeFragmentById(id);
+            }
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#getFragmentsByName(java.lang.String)
+     */
+    public List getFragmentsByName(String name)
+    {
+        // get fragments by name and filter by access
+        BaseFragmentElementImpl rootFragment = (BaseFragmentElementImpl)getRootFragment();
+        if (rootFragment instanceof FragmentImpl)
+        {
+            // return immutable filtered fragment list
+            FragmentImpl rootFragmentImpl = (FragmentImpl)rootFragment;
+            return rootFragmentImpl.filterFragmentsByAccess(rootFragmentImpl.getFragmentsByName(name), false);
+        }
+        return null;
+    }
+
+    /**
+     * Validate fragments.
+     * 
+     * @return validated flag
+     */
+    public boolean validateFragments()
+    {
+        // validate fragments using validation listener
+        BaseFragmentElementImpl rootFragment = (BaseFragmentElementImpl)getRootFragment();
+        if (rootFragment != null)
+        {
+            BaseFragmentValidationListener validationListener = newBaseFragmentValidationListener();
+            return (rootFragment.validateFragments(validationListener) && validationListener.validate());
+        }
+        return false;
+    }
+    
+    /**
+     * Fragment validation listener.
+     * 
+     * @return validation listener
+     */
+    protected abstract BaseFragmentValidationListener newBaseFragmentValidationListener();
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BasePageElementImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BasePageElementImpl.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BasePageElementImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BasePageElementImpl.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,217 @@
+/*
+ * 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.impl;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.jetspeed.om.folder.MenuDefinition;
+import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
+import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
+import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
+import org.apache.jetspeed.om.folder.MenuSeparatorDefinition;
+import org.apache.jetspeed.om.page.BasePageElement;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.PageMetadataImpl;
+import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
+
+/**
+ * BasePageElementImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public abstract class BasePageElementImpl extends BaseFragmentsElementImpl implements BasePageElement
+{
+    private String skin;
+    private String defaultLayoutDecorator;
+    private String defaultPortletDecorator;
+    private List menus;
+
+    private PageMenuDefinitionList menuDefinitions;
+
+    /**
+     * accessMenus
+     *
+     * Access mutable persistent collection member for List wrappers.
+     *
+     * @return persistent collection
+     */
+    List accessMenus()
+    {
+        // create initial collection if necessary
+        if (menus == null)
+        {
+            menus = DatabasePageManagerUtils.createList();;
+        }
+        return menus;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#resetCachedSecurityConstraints()
+     */
+    public void resetCachedSecurityConstraints()
+    {
+        // propagate to super and fragments
+        super.resetCachedSecurityConstraints();
+        BaseFragmentElementImpl rootFragment = (BaseFragmentElementImpl)getRootFragment();
+        if (rootFragment != null)
+        {
+            rootFragment.resetCachedSecurityConstraints();
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.impl.NodeImpl#newPageMetadata(java.util.Collection)
+     */
+    public PageMetadataImpl newPageMetadata(Collection fields)
+    {
+        PageMetadataImpl pageMetadata = new PageMetadataImpl(PageMetadataLocalizedFieldImpl.class);
+        pageMetadata.setFields(fields);
+        return pageMetadata;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#getSkin()
+     */
+    public String getSkin()
+    {
+        return skin;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#setSkin(java.lang.String)
+     */
+    public void setSkin(String skinName)
+    {
+        this.skin = skinName;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#getDefaultDecorator(java.lang.String)
+     */
+    public String getDefaultDecorator(String fragmentType)
+    {
+        // retrieve supported decorator types
+        if (fragmentType != null)
+        {
+            if (fragmentType.equals(Fragment.LAYOUT))
+            {
+                return defaultLayoutDecorator; 
+            }
+            if (fragmentType.equals(Fragment.PORTLET))
+            {
+                return defaultPortletDecorator; 
+            }
+        }
+        return null;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#getDefaultDecorator(java.lang.String,java.lang.String)
+     */
+    public void setDefaultDecorator(String decoratorName, String fragmentType)
+    {
+        // save supported decorator types
+        if (fragmentType != null)
+        {
+            if (fragmentType.equals(Fragment.LAYOUT))
+            {
+                defaultLayoutDecorator = decoratorName; 
+            }
+            if (fragmentType.equals(Fragment.PORTLET))
+            {
+                defaultPortletDecorator = decoratorName; 
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#getMenuDefinitions()
+     */
+    public List getMenuDefinitions()
+    {
+        // return mutable menu definition list
+        // by using list wrapper to manage
+        // element uniqueness
+        if (menuDefinitions == null)
+        {
+            menuDefinitions = new PageMenuDefinitionList(this);
+        }
+        return menuDefinitions;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#newMenuDefinition()
+     */
+    public MenuDefinition newMenuDefinition()
+    {
+        return new PageMenuDefinitionImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#newMenuExcludeDefinition()
+     */
+    public MenuExcludeDefinition newMenuExcludeDefinition()
+    {
+        return new PageMenuExcludeDefinitionImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#newMenuIncludeDefinition()
+     */
+    public MenuIncludeDefinition newMenuIncludeDefinition()
+    {
+        return new PageMenuIncludeDefinitionImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#newMenuOptionsDefinition()
+     */
+    public MenuOptionsDefinition newMenuOptionsDefinition()
+    {
+        return new PageMenuOptionsDefinitionImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#newMenuSeparatorDefinition()
+     */
+    public MenuSeparatorDefinition newMenuSeparatorDefinition()
+    {
+        return new PageMenuSeparatorDefinitionImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#setMenuDefinitions(java.util.List)
+     */
+    public void setMenuDefinitions(List definitions)
+    {
+        // set menu definitions by replacing
+        // existing entries with new elements if
+        // new collection is specified
+        List menuDefinitions = getMenuDefinitions();
+        if (definitions != menuDefinitions)
+        {
+            // replace all menu definitions
+            menuDefinitions.clear();
+            if (definitions != null)
+            {
+                menuDefinitions.addAll(definitions);
+            }
+        }
+    }
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/DynamicPageImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/DynamicPageImpl.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/DynamicPageImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/DynamicPageImpl.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,56 @@
+/*
+ * 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.impl;
+
+import org.apache.jetspeed.om.page.DynamicPage;
+
+/**
+ * DynamicPageImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class DynamicPageImpl extends BaseConcretePageElementImpl implements DynamicPage
+{
+    private static final long serialVersionUID = 1L;
+    
+    private String pageType;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.DynamicPage#getPageType()
+     */
+    public String getPageType()
+    {
+        return pageType;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.DynamicPage#setPageType(java.lang.String)
+     */
+    public void setPageType(String pageType)
+    {
+        this.pageType = pageType;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.impl.NodeImpl#getType()
+     */
+    public String getType()
+    {
+        return DOCUMENT_TYPE;
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FilteredFragmentList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FilteredFragmentList.java?rev=881862&r1=881861&r2=881862&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FilteredFragmentList.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FilteredFragmentList.java Wed Nov 18 18:24:48 2009
@@ -47,10 +47,10 @@
         filteredList.add(index, element);
         // add object to persistent list
         fragment.accessFragments().add(element);
-        // maintain page implementation reference
-        if ((fragment.getPage() != null) && (element instanceof FragmentImpl))
+        // maintain base fragments implementation reference
+        if ((fragment.getBaseFragmentsElement() != null) && (element instanceof FragmentImpl))
         {
-            ((FragmentImpl)element).setPage(fragment.getPage());
+            ((FragmentImpl)element).setBaseFragmentsElement(fragment.getBaseFragmentsElement());
         }
     }
 
@@ -106,10 +106,10 @@
                 }
             }
         }
-        // maintain page implementation reference
-        if ((fragment.getPage() != null) && (element instanceof FragmentImpl))
+        // maintain base fragments implementation reference
+        if ((fragment.getBaseFragmentsElement() != null) && (element instanceof FragmentImpl))
         {
-            ((FragmentImpl)element).setPage(fragment.getPage());
+            ((FragmentImpl)element).setBaseFragmentsElement(fragment.getBaseFragmentsElement());
         }
         return o;
     }

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentDefinitionImpl.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentDefinitionImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentDefinitionImpl.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,93 @@
+/*
+ * 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.impl;
+
+import org.apache.jetspeed.om.page.BaseFragmentElement;
+import org.apache.jetspeed.om.page.FragmentDefinition;
+import org.apache.jetspeed.om.page.FragmentReference;
+import org.apache.jetspeed.om.page.BaseFragmentValidationListener;
+import org.apache.jetspeed.om.page.PageFragment;
+
+/**
+ * FragmentDefinitionImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class FragmentDefinitionImpl extends BaseFragmentsElementImpl implements FragmentDefinition
+{
+    private static final long serialVersionUID = 1L;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.FragmentDefinition#getDefId()
+     */
+    public String getDefId()
+    {
+        BaseFragmentElement rootFragment = getRootFragment();
+        return ((rootFragment != null) ? rootFragment.getId() : null);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.impl.NodeImpl#getType()
+     */
+    public String getType()
+    {
+        return DOCUMENT_TYPE;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.impl.NodeImpl#isHidden()
+     */
+    public boolean isHidden()
+    {
+        return false;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.impl.NodeImpl#setHidden(boolean)
+     */
+    public void setHidden(boolean hidden)
+    {
+        throw new UnsupportedOperationException("PageTemplate.setHidden()");
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.BaseFragmentsElementImpl#newBaseFragmentValidationListener()
+     */
+    protected BaseFragmentValidationListener newBaseFragmentValidationListener()
+    {
+        return new BaseFragmentValidationListener()
+        {
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.om.page.BaseFragmentValidationListener#validate(org.apache.jetspeed.om.page.BaseFragmentElement)
+             */
+            public boolean validate(BaseFragmentElement fragmentElement)
+            {
+                // PageFragments can only appear in PageTemplates; recursive FragmentReference not supported
+                return (!(fragmentElement instanceof PageFragment) && !(fragmentElement instanceof FragmentReference));
+            }
+
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.om.page.BaseFragmentValidationListener#validate()
+             */
+            public boolean validate()
+            {
+                return true;
+            }
+        };
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java?rev=881862&r1=881861&r2=881862&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentImpl.java Wed Nov 18 18:24:48 2009
@@ -16,18 +16,15 @@
  */
 package org.apache.jetspeed.om.page.impl;
 
-import java.security.AccessController;
-import java.security.Permission;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.jetspeed.JetspeedActions;
 import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.BaseFragmentElement;
+import org.apache.jetspeed.om.page.BaseFragmentValidationListener;
 import org.apache.jetspeed.om.page.Fragment;
-import org.apache.jetspeed.om.page.PageSecurity;
 import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
-import org.apache.jetspeed.security.PermissionFactory;
 
 /**
  * FragmentImpl
@@ -35,45 +32,12 @@
  * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
  * @version $Id$
  */
-public class FragmentImpl extends BaseElementImpl implements Fragment
+public class FragmentImpl extends BaseFragmentElementImpl implements Fragment
 {
     private List fragments;
-    private String fragmentId;
     private String type;
-    private String skin;
-    private String decorator;
-    private String state;
-    private String mode;
-    private int layoutRowProperty = -1;
-    private int layoutColumnProperty = -1;
-    private String layoutSizesProperty;
-    private float layoutXProperty = -1.0F;
-    private float layoutYProperty = -1.0F;
-    private float layoutZProperty = -1.0F;
-    private float layoutWidthProperty = -1.0F;
-    private float layoutHeightProperty = -1.0F;
-    private String extendedPropertyName1;
-    private String extendedPropertyValue1;
-    private String extendedPropertyName2;
-    private String extendedPropertyValue2;
-    private List preferences;
 
     private FragmentList fragmentsList;
-    private FragmentPropertyMap propertiesMap;
-    private FragmentPreferenceList fragmentPreferences;
-    private PageImpl page;
-
-    private static PermissionFactory pf;
-    
-    public static void setPermissionsFactory(PermissionFactory pf)
-    {
-        FragmentImpl.pf = pf;
-    }
-    
-    public FragmentImpl()
-    {
-        super(new FragmentSecurityConstraintsImpl());
-    }
 
     /**
      * accessFragments
@@ -92,68 +56,29 @@
         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;
-    }
-
-    /**
-     * getPage
-     *
-     * Get page implementation that owns fragment.
-     *
-     * @return owning page implementation
-     */
-    PageImpl getPage()
-    {
-        return page;
-    }
-
-    /**
-     * setPage
-     *
-     * Set page implementation that owns fragment and
-     * propagate to all child fragments.
-     *
-     * @param page owning page implementation
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.BaseFragmentElementImpl#setBaseFragmentsElement(org.apache.jetspeed.om.page.impl.BaseFragmentsElementImpl)
      */
-    void setPage(PageImpl page)
+    void setBaseFragmentsElement(BaseFragmentsElementImpl baseFragmentsElement)
     {
         // set page implementation
-        this.page = page;
+        super.setBaseFragmentsElement(baseFragmentsElement);
         // propagate to children
         if (fragments != null)
         {
             Iterator fragmentsIter = fragments.iterator();
             while (fragmentsIter.hasNext())
             {
-                ((FragmentImpl)fragmentsIter.next()).setPage(page);
+                ((BaseFragmentElementImpl)fragmentsIter.next()).setBaseFragmentsElement(baseFragmentsElement);
             }
         }
     }
 
-    /**
-     * getFragmentById
-     *
-     * Retrieve fragment with matching id from
-     * this or child fragments.
-     *
-     * @param id fragment id to retrieve.
-     * @return matched fragment
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#getFragmentById(java.lang.String)
+     * @see org.apache.jetspeed.om.page.impl.BaseFragmentElementImpl#getFragmentById(java.lang.String)
      */
-    Fragment getFragmentById(String id)
+    public BaseFragmentElement getFragmentById(String id)
     {
         // check for match
         if (getId().equals(id))
@@ -166,7 +91,7 @@
             Iterator fragmentsIter = fragments.iterator();
             while (fragmentsIter.hasNext())
             {
-                Fragment matchedFragment = ((FragmentImpl)fragmentsIter.next()).getFragmentById(id);
+                BaseFragmentElement matchedFragment = ((BaseFragmentElementImpl)fragmentsIter.next()).getFragmentById(id);
                 if (matchedFragment != null)
                 {
                     return matchedFragment;
@@ -176,16 +101,10 @@
         return null;
     }
 
-    /**
-     * removeFragmentById
-     *
-     * Remove fragment with matching id from
-     * child fragments.
-     *
-     * @param id fragment id to remove.
-     * @return removed fragment
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Fragment#removeFragmentById(java.lang.String)
      */
-    Fragment removeFragmentById(String id)
+    public BaseFragmentElement removeFragmentById(String id)
     {
         // remove from deep children
         if (fragments != null)
@@ -193,13 +112,16 @@
             Iterator fragmentsIter = fragments.iterator();
             while (fragmentsIter.hasNext())
             {
-                FragmentImpl fragment = (FragmentImpl)fragmentsIter.next();
+                BaseFragmentElementImpl fragment = (BaseFragmentElementImpl)fragmentsIter.next();
                 if (!fragment.getId().equals(id))
                 {
-                    Fragment removed = fragment.removeFragmentById(id);
-                    if (removed != null)
+                    if (fragment instanceof FragmentImpl)
                     {
-                        return removed;
+                        BaseFragmentElement removed = ((FragmentImpl)fragment).removeFragmentById(id);
+                        if (removed != null)
+                        {
+                            return removed;
+                        }
                     }
                 }
                 else
@@ -212,34 +134,20 @@
         return null;
     }
 
-    /**
-     * getFragmentsByName
-     *
-     * Retrieve fragments with matching name including
-     * this and child fragments.
-     *
-     * @param name fragment name to retrieve.
-     * @return list of matched fragments
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.BaseFragmentElementImpl#getFragmentsByName(java.lang.String)
      */
     List getFragmentsByName(String name)
     {
-        List matchedFragments = null;
         // check for match
-        if ((getName() != null) && getName().equals(name))
-        {
-            if (matchedFragments == null)
-            {
-                matchedFragments = DatabasePageManagerUtils.createList();
-            }
-            matchedFragments.add(this);
-        }
-        // match children
+        List matchedFragments = super.getFragmentsByName(name);
+        // match named children
         if (fragments != null)
         {
             Iterator fragmentsIter = fragments.iterator();
             while (fragmentsIter.hasNext())
             {
-                List matchedChildFragments = ((FragmentImpl)fragmentsIter.next()).getFragmentsByName(name);
+                List matchedChildFragments = ((BaseFragmentElementImpl)fragmentsIter.next()).getFragmentsByName(name);
                 if (matchedChildFragments != null)
                 {
                     if (matchedFragments == null)
@@ -256,293 +164,6 @@
         return matchedFragments;
     }
 
-    /**
-     * getPropertyMemberKeys
-     *
-     * Get valid explicit property member keys.
-     *
-     * @return list of property member keys with values
-     */
-    List getPropertyMemberKeys()
-    {
-        List keys = DatabasePageManagerUtils.createList();
-        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.impl.BaseElementImpl#getEffectivePageSecurity()
-     */
-    public PageSecurity getEffectivePageSecurity()
-    {
-        // delegate to page implementation
-        if (page != null)
-        {
-            return page.getEffectivePageSecurity();
-        }
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#getLogicalPermissionPath()
-     */
-    public String getLogicalPermissionPath()
-    {
-        // use page implementation path as base and append name
-        if ((page != null) && (getName() != null))
-        {
-            return page.getLogicalPermissionPath() + Folder.PATH_SEPARATOR + getName();
-        }
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#getPhysicalPermissionPath()
-     */
-    public String getPhysicalPermissionPath()
-    {
-        // use page implementation path as base and append name
-        if ((page != null) && (getName() != null))
-        {
-            return page.getPhysicalPermissionPath() + Folder.PATH_SEPARATOR + getName();
-        }
-        return null;
-    }
-
     /* (non-Javadoc)
      * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#resetCachedSecurityConstraints()
      */
@@ -555,62 +176,35 @@
             Iterator fragmentsIter = fragments.iterator();
             while (fragmentsIter.hasNext())
             {
-                ((FragmentImpl)fragmentsIter.next()).resetCachedSecurityConstraints();
+                ((BaseFragmentElementImpl)fragmentsIter.next()).resetCachedSecurityConstraints();
             }
         }
     }
 
     /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.impl.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 (page != null)
-        {
-            return page.getConstraintsEnabled();
-        }
-        return false;
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.common.SecuredResource#getPermissionsEnabled()
+     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#getLogicalPermissionPath()
      */
-    public boolean getPermissionsEnabled()
+    public String getLogicalPermissionPath()
     {
-        if (page != null)
+        // use base fragments implementation path as base and append name
+        if ((getBaseFragmentsElement() != null) && (getName() != null))
         {
-            return page.getPermissionsEnabled();
+            return getBaseFragmentsElement().getLogicalPermissionPath() + Folder.PATH_SEPARATOR + getName();
         }
-        return false;
+        return null;
     }
 
     /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#getId()
+     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#getPhysicalPermissionPath()
      */
-    public String getId()
+    public String getPhysicalPermissionPath()
     {
-        if (fragmentId != null)
+        // use base fragments implementation path as base and append name
+        if ((getBaseFragmentsElement() != null) && (getName() != null))
         {
-            return fragmentId;
+            return getBaseFragmentsElement().getPhysicalPermissionPath() + Folder.PATH_SEPARATOR + getName();
         }
-        return super.getId();
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Fragment#setId(java.lang.String)
-     */
-    public void setId(String fragmentId)
-    {
-        this.fragmentId = fragmentId;
+        return null;
     }
 
     /* (non-Javadoc)
@@ -630,70 +224,6 @@
     }
 
     /* (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()
@@ -706,295 +236,30 @@
         }
         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)
+     * @see org.apache.jetspeed.om.page.impl.BaseFragmentElementImpl#validateFragments(org.apache.jetspeed.om.page.BaseFragmentValidationListener)
      */
-    public void setLayoutZ(float z)
+    protected boolean validateFragments(BaseFragmentValidationListener validationListener)
     {
-        // set standard float property
-        if (z >= 0.0F)
+        // validate fragment using validation listener
+        if (!validationListener.validate(this))
         {
-            getProperties().put(Z_PROPERTY_NAME, String.valueOf(z));
+            return false;
         }
-        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)
+        // validate fragments using validation listener
+        if (fragments != null)
         {
-            // replace all preferences
-            fragmentPreferences.clear();
-            if (preferences != null)
+            Iterator fragmentsIter = fragments.iterator();
+            while (fragmentsIter.hasNext())
             {
-                fragmentPreferences.addAll(preferences);
+                if (!((BaseFragmentElementImpl)fragmentsIter.next()).validateFragments(validationListener))
+                {
+                    return false;
+                }
             }
         }
+        return true;
     }
     
     /**
@@ -1016,7 +281,7 @@
             Iterator checkAccessIter = fragments.iterator();
             while (checkAccessIter.hasNext())
             {
-                Fragment fragment = (Fragment)checkAccessIter.next();
+                BaseFragmentElement fragment = (BaseFragmentElement)checkAccessIter.next();
                 try
                 {
                     // check access
@@ -1040,7 +305,7 @@
                         Iterator copyIter = fragments.iterator();
                         while (copyIter.hasNext())
                         {
-                            Fragment copyFragment = (Fragment)copyIter.next();
+                            BaseFragmentElement copyFragment = (BaseFragmentElement)copyIter.next();
                             if (copyFragment != fragment)
                             {
                                 filteredFragments.add(copyFragment);

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentList.java?rev=881862&r1=881861&r2=881862&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentList.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentList.java Wed Nov 18 18:24:48 2009
@@ -42,9 +42,9 @@
         // implement for modifiable AbstractList:
         // add and maintain page implementation reference
         fragment.accessFragments().add(index, element);
-        if ((fragment.getPage() != null) && (element instanceof FragmentImpl))
+        if ((fragment.getBaseFragmentsElement() != null) && (element instanceof FragmentImpl))
         {
-            ((FragmentImpl)element).setPage(fragment.getPage());
+            ((FragmentImpl)element).setBaseFragmentsElement(fragment.getBaseFragmentsElement());
         }
     }
 
@@ -74,9 +74,9 @@
         // implement for modifiable AbstractList:
         // set and maintain page implementation reference
         Object o = fragment.accessFragments().set(index, element);
-        if ((fragment.getPage() != null) && (element instanceof FragmentImpl))
+        if ((fragment.getBaseFragmentsElement() != null) && (element instanceof FragmentImpl))
         {
-            ((FragmentImpl)element).setPage(fragment.getPage());
+            ((FragmentImpl)element).setBaseFragmentsElement(fragment.getBaseFragmentsElement());
         }
         return o;
     }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceList.java?rev=881862&r1=881861&r2=881862&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceList.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentPreferenceList.java Wed Nov 18 18:24:48 2009
@@ -28,11 +28,11 @@
  */
 class FragmentPreferenceList extends AbstractList
 {
-    private FragmentImpl fragment;
+    private BaseFragmentElementImpl fragment;
 
     private List removedPreferences;
 
-    FragmentPreferenceList(FragmentImpl fragment)
+    FragmentPreferenceList(BaseFragmentElementImpl fragment)
     {
         super();
         this.fragment = fragment;

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentPropertyMap.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentPropertyMap.java?rev=881862&r1=881861&r2=881862&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentPropertyMap.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentPropertyMap.java Wed Nov 18 18:24:48 2009
@@ -32,10 +32,10 @@
  */
 class FragmentPropertyMap extends AbstractMap
 {
-    private FragmentImpl fragment;
+    private BaseFragmentElementImpl fragment;
     private FragmentPropertiesEntrySet entrySet;
 
-    FragmentPropertyMap(FragmentImpl fragment)
+    FragmentPropertyMap(BaseFragmentElementImpl fragment)
     {
         super();
         this.fragment = fragment;

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentReferenceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentReferenceImpl.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentReferenceImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentReferenceImpl.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,40 @@
+/*
+ * 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.impl;
+
+import org.apache.jetspeed.om.page.FragmentReference;
+
+public class FragmentReferenceImpl extends BaseFragmentElementImpl implements FragmentReference
+{
+    private String fragmentRefId;
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.FragmentReference#getRefId()
+     */
+    public String getRefId()
+    {
+        return fragmentRefId;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.FragmentReference#setRefId(java.lang.String)
+     */
+    public void setRefId(String refId)
+    {
+        this.fragmentRefId = refId;
+    }
+}



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