Author: chris.laprun(a)jboss.com
Date: 2010-02-23 13:00:04 -0500 (Tue, 23 Feb 2010)
New Revision: 1825
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
Log:
- GTNPORTAL-737: forgot to properly persist the fact that we had a cloned context.
- Fixed an issue where we could get a ClassCastException when updating WSRP state
(actually, this is still not quite clear why this happens).
- Added note after investigating consumer-side management of clones to revisit current
design as it's not adapted to support that use case.
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java 2010-02-23
16:55:05 UTC (rev 1824)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java 2010-02-23
18:00:04 UTC (rev 1825)
@@ -24,7 +24,6 @@
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.model.ApplicationState;
import org.exoplatform.portal.config.model.ApplicationType;
-import org.exoplatform.portal.config.model.PersistentApplicationState;
import org.exoplatform.portal.config.model.TransientApplicationState;
import org.exoplatform.portal.pc.ExoPortletState;
import org.exoplatform.portal.pc.ExoPortletStateType;
@@ -200,6 +199,13 @@
}
};
+ /**
+ * todo: this ModelAdapter is not quite good, what is really needed is a
ModelAdapter<WSRP, byte[]> so that the
+ * StatefulPortletContext returned by getPortletContext is actually of type
PortletStateType.OPAQUE so that it
+ * can be properly handled in WSRP...
+ * This model needs to be revisited if we want to properly support consumer-side state
management.
+ * See GTNPORTAL-736.
+ */
private static final ModelAdapter<WSRP, WSRP> WSRP = new ModelAdapter<WSRP,
WSRP>()
{
@Override
@@ -222,8 +228,10 @@
WSRP wsrp = dataStorage.load(state, ApplicationType.WSRP_PORTLET);
if (wsrp == null)
{
+ // create and save state
wsrp = new WSRP();
wsrp.setPortletId(applicationId);
+ dataStorage.save(state, wsrp);
}
return StatefulPortletContext.create(wsrp.getPortletId(),
WSRPPortletStateType.instance, wsrp);
}
@@ -240,9 +248,10 @@
}
else
{
- PersistentApplicationState<WSRP> persistentState =
(PersistentApplicationState<WSRP>)state;
+ //todo: it is possible to get a CloneApplicationState for some reason, need
to investigate
+
DataStorage dataStorage =
(DataStorage)container.getComponentInstanceOfType(DataStorage.class);
- return dataStorage.save(persistentState, updateState);
+ return dataStorage.save(state, updateState);
}
}
};
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-02-23
16:55:05 UTC (rev 1824)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-02-23
18:00:04 UTC (rev 1825)
@@ -742,6 +742,8 @@
{
WSRP wsrp = (WSRP)preferencesPortletContext.getState();
AccessMode accessMode = AccessMode.CLONE_BEFORE_WRITE;
+
+ // if the portlet is a cloned one already, we can modify it directly instead of
requesting a clone
if (wsrp.isCloned())
{
accessMode = AccessMode.READ_WRITE;
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-02-23
16:55:05 UTC (rev 1824)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-02-23
18:00:04 UTC (rev 1825)
@@ -114,6 +114,7 @@
{
WSRP wsrp = new WSRP();
wsrp.setPortletId(clonedContext.getId());
+ wsrp.setCloned(true); // mark the state as cloned
// if we have an associated state, record it as well...
if (clonedContext instanceof StatefulPortletContext)