Author: ilya
Date: 2007-03-06 11:47:53 -0500 (Tue, 06 Mar 2007)
New Revision: 73823

Modified:
   
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/ChangeLog
   
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPProfileProvider.cs
   
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPUserProfile.cs
Log:
1. Support of PortalPreferences, not defined in Web.config (and defined in 
portlet.xml)
2. Bug fixes



Modified: 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/ChangeLog
===================================================================
--- 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/ChangeLog
   2007-03-06 16:43:53 UTC (rev 73822)
+++ 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/ChangeLog
   2007-03-06 16:47:53 UTC (rev 73823)
@@ -1,3 +1,9 @@
+03-06-2007    Ilya Kharmatsky    <ilyak -at- mainsoft.com>
+       
+       * WPUserProfile.cs: added support for PortalPreferences (defined in
+       portlet.xml and not defined in Web.config)
+       * WPProfileProvider.cs: fixed action/render phases related code.
+
 03-04-2007    Ilya Kharmatsky    <ilyak -at- mainsoft.com>
 
        * WPUserProfile.cs: refactored.

Modified: 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPProfileProvider.cs
===================================================================
--- 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPProfileProvider.cs
        2007-03-06 16:43:53 UTC (rev 73822)
+++ 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPProfileProvider.cs
        2007-03-06 16:47:53 UTC (rev 73823)
@@ -95,9 +95,7 @@
 
         public override SettingsPropertyValueCollection 
GetPropertyValues(SettingsContext context, SettingsPropertyCollection 
properties)
         {
-            
             SettingsPropertyValueCollection settings = new 
SettingsPropertyValueCollection();
-            PortletRequest pr = null;
             if (properties.Count == 0)
                 return settings;
 
@@ -109,19 +107,6 @@
 #endif
                 return settings;
             }
-            if (!IsInActionPhase)
-            {
-//                throw new ApplicationException("The portlet is not in the 
process action phase");
-                pr = PortletUtils.getPortletRequest();
-                if (pr != null)
-                {
-                    SettingsPropertyValueCollection storedValues = 
-                        
(SettingsPropertyValueCollection)pr.getAttribute("VMW_PROPERTY_VALUES");
-                    if (storedValues != null)
-                        return storedValues;
-                }
-                return settings;
-            }
 
             foreach (SettingsProperty property in properties)
             {
@@ -134,17 +119,17 @@
                 settings.Add(new SettingsPropertyValue(property));
             }
 
-            Map portletPreferencesMap = pp.getMap();
-            for (Iterator iter = portletPreferencesMap.keySet().iterator(); 
iter.hasNext(); )
+            for(java.util.Enumeration enumer = pp.getNames(); 
enumer.hasMoreElements();)
             {
-                string name = (string)iter.next();
-                string value = (string)portletPreferencesMap.get(name);
+                string name = (string)enumer.nextElement();
 
                 SettingsPropertyValue property = settings[name];
                 
                 if (property == null)
                     continue;
 
+                string value = pp.getValue(name, null);
+
                 if (value == null)
                 {
                     property.IsDirty = false;
@@ -169,33 +154,28 @@
                     property.SerializedValue = value;
                 }
             }
-
-            pr = (pr == null) ? PortletUtils.getPortletRequest() : pr;
-            if (pr != null)
-            {
-                pr.setAttribute("VMW_PROPERTY_VALUES", settings);
-            }
             return settings;
 
         }
 
         public override void SetPropertyValues(SettingsContext context, 
SettingsPropertyValueCollection collection)
         {
-            PortletPreferences pp = PortletPreferences;
-            if (pp == null)
+            if (!IsInActionPhase)
             {
 #if DEBUG
-                Console.WriteLine("Cannot obtain PortletPreferences");
+                Console.WriteLine("The portlet not in the process action 
phase");
 #endif
                 return;
             }
-            if (!IsInActionPhase)
+            PortletPreferences pp = PortletPreferences;
+            if (pp == null)
             {
 #if DEBUG
-                Console.WriteLine("The portlet not in the process action 
phace");
+                Console.WriteLine("Cannot obtain PortletPreferences");
 #endif
-                throw new ApplicationException("The portlet is not in the 
process action phase");
+                return;
             }
+            
             try
             {
                 string username = (string)context["UserName"];

Modified: 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPUserProfile.cs
===================================================================
--- 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPUserProfile.cs
    2007-03-06 16:43:53 UTC (rev 73822)
+++ 
trunk/mcs/class/Mainsoft.Web/Mainsoft.Web.J2EE.WAS/Mainsoft.Web.Profile/WPUserProfile.cs
    2007-03-06 16:47:53 UTC (rev 73823)
@@ -44,6 +44,7 @@
     {
         private WPUser _user;
 
+        
         public WPUserProfile()
         {
             _user = new WPUser();
@@ -53,6 +54,52 @@
         {
             get { return _user; }
         }
+
+        public override object this[string propertyName]
+        {
+            get
+            {
+                
+                    if(Properties[propertyName] != null)
+                        return base[propertyName];
+                    return GetFromPortletPreferences(propertyName);            
  
+            }
+            set
+            {
+                    if (Properties[propertyName] != null)
+                        base[propertyName] = value;
+                    else
+                        SetInPortletPreferences(propertyName, value);
+            }
+        }
+
+        private object GetFromPortletPreferences(string propertyName)
+        {
+
+            javax.portlet.PortletPreferences prefs = Preferences;
+            if (prefs == null)
+                return null;
+
+            return prefs.getValue(propertyName, "NOT FOUND");
+        }
+
+        private void SetInPortletPreferences(string propName, object val)
+        {
+            javax.portlet.PortletPreferences prefs = Preferences;
+            prefs.setValue(propName, val.ToString());
+            prefs.store();
+        }
+
+        private javax.portlet.PortletPreferences Preferences
+        {
+            get
+            {
+                javax.portlet.PortletRequest pr = 
PortletUtils.getPortletRequest();
+                if (pr == null || !(pr is javax.portlet.ActionRequest))
+                    return null;
+                return pr.getPreferences();
+            }
+        }
     }
 
     /// <summary>

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to