[gatein-commits] gatein SVN: r6261 - in portal/trunk: webui/portal/src/main/java/org/exoplatform/portal/webui/application and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sun Apr 17 15:18:01 EDT 2011
Author: chris.laprun at jboss.com
Date: 2011-04-17 15:18:00 -0400 (Sun, 17 Apr 2011)
New Revision: 6261
Modified:
portal/trunk/pom.xml
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java
portal/trunk/wsrp-integration/extension-component/src/test/java/org/gatein/integration/wsrp/structure/MOPConsumerStructureProviderTestCase.java
Log:
- Updated to use WSRP 2.1.0-Beta02 and PC 2.3.0-Beta02 so that tests can be performed.
- Use proper PortletContext methods in ModelAdapter to avoid exposing internals of the portlet container.
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2011-04-17 18:06:47 UTC (rev 6260)
+++ portal/trunk/pom.xml 2011-04-17 19:18:00 UTC (rev 6261)
@@ -46,9 +46,9 @@
<nl.captcha.simplecaptcha.version>1.1.1-GA-Patch01</nl.captcha.simplecaptcha.version>
<org.gatein.common.version>2.0.4-Beta02</org.gatein.common.version>
<org.gatein.wci.version>2.1.0-Beta02</org.gatein.wci.version>
- <org.gatein.pc.version>2.3.0-Beta01</org.gatein.pc.version>
+ <org.gatein.pc.version>2.3.0-Beta02</org.gatein.pc.version>
<org.picketlink.idm>1.1.8.GA</org.picketlink.idm>
- <org.gatein.wsrp.version>2.1.0-Beta01</org.gatein.wsrp.version>
+ <org.gatein.wsrp.version>2.1.0-Beta02</org.gatein.wsrp.version>
<org.gatein.mop.version>1.0.6-Beta01</org.gatein.mop.version>
<org.slf4j.version>1.5.6</org.slf4j.version>
<rhino.version>1.6R5</rhino.version>
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 2011-04-17 18:06:47 UTC (rev 6260)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ModelAdapter.java 2011-04-17 19:18:00 UTC (rev 6261)
@@ -49,6 +49,7 @@
*/
public abstract class ModelAdapter<S, C extends Serializable>
{
+ private static final String LOCAL_STATE_ID = PortletContext.LOCAL_CONSUMER_CLONE.getId();
public static <S, C extends Serializable, I> ModelAdapter<S, C> getAdapter(ApplicationType<S> type)
{
@@ -82,7 +83,7 @@
@Override
public StatefulPortletContext<ExoPortletState> getPortletContext(ExoContainer container, String applicationId,
- ApplicationState<Portlet> applicationState) throws Exception
+ ApplicationState<Portlet> applicationState) throws Exception
{
DataStorage dataStorage = (DataStorage)container.getComponentInstanceOfType(DataStorage.class);
Portlet preferences = dataStorage.load(applicationState, ApplicationType.PORTLET);
@@ -95,12 +96,12 @@
map.getState().put(pref.getName(), pref.getValues());
}
}
- return StatefulPortletContext.create("local._dumbvalue", ExoPortletStateType.getInstance(), map);
+ return StatefulPortletContext.create(LOCAL_STATE_ID, ExoPortletStateType.getInstance(), map);
}
@Override
public ApplicationState<Portlet> update(ExoContainer container, ExoPortletState updateState,
- ApplicationState<Portlet> applicationState) throws Exception
+ ApplicationState<Portlet> applicationState) throws Exception
{
// Compute new preferences
PortletBuilder builder = new PortletBuilder();
@@ -128,8 +129,7 @@
String[] chunks = Utils.split("/", applicationState);
String appName = chunks[0];
String portletName = chunks[1];
- return PortletContext.createPortletContext(PortletInvoker.LOCAL_PORTLET_INVOKER_ID + "./" + appName + "."
- + portletName);
+ return PortletContext.reference(PortletInvoker.LOCAL_PORTLET_INVOKER_ID, PortletContext.createPortletContext(appName, portletName));
}
@Override
@@ -140,7 +140,9 @@
TransientApplicationState<Portlet> transientState = (TransientApplicationState<Portlet>)applicationState;
Portlet pref = transientState.getContentState();
if (pref == null)
+ {
pref = new Portlet();
+ }
return pref;
}
else
@@ -148,18 +150,20 @@
DataStorage dataStorage = (DataStorage)container.getComponentInstanceOfType(DataStorage.class);
Portlet pref = dataStorage.load(applicationState, ApplicationType.PORTLET);
if (pref == null)
+ {
pref = new Portlet();
+ }
return pref;
}
}
@Override
public ExoPortletState getStateFromModifiedContext(PortletContext originalPortletContext,
- PortletContext modifiedPortletContext)
+ PortletContext modifiedPortletContext)
{
if (modifiedPortletContext != null && modifiedPortletContext instanceof StatefulPortletContext)
{
- StatefulPortletContext statefulContext = (StatefulPortletContext) modifiedPortletContext;
+ StatefulPortletContext statefulContext = (StatefulPortletContext)modifiedPortletContext;
if (statefulContext.getState() instanceof ExoPortletState)
{
return (ExoPortletState)statefulContext.getState();
@@ -170,11 +174,11 @@
@Override
public ExoPortletState getstateFromClonedContext(PortletContext originalPortletContext,
- PortletContext clonedPortletContext)
+ PortletContext clonedPortletContext)
{
if (clonedPortletContext != null && clonedPortletContext instanceof StatefulPortletContext)
{
- StatefulPortletContext statefulContext = (StatefulPortletContext) clonedPortletContext;
+ StatefulPortletContext statefulContext = (StatefulPortletContext)clonedPortletContext;
if (statefulContext.getState() instanceof ExoPortletState)
{
return (ExoPortletState)statefulContext.getState();
@@ -184,18 +188,15 @@
}
};
+ private static final String DASHBOARD = "dashboard";
+ private static final String GADGET_PORTLET = "GadgetPortlet";
+ private static final PortletContext WRAPPER_CONTEXT = PortletContext.reference(PortletInvoker.LOCAL_PORTLET_INVOKER_ID, PortletContext.createPortletContext(DASHBOARD, GADGET_PORTLET));
+ private static final String WRAPPER_ID = WRAPPER_CONTEXT.getId();
private static final ModelAdapter<Gadget, ExoPortletState> GADGET = new ModelAdapter<Gadget, ExoPortletState>()
{
-
- /** . */
- private final String WRAPPER_ID = "local./" + "dashboard" + "." + "GadgetPortlet";
-
- /** . */
- private final PortletContext WRAPPER_CONTEXT = PortletContext.createPortletContext(WRAPPER_ID);
-
@Override
public StatefulPortletContext<ExoPortletState> getPortletContext(ExoContainer container, String applicationId,
- ApplicationState<Gadget> applicationState) throws Exception
+ ApplicationState<Gadget> applicationState) throws Exception
{
GadgetRegistryService gadgetService =
(GadgetRegistryService)container.getComponentInstanceOfType(GadgetRegistryService.class);
@@ -203,12 +204,12 @@
String url = GadgetUtil.reproduceUrl(model.getUrl(), model.isLocal());
ExoPortletState prefs = new ExoPortletState(WRAPPER_ID);
prefs.getState().put("url", Arrays.asList(url));
- return StatefulPortletContext.create("local._dumbvalue", ExoPortletStateType.getInstance(), prefs);
+ return StatefulPortletContext.create(LOCAL_STATE_ID, ExoPortletStateType.getInstance(), prefs);
}
@Override
public ApplicationState<Gadget> update(ExoContainer container, ExoPortletState updateState,
- ApplicationState<Gadget> gadgetApplicationState) throws Exception
+ ApplicationState<Gadget> gadgetApplicationState) throws Exception
{
throw new UnsupportedOperationException("Cannot edit gadget preferences");
}
@@ -228,11 +229,11 @@
@Override
public ExoPortletState getStateFromModifiedContext(PortletContext originalPortletContext,
- PortletContext modifiedPortletContext)
+ PortletContext modifiedPortletContext)
{
if (modifiedPortletContext != null && modifiedPortletContext instanceof StatefulPortletContext)
{
- StatefulPortletContext statefulContext = (StatefulPortletContext) modifiedPortletContext;
+ StatefulPortletContext statefulContext = (StatefulPortletContext)modifiedPortletContext;
if (statefulContext.getState() instanceof ExoPortletState)
{
return (ExoPortletState)statefulContext.getState();
@@ -243,11 +244,11 @@
@Override
public ExoPortletState getstateFromClonedContext(PortletContext originalPortletContext,
- PortletContext clonedPortletContext)
+ PortletContext clonedPortletContext)
{
if (clonedPortletContext != null && clonedPortletContext instanceof StatefulPortletContext)
{
- StatefulPortletContext statefulContext = (StatefulPortletContext) clonedPortletContext;
+ StatefulPortletContext statefulContext = (StatefulPortletContext)clonedPortletContext;
if (statefulContext.getState() instanceof ExoPortletState)
{
return (ExoPortletState)statefulContext.getState();
@@ -259,10 +260,9 @@
/**
* 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.
+ * 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>()
{
@@ -280,7 +280,7 @@
@Override
public StatefulPortletContext<WSRP> getPortletContext(ExoContainer container, String applicationId,
- ApplicationState<WSRP> state) throws Exception
+ ApplicationState<WSRP> state) throws Exception
{
DataStorage dataStorage = (DataStorage)container.getComponentInstanceOfType(DataStorage.class);
WSRP wsrp = dataStorage.load(state, ApplicationType.WSRP_PORTLET);
@@ -319,11 +319,11 @@
@Override
public WSRP getStateFromModifiedContext(PortletContext originalPortletContext,
- PortletContext modifiedPortletContext)
+ PortletContext modifiedPortletContext)
{
WSRP wsrp = new WSRP();
wsrp.setPortletId(modifiedPortletContext.getId());
-
+
// from the originalPortletContext see if we are dealing with a cloned context or not.
if (originalPortletContext instanceof StatefulPortletContext)
{
@@ -333,7 +333,7 @@
wsrp.setCloned(((WSRP)originalState).isCloned());
}
}
-
+
if (modifiedPortletContext instanceof StatefulPortletContext)
{
Object modifiedState = ((StatefulPortletContext)modifiedPortletContext).getState();
@@ -342,7 +342,7 @@
wsrp.setState((byte[])modifiedState);
}
}
-
+
return wsrp;
}
@@ -352,14 +352,14 @@
WSRP wsrp = new WSRP();
wsrp.setPortletId(clonedPortletContext.getId());
wsrp.setCloned(true);
-
+
// if we have an associated state, record it as well...
if (clonedPortletContext instanceof StatefulPortletContext)
{
StatefulPortletContext statefulPortletContext = (StatefulPortletContext)clonedPortletContext;
wsrp.setState((byte[])statefulPortletContext.getState());
}
-
+
return wsrp;
}
};
@@ -367,10 +367,10 @@
public abstract PortletContext getProducerOfferedPortletContext(String applicationId);
public abstract StatefulPortletContext<C> getPortletContext(ExoContainer container, String applicationId,
- ApplicationState<S> applicationState) throws Exception;
+ ApplicationState<S> applicationState) throws Exception;
public abstract ApplicationState<S> update(ExoContainer container, C updateState,
- ApplicationState<S> applicationState) throws Exception;
+ ApplicationState<S> applicationState) throws Exception;
/**
* Returns the state of the gadget as preferences or null if the preferences cannot be edited as such.
@@ -381,21 +381,21 @@
* @throws Exception any exception
*/
public abstract Portlet getState(ExoContainer container, ApplicationState<S> applicationState) throws Exception;
-
+
/**
* Extracts the state based on what the current PortletContext is and the new modified PortletContext.
- *
+ *
* @param originalPortletContext The current PortletContext for the Portlet
* @param modifiedPortletContext The new modified PortletContext
* @return
*/
public abstract C getStateFromModifiedContext(PortletContext originalPortletContext, PortletContext modifiedPortletContext);
-
+
/**
* Extracts the state based on what the current PortletContext is and the new cloned PortletContext
- *
+ *
* @param originalPortletContext The current PortletContext for the Portlet
- * @param clonedPortletContext The new cloned PortletContext
+ * @param clonedPortletContext The new cloned PortletContext
* @return
*/
public abstract C getstateFromClonedContext(PortletContext originalPortletContext, PortletContext clonedPortletContext);
Modified: portal/trunk/wsrp-integration/extension-component/src/test/java/org/gatein/integration/wsrp/structure/MOPConsumerStructureProviderTestCase.java
===================================================================
--- portal/trunk/wsrp-integration/extension-component/src/test/java/org/gatein/integration/wsrp/structure/MOPConsumerStructureProviderTestCase.java 2011-04-17 18:06:47 UTC (rev 6260)
+++ portal/trunk/wsrp-integration/extension-component/src/test/java/org/gatein/integration/wsrp/structure/MOPConsumerStructureProviderTestCase.java 2011-04-17 19:18:00 UTC (rev 6261)
@@ -88,7 +88,7 @@
public void testAssignPortletToWindow()
{
- String newCustomizationId = "new";
+ String newCustomizationId = "/app.new";
String newWindowName = "portlet";
provider.assignPortletToWindow(PortletContext.createPortletContext(newCustomizationId), "window11", "page1", newWindowName);
verify(structureAccess).getWindowFrom(getIdFor("window11"));
More information about the gatein-commits
mailing list