cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r106442 - in cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal: coplet layout pluto/om pluto/om/common pluto/test profile profile/impl
Date Wed, 24 Nov 2004 18:53:25 GMT
Author: rgoers
Date: Wed Nov 24 10:53:23 2004
New Revision: 106442

URL: http://svn.apache.org/viewcvs?view=rev&rev=106442
Log:
Added support for JSR-168 Portlet Preferences. Saving and rereading user profiles also works
properly.

Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletinstancedata.xml
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractLayout.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractParameters.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/layout.xml
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletApplicationDefinitionImpl.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletEntityImpl.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/common/PreferenceSetImpl.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/portletdefinitionmapping.xml
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/test/TestPortlet.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java?view=diff&rev=106442&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java&r1=106441&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java&r2=106442
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java
Wed Nov 24 10:53:23 2004
@@ -17,8 +17,16 @@
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Collection;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
 
 import org.apache.cocoon.portal.factory.impl.AbstractProducible;
+import org.apache.cocoon.portal.pluto.om.common.PreferenceSetImpl;
+import org.apache.cocoon.portal.profile.ProfileManager;
+import org.apache.cocoon.portal.util.AttributedMapItem;
+import org.apache.pluto.om.common.PreferenceSet;
 
 
 /**
@@ -39,6 +47,11 @@
     /** Temporary attributes are not persisted */
     protected Map temporaryAttributes = new HashMap();
 
+    /** Portlet preferences */
+    protected PreferenceSetImpl preferences = new PreferenceSetImpl();
+
+    protected ProfileManager profileManager;
+
     private String title = null;
 
 	/**
@@ -79,6 +92,24 @@
         return this.attributes;
     }
 
+    public final Collection getCastorAttributes() {
+        Set set = new HashSet(this.attributes.size());
+        Iterator iterator = this.attributes.entrySet().iterator();
+        Map.Entry entry;
+        while (iterator.hasNext()) {
+            entry = (Map.Entry) iterator.next();
+            AttributedMapItem item = new AttributedMapItem();
+            item.setKey((String) entry.getKey());
+            item.setValue((String) entry.getValue());
+            set.add(item);
+        }
+        return set;
+    }
+
+    public void addAttribute(AttributedMapItem item) {
+        this.attributes.put(item.getKey(), item.getValue());
+    }
+
     public Object getTemporaryAttribute(String key) {
         return this.temporaryAttributes.get(key);
     }
@@ -110,6 +141,31 @@
         this.title = title;
     }
 
+    public void setPreferences(PreferenceSetImpl preferences) {
+        this.preferences = preferences;
+    }
+
+    public PreferenceSet getPreferences() {
+        return this.preferences;
+    }
+
+    public PreferenceSet getCastorPreferences() {
+        return getPreferences();
+    }
+
+    public void setCastorPreferences(PreferenceSet castorPreferences) {
+        setPreferences((PreferenceSetImpl)castorPreferences);
+    }
+
+    public void setProfileManager(ProfileManager manager) {
+        this.profileManager = manager;
+    }
+
+    public ProfileManager getProfileManager() {
+        return this.profileManager;
+    }
+
+
     /* (non-Javadoc)
      * @see java.lang.Object#clone()
      */
@@ -119,7 +175,9 @@
         clone.copletData = this.copletData;
         clone.attributes = new HashMap(this.attributes);
         clone.temporaryAttributes = new HashMap(this.temporaryAttributes);
-        
+        clone.preferences = new PreferenceSetImpl();
+        clone.preferences.addAll(this.preferences.getPreferences());
+
         return clone;
     }
     

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletinstancedata.xml
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletinstancedata.xml?view=diff&rev=106442&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletinstancedata.xml&r1=106441&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletinstancedata.xml&r2=106442
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletinstancedata.xml
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletinstancedata.xml
Wed Nov 24 10:53:23 2004
@@ -33,6 +33,25 @@
         </field>
     </class>
 
+  <class name="org.apache.cocoon.portal.pluto.om.common.PreferenceImpl">
+    <field name="name" type="java.lang.String" required="true">
+      <bind-xml name="name" node="element"/>
+    </field>
+    <field name="castorValues" type="java.lang.String" collection="collection" required="true">
+      <bind-xml name="value" node="element"/>
+    </field>
+
+  </class>
+
+
+  <class name="org.apache.cocoon.portal.pluto.om.common.PreferenceSetImpl">
+    <field name="preferences" type="org.apache.cocoon.portal.pluto.om.common.PreferenceImpl"
+      collection="set">
+      <bind-xml name="preference" node="element"/>
+    </field>
+
+  </class>
+
 	<class name="org.apache.cocoon.portal.profile.impl.CopletInstanceDataManager">
 		<map-to xml="coplets" />
 
@@ -47,10 +66,15 @@
 
 		<field name="copletData" type="java.lang.String" handler="org.apache.cocoon.portal.util.CopletDataReferenceFieldHandler"/>
 
-		<field name="attributes" type="org.exolab.castor.mapping.MapItem" collection="map" handler="org.apache.cocoon.portal.util.AttributesFieldHandler">
-			<bind-xml name="attribute"/>
+		<field name="attributes" type="org.apache.cocoon.portal.util.AttributedMapItem" collection="collection"
+           get-method="getCastorAttributes" set-method="addAttribute">
+			<bind-xml name="attribute" node="element"/>
 		</field>
 
+    <field name="castorPreferences" type="org.apache.cocoon.portal.pluto.om.common.PreferenceSetImpl">
+      <bind-xml name="preferences" node="element"/>
+    </field>
+
     <field name="title" type="java.lang.String" get-method="getInstanceTitle" set-method="setTitle">
       <bind-xml name="title"/>
     </field>
@@ -65,6 +89,16 @@
 			<bind-xml name="value"/>
 		</field>
 	</class>
+
+  <class name="org.apache.cocoon.portal.util.AttributedMapItem">
+    <field name="key" type="java.lang.String">
+      <bind-xml name="name" node="attribute"/>
+    </field>
+
+    <field name="value">
+      <bind-xml name="value" node="attribute"/>
+    </field>
+  </class>
 
 </mapping>
 

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractLayout.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractLayout.java?view=diff&rev=106442&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractLayout.java&r1=106441&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractLayout.java&r2=106442
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractLayout.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractLayout.java
Wed Nov 24 10:53:23 2004
@@ -16,9 +16,15 @@
 package org.apache.cocoon.portal.layout;
 
 import java.util.Map;
+import java.util.Collection;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
 
 import org.apache.cocoon.portal.factory.impl.AbstractProducible;
+import org.apache.cocoon.portal.pluto.om.common.ParameterImpl;
 import org.apache.commons.collections.map.LinkedMap;
+import org.apache.pluto.om.common.Parameter;
 
 /**
  *
@@ -27,7 +33,7 @@
  * 
  * @version CVS $Id$
  */
-public abstract class AbstractLayout 
+public abstract class AbstractLayout
     extends AbstractProducible 
     implements Layout, Parameters {
     
@@ -42,6 +48,27 @@
      */
     public final Map getParameters() {
         return parameters;
+    }
+
+    public final Set getCastorParameters()
+    {
+        Set set = new HashSet(this.parameters.size());
+        Iterator iterator = this.parameters.entrySet().iterator();
+        Map.Entry entry;
+        while (iterator.hasNext())
+        {
+            entry = (Map.Entry) iterator.next();
+            ParameterImpl param = new ParameterImpl();
+            param.setName((String) entry.getKey());
+            param.setValue((String) entry.getValue());
+            set.add(param);
+        }
+        return set;
+    }
+
+    public void addParameter(Parameter parameter)
+    {
+        parameters.put(parameter.getName(), parameter.getValue());
     }
 
     /**

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractParameters.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractParameters.java?view=diff&rev=106442&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractParameters.java&r1=106441&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractParameters.java&r2=106442
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractParameters.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractParameters.java
Wed Nov 24 10:53:23 2004
@@ -16,8 +16,14 @@
 package org.apache.cocoon.portal.layout;
 
 import java.util.Map;
+import java.util.Iterator;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.commons.collections.map.LinkedMap;
+import org.apache.pluto.om.common.Parameter;
+import org.apache.cocoon.portal.pluto.om.common.ParameterImpl;
 
 /**
  *
@@ -37,7 +43,26 @@
     public final Map getParameters() {
         return parameters;
     }
-    
+
+    public final Set getCastorParameters() {
+        Set set = new HashSet(this.parameters.size());
+        Iterator iterator = this.parameters.entrySet().iterator();
+        Map.Entry entry;
+        while (iterator.hasNext())
+        {
+            entry = (Map.Entry) iterator.next();
+            ParameterImpl param = new ParameterImpl();
+            param.setName((String)entry.getKey());
+            param.setValue((String)entry.getValue());
+            set.add(param);
+        }
+        return set;
+    }
+
+    public void addParameter(Parameter parameter) {
+        parameters.put(parameter.getName(), parameter.getValue());
+    }
+
     /* (non-Javadoc)
      * @see java.lang.Object#clone()
      */

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/layout.xml
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/layout.xml?view=diff&rev=106442&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/layout.xml&r1=106441&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/layout.xml&r2=106442
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/layout.xml
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/layout.xml
Wed Nov 24 10:53:23 2004
@@ -15,109 +15,110 @@
   limitations under the License.
 -->
 <mapping>
-    <description>Portalprofile mapping file</description>
+  <description>Portalprofile mapping file</description>
 
+  <class name="org.apache.cocoon.portal.aspect.impl.AbstractAspectalizable">
+    <field name="persistentAspectData" type="org.exolab.castor.mapping.MapItem" collection="map"
handler="org.apache.cocoon.portal.util.AspectDataFieldHandler">
+      <bind-xml name="aspect"/>
+    </field>
+  </class>
+
+  <class name="org.apache.cocoon.portal.factory.impl.AbstractProducible"
+    extends="org.apache.cocoon.portal.aspect.impl.AbstractAspectalizable">
+    <field name="name" type="java.lang.String">
+      <bind-xml name="name" node="attribute"/>
+    </field>
+    <field name="id" type="java.lang.String">
+      <bind-xml name="id" node="attribute"/>
+    </field>
+  </class>
+
+  <class name="org.apache.cocoon.portal.layout.AbstractParameters">
+    <field name="parameters" type="org.apache.cocoon.portal.pluto.om.common.ParameterImpl"
collection="set"
+      get-method="getCastorParameters" set-method="addParameter">
+      <bind-xml name="parameter" node="element"/>
+    </field>
+  </class>
+
+  <class name="org.apache.cocoon.portal.layout.AbstractLayout"
+    extends="org.apache.cocoon.portal.factory.impl.AbstractProducible">
+    <field name="layoutRendererName" type="java.lang.String">
+      <bind-xml name="layout-renderer-name" node="attribute"/>
+    </field>
+    <field name="parameters" type="org.apache.cocoon.portal.pluto.om.common.ParameterImpl"
collection="set"
+      get-method="getCastorParameters" set-method="addParameter">
+      <bind-xml name="parameter" node="element"/>
+    </field>
+  </class>
+
+  <class name="org.apache.cocoon.portal.layout.impl.LinkLayout"
+    extends="org.apache.cocoon.portal.layout.AbstractLayout">
+    <map-to xml="link-layout"/>
+    <field name="layoutKey" type="java.lang.String">
+      <bind-xml name="layout-key" node="attribute"/>
+    </field>
+    <field name="layoutId" type="java.lang.String">
+      <bind-xml name="layout-id" node="attribute"/>
+    </field>
+  </class>
+
+  <class name="org.apache.cocoon.portal.layout.impl.CompositeLayoutImpl"
+    extends="org.apache.cocoon.portal.layout.AbstractLayout">
+    <map-to xml="composite-layout"/>
+    <field name="items" type="org.apache.cocoon.portal.layout.Item"
+      collection="collection"
+      set-method="addItem"
+      get-method="getItems">
+      <bind-xml auto-naming="deriveByClass"/>
+    </field>
+  </class>
+
+  <class name="org.apache.cocoon.portal.layout.impl.FrameLayout"
+    extends="org.apache.cocoon.portal.layout.AbstractLayout">
+    <map-to xml="frame-layout"/>
+    <field name="source" type="java.lang.String"/>
+  </class>
+
+  <class name="org.apache.cocoon.portal.layout.Item"
+    extends="org.apache.cocoon.portal.layout.AbstractParameters">
+    <field name="layout" type="org.apache.cocoon.portal.layout.Layout">
+      <bind-xml auto-naming="deriveByClass"/>
+    </field>
+  </class>
+
+  <class name="org.apache.cocoon.portal.layout.NamedItem"
+    extends="org.apache.cocoon.portal.layout.Item">
+    <map-to xml="named-item"/>
+    <field name="name" type="java.lang.String">
+      <bind-xml name="name" node="attribute"/>
+    </field>
+  </class>
+
+  <class name="org.apache.cocoon.portal.pluto.om.common.ParameterImpl">
+    <field name="name" type="java.lang.String">
+      <bind-xml name="name" node="attribute"/>
+    </field>
+
+    <field name="value">
+      <bind-xml name="value" node="attribute"/>
+    </field>
+  </class>
+
+  <class name="org.exolab.castor.mapping.MapItem">
+    <field name="key" type="java.lang.String">
+      <bind-xml name="name"/>
+    </field>
+
+    <field name="value">
+      <bind-xml name="value"/>
+    </field>
+  </class>
+
+  <class name="org.apache.cocoon.portal.layout.impl.CopletLayout" auto-complete="false"
+    extends="org.apache.cocoon.portal.layout.AbstractLayout">
+    <map-to xml="coplet-layout"/>
 
-	<class name="org.apache.cocoon.portal.aspect.impl.AbstractAspectalizable">
-        <field name="persistentAspectData" type="org.exolab.castor.mapping.MapItem" collection="map"
handler="org.apache.cocoon.portal.util.AspectDataFieldHandler">
-            <bind-xml name="aspect"/>
-        </field>
-    </class>
-
-	<class name="org.apache.cocoon.portal.factory.impl.AbstractProducible"
-	       extends="org.apache.cocoon.portal.aspect.impl.AbstractAspectalizable">
-        <field name="name" type="java.lang.String">
-            <bind-xml name="name" node="attribute" />
-        </field>
-        <field name="id" type="java.lang.String" >
-            <bind-xml name="id" node="attribute" />
-        </field>
-    </class>
-
-	<class name="org.apache.cocoon.portal.layout.AbstractParameters">
-        <field name="parameters" type="org.apache.cocoon.portal.util.AttributedMapItem"
collection="map" handler="org.apache.cocoon.portal.util.ParameterFieldHandler">
-            <bind-xml name="parameter" />
-        </field>
-    </class>
-    
-    <class name="org.apache.cocoon.portal.layout.AbstractLayout"
-           extends="org.apache.cocoon.portal.factory.impl.AbstractProducible">
-        <field name="layoutRendererName" type="java.lang.String">
-            <bind-xml name="layout-renderer-name" node="attribute" />
-        </field>
-        <field name="parameters" type="org.exolab.castor.mapping.MapItem" collection="map"
handler="org.apache.cocoon.portal.util.ParameterFieldHandler">
-            <bind-xml name="parameter" />
-        </field>
-    </class>
-    
-    <class name="org.apache.cocoon.portal.layout.impl.LinkLayout"
-           extends="org.apache.cocoon.portal.layout.AbstractLayout">
-        <map-to xml="link-layout" />
-        <field name="layoutKey" type="java.lang.String">
-            <bind-xml name="layout-key" node="attribute" />
-        </field>
-        <field name="layoutId" type="java.lang.String">
-            <bind-xml name="layout-id" node="attribute" />
-        </field>
-    </class>
-
-    <class name="org.apache.cocoon.portal.layout.impl.CompositeLayoutImpl"
-           extends="org.apache.cocoon.portal.layout.AbstractLayout">
-        <map-to xml="composite-layout"/>
-        <field name="items" type="org.apache.cocoon.portal.layout.Item" 
-               collection="collection" 
-               set-method="addItem"
-               get-method="getItems">
-            <bind-xml auto-naming="deriveByClass" />
-        </field>
-    </class>
-
-   <class name="org.apache.cocoon.portal.layout.impl.FrameLayout"
-           extends="org.apache.cocoon.portal.layout.AbstractLayout">
-        <map-to xml="frame-layout" />
-        <field name="source" type="java.lang.String" />
-    </class>
-
-    <class name="org.apache.cocoon.portal.layout.Item"
-           extends="org.apache.cocoon.portal.layout.AbstractParameters">
-        <field name="layout" type="org.apache.cocoon.portal.layout.Layout">
-            <bind-xml auto-naming="deriveByClass" />
-        </field>
-    </class>
-
-    <class name="org.apache.cocoon.portal.layout.NamedItem"
-           extends="org.apache.cocoon.portal.layout.Item">
-        <map-to xml="named-item" />
-        <field name="name" type="java.lang.String">
-            <bind-xml name="name" node="attribute" />
-        </field>
-    </class>
-
-	<class name="org.exolab.castor.mapping.MapItem">
-		<field name="key" type="java.lang.String">
-			<bind-xml name="name"/>
-		</field>
-
-		<field name="value">
-			<bind-xml name="value"/>
-		</field>
-	</class>
-
-	<class name="org.apache.cocoon.portal.util.AttributedMapItem">
-		<field name="key" type="java.lang.String">
-			<bind-xml name="name" node="attribute"/>
-		</field>
-
-		<field name="value" type="java.lang.String">
-			<bind-xml name="value" node="attribute"/>
-		</field>
-	</class>
-
-    <class name="org.apache.cocoon.portal.layout.impl.CopletLayout" auto-complete="false"
-           extends="org.apache.cocoon.portal.layout.AbstractLayout">
-        <map-to xml="coplet-layout" />
-
-		<field name="copletInstanceData" type="java.lang.String" handler="org.apache.cocoon.portal.util.CopletInstanceDataReferenceFieldHandler"/>
-    </class>
+    <field name="copletInstanceData" type="java.lang.String" handler="org.apache.cocoon.portal.util.CopletInstanceDataReferenceFieldHandler"/>
+  </class>
 
 </mapping>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletApplicationDefinitionImpl.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletApplicationDefinitionImpl.java?view=diff&rev=106442&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletApplicationDefinitionImpl.java&r1=106441&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletApplicationDefinitionImpl.java&r2=106442
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletApplicationDefinitionImpl.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletApplicationDefinitionImpl.java
Wed Nov 24 10:53:23 2004
@@ -26,6 +26,7 @@
 import org.apache.pluto.om.servlet.WebApplicationDefinition;
 import org.apache.cocoon.portal.pluto.om.common.AbstractSupportSet;
 import org.apache.cocoon.portal.pluto.om.common.Support;
+import org.apache.cocoon.portal.PortalService;
 
 /**
  * 
@@ -42,8 +43,9 @@
 
     protected String appId;
     protected String version;
+    protected PortletDefinitionRegistryImpl registry;
+
 
-    
     private ArrayList customPortletMode = new ArrayList();
     private ArrayList customPortletState = new ArrayList();
     private ArrayList userAttribute = new ArrayList();
@@ -56,6 +58,22 @@
     private ObjectID objectId;
 
     private String contextPath;
+
+    /*
+     * (non-Javadoc)
+     * @return The PortletDefinitionRegistryImpl.
+     */
+    public PortletDefinitionRegistryImpl getRegistry() {
+        return this.registry;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @param service The PortletDefnitionRegistryImpl.
+     */
+    public void setRegistry(PortletDefinitionRegistryImpl registry) {
+        this.registry = registry;
+    }
 
     /* (non-Javadoc)
      * @see org.apache.pluto.om.portlet.PortletApplicationDefinition#getId()

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletEntityImpl.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletEntityImpl.java?view=diff&rev=106442&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletEntityImpl.java&r1=106441&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletEntityImpl.java&r2=106442
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletEntityImpl.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/PortletEntityImpl.java
Wed Nov 24 10:53:23 2004
@@ -19,6 +19,7 @@
 import java.util.Locale;
 
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
+import org.apache.cocoon.portal.pluto.om.common.PreferenceSetImpl;
 import org.apache.pluto.om.common.Description;
 import org.apache.pluto.om.common.ObjectID;
 import org.apache.pluto.om.common.PreferenceSet;
@@ -33,7 +34,7 @@
  *
  * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  * 
- * @version CVS $Id: PortletEntityImpl.java,v 1.2 2004/03/05 13:02:15 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public class PortletEntityImpl implements PortletEntity, PortletEntityCtrl {
 
@@ -95,7 +96,7 @@
      * @see org.apache.pluto.om.entity.PortletEntity#getPreferenceSet()
      */
     public PreferenceSet getPreferenceSet() {
-        return this.definition.getPreferenceSet();
+        return this.coplet.getPreferences();
     }
 
     /**
@@ -110,28 +111,28 @@
      * @see org.apache.pluto.om.entity.PortletEntityCtrl#reset()
      */
     public void reset() throws IOException {
-        // TODO Auto-generated method stub
+        // This method doesn't seem to be called by anything.
     }
 
     /* (non-Javadoc)
      * @see org.apache.pluto.om.entity.PortletEntityCtrl#setId(java.lang.String)
      */
     public void setId(String id) {
-        // TODO Auto-generated method stub
+        // This method doesn't seem to be called by anything.
     }
 
-    /* (non-Javadoc)
+    /* (non-Javadoc) This method doesn't seem to be called by anything.
      * @see org.apache.pluto.om.entity.PortletEntityCtrl#setPortletDefinition(org.apache.pluto.om.portlet.PortletDefinition)
      */
     public void setPortletDefinition(PortletDefinition portletDefinition) {
-        // TODO Auto-generated method stub
+        // This method doesn't seem to be called by anything
     }
 
     /* (non-Javadoc)
      * @see org.apache.pluto.om.entity.PortletEntityCtrl#store()
      */
     public void store() throws IOException {
-        // TODO Auto-generated method stub
+        coplet.getProfileManager().saveUserCopletInstance(null);
     }
 
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/common/PreferenceSetImpl.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/common/PreferenceSetImpl.java?view=diff&rev=106442&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/common/PreferenceSetImpl.java&r1=106441&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/common/PreferenceSetImpl.java&r2=106442
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/common/PreferenceSetImpl.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/common/PreferenceSetImpl.java
Wed Nov 24 10:53:23 2004
@@ -19,6 +19,7 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import javax.portlet.PreferencesValidator;
 
@@ -34,17 +35,18 @@
  * 
  * @version CVS $Id$
  */
-public class PreferenceSetImpl extends HashSet
+public class PreferenceSetImpl
 implements PreferenceSet, PreferenceSetCtrl, java.io.Serializable {
 
     private String castorPreferencesValidator; 
     private ClassLoader classLoader;
+    private Set preferences = new HashSet();
 
     // PreferenceSet implementation.
 
     public Preference get(String name)
     {
-        Iterator iterator = this.iterator();
+        Iterator iterator = this.preferences.iterator();
         while (iterator.hasNext()) {
             Preference preference = (Preference)iterator.next();
             if (preference.getName().equals(name)) {
@@ -54,6 +56,10 @@
         return null;
     }
 
+    public Iterator iterator() {
+        return this.preferences.iterator();
+    }
+
     public PreferencesValidator getPreferencesValidator()
     {
         if (this.classLoader == null)
@@ -80,18 +86,23 @@
         preference.setName(name);
         preference.setValues(values);
 
-        super.add(preference);
+        this.preferences.add(preference);
 
         return preference;
     }
 
+    public boolean add(Preference preference) {
+        return this.preferences.add(preference);
+    }
+
+
     public Preference remove(String name)
     {
         Iterator iterator = this.iterator();
         while (iterator.hasNext()) {
             Preference preference = (Preference)iterator.next();
             if (preference.getName().equals(name)) {
-                super.remove(preference);
+                this.preferences.remove(preference);
                 return preference;
             }
         }
@@ -100,7 +111,7 @@
 
     public void remove(Preference preference)
     {
-        super.remove(preference);
+        this.preferences.remove(preference);
     }
 
     // additional methods.
@@ -136,9 +147,9 @@
         this.castorPreferencesValidator = castorPreferencesValidator;
     }
 
-    public Collection getCastorPreferences()
+    public Set getPreferences()
     {
-        return this;
+        return this.preferences;
     }
 
     public void setClassLoader(ClassLoader loader)

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/portletdefinitionmapping.xml
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/portletdefinitionmapping.xml?view=diff&rev=106442&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/portletdefinitionmapping.xml&r1=106441&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/portletdefinitionmapping.xml&r2=106442
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/portletdefinitionmapping.xml
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/om/portletdefinitionmapping.xml
Wed Nov 24 10:53:23 2004
@@ -104,7 +104,7 @@
 
   <class name="org.apache.cocoon.portal.pluto.om.common.PreferenceSetImpl">
       
-    <field name="castorPreferences" type="org.apache.cocoon.portal.pluto.om.common.PreferenceImpl"
collection="collection">
+    <field name="preferences" type="org.apache.cocoon.portal.pluto.om.common.PreferenceImpl"
collection="set">
       <bind-xml name="portlet:preference" node="element"/>
     </field>
     <field name="castorPreferencesValidator" type="java.lang.String">
@@ -172,8 +172,7 @@
       <bind-xml name="portlet:portlet-info" node="element"/>
     </field>
 
-   <field name="castorPreferences"
-           type="org.apache.cocoon.portal.pluto.om.common.PreferenceSetImpl">
+   <field name="castorPreferences" type="org.apache.cocoon.portal.pluto.om.common.PreferenceSetImpl">
       <bind-xml name="portlet:portlet-preferences" node="element"/>
     </field>
     <field name="castorInitSecurityRoleRefs"

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/test/TestPortlet.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/test/TestPortlet.java?view=diff&rev=106442&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/test/TestPortlet.java&r1=106441&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/test/TestPortlet.java&r2=106442
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/test/TestPortlet.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/pluto/test/TestPortlet.java
Wed Nov 24 10:53:23 2004
@@ -17,6 +17,8 @@
 
 import java.io.IOException;
 import java.io.Writer;
+import java.util.Map;
+import java.util.Iterator;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -28,13 +30,14 @@
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.WindowState;
+import javax.portlet.PortletPreferences;
 
 /**
  * This is a very simple test portlet
  *
  * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  * 
- * @version CVS $Id: TestPortlet.java,v 1.6 2004/03/16 15:56:43 cziegeler Exp $
+ * @version CVS $Id$
  */
 public class TestPortlet implements Portlet  {
     
@@ -57,7 +60,19 @@
      */
     public void processAction(ActionRequest req, ActionResponse res)
     throws PortletException, IOException {
-        // nothing to do
+
+        PortletPreferences prefs = req.getPreferences();
+        String key = req.getParameter("name");
+        String value = req.getParameter("value");
+        if (key != null && value != null) {
+            prefs.setValue(key, value);
+            try {
+              prefs.store();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+         // nothing to do
     }
 
     /* (non-Javadoc)
@@ -72,12 +87,46 @@
         writer.write("<p>I'm running in: " + req.getPortalContext().getPortalInfo());
         writer.write("<p>Current portlet mode: " + req.getPortletMode() + "</p>");
         writer.write("<p>Current window state: " + req.getWindowState() + "</p>");
-        writer.write("<table><tr><td>Change Portlet Mode:</td>");
+        writer.write("<p>Portlet Preferences:</p>");
+        PortletPreferences prefs = req.getPreferences();
+        Map map = prefs.getMap();
+        Iterator iter = map.keySet().iterator();
+        while (iter.hasNext()) {
+            String key = (String)iter.next();
+            String[] values = (String [])map.get(key);
+            if (values.length == 1) {
+                writer.write("    Key: " + key + " Value: " + values[0] + "<br />");
+            } else if (values.length > 1) {
+                writer.write("    Key: " + key + " Value: " + values[0] + "<br />");
+                for (int i=1; i < values.length; ++i) {
+                    writer.write("       ");
+                    for (int j=0; j < key.length(); ++j) {
+                        writer.write(" ");
+                    }
+                    writer.write(" Value: " + values[i] + "<br />");
+                }
+            } else {
+                writer.write("    Key: " + key + " Value: <br />");
+            }
+        }
+
         PortletURL url;
+        url = res.createActionURL();
+        url.setPortletMode(PortletMode.EDIT);
+
+        writer.write("<form method=\"POST\" action=\"" + url.toString() + "\"><br
/>");
+        writer.write("Update Preferences: <br />");
+        writer.write("  Key: <input type=\"text\" name=\"name\" size=\"16\" maxlength=\"16\">");
+        writer.write("  Value: <input type=\"text\" name=\"value\" size=\"32\" maxlength=\"32\">");
+        writer.write("<br /><input type=\"submit\" value=\"Update Preferences\"/>");
+        writer.write("</form>");
+        writer.write("<table><tr><td>Change Portlet Mode:</td>");
+
         url = res.createRenderURL();
         url.setPortletMode(PortletMode.EDIT);
         this.writeLink(writer, url, "Edit");
-        
+
+
         url = res.createRenderURL();
         url.setPortletMode(PortletMode.HELP);
         this.writeLink(writer, url, "Help");

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java?view=diff&rev=106442&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java&r1=106441&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java&r2=106442
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java
Wed Nov 24 10:53:23 2004
@@ -93,7 +93,19 @@
      * Save the profile
      */
     void saveUserProfiles(String layoutKey);
-    
+
+    /**
+     * Save the layout
+     * @param layoutKey
+     */
+    void saveUserLayout(String layoutKey);
+
+    /**
+     * Save the coplet instance
+     * @param layoutKey
+     */
+    void saveUserCopletInstance(String layoutKey);
+
     /**
      * Get all instances
      */

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java?view=diff&rev=106442&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java&r1=106441&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java&r2=106442
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
Wed Nov 24 10:53:23 2004
@@ -62,7 +62,22 @@
      * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserProfiles(String)
      */
     public void saveUserProfiles(String layoutKey) {
-        // overwrite in subclass
+        saveUserCopletInstance(layoutKey);
+        saveUserLayout(layoutKey);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserCopletInstance(String)
+     */
+    public void saveUserCopletInstance(String layoutKey) {
+        // override in subclass
+    }
+
+    /* (non-Javadoc)
+    * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserLayout(String)
+    */
+    public void saveUserLayout(String layoutKey) {
+        // override in subclass
     }
 
     /* (non-Javadoc)

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java?view=diff&rev=106442&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java&r1=106441&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java&r2=106442
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
Wed Nov 24 10:53:23 2004
@@ -135,6 +135,7 @@
         Iterator iter =  copletInstanceDataManager.getCopletInstanceData().values().iterator();
         while ( iter.hasNext() ) {
             CopletInstanceData cid = (CopletInstanceData) iter.next();
+            cid.setProfileManager(this);
             CopletAdapter adapter = null;
             try {
                 adapter = (CopletAdapter) adapterSelector.select(cid.getCopletData().getCopletBaseData().getCopletAdapterName());
@@ -146,47 +147,82 @@
         
         return layout;
     }
-    
-    public void saveUserProfiles(String layoutKey) {
-		ProfileLS adapter = null;
-		PortalService service = null;
-		try {
-			adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
-			service = (PortalService) this.manager.lookup(PortalService.ROLE);
-            if ( layoutKey == null ) {
+
+    public void saveUserCopletInstance(String layoutKey) {
+        ProfileLS adapter = null;
+        PortalService service = null;
+        try {
+            adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
+            service = (PortalService) this.manager.lookup(PortalService.ROLE);
+            if (layoutKey == null) {
                 layoutKey = service.getDefaultLayoutKey();
             }
-            
+
             RequestState state = this.getRequestState();
             UserHandler handler = state.getHandler();
 
-			HashMap parameters = new HashMap();
-			parameters.put("type", "user");
-            parameters.put("config", state.getApplicationConfiguration().getConfiguration("portal").getChild("profiles"));
+            HashMap parameters = new HashMap();
+            parameters.put("type", "user");
+            parameters.put("config",
+                state.getApplicationConfiguration().getConfiguration("portal").getChild("profiles"));
             parameters.put("handler", handler);
             parameters.put("profiletype", "copletinstancedata");
 
-			Map key = this.buildKey(service, parameters, layoutKey, false);
-	
-			// save coplet instance data
-            CopletInstanceDataManager profileManager = ((CopletInstanceDataManager)service.getAttribute("CopletInstanceData:"
+ layoutKey));
-			adapter.saveProfile(key, parameters, profileManager);
+            Map key = this.buildKey(service, parameters, layoutKey, false);
+
+            // save coplet instance data
+            CopletInstanceDataManager profileManager = ((CopletInstanceDataManager) service.getAttribute("CopletInstanceData:"
+
+                layoutKey));
+            adapter.saveProfile(key, parameters, profileManager);
+        }
+        catch (Exception e) {
+            // TODO
+            throw new CascadingRuntimeException("Exception during save profile", e);
+        }
+        finally {
+            this.manager.release(adapter);
+            this.manager.release(service);
+        }
+    }
+
+    public void saveUserLayout(String layoutKey) {
+        ProfileLS adapter = null;
+        PortalService service = null;
+        try {
+            adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
+            service = (PortalService) this.manager.lookup(PortalService.ROLE);
+            if (layoutKey == null) {
+                layoutKey = service.getDefaultLayoutKey();
+            }
 
-			// save coplet instance data
-			parameters.put("profiletype", "layout");
+            RequestState state = this.getRequestState();
+            UserHandler handler = state.getHandler();
+
+            HashMap parameters = new HashMap();
+            parameters.put("type", "user");
+            parameters.put("config",
+                state.getApplicationConfiguration().getConfiguration("portal").getChild("profiles"));
+            parameters.put("handler", handler);
+
+            Map key = this.buildKey(service, parameters, layoutKey, false);
+
+            // save layout data
+            parameters.put("profiletype", "layout");
             key = this.buildKey(service, parameters, layoutKey, false);
-			Layout layout = (Layout)service.getAttribute("Layout:" + layoutKey);
-			adapter.saveProfile(key, parameters, layout);
-            
-		} catch (Exception e) {
-			// TODO
-			throw new CascadingRuntimeException("Exception during save profile", e);
-		} finally {
-			this.manager.release(adapter);
-			this.manager.release(service);
-		}
+            Layout layout = (Layout) service.getAttribute("Layout:" + layoutKey);
+            adapter.saveProfile(key, parameters, layout);
+
+        }
+        catch (Exception e) {
+            // TODO
+            throw new CascadingRuntimeException("Exception during save profile", e);
+        }
+        finally {
+            this.manager.release(adapter);
+            this.manager.release(service);
+        }
     }
-    
+
 	/**
 	 * Gets a profile and applies possible user and role deltas to it.
 	 */
@@ -331,6 +367,9 @@
 			}
 
 			return new Object[] {object, Boolean.TRUE};
+        } catch (SourceNotFoundException se) {
+            this.getLogger().warn("Unable to locate profile: " + se.getMessage());
+            throw se;
         } catch (ProfileException pe) {
             this.getLogger().error("Error loading profile: " + pe.getMessage(), pe);
             throw pe;

Mime
View raw message