Author: julien(a)jboss.com
Date: 2007-02-14 16:49:58 -0500 (Wed, 14 Feb 2007)
New Revision: 6283
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyContext.java
trunk/portlet/src/main/org/jboss/portal/portlet/state/PropertyContext.java
Log:
don't use the InstanceContext.getAccessMode() during render as this value cannot be
passed in WSRP
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java 2007-02-14
20:27:24 UTC (rev 6282)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java 2007-02-14
21:49:58 UTC (rev 6283)
@@ -134,7 +134,7 @@
value = prefs.getValue(key);
// If does not exist or read only use what the default one
- if (value == null || prefs.isPortletReadOnly(key))
+ if (value == null || isReadOnly(key))
{
value = prefs.getPortletValue(key);
}
@@ -182,7 +182,17 @@
{
throw new IllegalArgumentException("key must not be null");
}
- return prefs.isReadOnly() || prefs.isPortletReadOnly(key);
+ if (mode == ACTION)
+ {
+ // The accurate value is to combine what the portlet developer and the consumer
specifies
+ return prefs.isReadOnly() || prefs.isReadOnly(key);
+ }
+ else
+ {
+ // During render we cannot be aware of the consumer
+ // intent with respect to the access mode of the current state
+ return prefs.isReadOnly(key);
+ }
}
public void reset(String key) throws IllegalArgumentException, ReadOnlyException
@@ -238,18 +248,21 @@
throw new IllegalStateException("Store must be called within the scope of
an action request");
}
+ // Copy the transient set to the persistent set if the consumer allows it
+ if (prefs.isReadOnly())
+ {
+ throw new IOException("Should not happen");
+ }
+
// If the optional validator is present validate
if (validator != null)
{
validator.validate(this);
}
- // Copy the transient set to the persistent set if possible
- if (prefs.isReadOnly() == false)
- {
- PropertyChange[] changes = (PropertyChange[])updates.values().toArray(new
PropertyChange[updates.size()]);
- prefs.update(changes);
- }
+ //
+ PropertyChange[] changes = (PropertyChange[])updates.values().toArray(new
PropertyChange[updates.size()]);
+ prefs.update(changes);
// Clear the updates
updates.clear();
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyContext.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyContext.java 2007-02-14
20:27:24 UTC (rev 6282)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyContext.java 2007-02-14
21:49:58 UTC (rev 6283)
@@ -144,7 +144,7 @@
return null;
}
- public boolean isPortletReadOnly(String key) throws IllegalArgumentException
+ public boolean isReadOnly(String key) throws IllegalArgumentException
{
PreferenceInfo pref = portletPrefs.getPreference(key);
if (pref != null)
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/state/PropertyContext.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/state/PropertyContext.java 2007-02-14
20:27:24 UTC (rev 6282)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/state/PropertyContext.java 2007-02-14
21:49:58 UTC (rev 6283)
@@ -51,7 +51,9 @@
Value getValue(String key) throws IllegalArgumentException;
/**
- * Return true if the preferences are read only.
+ * Return true if the preferences are globally read only. The value returned by
+ * this method is valid only during the action request. Any call to this method
+ * during the render request will produce a non accurate value.
*
* @return true if the preferences are read only
*/
@@ -83,11 +85,11 @@
Value getPortletValue(String key) throws IllegalArgumentException;
/**
- * Say if the key is marked as read only or not.
+ * Say if the property key is marked as read only or not.
*
* @param key the requested key
* @return the read only value
* @throws IllegalArgumentException if the key or the array is null
*/
- boolean isPortletReadOnly(String key) throws IllegalArgumentException;
+ boolean isReadOnly(String key) throws IllegalArgumentException;
}