[jboss-cvs] jboss-portal/portlet/src/main/org/jboss/portal/portlet/state/producer ...
Julien Viet
julien at jboss.com
Wed Aug 23 08:55:01 EDT 2006
User: julien
Date: 06/08/23 08:55:01
Modified: portlet/src/main/org/jboss/portal/portlet/state/producer
StatefulPortletInvoker.java
Log:
updated implementation of PortletInvoker.setProperties(...) to use a list of property changes instead of a PropertyMap in order to match WSRP semantics
Revision Changes Path
1.14 +48 -14 jboss-portal/portlet/src/main/org/jboss/portal/portlet/state/producer/StatefulPortletInvoker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StatefulPortletInvoker.java
===================================================================
RCS file: /cvsroot/jboss/jboss-portal/portlet/src/main/org/jboss/portal/portlet/state/producer/StatefulPortletInvoker.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- StatefulPortletInvoker.java 22 Aug 2006 14:51:48 -0000 1.13
+++ StatefulPortletInvoker.java 23 Aug 2006 12:55:01 -0000 1.14
@@ -33,6 +33,7 @@
import org.jboss.portal.portlet.InvalidPortletIdException;
import org.jboss.portal.portlet.state.AccessMode;
import org.jboss.portal.portlet.state.AbstractPropertyContext;
+import org.jboss.portal.portlet.state.PropertyChange;
import org.jboss.portal.portlet.info.PreferenceInfo;
import org.jboss.portal.portlet.info.PreferencesInfo;
import org.jboss.portal.portlet.info.PortletInfo;
@@ -41,11 +42,10 @@
import java.util.Iterator;
import java.util.Set;
-import java.util.ArrayList;
/**
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.13 $
+ * @version $Revision: 1.14 $
*/
public class StatefulPortletInvoker extends AbstractJBossService implements PortletInvoker
{
@@ -396,8 +396,6 @@
}
}
-
-
public PropertyMap getProperties(String portletId, Set keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
if (keys == null)
@@ -476,15 +474,23 @@
}
}
- public void setProperties(String portletId, PropertyMap properties) throws PortletInvokerException
+ public void setProperties(String portletId, PropertyChange[] changes) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
if (portletId == null)
{
throw new IllegalArgumentException("No null portlet id accepted");
}
- if (properties == null)
+ if (changes == null)
+ {
+ throw new IllegalArgumentException("No null changes accepted");
+ }
+ for (int i = 0; i < changes.length; i++)
+ {
+ PropertyChange change = changes[i];
+ if (change == null)
{
- throw new IllegalArgumentException("No null properties accepted");
+ throw new IllegalArgumentException("No null change accepted");
+ }
}
if (portletId.startsWith(CLONE_ID_PREFIX) == false)
{
@@ -515,23 +521,51 @@
//
PreferencesInfo prefs = referencedPortletInfo.getPreferences();
- // Clone argument
- properties = new SimplePropertyMap(properties);
+ // Clone the current state
+ PropertyMap properties = new SimplePropertyMap(state.getProperties());
- // Remove read only values
- for (Iterator i = new ArrayList(properties.keySet()).iterator();i.hasNext();)
+ // Clone argument
+ for (int i = 0; i < changes.length; i++)
{
- String key = (String)i.next();
- Value value = properties.getProperty(key);
+ PropertyChange change = changes[i];
+ String key = change.getKey();
+ int type = change.getType();
+
+ // If the original value exist and is read only we perform a reset instead
PreferenceInfo pref = prefs.getPreference(key);
if (pref != null)
{
if (Boolean.TRUE.equals(pref.isReadOnly()))
{
- properties.setProperty(key, null);
+ type = PropertyChange.PREF_RESET;
+ }
+ }
+
+ //
+ if (type == PropertyChange.PREF_UPDATE)
+ {
+ properties.setProperty(key, change.getValue());
}
+ else
+ {
+ properties.remove(key);
}
}
+//
+// // Remove read only values
+// for (Iterator i = new ArrayList(properties.keySet()).iterator();i.hasNext();)
+// {
+// String key = (String)i.next();
+// Value value = properties.getProperty(key);
+// PreferenceInfo pref = prefs.getPreference(key);
+// if (pref != null)
+// {
+// if (Boolean.TRUE.equals(pref.isReadOnly()))
+// {
+// properties.setProperty(key, null);
+// }
+// }
+// }
//
stateStore.updateState(stateId, properties);
More information about the jboss-cvs-commits
mailing list