portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r678081 [1/3] - in /portals/jetspeed-2/portal/branches/JS2-869: components/jetspeed-portal/src/main/java/org/apache/jetspeed/util/descriptor/ components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/ components/jetspeed-registry/src/main...
Date Sat, 19 Jul 2008 00:17:28 GMT
Author: ate
Date: Fri Jul 18 17:17:27 2008
New Revision: 678081

URL: http://svn.apache.org/viewvc?rev=678081&view=rev
Log:
This first batch of changes provides a new backend and api implementation for the PortletPreferences.
Note: because of the dual usage of the Preferences for both PortletPreferences and Security Preferences, some areas in the Serializer combined these two together.
With the PortletPreferences now being refactored, the Serializer storage objects and some of the JetspeedSerializer implementations broke down.
For now, I've commented out that part of the code, with as result User preferences and User UserInfo temporarily not handled/supported anymore!

Added:
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PersistenceBrokerPortletPreferencesProvider.java   (with props)
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/preference/impl/PreferenceImpl.java   (with props)
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/preference/impl/PreferenceSetImpl.java   (with props)
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/preference/impl/PreferenceValueImpl.java   (with props)
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/test/java/org/apache/jetspeed/engine/
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/test/java/org/apache/jetspeed/engine/MockJetspeedEngine.java   (with props)
    portals/jetspeed-2/portal/branches/JS2-869/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletpreferences/
    portals/jetspeed-2/portal/branches/JS2-869/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesProvider.java   (with props)
Removed:
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/preference/impl/PrefsPreference.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/preference/impl/PrefsPreferenceSetImpl.java
Modified:
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-portal/src/main/java/org/apache/jetspeed/util/descriptor/PortletPreferenceRule.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FragmentPortletDefinition.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/serializer/JetspeedRegistrySerializer.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/AbstractRegistryTest.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/TestPortletRegistryDAO.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/TestRegistryCache.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/direct/TestRegistryDirectAll.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/direct/TestRegistryDirectPart1a.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/test/resources/registry-test.xml
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/objects/JSEntityPreference.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/objects/JSNVPElement.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/objects/JSNVPElements.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/objects/JSUser.java
    portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/objects/JSUserAttributes.java
    portals/jetspeed-2/portal/branches/JS2-869/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityAccessComponent.java
    portals/jetspeed-2/portal/branches/JS2-869/jetspeed-api/src/main/java/org/apache/jetspeed/om/common/portlet/MutablePortletEntity.java
    portals/jetspeed-2/portal/branches/JS2-869/jetspeed-api/src/main/java/org/apache/jetspeed/om/common/portlet/PortletDefinitionComposite.java
    portals/jetspeed-2/portal/branches/JS2-869/jetspeed-api/src/main/java/org/apache/jetspeed/om/common/preference/PreferenceComposite.java
    portals/jetspeed-2/portal/branches/JS2-869/jetspeed-portal-resources/src/main/ddl-schema/registry-schema.xml
    portals/jetspeed-2/portal/branches/JS2-869/jetspeed-portal-resources/src/main/resources/assembly/registry.xml

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-portal/src/main/java/org/apache/jetspeed/util/descriptor/PortletPreferenceRule.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-portal/src/main/java/org/apache/jetspeed/util/descriptor/PortletPreferenceRule.java?rev=678081&r1=678080&r2=678081&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-portal/src/main/java/org/apache/jetspeed/util/descriptor/PortletPreferenceRule.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-portal/src/main/java/org/apache/jetspeed/util/descriptor/PortletPreferenceRule.java Fri Jul 18 17:17:27 2008
@@ -21,7 +21,8 @@
 
 import org.apache.commons.digester.Rule;
 import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
-import org.apache.jetspeed.om.preference.impl.PrefsPreference;
+import org.apache.jetspeed.om.common.preference.PreferenceComposite;
+import org.apache.jetspeed.om.common.preference.PreferenceSetComposite;
 import org.apache.pluto.om.portlet.PortletApplicationDefinition;
 import org.xml.sax.Attributes;
 
@@ -36,7 +37,7 @@
     
     protected String name;
     protected boolean readOnly;
-    protected List values; 
+    protected List<String> values; 
  
     /**
      * <p>
@@ -57,7 +58,7 @@
         
         // reset properties to default values
         // as the same instance of this rule can be used multiple times
-        values = new ArrayList();        
+        values = new ArrayList<String>();        
         readOnly = false;
         
         TempValueObject temp = new TempValueObject();
@@ -75,9 +76,8 @@
      */
     public void end( String arg0, String arg1 ) throws Exception
     {       
-        PrefsPreference pref = new PrefsPreference(portlet, name);
-        pref.setValues(values);
-        pref.setReadOnly(readOnly);
+        PreferenceComposite pref = (PreferenceComposite)((PreferenceSetComposite)portlet.getPreferenceSet()).add(name,values);
+        pref.setReadOnly(Boolean.toString(readOnly));
         digester.pop();
     }
     

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml?rev=678081&r1=678080&r2=678081&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml Fri Jul 18 17:17:27 2008
@@ -1115,8 +1115,6 @@
    </class-descriptor>
 
 
-
-
  <!--
    - P O R T L E T  E N T I T Y
  -->
@@ -1138,12 +1136,14 @@
          name="appName"
          column="APP_NAME"
          jdbc-type="VARCHAR"
+         length="80"
       />
 
       <field-descriptor
          name="portletName"
          column="PORTLET_NAME"
          jdbc-type="VARCHAR"
+         length="80"
       />
 
       <field-descriptor
@@ -1152,10 +1152,136 @@
          jdbc-type="VARCHAR"
          autoincrement="true"
          conversion="org.apache.jetspeed.util.ojb.ObjectIDtoStringFieldConversion"
+         length="80"
       />
 
   </class-descriptor>
 
+   <!--
+   - P O R T L E T   P R E F E R E N C E S
+   -->
+  <class-descriptor
+      class="org.apache.jetspeed.om.preference.impl.PreferenceImpl"
+      table="PORTLET_PREFERENCE"
+  >
+      <documentation>Represents a Portlet Preference definition.</documentation>
+      <field-descriptor
+          name="id"
+          column="ID"
+          jdbc-type="BIGINT"
+          primarykey="true"
+          autoincrement="true"
+      >
+      </field-descriptor>
+      <field-descriptor
+          name="applicationName"
+          column="APPLICATION_NAME"
+          jdbc-type="VARCHAR"
+          nullable="false"
+          length="80"
+      >
+      </field-descriptor>
+      <field-descriptor
+          name="portletName"
+          column="PORTLET_NAME"
+          jdbc-type="VARCHAR"
+          nullable="false"
+          length="80"
+      >
+      </field-descriptor>
+      <field-descriptor
+          name="name"
+          column="NAME"
+          jdbc-type="VARCHAR"
+          nullable="false"
+          length="254"
+      >
+      </field-descriptor>
+  </class-descriptor>
+
+  <class-descriptor
+      class="org.apache.jetspeed.om.preference.impl.PreferenceValueImpl"
+      table="PORTLET_PREFERENCE_VALUE"
+  >
+      <documentation>Represents a Portlet Preference value.</documentation>
+      <field-descriptor
+          name="prefId"
+          column="PREF_ID"
+          jdbc-type="BIGINT"
+          primarykey="true"
+      >
+      </field-descriptor>
+      <reference-descriptor
+          name="preference"
+          class-ref="org.apache.jetspeed.om.preference.impl.PreferenceImpl"
+          auto-retrieve="false"
+          auto-update="none"
+          auto-delete="none"
+      >
+          <foreignkey field-ref="prefId"/>
+      </reference-descriptor>
+      
+      <field-descriptor
+          name="index"
+          column="INDEX"
+          jdbc-type="SMALLINT"
+          nullable="false"
+          primarykey="true"
+      >
+      </field-descriptor>
+      <field-descriptor
+          name="entityOid"
+          column="ENTITY_OID"
+          jdbc-type="BIGINT"
+          nullable="false"
+          primarykey="true"
+      >
+      </field-descriptor>
+      <field-descriptor
+          name="userName"
+          column="USER_NAME"
+          jdbc-type="VARCHAR"
+          nullable="false"
+          primarykey="true"
+          length="80"
+      >
+      </field-descriptor>
+      <field-descriptor
+          name="entityId"
+          column="ENTITY_ID"
+          jdbc-type="VARCHAR"
+          nullable="true"
+          length="80"
+      >
+      </field-descriptor>
+      <field-descriptor
+          name="readOnly"
+          column="READONLY"
+          jdbc-type="INTEGER"
+          conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"
+          nullable="false"
+      >
+      </field-descriptor>      
+      <field-descriptor
+          name="nullValue"
+          column="NULL_VALUE"
+          jdbc-type="INTEGER"
+          conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"
+          nullable="false"
+      >
+      </field-descriptor>      
+      <field-descriptor
+          name="value"
+          column="VALUE"
+          jdbc-type="VARCHAR"
+          nullable="true"
+          length="4000"
+      >
+      </field-descriptor>      
+
+  </class-descriptor>
+
+
   <!--
    - S E C U R T I T Y   R O L E   R E F
   -->

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java?rev=678081&r1=678080&r2=678081&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java Fri Jul 18 17:17:27 2008
@@ -16,11 +16,9 @@
  */
 package org.apache.jetspeed.components.portletentity;
 
-import java.io.IOException;
 import java.rmi.server.UID;
 import java.util.Collection;
 import java.util.Iterator;
-import java.util.prefs.BackingStoreException;
 
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.container.window.PortletWindowAccessor;
@@ -29,15 +27,11 @@
 import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
 import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.om.page.Fragment;
-import org.apache.jetspeed.om.preference.impl.PrefsPreferenceSetImpl;
-import org.apache.jetspeed.page.PageManager;
-import org.apache.jetspeed.request.RequestContextComponent;
 import org.apache.jetspeed.util.JetspeedObjectID;
 import org.apache.ojb.broker.query.Criteria;
 import org.apache.ojb.broker.query.Query;
 import org.apache.ojb.broker.query.QueryFactory;
 import org.apache.pluto.om.common.ObjectID;
-import org.apache.pluto.om.common.PreferenceSet;
 import org.apache.pluto.om.entity.PortletEntity;
 import org.apache.pluto.om.entity.PortletEntityCtrl;
 import org.apache.pluto.om.portlet.PortletDefinition;
@@ -77,47 +71,14 @@
     public PersistenceBrokerPortletEntityAccess( PortletRegistry registry )
     {
         super();
-        this.registry = registry;        
-        PortletEntityImpl.registry = registry;
+        this.registry = registry;
     }
 
-    public PersistenceBrokerPortletEntityAccess(PortletRegistry registry, RequestContextComponent rcc)
+    public PersistenceBrokerPortletEntityAccess(PortletRegistry registry, boolean mergeSharedPreferences)
     {
-        super();
-        this.registry = registry;        
-        PortletEntityImpl.registry = registry;
-        PortletEntityImpl.rcc = rcc;
-    }
-
-    public PersistenceBrokerPortletEntityAccess(PortletRegistry registry, RequestContextComponent rcc, PageManager pageManager)
-    {
-        super();
-        this.registry = registry;        
-        PortletEntityImpl.registry = registry;
-        PortletEntityImpl.rcc = rcc;
-        PortletEntityImpl.pm = pageManager;
-    }
-    
-    public PersistenceBrokerPortletEntityAccess(PortletRegistry registry, RequestContextComponent rcc, PageManager pageManager, boolean mergeSharedPreferences)
-    {
-        super();
-        this.registry = registry;        
-        PortletEntityImpl.registry = registry;
-        PortletEntityImpl.rcc = rcc;
-        PortletEntityImpl.pm = pageManager;
         this.mergeSharedPreferences = mergeSharedPreferences;
     }
     
-    public void setEntityAccessProxy(PortletEntityAccessComponent proxy)
-    {
-        PortletEntityImpl.pac = proxy;
-    }
-    
-    public void setPageManager(PageManager pageManager)
-    {
-        PortletEntityImpl.pm = pageManager;
-    }
-    
     /**
      * 
      * <p>
@@ -331,21 +292,8 @@
 
     public void removePortletEntity( PortletEntity portletEntity ) throws PortletEntityNotDeletedException
     {
-        PreferenceSet prefsSet  = portletEntity.getPreferenceSet();
         getPersistenceBrokerTemplate().delete(portletEntity);
-        
-        if(prefsSet instanceof PrefsPreferenceSetImpl)
-        {
-            try
-            {
-                ((PrefsPreferenceSetImpl)prefsSet).clear();
-                removeFromCache(portletEntity);
-            }
-            catch (BackingStoreException e)
-            {
-                throw new PortletEntityNotDeletedException("Failed to remove preferences for portlet entity "+portletEntity.getId()+".  "+e.getMessage(), e);
-            }
-        }
+        removeFromCache(portletEntity);
     }
 
     /**
@@ -384,45 +332,16 @@
     {
         try
         {
-            ((PortletEntityCtrl) portletEntity).store();
+            getPersistenceBrokerTemplate().store(portletEntity);
+            ((MutablePortletEntity)portletEntity).storeChildren();
         }
         catch (Exception e)
         {
-            throw new PortletEntityNotStoredException(e.toString(), e);
+            throw new PortletEntityNotStoredException("Failed to store portlet Entity: "+e.toString(), e);
         }
 
     }
 
-    /**
-     * <p>
-     * storePreferenceSet
-     * </p>
-     * 
-     * @see org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent#storePreferenceSet(org.apache.pluto.om.common.PreferenceSet)
-     * @param prefSet
-     * @throws IOException
-     */
-    public void storePreferenceSet( PreferenceSet prefSet, PortletEntity entity ) throws IOException
-    {
-        try
-        {            
-            getPersistenceBrokerTemplate().store(entity);
-            if (prefSet != null && prefSet instanceof PrefsPreferenceSetImpl)
-            {
-                ((PrefsPreferenceSetImpl)prefSet).flush();
-            }            
-
-        }
-        catch (Exception e)
-        {
-            String msg = "Failed to store portlet entity:" + e.toString();
-            IOException ioe = new IOException(msg);
-            ioe.initCause(e);            
-            throw ioe;
-        }
-
-    }
-    
     protected String autoGenerateID(PortletDefinition pd)
     {
         String appName = ((MutablePortletApplication)pd.getPortletApplicationDefinition()).getName();

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java?rev=678081&r1=678080&r2=678081&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java Fri Jul 18 17:17:27 2008
@@ -1,686 +1,678 @@
-/*
- * 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.components.portletentity;
-
-import java.io.IOException;
-import java.security.Principal;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.prefs.BackingStoreException;
-import java.util.prefs.Preferences;
-
-import javax.portlet.PortletMode;
-
-import org.apache.jetspeed.JetspeedActions;
-import org.apache.jetspeed.aggregator.RenderTrackable;
-import org.apache.jetspeed.components.persistence.store.PersistenceStore;
-import org.apache.jetspeed.components.persistence.store.PersistenceStoreRuntimeExcpetion;
-import org.apache.jetspeed.components.persistence.store.RemovalAware;
-import org.apache.jetspeed.components.portletregistry.PortletRegistry;
-import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
-import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
-import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
-import org.apache.jetspeed.om.common.portlet.PrincipalAware;
-import org.apache.jetspeed.om.page.Fragment;
-import org.apache.jetspeed.om.portlet.impl.FragmentPortletDefinition;
-import org.apache.jetspeed.om.preference.FragmentPreference;
-import org.apache.jetspeed.om.preference.impl.PrefsPreference;
-import org.apache.jetspeed.om.preference.impl.PrefsPreferenceSetImpl;
-import org.apache.jetspeed.om.window.impl.PortletWindowListImpl;
-import org.apache.jetspeed.page.PageManager;
-import org.apache.jetspeed.request.RequestContext;
-import org.apache.jetspeed.request.RequestContextComponent;
-import org.apache.jetspeed.util.JetspeedObjectID;
-import org.apache.pluto.om.common.Description;
-import org.apache.pluto.om.common.ObjectID;
-import org.apache.pluto.om.common.Preference;
-import org.apache.pluto.om.common.PreferenceSet;
-import org.apache.pluto.om.entity.PortletApplicationEntity;
-import org.apache.pluto.om.portlet.PortletDefinition;
-import org.apache.pluto.om.window.PortletWindow;
-import org.apache.pluto.om.window.PortletWindowList;
-import org.apache.pluto.util.StringUtils;
-
-/**
- * Portlet Entity default implementation.
- * 
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
- * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
- * @version $Id: PortletEntityImpl.java,v 1.9 2005/04/29 13:59:08 weaver Exp $
- */
-public class PortletEntityImpl implements MutablePortletEntity, PrincipalAware, RemovalAware, RenderTrackable
-{   
-    private long oid;
-    private JetspeedObjectID id;
-    protected static PortletEntityAccessComponent pac;    
-    protected static PortletRegistry registry;
-    protected static RequestContextComponent rcc;
-    protected static PageManager pm;
-    
-    protected PrefsPreferenceSetImpl pagePreferenceSet;
-    protected Map perPrincipalPrefs = new HashMap();
-    private PortletApplicationEntity applicationEntity = null;
-    private PortletWindowList portletWindows = new PortletWindowListImpl();
-    private PortletDefinitionComposite portletDefinition = null;  
-    protected String portletName;
-    protected String appName;
-    private boolean dirty = false;
-    private Fragment fragment;
-    
-    protected transient int timeoutCount = 0;
-    protected transient long expiration = 0;
-    
-    public PortletEntityImpl(Fragment fragment)
-    {
-        setFragment(fragment);
-    }
-
-    public PortletEntityImpl()
-    {
-        super();
-    }
-
-    public static final String NO_PRINCIPAL = "no-principal";
-    public static final String ENTITY_DEFAULT_PRINCIPAL = "entity-default";
-
-    public ObjectID getId()
-    {
-        return id;
-    }
-
-    public long getOid()
-    {
-        return oid;
-    }
-
-    public void setId( String id )
-    {
-        this.id = JetspeedObjectID.createFromString(id);
-    }
-
-    /**
-     * 
-     * <p>
-     * getPreferenceSet
-     * </p>
-     * 
-     * @see org.apache.pluto.om.entity.PortletEntity#getPreferenceSet()
-     * @return
-     */
-    public PreferenceSet getPreferenceSet()
-    {
-        if (isEditDefaultsMode())
-        {
-            return getPreferenceSetFromPage();
-        }
-        else
-        {
-            Principal currentUser = getPrincipal();
-            return getPreferenceSet(currentUser);
-        }
-    }
-
-    public PreferenceSet getPreferenceSet(Principal principal)
-    {
-        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) perPrincipalPrefs.get(principal);
-        try
-        {
-            if (preferenceSet == null || !dirty)
-            {
-                String prefNodePath = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/" + getId() +"/"+ principal.getName() +"/"
-                        + PrefsPreference.PORTLET_PREFERENCES_ROOT;
-                Preferences prefNode = Preferences.userRoot().node(prefNodePath);               
-                preferenceSet = new PrefsPreferenceSetImpl(prefNode);
-                perPrincipalPrefs.put(principal, preferenceSet);
-                if (pac.isMergeSharedPreferences())
-                {
-                    mergePreferencesSet(preferenceSet);
-                }
-                dirty = true;
-            }
-        }
-        catch (BackingStoreException e)
-        {
-            String msg = "Preference backing store failed: " + e.toString();
-            IllegalStateException ise = new IllegalStateException(msg);
-            ise.initCause(e);
-            throw ise;
-        }
-        return preferenceSet;
-    }
-    
-    private PreferenceSet getPreferenceSetFromPage()
-    {
-        PrefsPreferenceSetImpl preferenceSet = this.pagePreferenceSet;
-        
-        try
-        {
-            if (preferenceSet == null || !dirty)
-            {
-                String prefNodePath = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/" + 
-                                            getId() +"/"+ PrefsPreference.PORTLET_PREFERENCES_ROOT;
-
-                Preferences prefNode = Preferences.systemRoot().node(prefNodePath);
-                preferenceSet = new PrefsPreferenceSetImpl(prefNode);
-                this.pagePreferenceSet = preferenceSet;
-                
-                List fragmentPreferences = this.fragment.getPreferences();
-                
-                if (fragmentPreferences != null)
-                {
-                    for (Iterator it = fragmentPreferences.iterator(); it.hasNext(); )
-                    {
-                        FragmentPreference preference = (FragmentPreference) it.next();
-                        List preferenceValues = preference.getValueList();
-                        preferenceSet.add(preference.getName(), preferenceValues);
-                    }
-                }
-                dirty = true;
-            }
-        }
-        catch (BackingStoreException e)
-        {
-            String msg = "Preference backing store failed: " + e.toString();
-            IllegalStateException ise = new IllegalStateException(msg);
-            ise.initCause(e);
-            throw ise;
-        }
-        return preferenceSet;
-    }
-    
-    private void mergePreferencesSet(PrefsPreferenceSetImpl userPrefSet)
-    throws BackingStoreException
-    {
-        String sharedNodePath = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/" + 
-                                getId() +"/"+ NO_PRINCIPAL +"/" +
-                                PrefsPreference.PORTLET_PREFERENCES_ROOT;                
-        Preferences sharedNode = Preferences.userRoot().node(sharedNodePath);     
-        if (sharedNode == null)
-            return;
-        PrefsPreferenceSetImpl sharedSet = new PrefsPreferenceSetImpl(sharedNode);
-        if (sharedSet.size() == 0)
-            return;
-        Set names = userPrefSet.getNames();
-        Iterator sharedPrefs = sharedSet.iterator();
-        int index = 0;
-        while (sharedPrefs.hasNext())
-        {
-            PrefsPreference sharedPref = (PrefsPreference) sharedPrefs.next();
-// this seems limiting, removing if (names.contains(sharedPref.getName()))
-            List prefs = Arrays.asList(sharedPref.getValueArray());
-            userPrefSet.add(sharedPref.getName(), prefs);
-            index++;
-        }        
-    }
-
-    public PortletDefinition getPortletDefinition()
-    {
-        // there are cases when jetspeed gets initialized before
-        // all of the portlet web apps have.  In this event, premature
-        // access to the portal would cause portlet entities to be cached
-        // with their associated window without there corresponding PortletDefinition
-        // (becuase the PortletApplication has yet to be registered).
-        if(this.portletDefinition == null)
-        {
-            PortletDefinition pd = registry.getPortletDefinitionByIdentifier(getPortletUniqueName());
-            if ( pd != null )
-            {
-              // only store a really found PortletDefinition
-              // to prevent an IllegalArgumentException to be thrown
-              setPortletDefinition(pd);
-            }
-            else
-            {
-                return null;
-            }
-        }        
-        
-        // Wrap the portlet defintion every request thread
-        // JS2-852: don't use thread local
-        RequestContext rc = rcc.getRequestContext();
-        String entityFragmentKey = getEntityFragmentKey();
-        PortletDefinition fpd = null;
-        if (rc != null)
-        {
-            fpd= (PortletDefinition)rc.getAttribute(entityFragmentKey);
-        }
-        if (fpd == null)
-        {
-            fpd = new FragmentPortletDefinition(this.portletDefinition, fragment);
-            if (rc != null)
-            {
-                rc.setAttribute(entityFragmentKey, fpd);
-            }
-        }        
-        return fpd;
-    }
-
-    public PortletApplicationEntity getPortletApplicationEntity()
-    {
-        return applicationEntity;
-    }
-
-    public PortletWindowList getPortletWindowList()
-    {
-        return portletWindows;
-    }
-
-    /**
-     * 
-     * <p>
-     * store
-     * </p>
-     *  
-     */
-    public void store() throws IOException
-    {
-        if (isEditDefaultsMode())
-        {
-            storeToPage();
-        }
-        else
-        {
-            Principal currentUser = getPrincipal();
-            store(currentUser);
-        }
-    }
-    
-    public void store(Principal principal) throws IOException
-    {
-        if (pac == null)
-        {
-            throw new IllegalStateException("You must call PortletEntityImpl.setPorteltEntityDao() before "
-                    + "invoking PortletEntityImpl.store().");
-        }
-
-        PreferenceSet preferenceSet = (PreferenceSet)perPrincipalPrefs.get(principal);
-        pac.storePreferenceSet(preferenceSet, this);
-        dirty = false;
-    }
-    
-    private void storeToPage() throws IOException
-    {
-        if (pm == null)
-        {
-            throw new IllegalStateException("You must set pageManager before "
-                    + "invoking PortletEntityImpl.store().");
-        }
-        
-        PreferenceSet preferenceSet = this.pagePreferenceSet;
-        List preferences = new ArrayList();
-        
-        for (Iterator it = preferenceSet.iterator(); it.hasNext(); )
-        {
-            Preference pref = (Preference) it.next();
-            
-            FragmentPreference preference = pm.newFragmentPreference();
-            preference.setName(pref.getName());
-            List preferenceValues = new ArrayList();
-            
-            for (Iterator iterVals = pref.getValues(); iterVals.hasNext(); )
-            {
-                preferenceValues.add(iterVals.next());
-            }
-            
-            preference.setValueList(preferenceValues);
-            preferences.add(preference);
-        }
-        
-        this.fragment.setPreferences(preferences);
-        
-        try
-        {
-            pm.updatePage(rcc.getRequestContext().getPage());
-        }
-        catch (Exception e)
-        {
-        }
-        
-        dirty = false;
-    }
-
-    /**
-     * 
-     * <p>
-     * reset
-     * </p>
-     *  
-     */
-
-    public void reset() throws IOException
-    {
-        dirty = true;
-        getPreferenceSet(getPrincipal());        
-    }
-
-    // internal methods used for debugging purposes only
-
-    public String toString()
-    {
-        return toString(0);
-    }
-
-    public String toString( int indent )
-    {
-        StringBuffer buffer = new StringBuffer(1000);
-        StringUtils.newLine(buffer, indent);
-        buffer.append(getClass().toString());
-        buffer.append(":");
-        StringUtils.newLine(buffer, indent);
-        buffer.append("{");
-        StringUtils.newLine(buffer, indent);
-        buffer.append("id='");
-        buffer.append(oid);
-        buffer.append("'");
-        StringUtils.newLine(buffer, indent);
-        buffer.append("definition-id='");
-        if(portletDefinition != null)
-        {
-            buffer.append(portletDefinition.getId().toString());
-        }
-        else
-        {
-            buffer.append("null");
-        }
-        buffer.append("'");
-
-        StringUtils.newLine(buffer, indent);
-        //buffer.append(((PreferenceSetImpl)preferences).toString(indent));
-
-        StringUtils.newLine(buffer, indent);
-        buffer.append("}");
-        return buffer.toString();
-    }
-
-    /**
-     * @see org.apache.pluto.om.entity.PortletEntity#getDescription(java.util.Locale)
-     */
-    public Description getDescription( Locale arg0 )
-    {
-        return portletDefinition.getDescription(arg0);
-    }
-
-    /**
-     * <p>
-     * setPortletDefinition
-     * </p>
-     * 
-     * @param composite
-     *  
-     */
-    public void setPortletDefinition( PortletDefinition composite )
-    {
-        if(composite != null)
-        {
-            portletDefinition = (PortletDefinitionComposite) composite;
-            // if the portletDefinition is modified, clear threadlocal fragmentPortletDefinition cache
-            RequestContext rc = rcc.getRequestContext();
-            if (rc != null)
-            {
-                rc.getRequest().removeAttribute(getEntityFragmentKey());
-            }
-            this.appName = ((MutablePortletApplication)portletDefinition.getPortletApplicationDefinition()).getName();
-            this.portletName = portletDefinition.getName();
-        }
-        else
-        {
-            throw new IllegalArgumentException("Cannot pass a null PortletDefinition to a PortletEntity.");
-        }
-    }
-
-    /**
-     * @return Returns the principal.
-     */
-    public Principal getPrincipal()
-    {
-        if (rcc == null)
-        {
-            return new PortletEntityUserPrincipal(NO_PRINCIPAL);
-        }            
-        RequestContext rc = rcc.getRequestContext();
-        if (rc == null)
-        {
-            return new PortletEntityUserPrincipal(NO_PRINCIPAL);
-        }
-        Principal principal = rc.getUserPrincipal();
-        if (principal == null)
-        {
-            principal = new PortletEntityUserPrincipal(NO_PRINCIPAL);
-        }
-        return principal;
-    }
-
-    class PortletEntityUserPrincipal implements Principal
-    {
-        String name;
-
-        protected PortletEntityUserPrincipal( String name )
-        {
-            this.name = name;
-        }
-
-        /**
-         * <p>
-         * getName
-         * </p>
-         * 
-         * @see java.security.Principal#getName()
-         * @return
-         */
-        public String getName()
-        {
-            return name;
-        }
-
-        /**
-         * <p>
-         * equals
-         * </p>
-         * 
-         * @see java.lang.Object#equals(java.lang.Object)
-         * @param obj
-         * @return
-         */
-        public boolean equals( Object obj )
-        {
-            if (obj != null && obj instanceof Principal)
-            {
-                Principal p = (Principal) obj;
-                return name != null && p.getName() != null && name.equals(p.getName());
-            }
-            else
-            {
-                return false;
-            }
-        }
-
-        /**
-         * <p>
-         * hashCode
-         * </p>
-         * 
-         * @see java.lang.Object#hashCode()
-         * @return
-         */
-        public int hashCode()
-        {
-            if (name != null)
-            {
-                return (getClass().getName()+ ":" + name).hashCode();
-            }
-            else
-            {
-                return -1;
-            }
-        }
-
-        /**
-         * <p>
-         * toString
-         * </p>
-         * 
-         * @see java.lang.Object#toString()
-         * @return
-         */
-        public String toString()
-        {
-            return name;
-        }
-    }
-    /**
-     * <p>
-     * postRemoval
-     * </p>
-     *
-     * @see org.apache.jetspeed.components.persistence.store.RemovalAware#postRemoval(org.apache.jetspeed.components.persistence.store.PersistenceStore)
-     * @param store
-     * @throws {@link org.apache.jetspeed.persistence.store.PersistenceStoreRuntimeExcpetion}
-     * if the removal of the {@link java.util.prefs.Preference} related to this entity fails
-     */
-    public void postRemoval( PersistenceStore store )
-    {
-      
-
-    }
-    /**
-     * <p>
-     * preRemoval
-     * </p>
-     *	not implemented.
-     *
-     * @see org.apache.jetspeed.components.persistence.store.RemovalAware#preRemoval(org.apache.jetspeed.components.persistence.store.PersistenceStore)
-     * @param store
-     */
-    public void preRemoval( PersistenceStore store )
-    {
-        String rootForEntity = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/" + getId();
-        try
-        {
-            if(Preferences.userRoot().nodeExists(rootForEntity))
-            {
-                Preferences.userRoot().node(rootForEntity).removeNode();
-            }
-        }
-        catch (BackingStoreException e)
-        {           
-            throw new PersistenceStoreRuntimeExcpetion(e.toString(), e);
-        }        
-
-    }
-    public String getPortletUniqueName()
-    {
-        if(this.appName != null && this.portletName != null)
-        {
-            return this.appName+"::"+this.portletName;
-        }
-        else if(fragment != null)
-        {
-            return fragment.getName();
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-    public void setFragment(Fragment fragment)
-    {
-        this.fragment = fragment;
-        // if the fragment is set, clear threadlocal fragmentPortletDefinition cache
-        RequestContext rc = rcc.getRequestContext();
-        if (rc != null)
-        {
-            rc.getRequest().removeAttribute(getEntityFragmentKey());
-        }
-    }
-
-    public int getRenderTimeoutCount()
-    {
-        return timeoutCount;
-    }
-    
-    public synchronized void incrementRenderTimeoutCount()
-    {
-        timeoutCount++;
-    }
-    
-    public synchronized void setExpiration(long expiration)
-    {
-        this.expiration = expiration;
-    }
-    
-    public long getExpiration()
-    {
-        return this.expiration;
-    }
-    
-    public void success()
-    {
-        timeoutCount = 0;
-    }
-    
-    public void setRenderTimeoutCount(int timeoutCount)
-    {
-        this.timeoutCount = timeoutCount;
-    }
-
-    private boolean isEditDefaultsMode()
-    {
-        boolean editDefaultsMode = false;
-        
-        PortletWindow curWindow = null;
-        
-        if (this.portletWindows != null)
-        {
-            try
-            {
-                curWindow = (PortletWindow) this.portletWindows.iterator().next();
-            }
-            catch (Exception e)
-            {
-            }
-        }
-        
-        if (rcc != null)
-        {
-            RequestContext context = rcc.getRequestContext();
-            
-            try
-            {
-                PortletMode curMode = context.getPortalURL().getNavigationalState().getMode(curWindow);
-                editDefaultsMode = (JetspeedActions.EDIT_DEFAULTS_MODE.equals(curMode));
-            }
-            catch (Exception e)
-            {
-            }
-        }       
-        return editDefaultsMode;
-    }
-
-    protected String getEntityFragmentKey()
-    {
-        String entityId = (this.getId() == null) ? "-unknown-entity" : this.getId().toString();
-        return "org.apache.jetspeed" + entityId ;
-    }
-    
+/*
+ * 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.components.portletentity;
+
+import java.io.IOException;
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.portlet.PortletMode;
+
+import org.apache.jetspeed.Jetspeed;
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.aggregator.RenderTrackable;
+import org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider;
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
+import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
+import org.apache.jetspeed.om.common.portlet.PrincipalAware;
+import org.apache.jetspeed.om.common.preference.PreferenceComposite;
+import org.apache.jetspeed.om.common.preference.PreferenceSetComposite;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.portlet.impl.FragmentPortletDefinition;
+import org.apache.jetspeed.om.preference.FragmentPreference;
+import org.apache.jetspeed.om.preference.impl.PreferenceSetImpl;
+import org.apache.jetspeed.om.window.impl.PortletWindowListImpl;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.request.RequestContextComponent;
+import org.apache.jetspeed.util.JetspeedObjectID;
+import org.apache.pluto.om.common.Description;
+import org.apache.pluto.om.common.ObjectID;
+import org.apache.pluto.om.common.Preference;
+import org.apache.pluto.om.common.PreferenceSet;
+import org.apache.pluto.om.entity.PortletApplicationEntity;
+import org.apache.pluto.om.portlet.PortletDefinition;
+import org.apache.pluto.om.window.PortletWindow;
+import org.apache.pluto.om.window.PortletWindowList;
+import org.apache.pluto.util.StringUtils;
+
+/**
+ * Portlet Entity default implementation.
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
+ * @version $Id: PortletEntityImpl.java,v 1.9 2005/04/29 13:59:08 weaver Exp $
+ */
+public class PortletEntityImpl implements MutablePortletEntity, PrincipalAware, RenderTrackable
+{   
+    private Long oid;
+    private JetspeedObjectID id;
+    private static PortletPreferencesProvider portletPreferencesProvider;
+    private static PortletEntityAccessComponent portletEntityAccess;    
+    private static PortletRegistry registry;
+    private static RequestContextComponent requestContextComponent;
+    private static PageManager pageManager;
+    
+    protected PreferenceSetComposite pagePreferenceSet;
+    protected Map perPrincipalPrefs = new HashMap();
+    private PortletApplicationEntity applicationEntity = null;
+    private PortletWindowList portletWindows = new PortletWindowListImpl();
+    private PortletDefinitionComposite portletDefinition = null;  
+    protected String portletName;
+    protected String appName;
+    private boolean dirty = false;
+    private Fragment fragment;
+    
+    protected transient int timeoutCount = 0;
+    protected transient long expiration = 0;
+    
+    public PortletEntityImpl(Fragment fragment)
+    {
+        setFragment(fragment);
+    }
+
+    public PortletEntityImpl()
+    {
+        super();
+    }
+
+    public static final String NO_PRINCIPAL = "no-principal";
+    public static final String ENTITY_DEFAULT_PRINCIPAL = "entity-default";
+    
+    public ObjectID getId()
+    {
+        return id;
+    }
+
+    public Long getOid()
+    {
+        return oid;
+    }
+
+    public void setId( String id )
+    {
+        this.id = JetspeedObjectID.createFromString(id);
+    }
+
+    /**
+     * 
+     * <p>
+     * getPreferenceSet
+     * </p>
+     * 
+     * @see org.apache.pluto.om.entity.PortletEntity#getPreferenceSet()
+     * @return
+     */
+    public PreferenceSet getPreferenceSet()
+    {
+        if (isEditDefaultsMode())
+        {
+            return getPreferenceSetFromPage();
+        }
+        else
+        {
+            Principal currentUser = getPrincipal();
+            return getPreferenceSet(currentUser);
+        }
+    }
+
+    public PreferenceSet getPreferenceSet(Principal principal)
+    {
+        PreferenceSet preferenceSet = (PreferenceSet)perPrincipalPrefs.get(principal);
+//        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) perPrincipalPrefs.get(principal);
+        if (preferenceSet == null || !dirty)
+        {
+            retrievePortletPreferencesProvider();
+            preferenceSet = portletPreferencesProvider.getPreferenceSet(this, principal.getName());
+            perPrincipalPrefs.put(principal, preferenceSet);
+            /*
+             * TODO:  MergeSharedPreferences is broken AFAIK, this features needs to be reevaluated now that we also have edit_defaults!
+            if (pac.isMergeSharedPreferences())
+            {
+                mergePreferencesSet(preferenceSet);
+            }
+            */
+            dirty = true;
+        }
+        return preferenceSet;
+    }
+    
+    private PreferenceSet getPreferenceSetFromPage()
+    {
+        PreferenceSetComposite preferenceSet = this.pagePreferenceSet;
+        
+        if (preferenceSet == null || !dirty)
+        {
+            preferenceSet = new PreferenceSetImpl();
+            this.pagePreferenceSet = preferenceSet;
+            
+            List fragmentPreferences = this.fragment.getPreferences();
+            
+            if (fragmentPreferences != null)
+            {
+                for (Iterator it = fragmentPreferences.iterator(); it.hasNext(); )
+                {
+                    FragmentPreference preference = (FragmentPreference) it.next();
+                    List preferenceValues = preference.getValueList();
+                    PreferenceComposite pref = (PreferenceComposite)preferenceSet.add(preference.getName(), preferenceValues);
+                    pref.setReadOnly(Boolean.toString(preference.isReadOnly()));
+                }
+            }
+            dirty = true;
+        }
+        return preferenceSet;
+    }
+    
+/*    
+ * TODO:  MergeSharedPreferences is broken AFAIK, this features needs to be reevaluated now that we also have edit_defaults!
+    private void mergePreferencesSet(PrefsPreferenceSetImpl userPrefSet)
+    throws BackingStoreException
+    {
+        String sharedNodePath = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/" + 
+                                getId() +"/"+ NO_PRINCIPAL +"/" +
+                                PrefsPreference.PORTLET_PREFERENCES_ROOT;                
+        Preferences sharedNode = Preferences.userRoot().node(sharedNodePath);     
+        if (sharedNode == null)
+            return;
+        PrefsPreferenceSetImpl sharedSet = new PrefsPreferenceSetImpl(sharedNode);
+        if (sharedSet.size() == 0)
+            return;
+        Set names = userPrefSet.getNames();
+        Iterator sharedPrefs = sharedSet.iterator();
+        int index = 0;
+        while (sharedPrefs.hasNext())
+        {
+            PrefsPreference sharedPref = (PrefsPreference) sharedPrefs.next();
+// this seems limiting, removing if (names.contains(sharedPref.getName()))
+            List prefs = Arrays.asList(sharedPref.getValueArray());
+            userPrefSet.add(sharedPref.getName(), prefs);
+            index++;
+        }        
+    }
+*/
+    public PortletDefinition getPortletDefinition()
+    {
+        // there are cases when jetspeed gets initialized before
+        // all of the portlet web apps have.  In this event, premature
+        // access to the portal would cause portlet entities to be cached
+        // with their associated window without there corresponding PortletDefinition
+        // (becuase the PortletApplication has yet to be registered).
+        if(this.portletDefinition == null)
+        {
+            retrievePortletRegistry();
+            PortletDefinition pd = registry.getPortletDefinitionByIdentifier(getPortletUniqueName());
+            if ( pd != null )
+            {
+              // only store a really found PortletDefinition
+              // to prevent an IllegalArgumentException to be thrown
+              setPortletDefinition(pd);
+            }
+            else
+            {
+                return null;
+            }
+        }        
+        
+        // Wrap the portlet defintion every request thread
+        // JS2-852: don't use thread local
+        retrieveRequestContextComponent();
+        RequestContext rc = requestContextComponent.getRequestContext();
+        String entityFragmentKey = getEntityFragmentKey();
+        PortletDefinition fpd = null;
+        if (rc != null)
+        {
+            fpd= (PortletDefinition)rc.getAttribute(entityFragmentKey);
+        }
+        if (fpd == null)
+        {
+            fpd = new FragmentPortletDefinition(this.portletDefinition, fragment);
+            if (rc != null)
+            {
+                rc.setAttribute(entityFragmentKey, fpd);
+            }
+        }        
+        return fpd;
+    }
+
+    public PortletApplicationEntity getPortletApplicationEntity()
+    {
+        return applicationEntity;
+    }
+
+    public PortletWindowList getPortletWindowList()
+    {
+        return portletWindows;
+    }
+
+    /**
+     * 
+     * <p>
+     * store
+     * </p>
+     *  
+     */
+    public void store() throws IOException
+    {
+        retrievePortletEntityAccess();
+        try
+        {
+            portletEntityAccess.storePortletEntity(this);
+        }
+        catch (PortletEntityNotStoredException e)
+        {
+            IOException ioe = new IOException(e.getMessage());
+            ioe.initCause(e);            
+            throw ioe;
+        }
+    }
+    
+    public void storeChildren()
+    {
+        if (isEditDefaultsMode())
+        {
+            storeToPage();
+        }
+        else
+        {
+            Principal currentUser = getPrincipal();
+            store(currentUser);
+        }
+    }
+    
+    private void store(Principal principal)
+    {
+        PreferenceSetComposite preferenceSet = (PreferenceSetComposite)perPrincipalPrefs.get(principal);
+        
+        if (preferenceSet != null)
+        {
+            retrievePortletPreferencesProvider();
+            portletPreferencesProvider.savePreferenceSet(this, principal.getName(), preferenceSet);
+        }
+        dirty = false;
+    }
+    
+    private void storeToPage()
+    {
+        retrievePageManager();
+        retrieveRequestContextComponent();
+        
+        PreferenceSet preferenceSet = this.pagePreferenceSet;
+        List preferences = new ArrayList();
+        
+        for (Iterator it = preferenceSet.iterator(); it.hasNext(); )
+        {
+            Preference pref = (Preference) it.next();
+            
+            FragmentPreference preference = pageManager.newFragmentPreference();
+            preference.setName(pref.getName());
+            List preferenceValues = new ArrayList();
+            
+            for (Iterator iterVals = pref.getValues(); iterVals.hasNext(); )
+            {
+                preferenceValues.add(iterVals.next());
+            }
+            
+            preference.setValueList(preferenceValues);
+            preferences.add(preference);
+        }
+        
+        this.fragment.setPreferences(preferences);
+        
+        try
+        {
+            pageManager.updatePage(requestContextComponent.getRequestContext().getPage());
+        }
+        catch (Exception e)
+        {
+        }
+        
+        dirty = false;
+    }
+
+    /**
+     * 
+     * <p>
+     * reset
+     * </p>
+     *  
+     */
+
+    public void reset() throws IOException
+    {
+        dirty = true;
+        getPreferenceSet(getPrincipal());        
+    }
+
+    // internal methods used for debugging purposes only
+
+    public String toString()
+    {
+        return toString(0);
+    }
+
+    public String toString( int indent )
+    {
+        StringBuffer buffer = new StringBuffer(1000);
+        StringUtils.newLine(buffer, indent);
+        buffer.append(getClass().toString());
+        buffer.append(":");
+        StringUtils.newLine(buffer, indent);
+        buffer.append("{");
+        StringUtils.newLine(buffer, indent);
+        buffer.append("id='");
+        buffer.append(oid);
+        buffer.append("'");
+        StringUtils.newLine(buffer, indent);
+        buffer.append("definition-id='");
+        if(portletDefinition != null)
+        {
+            buffer.append(portletDefinition.getId().toString());
+        }
+        else
+        {
+            buffer.append("null");
+        }
+        buffer.append("'");
+
+        StringUtils.newLine(buffer, indent);
+        //buffer.append(((PreferenceSetImpl)preferences).toString(indent));
+
+        StringUtils.newLine(buffer, indent);
+        buffer.append("}");
+        return buffer.toString();
+    }
+
+    /**
+     * @see org.apache.pluto.om.entity.PortletEntity#getDescription(java.util.Locale)
+     */
+    public Description getDescription( Locale arg0 )
+    {
+        return portletDefinition.getDescription(arg0);
+    }
+
+    /**
+     * <p>
+     * setPortletDefinition
+     * </p>
+     * 
+     * @param composite
+     *  
+     */
+    public void setPortletDefinition( PortletDefinition composite )
+    {
+        if(composite != null)
+        {
+            portletDefinition = (PortletDefinitionComposite) composite;
+            // if the portletDefinition is modified, clear threadlocal fragmentPortletDefinition cache
+            retrieveRequestContextComponent();
+            RequestContext rc = requestContextComponent.getRequestContext();
+            if (rc != null)
+            {
+                rc.getRequest().removeAttribute(getEntityFragmentKey());
+            }
+            this.appName = ((MutablePortletApplication)portletDefinition.getPortletApplicationDefinition()).getName();
+            this.portletName = portletDefinition.getName();
+        }
+        else
+        {
+            throw new IllegalArgumentException("Cannot pass a null PortletDefinition to a PortletEntity.");
+        }
+    }
+
+    /**
+     * @return Returns the principal.
+     */
+    public Principal getPrincipal()
+    {
+        retrieveRequestContextComponent();
+        if (requestContextComponent == null)
+        {
+            // TODO: shouldn't be possible anymore
+            return new PortletEntityUserPrincipal(NO_PRINCIPAL);
+        }            
+        RequestContext rc = requestContextComponent.getRequestContext();
+        if (rc == null)
+        {
+            return new PortletEntityUserPrincipal(NO_PRINCIPAL);
+        }
+        Principal principal = rc.getUserPrincipal();
+        if (principal == null)
+        {
+            principal = new PortletEntityUserPrincipal(NO_PRINCIPAL);
+        }
+        return principal;
+    }
+
+    class PortletEntityUserPrincipal implements Principal
+    {
+        String name;
+
+        protected PortletEntityUserPrincipal( String name )
+        {
+            this.name = name;
+        }
+
+        /**
+         * <p>
+         * getName
+         * </p>
+         * 
+         * @see java.security.Principal#getName()
+         * @return
+         */
+        public String getName()
+        {
+            return name;
+        }
+
+        /**
+         * <p>
+         * equals
+         * </p>
+         * 
+         * @see java.lang.Object#equals(java.lang.Object)
+         * @param obj
+         * @return
+         */
+        public boolean equals( Object obj )
+        {
+            if (obj != null && obj instanceof Principal)
+            {
+                Principal p = (Principal) obj;
+                return name != null && p.getName() != null && name.equals(p.getName());
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        /**
+         * <p>
+         * hashCode
+         * </p>
+         * 
+         * @see java.lang.Object#hashCode()
+         * @return
+         */
+        public int hashCode()
+        {
+            if (name != null)
+            {
+                return (getClass().getName()+ ":" + name).hashCode();
+            }
+            else
+            {
+                return -1;
+            }
+        }
+
+        /**
+         * <p>
+         * toString
+         * </p>
+         * 
+         * @see java.lang.Object#toString()
+         * @return
+         */
+        public String toString()
+        {
+            return name;
+        }
+    }
+    
+    public String getPortletUniqueName()
+    {
+        if(this.appName != null && this.portletName != null)
+        {
+            return this.appName+"::"+this.portletName;
+        }
+        else if(fragment != null)
+        {
+            return fragment.getName();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+    public void setFragment(Fragment fragment)
+    {
+        this.fragment = fragment;
+        // if the fragment is set, clear threadlocal fragmentPortletDefinition cache
+        retrieveRequestContextComponent();
+        RequestContext rc = requestContextComponent.getRequestContext();
+        if (rc != null)
+        {
+            rc.getRequest().removeAttribute(getEntityFragmentKey());
+        }
+    }
+
+    public int getRenderTimeoutCount()
+    {
+        return timeoutCount;
+    }
+    
+    public synchronized void incrementRenderTimeoutCount()
+    {
+        timeoutCount++;
+    }
+    
+    public synchronized void setExpiration(long expiration)
+    {
+        this.expiration = expiration;
+    }
+    
+    public long getExpiration()
+    {
+        return this.expiration;
+    }
+    
+    public void success()
+    {
+        timeoutCount = 0;
+    }
+    
+    public void setRenderTimeoutCount(int timeoutCount)
+    {
+        this.timeoutCount = timeoutCount;
+    }
+
+    private boolean isEditDefaultsMode()
+    {
+        boolean editDefaultsMode = false;
+        
+        PortletWindow curWindow = null;
+        
+        if (this.portletWindows != null)
+        {
+            try
+            {
+                curWindow = (PortletWindow) this.portletWindows.iterator().next();
+            }
+            catch (Exception e)
+            {
+            }
+        }
+        retrieveRequestContextComponent();
+        RequestContext context = requestContextComponent.getRequestContext();
+        
+        try
+        {
+            PortletMode curMode = context.getPortalURL().getNavigationalState().getMode(curWindow);
+            editDefaultsMode = (JetspeedActions.EDIT_DEFAULTS_MODE.equals(curMode));
+        }
+        catch (Exception e)
+        {
+        }
+        return editDefaultsMode;
+    }
+
+    protected String getEntityFragmentKey()
+    {
+        String entityId = (this.getId() == null) ? "-unknown-entity" : this.getId().toString();
+        return "org.apache.jetspeed" + entityId ;
+    }
+    
+    private void retrievePortletRegistry()
+    {
+        if (registry == null)
+        {
+            registry = (PortletRegistry)Jetspeed.getComponentManager().getComponent("portletRegistry");
+        }
+    }
+
+    private void retrieveRequestContextComponent()
+    {
+        if (requestContextComponent == null)
+        {
+            requestContextComponent = (RequestContextComponent)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.request.RequestContextComponent");
+        }
+    }
+
+    private void retrievePortletEntityAccess()
+    {
+        if (portletEntityAccess == null)
+        {
+            portletEntityAccess = (PortletEntityAccessComponent)Jetspeed.getComponentManager().getComponent("portletEntityAccess");
+        }
+    }
+
+    private void retrievePortletPreferencesProvider()
+    {
+        if (portletPreferencesProvider == null)
+        {
+            portletPreferencesProvider = (PortletPreferencesProvider)Jetspeed.getComponentManager().getComponent("portletPreferencesProvider");
+        }
+    }
+
+    private void retrievePageManager()
+    {
+        if (pageManager == null)
+        {
+            pageManager = (PageManager)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.page.PageManager");
+        }
+    }
 }
\ No newline at end of file

Added: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PersistenceBrokerPortletPreferencesProvider.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PersistenceBrokerPortletPreferencesProvider.java?rev=678081&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PersistenceBrokerPortletPreferencesProvider.java (added)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PersistenceBrokerPortletPreferencesProvider.java Fri Jul 18 17:17:27 2008
@@ -0,0 +1,341 @@
+/*
+ * 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.components.portletpreferences;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.jetspeed.cache.CacheElement;
+import org.apache.jetspeed.cache.JetspeedCache;
+import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
+import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
+import org.apache.jetspeed.om.common.preference.PreferenceComposite;
+import org.apache.jetspeed.om.common.preference.PreferenceSetComposite;
+import org.apache.jetspeed.om.preference.impl.PreferenceImpl;
+import org.apache.jetspeed.om.preference.impl.PreferenceSetImpl;
+import org.apache.jetspeed.om.preference.impl.PreferenceValueImpl;
+import org.apache.jetspeed.prefs.NodeDoesNotExistException;
+import org.apache.ojb.broker.query.Criteria;
+import org.apache.ojb.broker.query.QueryByCriteria;
+import org.apache.ojb.broker.query.QueryFactory;
+import org.apache.ojb.broker.query.ReportQueryByCriteria;
+import org.springframework.orm.ojb.support.PersistenceBrokerDaoSupport;
+
+/**
+ * <p>
+ * PersistenceBrokerPortletPreferencesProvider
+ * </p>
+ * 
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id$
+ */
+public class PersistenceBrokerPortletPreferencesProvider extends PersistenceBrokerDaoSupport implements
+        PortletPreferencesProvider
+{
+    private static final Long UNDEFINED_ENTITY_OID = new Long(-1);
+    private static final String UNDEFINED_USER_NAME = "<no-user>";
+    
+    private JetspeedCache preferenceCache;
+    private List<String> preloadedApplications = null;
+    private boolean preloadEntities = false;    
+    
+    public PersistenceBrokerPortletPreferencesProvider()
+            throws ClassNotFoundException
+    {
+    }
+
+    public PersistenceBrokerPortletPreferencesProvider(JetspeedCache preferenceCache)
+            throws ClassNotFoundException
+    {
+        this.preferenceCache = preferenceCache;
+    }
+
+    public PersistenceBrokerPortletPreferencesProvider(JetspeedCache preferenceCache, List<String> apps, boolean preloadEntities)
+    throws ClassNotFoundException
+    {
+        this(preferenceCache);
+        this.preloadedApplications = apps;
+        this.preloadEntities = preloadEntities;
+    }
+    
+    public void destroy()
+    {
+        preferenceCache = null;
+        preloadedApplications = null;
+        preloadEntities = false;
+    }
+    
+    private String getPreferenceSetKey(String applicationName, String portletName, Long entityOid, String userName)
+    {
+        return applicationName + ":" + portletName + ":" + entityOid.toString() + ":" + userName;        
+    }
+
+    public PreferenceSetComposite getPreferenceSet(PortletDefinitionComposite pd)
+    {
+        return getPreferenceSet(((MutablePortletApplication)pd.getPortletApplicationDefinition()).getName(), pd.getName(), null, null);
+    }
+
+    public PreferenceSetComposite getPreferenceSet(MutablePortletEntity pe)
+    {
+        return getPreferenceSet(pe, null);
+    }
+
+    public PreferenceSetComposite getPreferenceSet(MutablePortletEntity pe, String userName)
+    {
+        PortletDefinitionComposite pd = (PortletDefinitionComposite)pe.getPortletDefinition();
+        return getPreferenceSet(((MutablePortletApplication)pd.getPortletApplicationDefinition()).getName(), pd.getName(), pe.getOid(), userName);
+    }
+
+    private PreferenceSetImpl getPreferenceSet(String applicationName, String portletName, Long entityOid, String userName)
+    {
+        if (entityOid == null)
+        {
+            entityOid = UNDEFINED_ENTITY_OID;
+            userName = UNDEFINED_USER_NAME;
+        }
+        else if (userName == null)
+        {
+            userName = UNDEFINED_USER_NAME;
+        }
+        
+        String cacheKey = getPreferenceSetKey(applicationName, portletName, entityOid, userName);
+        PreferenceSetImpl prefs = null;
+        CacheElement cachedElement = preferenceCache.get(cacheKey);        
+        if (cachedElement != null)
+        {
+            prefs = (PreferenceSetImpl)cachedElement.getContent();
+        }
+        else
+        {
+            prefs = new PreferenceSetImpl();
+            
+            Criteria c = new Criteria();
+            c.addEqualTo("applicationName", applicationName);
+            c.addEqualTo("portletName", portletName);
+            QueryByCriteria query = QueryFactory.newQuery(PreferenceImpl.class, c);
+
+            HashMap<Long, String> prefsMap = new HashMap<Long, String>();
+            Iterator<PreferenceImpl> prefsIter = getPersistenceBrokerTemplate().getIteratorByQuery(query);
+            while (prefsIter.hasNext())
+            {
+                PreferenceImpl pref = prefsIter.next();
+                prefsMap.put(new Long(pref.getId()), pref.getName());
+            }
+            
+            c = new Criteria();
+            c.addEqualTo("preference.applicationName", applicationName);
+            c.addEqualTo("preference.portletName", portletName);
+            c.addEqualTo("entityOid", entityOid);
+            c.addEqualTo("userName", userName);
+            
+            query = QueryFactory.newQuery(PreferenceValueImpl.class, c);
+            
+            query.addOrderByAscending("prefId");
+            query.addOrderByAscending("index");
+            
+            Iterator<PreferenceValueImpl> prefsValueIter = getPersistenceBrokerTemplate().getIteratorByQuery(query);
+            
+            Long prefId = null;
+            PreferenceComposite preference = null;
+            while (prefsValueIter.hasNext())
+            {
+                PreferenceValueImpl value = prefsValueIter.next();
+                if (prefId == null || prefId.longValue() != value.getPrefId())
+                {
+                    prefId = new Long(value.getPrefId());
+                    preference = prefs.add(prefsMap.get(prefId), null);
+                    preference.setReadOnly(Boolean.toString(value.isReadOnly()));
+                }
+                if (preference != null)
+                {
+                    preference.addValue(value.getValue());
+                }
+            }        
+            preferenceCache.put(preferenceCache.createElement(cacheKey, prefs));
+        }
+        return new PreferenceSetImpl(prefs);
+    }
+    
+    public Iterator<String> getUserNames(MutablePortletEntity pe)
+    {
+        Criteria c = new Criteria();
+        c.addEqualTo("entityId", pe.getId());
+        final ReportQueryByCriteria q = QueryFactory.newReportQuery(PreferenceValueImpl.class, c, true);
+        q.setAttributes(new String[]{"userName"});        
+
+        return new Iterator<String>(){
+            private final Iterator<Object[]> iterator = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(q);
+            public boolean hasNext()
+            {
+                return iterator.hasNext();
+            }
+
+            public String next()
+            {
+                return (String)iterator.next()[0];
+            }
+
+            public void remove()
+            {
+                throw new UnsupportedOperationException();
+            }
+        };
+    }
+    
+    public void savePreferenceSet(PortletDefinitionComposite pd, PreferenceSetComposite preferenceSet)
+    {
+        savePreferenceSet(((MutablePortletApplication)pd.getPortletApplicationDefinition()).getName(), pd.getName(), null, null, null, preferenceSet);
+    }
+
+    public void savePreferenceSet(MutablePortletEntity pe, PreferenceSetComposite preferenceSet)
+    {
+        savePreferenceSet(pe, null, preferenceSet);
+    }
+    
+    public void savePreferenceSet(MutablePortletEntity pe, String userName, PreferenceSetComposite preferenceSet)
+    {
+        PortletDefinitionComposite pd = (PortletDefinitionComposite)pe.getPortletDefinition();
+        savePreferenceSet(((MutablePortletApplication)pd.getPortletApplicationDefinition()).getName(), pd.getName(), pe.getOid(), pe.getId().toString(), userName, preferenceSet);
+    }
+    
+    private void savePreferenceSet(String applicationName, String portletName, Long entityOid, String entityId, String userName, PreferenceSetComposite preferenceSet)
+    {
+        if (entityOid == null)
+        {
+            // TODO: *** what Oid is provided for "on the fly" portletWindows without a page fragment/entityId??? ***
+            //       need to check if that doesn't end up potentially modifying the portlet defaults or otherwise wreck havoc ...
+            entityOid = UNDEFINED_ENTITY_OID;
+            userName = UNDEFINED_USER_NAME;
+        }
+        else if (userName == null)
+        {
+            userName = UNDEFINED_USER_NAME;
+        }
+        PreferenceSetImpl current = getPreferenceSet(applicationName, portletName, entityOid, userName);
+
+        Criteria c;
+        PreferenceSetImpl.PreferenceImpl currentPref;
+        PreferenceImpl prefImpl;
+        PreferenceValueImpl valueImpl;
+        
+        // check and synchronize provided PreferenceSet with persistent state
+        
+        Iterator<PreferenceComposite> prefSetIter = preferenceSet.iterator();
+        while (prefSetIter.hasNext())
+        {
+            PreferenceComposite pref = prefSetIter.next();
+            currentPref = current.remove(pref.getName());
+            boolean saveValues = false;
+            long prefId = -1;
+            if (currentPref != null && !pref.equals(currentPref))
+            {
+                c = new Criteria();
+                c.addEqualTo("prefId", new Long(currentPref.getId()));
+                c.addEqualTo("entityOid", entityOid);
+                c.addEqualTo("userName", userName);
+                getPersistenceBrokerTemplate().deleteByQuery(QueryFactory.newQuery(PreferenceValueImpl.class, c));
+                prefId = currentPref.getId();
+                saveValues = true;
+            }
+            if (currentPref == null)
+            {
+                prefImpl = new PreferenceImpl();
+                prefImpl.setApplicationName(applicationName);
+                prefImpl.setPortletName(portletName);
+                prefImpl.setName(pref.getName());
+                getPersistenceBrokerTemplate().store(prefImpl);
+                saveValues = true;
+                prefId = prefImpl.getId();
+            }
+            if (saveValues)
+            {
+                Iterator<String> valuesIter = pref.getValues();
+                short index = 0;
+                while (valuesIter.hasNext())
+                {
+                    valueImpl = new PreferenceValueImpl();
+                    valueImpl.setPrefId(prefId);
+                    valueImpl.setIndex(index);
+                    valueImpl.setEntityOid(entityOid);
+                    valueImpl.setEntityId(entityId);
+                    valueImpl.setReadOnly(pref.isReadOnly());
+                    valueImpl.setUserName(userName);
+                    valueImpl.setValue(valuesIter.next());
+                    getPersistenceBrokerTemplate().store(valueImpl);
+                    index++;
+                }
+                if (index == 0 && pref.isReadOnly())
+                {
+                    // special case: to be able to store the readOnly state without values
+                    // one empty value entry is needed
+                    valueImpl = new PreferenceValueImpl();
+                    valueImpl.setPrefId(prefId);
+                    valueImpl.setIndex(index);
+                    valueImpl.setEntityOid(entityOid);
+                    valueImpl.setEntityId(entityId);
+                    valueImpl.setReadOnly(true);
+                    valueImpl.setUserName(userName);
+                    getPersistenceBrokerTemplate().store(valueImpl);
+                }
+            }
+        }
+        for (String name : current.getNames())
+        {
+            currentPref = current.get(name);
+            c = new Criteria();
+            c.addEqualTo("prefId", new Long(currentPref.getId()));
+            c.addEqualTo("entityOid", entityOid);
+            c.addEqualTo("userName", userName);
+            getPersistenceBrokerTemplate().deleteByQuery(QueryFactory.newQuery(PreferenceValueImpl.class, c));
+            
+            c = new Criteria();
+            c.addEqualTo("prefId", new Long(currentPref.getId()));
+            Criteria c2 = new Criteria();
+            c2.addNotExists(QueryFactory.newQuery(PreferenceValueImpl.class, c));
+            getPersistenceBrokerTemplate().deleteByQuery(QueryFactory.newQuery(PreferenceImpl.class, c2));
+        }
+        String cacheKey = getPreferenceSetKey(applicationName, portletName, entityOid, userName);
+        preferenceCache.remove(cacheKey);
+    }
+
+    public void init() throws Exception
+    {
+        if (preloadedApplications != null)
+        {
+            Iterator<String> apps = this.preloadedApplications.iterator();
+            while (apps.hasNext())
+            {
+                String appName = (String)apps.next();
+                preloadApplicationPreferences(appName);
+            }
+        }
+        if (preloadEntities)
+        {
+            preloadAllEntities();
+        }
+    }    
+
+    public void preloadApplicationPreferences(String portletApplicationName)
+    {
+    }
+    
+    public void preloadAllEntities() throws NodeDoesNotExistException
+    {
+    }
+}
\ No newline at end of file

Propchange: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PersistenceBrokerPortletPreferencesProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PersistenceBrokerPortletPreferencesProvider.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PersistenceBrokerPortletPreferencesProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java?rev=678081&r1=678080&r2=678081&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java Fri Jul 18 17:17:27 2008
@@ -29,7 +29,6 @@
 import org.apache.jetspeed.cache.JetspeedCache;
 import org.apache.jetspeed.cache.JetspeedCacheEventListener;
 import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport;
-import org.apache.jetspeed.factory.PortletFactory;
 import org.apache.jetspeed.om.common.MutableLanguage;
 import org.apache.jetspeed.om.common.Support;
 import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
@@ -77,19 +76,17 @@
     // for testing purposes only: no need for the portletFactory then
     public PersistenceBrokerPortletRegistry(String repositoryPath)
     {
-        this(repositoryPath, null, null, null, null, null);
+        this(repositoryPath, null, null, null, null);
     }
     
     /**
      *  
      */
-    public PersistenceBrokerPortletRegistry(String repositoryPath, PortletFactory portletFactory, 
+    public PersistenceBrokerPortletRegistry(String repositoryPath,
             JetspeedCache applicationOidCache, JetspeedCache portletOidCache, 
             JetspeedCache applicationNameCache, JetspeedCache portletNameCache)
     {
         super(repositoryPath);
-        PortletDefinitionImpl.setPortletRegistry(this);
-        PortletDefinitionImpl.setPortletFactory(portletFactory);
         this.applicationOidCache = applicationOidCache;
         this.portletOidCache = portletOidCache;
         this.applicationNameCache = applicationNameCache;
@@ -315,13 +312,13 @@
         try
         {
             getPersistenceBrokerTemplate().store(portlet);
+            ((PortletDefinitionComposite)portlet).storeChildren();
         }
         catch (DataAccessException e)
         {
             
            throw new FailedToStorePortletDefinitionException(portlet, e);
         }
-
     }
 
     public PortletDefinitionComposite getPortletDefinition(ObjectID id)

Modified: portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FragmentPortletDefinition.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FragmentPortletDefinition.java?rev=678081&r1=678080&r2=678081&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FragmentPortletDefinition.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-869/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FragmentPortletDefinition.java Fri Jul 18 17:17:27 2008
@@ -339,6 +339,11 @@
     {
         portletDefinition.store();
     }
+
+    public void storeChildren()
+    {
+        portletDefinition.storeChildren();
+    }
     
     public String getJetspeedSecurityConstraint()
     {
@@ -349,5 +354,4 @@
     {
         portletDefinition.setJetspeedSecurityConstraint(constraint);
     }
-    
 }



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