portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r892529 [1/4] - in /portals/jetspeed-2/portal/trunk: components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/ components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ components/jetspeed-page-man...
Date Sat, 19 Dec 2009 23:33:50 GMT
Author: rwatler
Date: Sat Dec 19 23:33:49 2009
New Revision: 892529

URL: http://svn.apache.org/viewvc?rev=892529&view=rev
Log:
Scoped Fragment Properties
----------------------------------------------------------------------------
- Add FragmentProperty classes and persistence mappings for scoped property PSML.
- Add fragment property accessors to PageManager and PageLayout fragments that include scope/scopeValue key pairs to enable fine grain customization.
- Support User, Group, Role, and Global property scopes.
- Enable/Disable Group and Role property scopes at a code level, (disabled by default to limit projected performance overhead).
- Add protocol on PageManager to support reaping of request level cacheing on CleanupValve invocation for DBPM implementation.
- Add CleanupValve to all pipelines that utilize the PageManager.
- Remove extended property columns in DBPM schema that will be replaced by new FragmentProperty table, (common layout, state, mode, decorator, and skin columns remain supported for Global properties).

TODO: extended and scoped property persistence in DBPSML.


Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentPropertyImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/BaseFragmentPropertyImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentPropertyImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentPropertyList.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/FragmentProperty.java
Removed:
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/FragmentPropertyMap.java
Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseFragmentElementImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseFragmentsElementImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseFragmentElement.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/PropertyImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/AbstractPageManager.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/psml/CastorXmlPageManager.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/resources/JETSPEED-INF/castor/page-mapping.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/resources/JETSPEED-INF/ojb/page-manager-repository.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/PageManagerTestShared.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestCastorXmlPageManager.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/TestDatabasePageManager.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/testdata/pages/clonetest.psml
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/testdata/pages/test001.psml
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/MovePortletAction.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletPlacementContextImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/CleanupValveImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/beans/ContentFragmentBean.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/layout/PageLayoutComponent.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/BaseFragmentElement.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/ContentFragment.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/page/PageManager.java
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/ddl-schema/phase2-schema.xml
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pipelines.xml

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentImpl.java?rev=892529&r1=892528&r2=892529&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentImpl.java Sat Dec 19 23:33:49 2009
@@ -40,6 +40,7 @@
 import org.apache.jetspeed.om.page.DynamicPage;
 import org.apache.jetspeed.om.page.Fragment;
 import org.apache.jetspeed.om.page.FragmentDefinition;
+import org.apache.jetspeed.om.page.FragmentProperty;
 import org.apache.jetspeed.om.page.FragmentReference;
 import org.apache.jetspeed.om.page.BaseConcretePageElement;
 import org.apache.jetspeed.om.page.Page;
@@ -47,6 +48,7 @@
 import org.apache.jetspeed.om.page.PageTemplate;
 import org.apache.jetspeed.om.page.impl.ContentFragmentImpl;
 import org.apache.jetspeed.om.page.impl.ContentFragmentPreferenceImpl;
+import org.apache.jetspeed.om.page.impl.ContentFragmentPropertyImpl;
 import org.apache.jetspeed.om.page.impl.ContentLocalizedFieldImpl;
 import org.apache.jetspeed.om.page.impl.ContentPageImpl;
 import org.apache.jetspeed.om.portlet.LocalizedField;
@@ -139,11 +141,11 @@
             contentFragmentImpl.initialize(this, page, page, newFragment, null, false);
             if (!Utils.isNull(row))
             {
-                contentFragmentImpl.setLayoutRow(row);
+                contentFragmentImpl.setLayoutRow(null, null, row);
             }
             if (!Utils.isNull(column))
             {
-                contentFragmentImpl.setLayoutColumn(column);
+                contentFragmentImpl.setLayoutColumn(null, null, column);
             }
             pageRootContentFragmentImpl.getFragments().add(contentFragmentImpl);
             String newContentFragmentId = pageRootContentFragmentImpl.getId()+"."+contentFragmentImpl.getFragment().getId();
@@ -882,6 +884,14 @@
      */
     public void updateDecorator(ContentFragment contentFragment, String decoratorName)
     {
+        updateDecorator(contentFragment, decoratorName, null, null);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.layout.PageLayoutComponent#updateDecorator(org.apache.jetspeed.om.page.ContentFragment, java.lang.String, java.lang.String, java.lang.String)
+     */
+    public void updateDecorator(ContentFragment contentFragment, String decoratorName, String scope, String scopeValue)
+    {
         log.debug("PageLayoutComponentImpl.updateDecorator() invoked");
         try
         {
@@ -911,7 +921,7 @@
             if (((decoratorName != null) && !decoratorName.equals(fragment.getDecorator()) ||
                 ((decoratorName == null) && (fragment.getDecorator() != null))))
             {
-                fragment.setDecorator(decoratorName);
+                fragment.setDecorator(scope, scopeValue, decoratorName);
                 update = true;
             }
             if (update)
@@ -920,7 +930,7 @@
             }
             
             // update content context
-            contentFragmentImpl.setDecorator(decoratorName);
+            contentFragmentImpl.setDecorator(scope, scopeValue, decoratorName);
         }
         catch (Exception e)
         {
@@ -1084,6 +1094,14 @@
      */
     public void updatePosition(ContentFragment contentFragment, float x, float y, float z, float width, float height)
     {
+        updatePosition(contentFragment, x, y, z, width, height, null, null);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.layout.PageLayoutComponent#updatePosition(org.apache.jetspeed.om.page.ContentFragment, float, float, float, float, float, java.lang.String, java.lang.String)
+     */
+    public void updatePosition(ContentFragment contentFragment, float x, float y, float z, float width, float height, String scope, String scopeValue)
+    {
         log.debug("PageLayoutComponentImpl.updatePosition() invoked");
         try
         {
@@ -1113,7 +1131,7 @@
             {
                 if (x != fragment.getLayoutX())
                 {
-                    fragment.setLayoutX(x);
+                    fragment.setLayoutX(scope, scopeValue, x);
                     update = true;
                 }
             }
@@ -1121,7 +1139,7 @@
             {
                 if (y != fragment.getLayoutY())
                 {
-                    fragment.setLayoutY(y);
+                    fragment.setLayoutY(scope, scopeValue, y);
                     update = true;
                 }
             }
@@ -1129,7 +1147,7 @@
             {
                 if (z != fragment.getLayoutZ())
                 {
-                    fragment.setLayoutZ(z);
+                    fragment.setLayoutZ(scope, scopeValue, z);
                     update = true;
                 }
             }
@@ -1137,7 +1155,7 @@
             {
                 if (width != fragment.getLayoutWidth())
                 {
-                    fragment.setLayoutWidth(width);
+                    fragment.setLayoutWidth(scope, scopeValue, width);
                     update = true;
                 }
             }
@@ -1145,7 +1163,7 @@
             {
                 if (height != fragment.getLayoutHeight())
                 {
-                    fragment.setLayoutWidth(height);
+                    fragment.setLayoutWidth(scope, scopeValue, height);
                     update = true;
                 }
             }
@@ -1157,23 +1175,23 @@
             // update content context
             if (!Utils.isNull(x))
             {
-                contentFragmentImpl.setLayoutX(x);
+                contentFragmentImpl.setLayoutX(scope, scopeValue, x);
             }
             if (!Utils.isNull(y))
             {
-                contentFragmentImpl.setLayoutY(y);
+                contentFragmentImpl.setLayoutY(scope, scopeValue, y);
             }
             if (!Utils.isNull(z))
             {
-                contentFragmentImpl.setLayoutZ(z);
+                contentFragmentImpl.setLayoutZ(scope, scopeValue, z);
             }
             if (!Utils.isNull(width))
             {
-                contentFragmentImpl.setLayoutWidth(width);
+                contentFragmentImpl.setLayoutWidth(scope, scopeValue, width);
             }
             if (!Utils.isNull(height))
             {
-                contentFragmentImpl.setLayoutWidth(height);
+                contentFragmentImpl.setLayoutWidth(scope, scopeValue, height);
             }
         }
         catch (Exception e)
@@ -1260,10 +1278,72 @@
     }
 
     /* (non-Javadoc)
+     * @see org.apache.jetspeed.layout.PageLayoutComponent#updateProperty(org.apache.jetspeed.om.page.ContentFragment, java.lang.String, java.lang.String)
+     */
+    public void updateProperty(ContentFragment contentFragment, String propName, String propValue)
+    {
+        updateProperty(contentFragment, propName, propValue, null, null);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.layout.PageLayoutComponent#updateProperty(org.apache.jetspeed.om.page.ContentFragment, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+     */
+    public void updateProperty(ContentFragment contentFragment, String propName, String propValue, String scope, String scopeValue)
+    {
+        log.debug("PageLayoutComponentImpl.updateProperty() invoked");
+        try
+        {
+            // validate content fragment
+            ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
+            boolean contentFragmentDefinitionIsPage = ((contentFragmentImpl.getDefinition() instanceof BaseConcretePageElement) && contentFragmentImpl.getDefinition().getPath().equals(contentFragmentImpl.getPage().getPath()));
+            if (!contentFragmentDefinitionIsPage && (contentFragmentImpl.getReference() == null))
+            {
+                throw new IllegalArgumentException("Only page fragments and fragment references are mutable");
+            }
+            
+            // retrieve current fragment and page from page manager
+            BaseConcretePageElement page = getPage(contentFragmentImpl.getPage().getPath());
+            String pageFragmentId = (contentFragmentDefinitionIsPage ? contentFragmentImpl.getFragment().getId() : contentFragmentImpl.getReference().getId());
+            BaseFragmentElement fragment = page.getFragmentById(pageFragmentId);
+            if (fragment == null)
+            {
+                throw new IllegalArgumentException("Fragment and page not consistent");                
+            }
+
+            // check for edit permission
+            fragment.checkAccess(JetspeedActions.EDIT);            
+
+            // update fragment property and page in page manager
+            propValue = (!Utils.isNull(propValue) ? propValue : null);
+            String currentPropValue = fragment.getProperty(propName, scope, scopeValue);
+            if (((propValue == null) && (currentPropValue != null)) || ((propValue != null) && !propValue.equals(currentPropValue)))
+            {
+                fragment.setProperty(propName, scope, scopeValue, propValue);
+                updatePage(page);
+            }
+
+            // update content context
+            contentFragmentImpl.setProperty(propName, scope, scopeValue, propValue);
+        }
+        catch (Exception e)
+        {
+            throw new PageLayoutComponentException("Unexpected exception: "+e, e);
+        }
+    }
+
+    /* (non-Javadoc)
      * @see org.apache.jetspeed.layout.PageLayoutComponent#updateRowColumn(org.apache.jetspeed.om.page.ContentFragment, int, int)
      */
     public void updateRowColumn(ContentFragment contentFragment, int row, int column)
     {
+        updateRowColumn(contentFragment, row, column, null, null);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.layout.PageLayoutComponent#updateRowColumn(org.apache.jetspeed.om.page.ContentFragment, int, int, java.lang.String, java.lang.String)
+     */
+    public void updateRowColumn(ContentFragment contentFragment, int row, int column, String scope, String scopeValue)
+    {
         log.debug("PageLayoutComponentImpl.updateRowColumn() invoked");
         try
         {
@@ -1293,7 +1373,7 @@
             {
                 if (row != fragment.getLayoutRow())
                 {
-                    fragment.setLayoutRow(row);
+                    fragment.setLayoutRow(scope, scopeValue, row);
                     update = true;
                 }
             }
@@ -1301,7 +1381,7 @@
             {
                 if (column != fragment.getLayoutColumn())
                 {
-                    fragment.setLayoutColumn(column);
+                    fragment.setLayoutColumn(scope, scopeValue, column);
                     update = true;
                 }
             }
@@ -1313,11 +1393,11 @@
             // update content context
             if (!Utils.isNull(row))
             {
-                contentFragmentImpl.setLayoutRow(row);
+                contentFragmentImpl.setLayoutRow(scope, scopeValue, row);
             }
             if (!Utils.isNull(column))
             {
-                contentFragmentImpl.setLayoutColumn(column);
+                contentFragmentImpl.setLayoutColumn(scope, scopeValue, column);
             }
         }
         catch (Exception e)
@@ -1331,6 +1411,14 @@
      */
     public void updateStateMode(ContentFragment contentFragment, String portletState, String portletMode)
     {
+        updateStateMode(contentFragment, portletState, portletMode, null, null);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.layout.PageLayoutComponent#updateStateMode(org.apache.jetspeed.om.page.ContentFragment, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+     */
+    public void updateStateMode(ContentFragment contentFragment, String portletState, String portletMode, String scope, String scopeValue)
+    {
         log.debug("PageLayoutComponentImpl.updateStateMode() invoked");
         try
         {
@@ -1360,7 +1448,7 @@
             {
                 if (!portletState.equals(fragment.getState()))
                 {
-                    fragment.setState(portletState);
+                    fragment.setState(scope, scopeValue, portletState);
                     update = true;
                 }
             }
@@ -1368,7 +1456,7 @@
             {
                 if (!portletMode.equals(fragment.getMode()))
                 {
-                    fragment.setMode(portletMode);
+                    fragment.setMode(scope, scopeValue, portletMode);
                     update = true;
                 }
             }
@@ -1380,11 +1468,11 @@
             // update content context
             if (!Utils.isNull(portletState))
             {
-                contentFragmentImpl.setState(portletState);
+                contentFragmentImpl.setState(scope, scopeValue, portletState);
             }
             if (!Utils.isNull(portletMode))
             {
-                contentFragmentImpl.setMode(portletMode);
+                contentFragmentImpl.setMode(scope, scopeValue, portletMode);
             }
         }
         catch (Exception e)
@@ -1720,16 +1808,70 @@
             {
                 contentFragmentImpl.setDecorator(fragment.getDecorator());
             }
+            if (contentFragmentImpl.getLayoutColumn() <  0)
+            {
+                contentFragmentImpl.setLayoutColumn(fragment.getLayoutColumn());
+            }
+            if (contentFragmentImpl.getLayoutHeight() < 0.0F)
+            {
+                contentFragmentImpl.setLayoutHeight(fragment.getLayoutHeight());
+            }
+            if (contentFragmentImpl.getLayoutRow() < 0)
+            {
+                contentFragmentImpl.setLayoutRow(fragment.getLayoutRow());
+            }
+            if (contentFragmentImpl.getLayoutSizes() == null)
+            {
+                contentFragmentImpl.setLayoutSizes(fragment.getLayoutSizes());
+            }
+            if (contentFragmentImpl.getLayoutX() < 0.0F)
+            {
+                contentFragmentImpl.setLayoutX(fragment.getLayoutX());
+            }
+            if (contentFragmentImpl.getLayoutY() < 0.0F)
+            {
+                contentFragmentImpl.setLayoutY(fragment.getLayoutY());
+            }
+            if (contentFragmentImpl.getLayoutZ() < 0.0F)
+            {
+                contentFragmentImpl.setLayoutZ(fragment.getLayoutZ());
+            }
+            if (contentFragmentImpl.getLayoutWidth() < 0.0F)
+            {
+                contentFragmentImpl.setLayoutWidth(fragment.getLayoutWidth());
+            }
             if (fragment.getProperties() != null)
             {
-                Iterator propertiesIter = fragment.getProperties().entrySet().iterator();
+                Iterator propertiesIter = fragment.getProperties().iterator();
                 while (propertiesIter.hasNext())
                 {
-                    Map.Entry property = (Map.Entry)propertiesIter.next();
-                    String propertyKey = (String)property.getKey();
-                    if (!contentFragmentImpl.getProperties().containsKey(propertyKey))
+                    boolean foundProperty = false;
+                    FragmentProperty fragmentProperty = (FragmentProperty)propertiesIter.next();
+                    String name = fragmentProperty.getName();
+                    String scope = fragmentProperty.getScope();
+                    String scopeValue = fragmentProperty.getScopeValue();
+                    Iterator scanPropertiesIter = contentFragmentImpl.getProperties().iterator();
+                    while (!foundProperty && scanPropertiesIter.hasNext())
+                    {
+                        FragmentProperty scanFragmentProperty = (FragmentProperty)scanPropertiesIter.next();
+                        String scanName = scanFragmentProperty.getName();
+                        if (name.equals(scanName))
+                        {
+                            String scanScope = scanFragmentProperty.getScope();
+                            if ((scope == null) && (scanScope == null))
+                            {
+                                foundProperty = true;
+                            }
+                            else if ((scope != null) && scope.equals(scanScope))
+                            {
+                                String scanScopeValue = scanFragmentProperty.getScopeValue();
+                                foundProperty = ((scopeValue != null) && scopeValue.equals(scanScopeValue));
+                            }
+                        }
+                    }
+                    if (!foundProperty)
                     {
-                        contentFragmentImpl.getProperties().put(propertyKey, property.getValue());                    
+                        contentFragmentImpl.getProperties().add(new ContentFragmentPropertyImpl(name, scope, scopeValue, fragmentProperty.getValue()));
                     }
                 }
             }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java?rev=892529&r1=892528&r2=892529&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java Sat Dec 19 23:33:49 2009
@@ -19,9 +19,11 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.jetspeed.aggregator.PortletContent;
 import org.apache.jetspeed.decoration.Decoration;
@@ -31,6 +33,7 @@
 import org.apache.jetspeed.om.page.BaseFragmentsElement;
 import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.FragmentProperty;
 import org.apache.jetspeed.om.page.FragmentReference;
 import org.apache.jetspeed.om.preference.FragmentPreference;
 import org.apache.pluto.container.PortletPreference;
@@ -61,15 +64,11 @@
     private PortletContent portletContent;
     private Decoration decoration;
 
-    private String decorator;
-    private Map properties;
+    private List properties;
     private List fragments;
-    private String mode;
     private String name;
     private List preferences;
     private String shortTitle;
-    private String skin;
-    private String state;
     private String title;
     private String type;
 
@@ -173,7 +172,7 @@
      */
     public String getDecorator()
     {
-        return decorator;
+        return getProperty(DECORATOR_PROPERTY_NAME);
     }
 
     /* (non-Javadoc)
@@ -181,7 +180,7 @@
      */
     public float getFloatProperty(String propName)
     {
-        String propValue = (String)getProperties().get(propName);
+        String propValue = getProperty(propName);
         if (propValue != null)
         {
             return Float.parseFloat(propValue);
@@ -190,6 +189,19 @@
     }
 
     /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentFragment#getFloatProperty(java.lang.String, java.lang.String)
+     */
+    public float getFloatProperty(String propName, String scope)
+    {
+        String propValue = getProperty(propName, scope);
+        if (propValue != null)
+        {
+            return Float.parseFloat(propValue);
+        }
+        return -1.0F;        
+    }
+
+    /* (non-Javadoc)
      * @see org.apache.jetspeed.om.page.ContentFragment#getFragments()
      */
     public List getFragments()
@@ -214,7 +226,20 @@
      */
     public int getIntProperty(String propName)
     {
-        String propValue = (String)getProperties().get(propName);
+        String propValue = getProperty(propName);
+        if (propValue != null)
+        {
+            return Integer.parseInt(propValue);
+        }
+        return -1;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentFragment#getIntProperty(java.lang.String, java.lang.String)
+     */
+    public int getIntProperty(String propName, String scope)
+    {
+        String propValue = getProperty(propName, scope);
         if (propValue != null)
         {
             return Integer.parseInt(propValue);
@@ -291,7 +316,7 @@
      */
     public String getMode()
     {
-        return mode;
+        return getProperty(MODE_PROPERTY_NAME);
     }
 
     /* (non-Javadoc)
@@ -341,21 +366,118 @@
     /* (non-Javadoc)
      * @see org.apache.jetspeed.om.page.ContentFragment#getProperties()
      */
-    public Map getProperties()
+    public List getProperties()
     {
         if (properties == null)
         {
-            properties = new HashMap();
+            properties = new ArrayList();
         }
         return properties;
     }
 
     /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentFragment#getPropertiesMap()
+     */
+    public Map getPropertiesMap()
+    {
+        // get property names
+        Set propertyNames = new HashSet();
+        Iterator propertiesIter = getProperties().iterator();
+        while (propertiesIter.hasNext())
+        {
+            FragmentProperty fragmentProperty = (FragmentProperty)propertiesIter.next();
+            propertyNames.add(fragmentProperty.getName());
+        }
+        
+        // construct and return properties map 
+        Map propertiesMap = new HashMap();
+        Iterator propertyNamesIter = propertyNames.iterator();
+        while (propertyNamesIter.hasNext())
+        {
+            String propertyName = (String)propertyNamesIter.next();
+            String propertyValue = getProperty(propertyName);
+            if (propertyValue != null)
+            {
+                propertiesMap.put(propertyName, propertyValue);
+            }
+        }
+        return propertiesMap;
+    }
+
+    /* (non-Javadoc)
      * @see org.apache.jetspeed.om.page.ContentFragment#getProperty(java.lang.String)
      */
     public String getProperty(String propName)
     {
-        return (String)getProperties().get(propName);
+        // scoped property values
+        String userValue = null;
+        String groupValue = null;
+        String roleValue = null;
+        String globalValue = null;
+
+        // iterate through properties list to determine most specific
+        // property value; assumes properties are already filtered
+        // for current user user, group, and role scopes
+        Iterator propertiesIter = getProperties().iterator();
+        while ((userValue == null) && propertiesIter.hasNext())
+        {
+            FragmentProperty fragmentProperty = (FragmentProperty)propertiesIter.next();
+            if (fragmentProperty.getName().equals(propName))
+            {
+                String fragmentPropertyScope = fragmentProperty.getScope();
+                if (fragmentPropertyScope != null)
+                {
+                    if (fragmentPropertyScope.equals(FragmentProperty.USER_PROPERTY_SCOPE))
+                    {
+                        userValue = fragmentProperty.getValue();
+                    }
+                    else if (groupValue == null)
+                    {
+                        if (fragmentPropertyScope.equals(FragmentProperty.GROUP_PROPERTY_SCOPE))
+                        {
+                            groupValue = fragmentProperty.getValue();
+                        }
+                        else if (roleValue == null)
+                        {
+                            if (fragmentPropertyScope.equals(FragmentProperty.ROLE_PROPERTY_SCOPE))
+                            {
+                                roleValue = fragmentProperty.getValue();
+                            }
+                        }
+                    }
+                }
+                else if ((groupValue == null) && (roleValue == null) && (globalValue == null))
+                {
+                    globalValue = fragmentProperty.getValue();
+                }
+            }
+        }
+
+        // return most specifically scoped property value
+        return ((userValue != null) ? userValue : ((groupValue != null) ? groupValue : ((roleValue != null) ? roleValue : globalValue)));
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentFragment#getProperty(java.lang.String, java.lang.String)
+     */
+    public String getProperty(String propName, String scope)
+    {
+        // iterate through properties list to get property value
+        Iterator propertiesIter = getProperties().iterator();
+        while (propertiesIter.hasNext())
+        {
+            FragmentProperty fragmentProperty = (FragmentProperty)propertiesIter.next();
+            if (fragmentProperty.getName().equals(propName))
+            {
+                String fragmentPropertyScope = fragmentProperty.getScope();
+                if (((fragmentPropertyScope == null) && (scope == null)) ||
+                    ((fragmentPropertyScope != null) && fragmentPropertyScope.equals(scope)))
+                {
+                    return fragmentProperty.getValue();
+                }
+            }
+        }
+        return null;
     }
 
     /* (non-Javadoc)
@@ -414,7 +536,7 @@
      */
     public String getSkin()
     {
-        return skin;
+        return getProperty(SKIN_PROPERTY_NAME);
     }
 
     /* (non-Javadoc)
@@ -422,7 +544,7 @@
      */
     public String getState()
     {
-        return state;
+        return getProperty(STATE_PROPERTY_NAME);
     }
 
     /* (non-Javadoc)
@@ -547,16 +669,24 @@
      */
     public void updateDecorator(String decoratorName)
     {
+        updateDecorator(decoratorName, null, null);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentFragment#updateDecorator(java.lang.String, java.lang.String, java.lang.String)
+     */
+    public void updateDecorator(String decoratorName, String scope, String scopeValue)
+    {
         if (pageLayoutComponent != null)
         {
             // delegate to page layout component
-            pageLayoutComponent.updateDecorator(this, decoratorName);
+            pageLayoutComponent.updateDecorator(this, decoratorName, scope, scopeValue);
         }
         else
         {
             // perform locally only
             decoratorName = (!Utils.isNull(decoratorName) ? decoratorName : null);
-            setDecorator(decoratorName);
+            setDecorator(scope, scopeValue, decoratorName);
         }
     }
 
@@ -582,33 +712,41 @@
      */
     public void updatePosition(float x, float y, float z, float width, float height)
     {
+        updatePosition(x, y, z, width, height, null, null);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentFragment#updatePosition(float, float, float, float, float, java.lang.String, java.lang.String)
+     */
+    public void updatePosition(float x, float y, float z, float width, float height, String scope, String scopeValue)
+    {
         if (pageLayoutComponent != null)
         {
             // delegate to page layout component
-            pageLayoutComponent.updatePosition(this, x, y, z, width, height);
+            pageLayoutComponent.updatePosition(this, x, y, z, width, height, scope, scopeValue);
         }
         else
         {
             // perform locally only
             if (!Utils.isNull(x))
             {
-                setLayoutX(x);
+                setLayoutX(scope, scopeValue, x);
             }
             if (!Utils.isNull(y))
             {
-                setLayoutY(y);
+                setLayoutY(scope, scopeValue, y);
             }
             if (!Utils.isNull(z))
             {
-                setLayoutZ(z);
+                setLayoutZ(scope, scopeValue, z);
             }
             if (!Utils.isNull(width))
             {
-                setLayoutWidth(width);
+                setLayoutWidth(scope, scopeValue, width);
             }
             if (!Utils.isNull(height))
             {
-                setLayoutWidth(height);
+                setLayoutWidth(scope, scopeValue, height);
             }
         }
     }
@@ -631,49 +769,90 @@
     }
     
     /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentFragment#updateProperty(java.lang.String, java.lang.String)
+     */
+    public void updateProperty(String propName, String propValue)
+    {
+        updateProperty(propName, propValue, null, null);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentFragment#updateProperty(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+     */
+    public void updateProperty(String propName, String propValue, String scope, String scopeValue)
+    {
+        if (pageLayoutComponent != null)
+        {
+            // delegate to page layout component
+            pageLayoutComponent.updateProperty(this, propName, propValue, scope, scopeValue);
+        }
+        else
+        {
+            // perform locally only            
+            setProperty(propName, scope, scopeValue, propValue);
+        }        
+    }
+
+    /* (non-Javadoc)
      * @see org.apache.jetspeed.om.page.ContentFragment#updateRowColumn(int, int)
      */
     public void updateRowColumn(int row, int column)
     {
+        updateRowColumn(row, column, null, null);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentFragment#updateRowColumn(int, int, java.lang.String, java.lang.String)
+     */
+    public void updateRowColumn(int row, int column, String scope, String scopeValue)
+    {
         if (pageLayoutComponent != null)
         {
             // delegate to page layout component
-            pageLayoutComponent.updateRowColumn(this, row, column);
+            pageLayoutComponent.updateRowColumn(this, row, column, scope, scopeValue);
         }
         else
         {
             // perform locally only            
             if (!Utils.isNull(row))
             {
-                setLayoutRow(row);
+                setLayoutRow(scope, scopeValue, row);
             }
             if (!Utils.isNull(column))
             {
-                setLayoutColumn(column);
+                setLayoutColumn(scope, scopeValue, column);
             }
         }
     }
-    
+
     /* (non-Javadoc)
      * @see org.apache.jetspeed.om.page.ContentFragment#updateStateMode(java.lang.String, java.lang.String)
      */
     public void updateStateMode(String portletState, String portletMode)
     {
+        updateStateMode(portletState, portletMode, null, null);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.ContentFragment#updateStateMode(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+     */
+    public void updateStateMode(String portletState, String portletMode, String scope, String scopeValue)
+    {
         if (pageLayoutComponent != null)
         {
             // delegate to page layout component
-            pageLayoutComponent.updateStateMode(this, portletState, portletMode);
+            pageLayoutComponent.updateStateMode(this, portletState, portletMode, scope, scopeValue);
         }
         else
         {
             // perform locally only            
             if (!Utils.isNull(portletState))
             {
-                setState(portletState);
+                setState(scope, scopeValue, portletState);
             }
             if (!Utils.isNull(portletMode))
             {
-                setMode(portletMode);
+                setMode(scope, scopeValue, portletMode);
             }            
         }
     }
@@ -921,129 +1100,296 @@
     }
 
     /**
-     * Set content fragment decorator.
+     * Set global content fragment decorator.
      * 
      * @param decorator the decorator to set
      */
     public void setDecorator(String decorator)
     {
-        this.decorator = decorator;
+        setProperty(DECORATOR_PROPERTY_NAME, null, null, decorator);
+    }
+
+    /**
+     * Set content fragment decorator.
+     * 
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param decorator the decorator to set
+     */
+    public void setDecorator(String scope, String scopeValue, String decorator)
+    {
+        setProperty(DECORATOR_PROPERTY_NAME, scope, scopeValue, decorator);
     }
 
     /**
      * Set int property.
      * 
      * @param name property name
+     * @param scope property scope
+     * @param scopeValue property scope value
      * @param value int property value
      */
-    public void setIntProperty(String name, int value)
+    public void setIntProperty(String name, String scope, String scopeValue, int value)
     {
-        if (value >= 0)
-        {
-            getProperties().put(name, String.valueOf(value));
-        }
-        else
-        {
-            getProperties().remove(name);            
-        }
+        setProperty(name, scope, scopeValue, ((value >= 0) ? String.valueOf(value) : null));
     }
 
     /**
      * Set float property.
      * 
      * @param name property name
+     * @param scope property scope
+     * @param scopeValue property scope value
      * @param value float property value
      */
-    public void setFloatProperty(String name, float value)
+    public void setFloatProperty(String name, String scope, String scopeValue, float value)
     {
-        if (value >= 0)
-        {
-            getProperties().put(name, String.valueOf(value));
-        }
-        else
-        {
-            getProperties().remove(name);            
-        }
+        setProperty(name, scope, scopeValue, ((value >= 0.0F) ? String.valueOf(value) : null));
     }
 
     /**
-     * Set layout column property.
+     * Set global layout column property.
      * 
      * @param column column property value
      */
     public void setLayoutColumn(int column)
     {
-        setIntProperty(COLUMN_PROPERTY_NAME, column);
+        setIntProperty(COLUMN_PROPERTY_NAME, null, null, column);
     }
 
     /**
-     * Set layout height property.
+     * Set layout column property.
+     * 
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param column column property value
+     */
+    public void setLayoutColumn(String scope, String scopeValue, int column)
+    {
+        setIntProperty(COLUMN_PROPERTY_NAME, scope, scopeValue, column);
+    }
+
+    /**
+     * Set global layout height property.
      * 
      * @param height height property value
      */
     public void setLayoutHeight(float height)
     {
-        setFloatProperty(HEIGHT_PROPERTY_NAME, height);
+        setFloatProperty(HEIGHT_PROPERTY_NAME, null, null, height);
     }
 
     /**
-     * Set layout row property.
+     * Set layout height property.
+     * 
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param height height property value
+     */
+    public void setLayoutHeight(String scope, String scopeValue, float height)
+    {
+        setFloatProperty(HEIGHT_PROPERTY_NAME, scope, scopeValue, height);
+    }
+
+    /**
+     * Set global layout sizes property.
+     * 
+     * @param sizes sizes property value
+     */
+    public void setLayoutSizes(String sizes)
+    {
+        setProperty(SIZES_PROPERTY_NAME, null, null, sizes);
+    }
+
+    /**
+     * Set layout sizes property.
+     * 
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param sizes sizes property value
+     */
+    public void setLayoutSizes(String scope, String scopeValue, String sizes)
+    {
+        setProperty(SIZES_PROPERTY_NAME, scope, scopeValue, sizes);
+    }
+
+    /**
+     * Set global layout row property.
      * 
      * @param row row property value
      */
     public void setLayoutRow(int row)
     {
-        setIntProperty(ROW_PROPERTY_NAME, row);
+        setIntProperty(ROW_PROPERTY_NAME, null, null, row);
     }
 
     /**
-     * Set layout width property.
+     * Set layout row property.
+     * 
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param row row property value
+     */
+    public void setLayoutRow(String scope, String scopeValue, int row)
+    {
+        setIntProperty(ROW_PROPERTY_NAME, scope, scopeValue, row);
+    }
+
+    /**
+     * Set global layout width property.
      * 
      * @param width width property value
      */
     public void setLayoutWidth(float width)
     {
-        setFloatProperty(WIDTH_PROPERTY_NAME, width);
+        setFloatProperty(WIDTH_PROPERTY_NAME, null, null, width);
     }
 
     /**
-     * Set layout x property.
+     * Set layout width property.
+     * 
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param width width property value
+     */
+    public void setLayoutWidth(String scope, String scopeValue, float width)
+    {
+        setFloatProperty(WIDTH_PROPERTY_NAME, scope, scopeValue, width);
+    }
+
+    /**
+     * Set global layout x property.
      * 
      * @param x x property value
      */
     public void setLayoutX(float x)
     {
-        setFloatProperty(X_PROPERTY_NAME, x);
+        setFloatProperty(X_PROPERTY_NAME, null, null, x);
     }
 
     /**
-     * Set layout y property.
+     * Set layout x property.
+     * 
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param x x property value
+     */
+    public void setLayoutX(String scope, String scopeValue, float x)
+    {
+        setFloatProperty(X_PROPERTY_NAME, scope, scopeValue, x);
+    }
+
+    /**
+     * Set global layout y property.
      * 
      * @param y y property value
      */
     public void setLayoutY(float y)
     {
-        setFloatProperty(Y_PROPERTY_NAME, y);
+        setFloatProperty(Y_PROPERTY_NAME, null, null, y);
     }
 
     /**
-     * Set layout z property.
+     * Set layout y property.
+     * 
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param y y property value
+     */
+    public void setLayoutY(String scope, String scopeValue, float y)
+    {
+        setFloatProperty(Y_PROPERTY_NAME, scope, scopeValue, y);
+    }
+
+    /**
+     * Set global layout z property.
      * 
      * @param z z property value
      */
     public void setLayoutZ(float z)
     {
-        setFloatProperty(Z_PROPERTY_NAME, z);
+        setFloatProperty(Z_PROPERTY_NAME, null, null, z);
     }
 
     /**
-     * Set content fragment mode.
+     * Set layout z property.
+     * 
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param z z property value
+     */
+    public void setLayoutZ(String scope, String scopeValue, float z)
+    {
+        setFloatProperty(Z_PROPERTY_NAME, scope, scopeValue, z);
+    }
+
+    /**
+     * Set property.
+     * 
+     * @param name property name
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param value property value
+     */
+    public void setProperty(String propName, String scope, String scopeValue, String value)
+    {
+        // iterate through properties list to find property
+        FragmentProperty fragmentProperty = null;
+        Iterator propertiesIter = getProperties().iterator();
+        while (propertiesIter.hasNext())
+        {
+            FragmentProperty findFragmentProperty = (FragmentProperty)propertiesIter.next();
+            if (findFragmentProperty.getName().equals(propName))
+            {
+                String findFragmentPropertyScope = findFragmentProperty.getScope();
+                if ((scope == null) && (findFragmentPropertyScope == null))
+                {
+                    fragmentProperty = findFragmentProperty;
+                    break;
+                }
+                else if ((findFragmentPropertyScope != null) && findFragmentPropertyScope.equals(scope))
+                {
+                    String findFragmentPropertyScopeValue = findFragmentProperty.getScopeValue();
+                    if ((findFragmentPropertyScopeValue != null) && findFragmentPropertyScopeValue.equals(scopeValue))
+                    {
+                        fragmentProperty = findFragmentProperty;
+                        break;
+                    }
+                }
+            }
+        }
+        
+        // add, set, or remove property
+        if (fragmentProperty != null)
+        {
+            getProperties().remove(fragmentProperty);                
+        }
+        if (value != null)
+        {
+            getProperties().add(new ContentFragmentPropertyImpl(propName, scope, scopeValue, value));
+        }
+    }
+
+    /**
+     * Set global content fragment mode.
      * 
      * @param mode the mode to set
      */
     public void setMode(String mode)
     {
-        this.mode = mode;
+        setProperty(MODE_PROPERTY_NAME, null, null, mode);
+    }
+
+    /**
+     * Set content fragment mode.
+     * 
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param mode the mode to set
+     */
+    public void setMode(String scope, String scopeValue, String mode)
+    {
+        setProperty(MODE_PROPERTY_NAME, scope, scopeValue, mode);
     }
 
     /**
@@ -1065,7 +1411,7 @@
      */
     public void setPreferences(Map preferences)
     {
-        this.preferences.clear();
+        getPreferences().clear();
         if (preferences != null)
         {
             Iterator preferencesIter = preferences.entrySet().iterator();
@@ -1097,7 +1443,7 @@
                 {
                     throw new IllegalArgumentException("Unexpected preference value type");
                 }
-                this.preferences.add(preference);
+                getPreferences().add(preference);
             }
         }        
     }
@@ -1113,23 +1459,47 @@
     }
 
     /**
-     * Set content fragment skin.
+     * Set global content fragment skin.
      * 
      * @param skin the skin to set
      */
     public void setSkin(String skin)
     {
-        this.skin = skin;
+        setProperty(SKIN_PROPERTY_NAME, null, null, skin);
     }
 
     /**
-     * Set content fragment state.
+     * Set content fragment skin.
+     * 
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param skin the skin to set
+     */
+    public void setSkin(String scope, String scopeValue, String skin)
+    {
+        setProperty(SKIN_PROPERTY_NAME, scope, scopeValue, skin);
+    }
+
+    /**
+     * Set global content fragment state.
      * 
      * @param state the state to set
      */
     public void setState(String state)
     {
-        this.state = state;
+        setProperty(STATE_PROPERTY_NAME, null, null, state);
+    }
+
+    /**
+     * Set content fragment state.
+     * 
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param state the state to set
+     */
+    public void setState(String scope, String scopeValue, String state)
+    {
+        setProperty(STATE_PROPERTY_NAME, scope, scopeValue, state);
     }
 
     /**

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentPropertyImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentPropertyImpl.java?rev=892529&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentPropertyImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentPropertyImpl.java Sat Dec 19 23:33:49 2009
@@ -0,0 +1,113 @@
+/* 
+ * 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.FragmentProperty;
+
+/**
+ * Immutable content fragment property element implementation.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id:$
+ */
+public class ContentFragmentPropertyImpl implements FragmentProperty
+{
+    private String name;
+    private String scope;
+    private String scopeValue;
+    private String value;
+
+    /**
+     * Construct content fragment property element.
+     * 
+     * @param name property name
+     * @param scope property scope
+     * @param scopeValue property scope value
+     * @param value property value
+     */
+    public ContentFragmentPropertyImpl(String name, String scope, String scopeValue, String value)
+    {
+        this.name = name;
+        this.scope = scope;
+        this.scopeValue = scopeValue;
+        this.value = value;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.FragmentProperty#getName()
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.FragmentProperty#getScope()
+     */
+    public String getScope()
+    {
+        return scope;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.FragmentProperty#getScopeValue()
+     */
+    public String getScopeValue()
+    {
+        return scopeValue;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.FragmentProperty#getValue()
+     */
+    public String getValue()
+    {
+        return value;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.FragmentProperty#setName(java.lang.String)
+     */
+    public void setName(String name)
+    {
+        throw new UnsupportedOperationException("FragmentProperty.setName()");
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.FragmentProperty#setScope(java.lang.String)
+     */
+    public void setScope(String scope)
+    {
+        throw new UnsupportedOperationException("FragmentProperty.setScope()");
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.FragmentProperty#setScopeValue(java.lang.String)
+     */
+    public void setScopeValue(String scopeValue)
+    {
+        throw new UnsupportedOperationException("FragmentProperty.setScopeValue()");
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.FragmentProperty#setValue(java.lang.String)
+     */
+    public void setValue(String value)
+    {
+        throw new UnsupportedOperationException("FragmentProperty.setValue()");
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java?rev=892529&r1=892528&r2=892529&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java Sat Dec 19 23:33:49 2009
@@ -23,7 +23,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.jetspeed.Jetspeed;
 import org.apache.jetspeed.JetspeedActions;
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.folder.FolderNotFoundException;
@@ -46,7 +45,6 @@
 import org.apache.jetspeed.om.page.impl.PageImpl;
 import org.apache.jetspeed.om.page.impl.PageSecurityImpl;
 import org.apache.jetspeed.om.page.impl.PageTemplateImpl;
-import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.page.PageNotFoundException;
 import org.apache.jetspeed.page.document.DocumentException;
 import org.apache.jetspeed.page.document.DocumentNotFoundException;
@@ -75,7 +73,6 @@
     private List orders;
     private List menus;
 
-    private PageManager pageManager;
     private List folders;
     private boolean foldersCached;
     private List pages;
@@ -151,18 +148,6 @@
     }
 
     /**
-     * setPageManager
-     *
-     * Infuses PageManager for use by this folder instance.
-     *
-     * @param pageManager page manager that manages this folder instance
-     */
-    public void setPageManager(PageManager pageManager)
-    {
-        this.pageManager = pageManager;
-    }
-
-    /**
      * accessFolders
      *
      * Access folders transient cache collection for use by PageManager.
@@ -1467,13 +1452,4 @@
         }
         return nodes;
     }
-    
-    public PageManager getPageManager()
-    {
-        if(pageManager == null)
-        {
-            pageManager = (PageManager)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.page.PageManager");
-        }        
-        return pageManager;
-    }     
 }

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/BaseFragmentPropertyImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/BaseFragmentPropertyImpl.java?rev=892529&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/BaseFragmentPropertyImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/BaseFragmentPropertyImpl.java Sat Dec 19 23:33:49 2009
@@ -0,0 +1,207 @@
+/*
+ * 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;
+
+import java.security.AccessController;
+import java.security.Principal;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+
+import org.apache.jetspeed.om.page.FragmentProperty;
+import org.apache.jetspeed.security.Group;
+import org.apache.jetspeed.security.JSSubject;
+import org.apache.jetspeed.security.Role;
+import org.apache.jetspeed.security.SubjectHelper;
+import org.apache.jetspeed.security.User;
+
+/**
+ * BaseFragmentPropertyImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public abstract class BaseFragmentPropertyImpl implements FragmentProperty
+{
+    /**
+     * Lookup fragment property in list based on current user.
+     * 
+     * @param propName property name
+     * @param properties fragment properties list
+     * @param userValue returned user value
+     * @param groupValue returned group value
+     * @param roleValue returned role value
+     * @param globalValue returned global value
+     * @return value found flag
+     */
+    public static boolean getFragmentProperty(String propName, List properties, String [] userValue, String [] groupValue, String [] roleValue, String [] globalValue)
+    {
+        boolean valueFound = false;
+        
+        // iterate through properties list and merge with current
+        // principals to determine most specific property value
+        Set principals = null;
+        Principal userPrincipal = null;
+        boolean skipPropertyScopes = false;
+        Iterator propertiesIter = properties.iterator();
+        while ((userValue[0] == null) && propertiesIter.hasNext())
+        {
+            FragmentProperty fragmentProperty = (FragmentProperty)propertiesIter.next();
+            if (fragmentProperty.getName().equals(propName))
+            {
+                String fragmentPropertyScope = fragmentProperty.getScope();
+                if (fragmentPropertyScope != null)
+                {
+                    if (!skipPropertyScopes)
+                    {
+                        // get principals
+                        if (principals == null)
+                        {
+                            // get current request context subject for principals
+                            Subject subject = JSSubject.getSubject(AccessController.getContext());
+                            if (subject != null)
+                            {
+                                if (GROUP_AND_ROLE_PROPERTY_SCOPES_ENABLED)
+                                {
+                                    principals = subject.getPrincipals();
+                                }
+                                else
+                                {
+                                    userPrincipal = SubjectHelper.getBestPrincipal(subject, User.class);
+                                }
+                            }
+                            else
+                            {
+                                skipPropertyScopes = true;
+                            }
+                        }
+                        String fragmentPropertyScopeValue = fragmentProperty.getScopeValue();
+                        if (userPrincipal != null)
+                        {
+                            // match user property scope and scope value with user principal
+                            if (fragmentPropertyScope.equals(USER_PROPERTY_SCOPE) && userPrincipal.getName().equals(fragmentPropertyScopeValue))
+                            {
+                                userValue[0] = fragmentProperty.getValue();
+                                valueFound = true;
+                            }
+                        }
+                        else if (principals != null)
+                        {
+                            // match property scope and scope value with most specific
+                            // principal without a value
+                            Iterator principalsIter = principals.iterator();
+                            while ((userValue[0] == null) && principalsIter.hasNext())
+                            {
+                                Principal principal = (Principal)principalsIter.next();
+                                if (principal.getName().equals(fragmentPropertyScopeValue))
+                                {
+                                    if (fragmentPropertyScope.equals(USER_PROPERTY_SCOPE) && (principal instanceof User))
+                                    {
+                                        userValue[0] = fragmentProperty.getValue();
+                                        valueFound = true;
+                                    }
+                                    else if (groupValue[0] == null)
+                                    {
+                                        if (fragmentPropertyScope.equals(GROUP_PROPERTY_SCOPE) && (principal instanceof Group))
+                                        {
+                                            groupValue[0] = fragmentProperty.getValue();
+                                            valueFound = true;
+                                        }
+                                        else if (roleValue[0] == null)
+                                        {
+                                            if (fragmentPropertyScope.equals(ROLE_PROPERTY_SCOPE) && (principal instanceof Role))
+                                            {
+                                                roleValue[0] = fragmentProperty.getValue();
+                                                valueFound = true;
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+                else if ((groupValue[0] == null) && (roleValue[0] == null) && (globalValue[0] == null))
+                {
+                    globalValue[0] = fragmentProperty.getValue();
+                    valueFound = true;
+                }
+            }
+        }
+        
+        return valueFound;
+    }
+
+    /**
+     * Find fragment property by name, scope, and scope value.
+     * 
+     * @param propName property name
+     * @param propScope property scope
+     * @param propScopeValue property scope value
+     * @param properties fragment properties list
+     * @return fragment property
+     */
+    public static FragmentProperty findFragmentProperty(String propName, String propScope, String propScopeValue, List properties)
+    {
+        // iterate through properties to find specified scoped property
+        FragmentProperty fragmentProperty = null;
+        Iterator propertiesIter = properties.iterator();
+        while (propertiesIter.hasNext())
+        {
+            FragmentProperty findFragmentProperty = (FragmentProperty)propertiesIter.next();
+            if (findFragmentProperty.getName().equals(propName))
+            {
+                String findFragmentPropertyScope = findFragmentProperty.getScope();
+                if ((propScope == null) && (findFragmentPropertyScope == null))
+                {
+                    return findFragmentProperty;
+                }
+                else if ((findFragmentPropertyScope != null) && findFragmentPropertyScope.equals(propScope))
+                {
+                    String findFragmentPropertyScopeValue = findFragmentProperty.getScopeValue();
+                    if ((findFragmentPropertyScopeValue != null) && findFragmentPropertyScopeValue.equals(propScopeValue))
+                    {
+                        return findFragmentProperty;
+                    }
+                }
+            }
+        }
+        return null;
+    }
+    
+    /**
+     * Lookup current user scope value used to default new fragment properties.
+     * 
+     * @return current user principal name
+     */
+    public static String getCurrentUserScopeValue()
+    {
+        // lookup current user principal using subject
+        Subject subject = JSSubject.getSubject(AccessController.getContext());
+        if (subject != null)
+        {
+            Principal userPrincipal = SubjectHelper.getBestPrincipal(subject, User.class);
+            if (userPrincipal != null)
+            {
+                return userPrincipal.getName();
+            }
+        }
+        return null;
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.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/BaseElementImpl.java?rev=892529&r1=892528&r2=892529&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.java Sat Dec 19 23:33:49 2009
@@ -25,12 +25,14 @@
 
 import javax.security.auth.Subject;
 
+import org.apache.jetspeed.Jetspeed;
 import org.apache.jetspeed.JetspeedActions;
 import org.apache.jetspeed.om.common.SecurityConstraint;
 import org.apache.jetspeed.om.common.SecurityConstraints;
 import org.apache.jetspeed.om.page.BaseElement;
 import org.apache.jetspeed.om.page.PageSecurity;
 import org.apache.jetspeed.om.page.SecurityConstraintImpl;
+import org.apache.jetspeed.page.impl.DatabasePageManager;
 import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
 import org.apache.jetspeed.security.Group;
 import org.apache.jetspeed.security.JSSubject;
@@ -54,6 +56,7 @@
 
     private boolean constraintsEnabled;
     private boolean permissionsEnabled;
+    private DatabasePageManager pageManager;
     protected static PermissionFactory pf;
     
     public static void setPermissionsFactory(PermissionFactory pf)
@@ -105,6 +108,30 @@
     {
         permissionsEnabled = enabled;
     }
+    
+    /**
+     * Infuses PageManager for use by this folder instance.
+     *
+     * @param pageManager page manager that manages this folder instance
+     */
+    public void setPageManager(DatabasePageManager pageManager)
+    {
+        this.pageManager = pageManager;
+    }
+
+    /**
+     * Get infused or registered page manager instance managing this base element.
+     * 
+     * @return page manager instance
+     */
+    public DatabasePageManager getPageManager()
+    {
+        if (pageManager == null)
+        {
+            pageManager = (DatabasePageManager)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.page.PageManager");
+        }        
+        return pageManager;
+    }     
 
     /**
      * grantViewActionAccess



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