Author: julien(a)jboss.com
Date: 2007-02-19 07:26:51 -0500 (Mon, 19 Feb 2007)
New Revision: 6331
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/PortletManagerBean.java
trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java
trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java
trunk/core/src/main/org/jboss/portlet/JBossPortletPreferences.java
trunk/portlet-federation/src/main/org/jboss/portal/test/portlet/federation/FederatingPortletInvokerTestCase.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerInvoker.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferenceInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/info/PreferenceInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyContext.java
trunk/portlet/src/main/org/jboss/portal/portlet/state/PropertyContext.java
trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/PreferenceInfoSupport.java
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/PreferencesInfoSupport.java
trunk/portlet/src/main/org/jboss/portal/portlet/test/support/PortletInvokerSupport.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/info/PortletInfoTest.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/info/PreferenceInfoTest.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java
Log:
removed the defaultValue from the PreferenceInfo interface in order to simplify the
implementations of the PreferenceInfo interfaces
Modified:
trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -56,7 +56,6 @@
import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.support.info.PreferencesInfoSupport;
import org.jboss.portal.portlet.info.MetaInfo;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -120,8 +119,6 @@
public TestPortletSupport()
{
- PreferencesInfoSupport prefs = this.info.getPreferencesSupport();
- prefs.addPreference("_abc", new StringValue("_def"));
this.info.getMetaSupport().setDisplayName("Foo");
}
@@ -317,13 +314,8 @@
public void testConfigureInstance() throws Exception
{
- portletContainer.addPortlet("MyPortlet", new PortletSupport()
- {
- {
- PreferencesInfoSupport prefs = info.getPreferencesSupport();
- prefs.addPreference("abc", new StringValue("def"));
- }
- });
+ PortletInvokerSupport.InternalPortlet internalPortlet =
portletContainer.addInternalPortlet("MyPortlet", new PortletSupport());
+ internalPortlet.addPreference("abc", new StringValue("def"));
//
Instance instance = instanceContainer.createDefinition("MyInstance",
"MyPortlet", true);
@@ -424,13 +416,14 @@
public void execute() throws Exception
{
- portletContainer.addPortlet("MyPortlet", new TestPortletSupport()
+ PortletInvokerSupport.InternalPortlet internalPortlet =
portletContainer.addInternalPortlet("MyPortlet", new TestPortletSupport()
{
public PortletInvocationResponse execute()
{
return TestCloneBeforeWrite.this.execute(this);
}
});
+ internalPortlet.addPreference("_abc", new
StringValue("_def"));
String popId = getSinglePOP().getContext().getId();
//
@@ -694,7 +687,7 @@
public void testDestroyCCPInstance() throws Exception
{
- portletContainer.addPortlet("MyPortlet", new TestPortletSupport()
+ PortletInvokerSupport.InternalPortlet internalPortlet =
portletContainer.addInternalPortlet("MyPortlet", new TestPortletSupport()
{
public PortletInvocationResponse execute()
{
@@ -702,6 +695,7 @@
return null;
}
});
+ internalPortlet.addPreference("_abc", new
StringValue("_def"));
// Create the instance
TransactionAssert.beginTransaction();
@@ -762,7 +756,8 @@
public void testRecreate() throws Exception
{
- portletContainer.addPortlet("MyPortlet", new TestPortletSupport());
+ PortletInvokerSupport.InternalPortlet internalPortlet =
portletContainer.addInternalPortlet("MyPortlet", new TestPortletSupport());
+ internalPortlet.addPreference("_abc", new
StringValue("_def"));
//
TransactionAssert.beginTransaction();
@@ -790,7 +785,8 @@
public void testCreateDefinitionThrowsDuplicateInstanceException() throws
PortletInvokerException, DuplicateInstanceException
{
- portletContainer.addPortlet("MyPortlet", new TestPortletSupport());
+ PortletInvokerSupport.InternalPortlet internalPortlet =
portletContainer.addInternalPortlet("MyPortlet", new TestPortletSupport());
+ internalPortlet.addPreference("_abc", new
StringValue("_def"));
//
TransactionAssert.beginTransaction();
Modified: trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java 2007-02-18
14:40:32 UTC (rev 6330)
+++ trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -55,7 +55,6 @@
import org.jboss.portal.portlet.state.SimplePropertyMap;
import org.jboss.portal.portlet.state.producer.PortletState;
import org.jboss.portal.portlet.state.producer.PortletStateContext;
-import org.jboss.portal.portlet.support.info.PreferencesInfoSupport;
import org.jboss.portal.portlet.test.ActionContextImpl;
import org.jboss.portal.portlet.test.InstanceContextImpl;
import org.jboss.portal.portlet.test.UserContextImpl;
@@ -214,10 +213,9 @@
runtimeContext.addBean("HibernateConfig",
HibernateSupport.getConfig(dataSourceConfigParameter.getName()));
runtimeContext.start();
- portletContainer.addPortlet("SimplePortlet", new PortletSupport()
+ PortletInvokerSupport.InternalPortlet internalSimplePortlet =
portletContainer.addInternalPortlet("SimplePortlet", new PortletSupport()
{
{
- info.getPreferencesSupport().addPreference("abc", new
StringValue("def"));
info.getMetaSupport().setDisplayName("SimplePortlet");
}
@@ -228,14 +226,10 @@
return null;
}
});
+ internalSimplePortlet.addPreference("abc", new
StringValue("def"));
- portletContainer.addPortlet("CloningPortlet", new PortletSupport()
+ PortletInvokerSupport.InternalPortlet internalCloningPortlet =
portletContainer.addInternalPortlet("CloningPortlet", new PortletSupport()
{
- {
- PreferencesInfoSupport prefs = info.getPreferencesSupport();
- prefs.addPreference("abc", new StringValue("def"));
- }
-
public PortletInvocationResponse invoke(PortletInvocation invocation)
{
AbstractPropertyContext props =
(AbstractPropertyContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PREFERENCES_ATTRIBUTE);
@@ -243,14 +237,10 @@
return null;
}
});
+ internalCloningPortlet.addPreference("abc", new
StringValue("def"));
- portletContainer.addPortlet("CloneFailedCloningPortlet", new
PortletSupport()
+ PortletInvokerSupport.InternalPortlet internalCloneFailedCloningPortlet =
portletContainer.addInternalPortlet("CloneFailedCloningPortlet", new
PortletSupport()
{
- {
- PreferencesInfoSupport prefs = info.getPreferencesSupport();
- prefs.addPreference("abc", new StringValue("def"));
- }
-
public PortletInvocationResponse invoke(PortletInvocation invocation)
{
try
@@ -265,14 +255,10 @@
return null;
}
});
+ internalCloneFailedCloningPortlet.addPreference("abc", new
StringValue("def"));
- portletContainer.addPortlet("CloningPortletThrowingRuntimeException", new
PortletSupport()
+ PortletInvokerSupport.InternalPortlet
internalCloningPortletThrowingRuntimeException =
portletContainer.addInternalPortlet("CloningPortletThrowingRuntimeException",
new PortletSupport()
{
- {
- PreferencesInfoSupport prefs = info.getPreferencesSupport();
- prefs.addPreference("abc", new StringValue("def"));
- }
-
public PortletInvocationResponse invoke(PortletInvocation invocation)
{
AbstractPropertyContext props =
(AbstractPropertyContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PREFERENCES_ATTRIBUTE);
@@ -280,6 +266,7 @@
throw new RuntimeException("custom_message");
}
});
+ internalCloningPortletThrowingRuntimeException.addPreference("abc", new
StringValue("def"));
// Create registration
if (useRegistration)
Modified: trunk/core/src/main/org/jboss/portlet/JBossPortletPreferences.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossPortletPreferences.java 2007-02-18 14:40:32
UTC (rev 6330)
+++ trunk/core/src/main/org/jboss/portlet/JBossPortletPreferences.java 2007-02-19 12:26:51
UTC (rev 6331)
@@ -25,6 +25,7 @@
import org.jboss.portal.common.util.ProxyInfo;
import org.jboss.portal.portlet.impl.jsr168.PortletPreferencesImpl;
import org.jboss.portal.portlet.state.PropertyContext;
+import org.jboss.portal.portlet.container.info.ContainerPreferencesInfo;
import javax.portlet.PreferencesValidator;
import java.lang.reflect.InvocationHandler;
@@ -44,11 +45,12 @@
public JBossPortletPreferences(
PropertyContext manager,
+ ContainerPreferencesInfo containerPrefs,
PreferencesValidator validator,
int mode,
ProxyInfo proxyInfo)
{
- super(manager, validator, mode);
+ super(manager, containerPrefs, validator, mode);
this.proxyInfo = proxyInfo;
}
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/PortletManagerBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/PortletManagerBean.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/core-admin/src/main/org/jboss/portal/core/portlet/management/PortletManagerBean.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -37,6 +37,7 @@
import org.jboss.logging.Logger;
import org.jboss.portal.common.util.LocalizedString;
import org.jboss.portal.common.value.Value;
+import org.jboss.portal.common.value.StringValue;
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.faces.matrix.Cell;
import org.jboss.portal.faces.matrix.Row;
@@ -311,7 +312,7 @@
//
PreferenceInfo prefs = prefsInfo.getPreference(key);
- Value value = prefs.getDefaultValue();
+ Value value = new StringValue();
Boolean readOnly = prefs.isReadOnly();
//
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerInvoker.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerInvoker.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerInvoker.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -33,11 +33,14 @@
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.container.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.container.info.ContainerPreferencesInfo;
+import org.jboss.portal.portlet.container.info.ContainerPreferenceInfo;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.state.PropertyChange;
import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.portlet.state.SimplePropertyMap;
import java.util.HashMap;
import java.util.HashSet;
@@ -202,22 +205,56 @@
}
}
- public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PropertyMap getProperties(PortletContext portletContext, Set keys) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
- throw new UnsupportedOperationException();
+ PortletImpl portlet = (PortletImpl)portlets.get(portletContext.getId());
+ if (portlet == null)
+ {
+ throw new NoSuchPortletException(portletContext.getId());
+ }
+ ContainerPortletInfo info = (ContainerPortletInfo)portlet.getInfo();
+ ContainerPreferencesInfo prefs = (ContainerPreferencesInfo)info.getPreferences();
+ PropertyMap result = new SimplePropertyMap();
+ for (Iterator i = keys.iterator();i.hasNext();)
+ {
+ String key = (String)i.next();
+ ContainerPreferenceInfo pref = prefs.getContainerPreference(key);
+ if (pref != null)
+ {
+ result.put(key, pref.getDefaultValue());
+ }
+ }
+ return result;
}
- public List destroyClones(List portletContexts) throws IllegalArgumentException,
PortletInvokerException, UnsupportedOperationException
+ public PropertyMap getProperties(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
- throw new UnsupportedOperationException();
+ PortletImpl portlet = (PortletImpl)portlets.get(portletContext.getId());
+ if (portlet == null)
+ {
+ throw new NoSuchPortletException(portletContext.getId());
+ }
+ ContainerPortletInfo info = (ContainerPortletInfo)portlet.getInfo();
+ ContainerPreferencesInfo prefs = (ContainerPreferencesInfo)info.getPreferences();
+ PropertyMap result = new SimplePropertyMap();
+ for (Iterator i = prefs.getKeys().iterator();i.hasNext();)
+ {
+ String key = (String)i.next();
+ ContainerPreferenceInfo pref = prefs.getContainerPreference(key);
+ if (pref != null)
+ {
+ result.put(key, pref.getDefaultValue());
+ }
+ }
+ return result;
}
- public PropertyMap getProperties(PortletContext portletContext, Set keys) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public PropertyMap getProperties(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public List destroyClones(List portletContexts) throws IllegalArgumentException,
PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferenceInfo.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferenceInfo.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferenceInfo.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -68,6 +68,11 @@
return readOnly;
}
+ /**
+ * Return the value provided by the portlet.xml deployment descriptor.
+ *
+ * @return the preference value associated with this preference meta data
+ */
public Value getDefaultValue()
{
return value;
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-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -27,6 +27,8 @@
import org.jboss.portal.common.value.Value;
import org.jboss.portal.portlet.state.PropertyChange;
import org.jboss.portal.portlet.state.PropertyContext;
+import org.jboss.portal.portlet.container.info.ContainerPreferenceInfo;
+import org.jboss.portal.portlet.container.info.ContainerPreferencesInfo;
import javax.portlet.PortletPreferences;
import javax.portlet.PreferencesValidator;
@@ -66,6 +68,9 @@
protected final PreferencesValidator validator;
/** . */
+ protected final ContainerPreferencesInfo containerPrefs;
+
+ /** . */
protected final int mode;
/** Keep track of updates */
@@ -73,11 +78,13 @@
public PortletPreferencesImpl(
PropertyContext prefs,
+ ContainerPreferencesInfo containerPrefs,
PreferencesValidator validator,
int mode)
{
this.prefs = prefs;
this.validator = validator;
+ this.containerPrefs = containerPrefs;
this.mode = mode;
this.updates = new HashMap();
}
@@ -115,7 +122,7 @@
private Value getValue(String key)
{
- Value value;
+ Value value = null;
PropertyChange change = (PropertyChange)updates.get(key);
if (change != null)
{
@@ -125,7 +132,11 @@
}
else
{
- value = prefs.getPortletValue(key);
+ ContainerPreferenceInfo containerPref =
containerPrefs.getContainerPreference(key);
+ if (containerPref != null)
+ {
+ value = containerPref.getDefaultValue();
+ }
}
}
else
@@ -136,7 +147,11 @@
// If does not exist or read only use what the default one
if (value == null || isReadOnly(key))
{
- value = prefs.getPortletValue(key);
+ ContainerPreferenceInfo containerPref =
containerPrefs.getContainerPreference(key);
+ if (containerPref != null)
+ {
+ value = containerPref.getDefaultValue();
+ }
}
}
return value;
@@ -279,10 +294,10 @@
super(10);
//
- for (Iterator i = prefs.getPortletKeys().iterator(); i.hasNext();)
+ for (Iterator i = containerPrefs.getKeys().iterator(); i.hasNext();)
{
String key = (String)i.next();
- String[] value = prefs.getPortletValue(key).asStringArray();
+ String[] value =
containerPrefs.getContainerPreference(key).getDefaultValue().asStringArray();
String[] clone = new String[value.length];
System.arraycopy(value, 0, clone, 0, value.length);
super.put(key, clone);
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestImpl.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestImpl.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -29,6 +29,7 @@
import org.jboss.portal.portlet.container.PortletContainer;
import org.jboss.portal.portlet.container.info.ContainerPortletInfo;
import org.jboss.portal.portlet.container.info.ContentTypes;
+import org.jboss.portal.portlet.container.info.ContainerPreferencesInfo;
import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.spi.InstanceContext;
@@ -109,11 +110,12 @@
this.portalContext = new PortalContextImpl(invocation.getPortalContext());
this.parameters = null;
+ //
int mode = this instanceof RenderRequest ? PortletPreferencesImpl.RENDER :
PortletPreferencesImpl.ACTION;
PropertyContext prefs =
(PropertyContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PREFERENCES_ATTRIBUTE);
PreferencesValidator validator = container.getPreferencesValidator();
-
- this.preferences = new PortletPreferencesImpl(prefs, validator, mode);
+ ContainerPreferencesInfo containerPrefs =
(ContainerPreferencesInfo)container.getInfo().getPreferences();
+ this.preferences = new PortletPreferencesImpl(prefs, containerPrefs, validator,
mode);
}
// PLT.11.1.1
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/info/PreferenceInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/info/PreferenceInfo.java 2007-02-18
14:40:32 UTC (rev 6330)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/info/PreferenceInfo.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -69,5 +69,5 @@
*
* @return the default value
*/
- Value getDefaultValue();
+// Value getDefaultValue();
}
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-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/state/AbstractPropertyContext.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -134,16 +134,6 @@
return portletPrefs.getKeys();
}
- public Value getPortletValue(String key) throws IllegalArgumentException
- {
- PreferenceInfo pref = portletPrefs.getPreference(key);
- if (pref != null)
- {
- return pref.getDefaultValue();
- }
- return null;
- }
-
public boolean isReadOnly(String key) throws IllegalArgumentException
{
PreferenceInfo pref = portletPrefs.getPreference(key);
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-18
14:40:32 UTC (rev 6330)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/state/PropertyContext.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -76,15 +76,6 @@
Set getPortletKeys() throws IllegalArgumentException;
/**
- * Return for a key a value or null if no suitable value is found.
- *
- * @param key the requested key
- * @return the found value or null
- * @throws IllegalArgumentException if the key or the array is null
- */
- Value getPortletValue(String key) throws IllegalArgumentException;
-
- /**
* Say if the property key is marked as read only or not.
*
* @param key the requested key
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/state/producer/ProducerPortletInvoker.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -56,6 +56,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -194,7 +196,7 @@
AccessMode access = instanceCtx.getAccessMode();
// Get a state contxt for the portlet context
- InternalPortletContext context = getStateContext(portletContext);
+ InternalContext context = getStateContext(portletContext);
// If it is a producer offered portlet we consider read-write as read-only
if (context.isStateful() == false && access == AccessMode.READ_WRITE)
@@ -203,10 +205,10 @@
}
// Get the portlet container and set it on invocation
- Portlet portlet =
portletInvoker.getPortlet(PortletContext.createPortletContext(context.getPortletId()));
+ Portlet portlet = portletInvoker.getPortlet(context.getPortletContext());
if (portlet == null)
{
- throw new NoSuchPortletException("Portlet " + context.getPortletId() +
" not found", context.getPortletId());
+ throw new NoSuchPortletException("Portlet " +
context.getPortletContext() + " not found", context.getPortletId());
}
// Create prefs
@@ -218,7 +220,7 @@
PortletInvocationResponse response;
try
{
- invocation.setAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE,
PortletContext.createPortletContext(context.getPortletId()));
+ invocation.setAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, context.getPortletContext());
invocation.setAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PREFERENCES_ATTRIBUTE, prefs);
invocation.setInfo(info);
@@ -283,18 +285,7 @@
else
{
// Add the missing mutable portlet state
- for (Iterator i = prefsInfo.getKeys().iterator(); i.hasNext();)
- {
- String key = (String)i.next();
- if (!newPrefs.keySet().contains(key))
- {
- PreferenceInfo pref = prefsInfo.getPreference(key);
- if (Boolean.FALSE.equals(pref.isReadOnly()))
- {
- newPrefs.setProperty(key, pref.getDefaultValue());
- }
- }
- }
+ getPropertiesFromMetaData(portlet.getContext(), newPrefs);
// Create the new state
String cloneStateId =
persistenceManager.createState(context.getPortletId(), newPrefs);
@@ -354,7 +345,7 @@
//
String portletId = portletContext.getId();
- InternalPortletContext context = getStateContext(portletContext);
+ InternalContext context = getStateContext(portletContext);
boolean useStore = stateManagementPolicy.persistLocally();
//
@@ -385,14 +376,8 @@
}
else
{
- PropertyMap originalState = getPropertiesFromMetaData(portletId);
PropertyMap newState = new SimplePropertyMap();
- for (Iterator i = originalState.keySet().iterator(); i.hasNext();)
- {
- String key = (String)i.next();
- Value originalValue = originalState.getProperty(key);
- newState.setProperty(key, originalValue);
- }
+ getPropertiesFromMetaData(portletContext, newState);
if (useStore)
{
String cloneId = persistenceManager.createState(portletId, newState);
@@ -472,7 +457,7 @@
//
String portletId = portletContext.getId();
- InternalPortletContext context = getStateContext(portletContext);
+ InternalContext context = getStateContext(portletContext);
//
if (context.isStateful())
@@ -483,40 +468,29 @@
PropertyMap props = new SimplePropertyMap(statefulContext.getProperties());
// Dereference the portlet
- String referencedPortletId = context.getPortletId();
+ PortletContext refPortletContext = context.getPortletContext();
- // Get the container
- Portlet referencedPortlet =
portletInvoker.getPortlet(PortletContext.createPortletContext(referencedPortletId));
+ // Get the referenced portlet
+ Portlet refPortlet = portletInvoker.getPortlet(refPortletContext);
// We need the referenced portlet
- if (referencedPortlet == null)
+ if (refPortlet == null)
{
- throw new PortletInvokerException("The portlet " +
referencedPortletId + " referenced by this clone " + portletId + " is not
available");
+ throw new PortletInvokerException("The portlet " +
refPortletContext + " referenced by this clone " + portletId + " is not
available");
}
- // Get the portlet info
- PortletInfo referencedPortletInfo = referencedPortlet.getInfo();
+ //
+ getPropertiesFromMetaData(refPortletContext, props);
- // Add missing or read only properties from the referenced portlet
- PreferencesInfo prefs = referencedPortletInfo.getPreferences();
- for (Iterator i = prefs.getKeys().iterator(); i.hasNext();)
- {
- String key = (String)i.next();
- PreferenceInfo pref = prefs.getPreference(key);
- if (Boolean.TRUE.equals(pref.isReadOnly()) ||
!props.keySet().contains(pref.getKey()))
- {
- Value defaultValue = pref.getDefaultValue();
- props.setProperty(key, (Value)defaultValue.clone());
- }
- }
-
//
return props;
}
else
{
// Get the container
- return getPropertiesFromMetaData(context.getPortletId());
+ PropertyMap props = new SimplePropertyMap();
+ getPropertiesFromMetaData(context.getPortletContext(), props);
+ return props;
}
}
@@ -541,7 +515,7 @@
//
String portletId = portletContext.getId();
- InternalPortletContext context = getStateContext(portletContext);
+ InternalContext context = getStateContext(portletContext);
//
if (context.isStateful() == false)
@@ -550,16 +524,13 @@
}
StatefulContext statefulContext = (StatefulContext)context;
- // Dereference the portlet
- String referencedPortletId = context.getPortletId();
-
// Get the container
- Portlet referencedPortlet =
portletInvoker.getPortlet(PortletContext.createPortletContext(referencedPortletId));
+ Portlet referencedPortlet =
portletInvoker.getPortlet(context.getPortletContext());
// We need the referenced portlet
if (referencedPortlet == null)
{
- throw new PortletInvokerException("The portlet " + referencedPortletId
+ " referenced by this clone " + portletId + " is not available");
+ throw new PortletInvokerException("The portlet " +
context.getPortletContext() + " referenced by this clone " + portletId + "
is not available");
}
// Get the portlet info
@@ -620,7 +591,7 @@
}
else
{
- return marshall(referencedPortletId, properties);
+ return marshall(context.getPortletId(), properties);
}
}
@@ -641,29 +612,40 @@
/**
* Retrieve the properties from the portlet meta data.
*
- * @param portletId the portlet id
+ * @param portletContext the portlet context
* @return the properties
* @throws PortletInvokerException
*/
- private PropertyMap getPropertiesFromMetaData(String portletId) throws
PortletInvokerException
+ private void getPropertiesFromMetaData(PortletContext portletContext, PropertyMap
props) throws PortletInvokerException
{
//
- Portlet portlet =
portletInvoker.getPortlet(PortletContext.createPortletContext(portletId));
+ Portlet portlet = portletInvoker.getPortlet(portletContext);
// The prefs info
PreferencesInfo prefs = portlet.getInfo().getPreferences();
- // Get the state
- PropertyMap property = new SimplePropertyMap();
+ // Collect missing or read only properties from the referenced portlet
+ Set keys = new HashSet();
for (Iterator i = prefs.getKeys().iterator(); i.hasNext();)
{
String key = (String)i.next();
PreferenceInfo pref = prefs.getPreference(key);
- property.setProperty(key, (Value)pref.getDefaultValue().clone());
+ if (Boolean.TRUE.equals(pref.isReadOnly()) ||
!props.keySet().contains(pref.getKey()))
+ {
+ keys.add(key);
+ }
}
- //
- return property;
+ // Get the missing or read only properties from the referenced portlet properties
+ // and add them to the actual state
+ PropertyMap refPreferencesInfo = portletInvoker.getProperties(portletContext,
keys);
+ for (Iterator i = refPreferencesInfo.entrySet().iterator();i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String key = (String)entry.getKey();
+ Value value = (Value)entry.getValue();
+ props.setProperty(key, (Value)value.clone());
+ }
}
/**
@@ -674,7 +656,7 @@
* @throws NoSuchPortletException if the underlying state does not exist
* @throws InvalidPortletIdException if the state id is not valid
*/
- private InternalPortletContext getStateContext(final PortletContext portletContext)
throws NoSuchPortletException, InvalidPortletIdException
+ private InternalContext getStateContext(final PortletContext portletContext) throws
NoSuchPortletException, InvalidPortletIdException
{
byte[] bytes = portletContext.getState();
if (bytes == null)
@@ -719,24 +701,28 @@
/**
* An internal portlet context that describe how the portlet was obtained.
*/
- private abstract static class InternalPortletContext
+ private abstract static class InternalContext
{
/** . */
private final String portletId;
+ /** . */
+ private final PortletContext portletContext;
+
/**
* @return true if the context represent a cloned portlet
*/
public abstract boolean isStateful();
- public InternalPortletContext(String portletId)
+ public InternalContext(String portletId)
{
if (portletId == null)
{
throw new IllegalArgumentException();
}
this.portletId = portletId;
+ this.portletContext = PortletContext.createPortletContext(portletId);
}
/**
@@ -746,12 +732,17 @@
{
return portletId;
}
+
+ public PortletContext getPortletContext()
+ {
+ return portletContext;
+ }
}
/**
* Describe delegate portlets.
*/
- private static class StatelessContext extends InternalPortletContext
+ private static class StatelessContext extends InternalContext
{
public StatelessContext(String portletId)
{
@@ -767,7 +758,7 @@
/**
* A cloned portlet that points to a delegate portlet.
*/
- private abstract static class StatefulContext extends InternalPortletContext
+ private abstract static class StatefulContext extends InternalContext
{
/** . */
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/PreferenceInfoSupport.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/PreferenceInfoSupport.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/PreferenceInfoSupport.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -23,7 +23,6 @@
package org.jboss.portal.portlet.support.info;
import org.jboss.portal.common.util.LocalizedString;
-import org.jboss.portal.common.value.Value;
import org.jboss.portal.portlet.info.PreferenceInfo;
import java.util.Locale;
@@ -47,34 +46,20 @@
/** . */
private Boolean readOnly;
- /** . */
- private Value defaultValue;
-
public PreferenceInfoSupport(String key)
{
this.key = key;
this.displayName = new LocalizedString("Display name of " + key,
Locale.ENGLISH);
this.description = new LocalizedString("Description of " + key,
Locale.ENGLISH);
this.readOnly = null;
- this.defaultValue = null;
}
- public PreferenceInfoSupport(String key, Value defaultValue)
+ public PreferenceInfoSupport(String key, Boolean readOnly)
{
this.key = key;
this.displayName = new LocalizedString("Display name of " + key,
Locale.ENGLISH);
this.description = new LocalizedString("Description of " + key,
Locale.ENGLISH);
- this.readOnly = Boolean.FALSE;
- this.defaultValue = defaultValue;
- }
-
- public PreferenceInfoSupport(String key, Value defaultValue, Boolean readOnly)
- {
- this.key = key;
- this.displayName = new LocalizedString("Display name of " + key,
Locale.ENGLISH);
- this.description = new LocalizedString("Description of " + key,
Locale.ENGLISH);
this.readOnly = readOnly;
- this.defaultValue = defaultValue;
}
public String getKey()
@@ -102,16 +87,6 @@
this.readOnly = readOnly;
}
- public Value getDefaultValue()
- {
- return defaultValue;
- }
-
- public void setDefaultValue(Value defaultValue)
- {
- this.defaultValue = defaultValue;
- }
-
public void setDisplayName(LocalizedString displayName)
{
this.displayName = displayName;
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/PreferencesInfoSupport.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/PreferencesInfoSupport.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/PreferencesInfoSupport.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -69,13 +69,8 @@
preferences.put(key, new PreferenceInfoSupport(key));
}
- public void addPreference(String key, Value value)
+ public void addPreference(String key, Boolean readOnly)
{
- preferences.put(key, new PreferenceInfoSupport(key, value));
+ preferences.put(key, new PreferenceInfoSupport(key, readOnly));
}
-
- public void addPreference(String key, Value value, Boolean readOnly)
- {
- preferences.put(key, new PreferenceInfoSupport(key, value, readOnly));
- }
}
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/test/support/PortletInvokerSupport.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/test/support/PortletInvokerSupport.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/test/support/PortletInvokerSupport.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -35,12 +35,15 @@
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.state.PropertyChange;
import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.portlet.state.SimplePropertyMap;
+import org.jboss.portal.common.value.Value;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Iterator;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -59,24 +62,15 @@
public void setValid(String portletId, boolean valid)
{
- if (portletId == null)
- {
- throw new IllegalArgumentException();
- }
- InternalPortlet portlet = (InternalPortlet)portlets.get(portletId);
- if (portlet == null)
- {
- throw new IllegalArgumentException();
- }
- portlet.setValid(valid);
+ getInternalPortlet(portletId).valid = valid;
}
- public PortletInvokerSupport addPortlet(String portletId, PortletInfoSupport info)
+ public InternalPortlet addInternalPortlet(String portletId, PortletInfoSupport info)
{
- return addPortlet(portletId, new PortletSupport(info));
+ return addInternalPortlet(portletId, new PortletSupport(info));
}
- public PortletInvokerSupport addPortlet(String portletId, PortletSupport support)
+ public InternalPortlet addInternalPortlet(String portletId, PortletSupport support)
{
if (portletId == null)
{
@@ -91,10 +85,10 @@
{
throw new IllegalStateException();
}
- return this;
+ return portlet;
}
- public PortletInvokerSupport removePortlet(String portletId)
+ public PortletInvokerSupport removeInternalPortlet(String portletId)
{
if (portlets.remove(portletId) == null)
{
@@ -103,6 +97,20 @@
return this;
}
+ public InternalPortlet getInternalPortlet(String portletId)
+ {
+ if (portletId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ InternalPortlet portlet = (InternalPortlet)portlets.get(portletId);
+ if (portlet == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return portlet;
+ }
+
public Set getPortlets()
{
return new HashSet(portlets.values());
@@ -139,7 +147,7 @@
return portlet;
}
- private static class InternalPortlet implements Portlet
+ public static class InternalPortlet implements Portlet
{
/** . */
@@ -151,6 +159,9 @@
/** . */
private boolean valid;
+ /** . */
+ private Map state;
+
public InternalPortlet(String portletId, PortletSupport support)
{
if (portletId == null)
@@ -164,8 +175,21 @@
this.portletContext = PortletContext.createPortletContext(portletId);
this.support = support;
this.valid = true;
+ this.state = new HashMap();
}
+ public void addPreference(String key, Value value)
+ {
+ support.getInfoSupport().getPreferencesSupport().addPreference(key);
+ state.put(key, value);
+ }
+
+ public void addPreference(String key, Value value, Boolean readOnly)
+ {
+ support.getInfoSupport().getPreferencesSupport().addPreference(key, readOnly);
+ state.put(key, value);
+ }
+
public PortletContext getContext()
{
return portletContext;
@@ -185,33 +209,50 @@
{
return valid;
}
+ }
- public void setValid(boolean valid)
+ public PropertyMap getProperties(PortletContext portletContext, Set keys) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ InternalPortlet internalPortlet = internalGetPortlet(portletContext);
+ PropertyMap props = new SimplePropertyMap();
+ for (Iterator i = keys.iterator();i.hasNext();)
{
- this.valid = valid;
+ String key = (String)i.next();
+ Value value = (Value)internalPortlet.state.get(key);
+ if (value != null)
+ {
+ props.put(key, value.clone());
+ }
}
+ return props;
}
- public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PropertyMap getProperties(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
- throw new UnsupportedOperationException();
+ InternalPortlet internalPortlet = internalGetPortlet(portletContext);
+ PropertyMap props = new SimplePropertyMap();
+ for (Iterator i = internalPortlet.state.keySet().iterator();i.hasNext();)
+ {
+ String key = (String)i.next();
+ Value value = (Value)internalPortlet.state.get(key);
+ if (value != null)
+ {
+ props.put(key, value.clone());
+ }
+ }
+ return props;
}
- public List destroyClones(List portletContexts) throws IllegalArgumentException,
PortletInvokerException, UnsupportedOperationException
+ public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public PropertyMap getProperties(PortletContext portletContext, Set keys) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public List destroyClones(List portletContexts) throws IllegalArgumentException,
PortletInvokerException, UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
- public PropertyMap getProperties(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
- {
- throw new UnsupportedOperationException();
- }
-
public PortletContext setProperties(PortletContext portletContext, PropertyChange[]
changes) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
{
throw new UnsupportedOperationException();
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/info/PortletInfoTest.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/info/PortletInfoTest.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/info/PortletInfoTest.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -45,7 +45,7 @@
public DriverResponse execute(ServerInvocation invocation, HttpTestContext
testContext)
{
//This asserts only .isRemotable() as rest is checked in other tests
- PortletContainer container =
(PortletContainer)registry.getPortletApplication("/test-info").getPortletContainer("RemotablePortlet1");
+ PortletContainer container =
registry.getPortletApplication("/test-info").getPortletContainer("RemotablePortlet1");
PortletInfo info = container.getInfo();
ExtendedAssert.assertEquals(Boolean.TRUE, info.isRemotable());
@@ -57,11 +57,11 @@
ExtendedAssert.assertNotNull(info.getSecurity());
ExtendedAssert.assertNotNull(info.getSession());
- container =
(PortletContainer)registry.getPortletApplication("/test-info").getPortletContainer("RemotablePortlet2");
+ container =
registry.getPortletApplication("/test-info").getPortletContainer("RemotablePortlet2");
info = container.getInfo();
ExtendedAssert.assertEquals(Boolean.FALSE, info.isRemotable());
- container =
(PortletContainer)registry.getPortletApplication("/test-info").getPortletContainer("RemotablePortlet3");
+ container =
registry.getPortletApplication("/test-info").getPortletContainer("RemotablePortlet3");
info = container.getInfo();
ExtendedAssert.assertEquals(Boolean.TRUE, info.isRemotable());
Modified:
trunk/portlet/src/main/org/jboss/portal/test/portlet/info/PreferenceInfoTest.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/info/PreferenceInfoTest.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/info/PreferenceInfoTest.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -22,11 +22,10 @@
******************************************************************************/
package org.jboss.portal.test.portlet.info;
-import org.jboss.portal.portlet.container.PortletApplicationRegistry;
import org.jboss.portal.portlet.container.PortletContainer;
+import org.jboss.portal.portlet.container.info.ContainerPreferencesInfo;
+import org.jboss.portal.portlet.container.info.ContainerPreferenceInfo;
import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.info.PreferenceInfo;
-import org.jboss.portal.portlet.info.PreferencesInfo;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.common.test.driver.response.EndTestResponse;
import org.jboss.portal.common.test.driver.DriverResponse;
@@ -54,10 +53,10 @@
//
PortletInfo info = container.getInfo();
- PreferencesInfo prefsInfo = info.getPreferences();
+ ContainerPreferencesInfo prefsInfo =
(ContainerPreferencesInfo)info.getPreferences();
//
- PreferenceInfo prefInfo = prefsInfo.getPreference("localized_pref");
+ ContainerPreferenceInfo prefInfo =
prefsInfo.getContainerPreference("localized_pref");
ExtendedAssert.assertEquals("localized_pref", prefInfo.getKey());
ExtendedAssert.assertEquals("english localized description",
prefInfo.getDescription().getString(Locale.ENGLISH, false));
ExtendedAssert.assertEquals("polish localized description",
prefInfo.getDescription().getString(new Locale("pl"), false));
@@ -73,28 +72,28 @@
ExtendedAssert.assertTrue(keys.contains("multi_pref_bis"));
//
- prefInfo = prefsInfo.getPreference("single_pref");
+ prefInfo = prefsInfo.getContainerPreference("single_pref");
ExtendedAssert.assertEquals("single_pref", prefInfo.getKey());
String[] values = prefInfo.getDefaultValue().asStringArray();
ExtendedAssert.assertEquals(new String[]{"single_pref_value"}, values);
ExtendedAssert.assertTrue(!prefInfo.isReadOnly().booleanValue());
//
- prefInfo = prefsInfo.getPreference("multi_pref");
+ prefInfo = prefsInfo.getContainerPreference("multi_pref");
ExtendedAssert.assertEquals("multi_pref", prefInfo.getKey());
values = prefInfo.getDefaultValue().asStringArray();
ExtendedAssert.assertEquals(new String[]{"multi_pref_value_1",
"multi_pref_value_2"}, values);
ExtendedAssert.assertTrue(!prefInfo.isReadOnly().booleanValue());
//
- prefInfo = prefsInfo.getPreference("single_pref_bis");
+ prefInfo = prefsInfo.getContainerPreference("single_pref_bis");
ExtendedAssert.assertEquals("single_pref_bis", prefInfo.getKey());
values = prefInfo.getDefaultValue().asStringArray();
ExtendedAssert.assertEquals(new String[]{"single_pref_value"}, values);
ExtendedAssert.assertTrue(prefInfo.isReadOnly().booleanValue());
//
- prefInfo = prefsInfo.getPreference("multi_pref_bis");
+ prefInfo = prefsInfo.getContainerPreference("multi_pref_bis");
ExtendedAssert.assertEquals("multi_pref_bis", prefInfo.getKey());
values = prefInfo.getDefaultValue().asStringArray();
ExtendedAssert.assertEquals(new String[]{"multi_pref_value_1",
"multi_pref_value_2"}, values);
Modified:
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/AbstractStatefulPortletInvokerTestCase.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -26,6 +26,7 @@
import org.jboss.portal.common.util.CollectionBuilder;
import org.jboss.portal.common.util.LocalizedString;
import org.jboss.portal.common.value.StringValue;
+import org.jboss.portal.common.value.Value;
import org.jboss.portal.portlet.InvalidPortletIdException;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.Portlet;
@@ -147,6 +148,16 @@
/**
*
*/
+ protected abstract void addPreference(PortletContext popRef, String key, Value
defaultValue);
+
+ /**
+ *
+ */
+ protected abstract void addPreference(PortletContext popRef, String key, Value
defaultValue, Boolean readOnly);
+
+ /**
+ *
+ */
protected final PortletContext createPOPRef(PortletInfoSupport portletInfo) throws
PortletInvokerException
{
PortletSupport portletSupport = new PortletSupport(portletInfo);
@@ -255,11 +266,13 @@
{
PortletInfoSupport info = new PortletInfoSupport();
info.getMetaSupport().setDisplayName("MyPortlet");
- info.getPreferencesSupport().addPreference("abc", new
StringValue("def"));
+ PortletContext popCtx = createPOPRef(info);
+ addPreference(popCtx, "abc", new StringValue("def"));
- PortletContext popCtx = createPOPRef(info);
+ //
PortletContext ccp1Ctx = createClone(popCtx);
+
// Check state
PropertyMap expected = new SimplePropertyMap();
expected.setProperty("abc", new StringValue("def"));
@@ -537,9 +550,9 @@
public void testGetPOPProperties() throws Exception
{
PortletInfoSupport info = new PortletInfoSupport();
- info.getPreferencesSupport().addPreference("abc", new
StringValue("def"));
- info.getPreferencesSupport().addPreference("ghi", new
StringValue("jkl"), Boolean.TRUE);
PortletContext popCtx = createPOPRef(info);
+ addPreference(popCtx, "abc", new StringValue("def"));
+ addPreference(popCtx, "ghi", new StringValue("jkl"),
Boolean.TRUE);
//
PropertyMap props = getProperties(popCtx);
@@ -558,11 +571,11 @@
public void testGetCCPProperties() throws Exception
{
PortletInfoSupport info = new PortletInfoSupport();
- info.getPreferencesSupport().addPreference("abc", new
StringValue("def"));
- info.getPreferencesSupport().addPreference("ghi", new
StringValue("jkl"));
- info.getPreferencesSupport().addPreference("mno", new
StringValue("pqr"), Boolean.TRUE);
- info.getPreferencesSupport().addPreference("stu", new
StringValue("vwx"), Boolean.TRUE);
PortletContext popCtx = createPOPRef(info);
+ addPreference(popCtx, "abc", new StringValue("def"));
+ addPreference(popCtx, "ghi", new StringValue("jkl"));
+ addPreference(popCtx, "mno", new StringValue("pqr"),
Boolean.TRUE);
+ addPreference(popCtx, "stu", new StringValue("vwx"),
Boolean.TRUE);
//
PortletContext ccpCtx = createClone(popCtx);
@@ -643,11 +656,11 @@
public void testSetCCPProperties() throws Exception
{
PortletInfoSupport info = new PortletInfoSupport();
- info.getPreferencesSupport().addPreference("override_update", new
StringValue("override_update_portlet_value"));
- info.getPreferencesSupport().addPreference("override_reset", new
StringValue("override_reset_portlet_value"));
- info.getPreferencesSupport().addPreference("override_create", new
StringValue("override_create_portlet_value"));
- info.getPreferencesSupport().addPreference("readonly_create", new
StringValue("readonly_create_portlet_value"), Boolean.TRUE);
PortletContext popCtx = createPOPRef(info);
+ addPreference(popCtx, "override_update", new
StringValue("override_update_portlet_value"));
+ addPreference(popCtx, "override_reset", new
StringValue("override_reset_portlet_value"));
+ addPreference(popCtx, "override_create", new
StringValue("override_create_portlet_value"));
+ addPreference(popCtx, "readonly_create", new
StringValue("readonly_create_portlet_value"), Boolean.TRUE);
//
PortletContext ccpCtx = createClone(popCtx);
@@ -697,7 +710,6 @@
public void testInvokeCloneBeforeWriteWithUpdate() throws Exception
{
PortletInfoSupport info = new PortletInfoSupport();
- info.getPreferencesSupport().addPreference("abc", new
StringValue("def"));
PortletSupport portletSupport = new PortletSupport(info)
{
public PortletInvocationResponse invoke(PortletInvocation invocation)
@@ -708,6 +720,7 @@
}
};
PortletContext popCtx = createPOPRef(portletSupport);
+ addPreference(popCtx, "abc", new StringValue("def"));
//
ActionInvocation invocation = createAction(popCtx, AccessMode.CLONE_BEFORE_WRITE);
@@ -729,7 +742,6 @@
final Boolean[] ise = {Boolean.FALSE};
PortletInfoSupport info = new PortletInfoSupport();
- info.getPreferencesSupport().addPreference("abc", new
StringValue("def"));
PortletSupport portletSupport = new PortletSupport(info)
{
public PortletInvocationResponse invoke(PortletInvocation invocation)
@@ -748,6 +760,7 @@
}
};
PortletContext popCtx = createPOPRef(portletSupport);
+ addPreference(popCtx, "abc", new StringValue("def"));
//
ActionInvocation invocation = createAction(popCtx, AccessMode.READ_ONLY);
@@ -762,7 +775,6 @@
public void testInvokeReadWriteWithUpdate() throws Exception
{
PortletInfoSupport info = new PortletInfoSupport();
- info.getPreferencesSupport().addPreference("abc", new
StringValue("def"));
PortletSupport portletSupport = new PortletSupport(info)
{
public PortletInvocationResponse invoke(PortletInvocation invocation)
@@ -773,6 +785,9 @@
}
};
PortletContext popCtx = createPOPRef(portletSupport);
+ addPreference(popCtx, "abc", new StringValue("def"));
+
+ //
PortletContext ccpCtx = createClone(popCtx);
//
Modified:
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ConsumerStatefulPortletInvokerTestCase.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -41,6 +41,7 @@
import org.jboss.portal.portlet.test.InstanceContextImpl;
import org.jboss.portal.portlet.test.support.PortletInvokerSupport;
import org.jboss.portal.portlet.test.support.PortletSupport;
+import org.jboss.portal.common.value.Value;
import java.util.Collections;
import java.util.List;
@@ -108,27 +109,27 @@
protected Portlet getPortlet(PortletContext portletRef) throws
PortletInvokerException
{
- return consumer.getPortlet((PortletContext)portletRef);
+ return consumer.getPortlet(portletRef);
}
protected PortletContext createPOPRef(PortletSupport portletSupport) throws
PortletInvokerException
{
- container.addPortlet("PortletId", portletSupport);
+ container.addInternalPortlet("PortletId", portletSupport);
Portlet portlet = getSinglePOP();
return portlet.getContext();
}
protected PortletContext createNonExistingPOPRef() throws PortletInvokerException
{
- container.addPortlet("NonExistingPortletId", new PortletInfoSupport());
+ container.addInternalPortlet("NonExistingPortletId", new
PortletInfoSupport());
PortletContext popContext = getSinglePOP().getContext();
- container.removePortlet("NonExistingPortletId");
+ container.removeInternalPortlet("NonExistingPortletId");
return popContext;
}
protected PortletContext createInvalidPOPRef() throws PortletInvokerException
{
- container.addPortlet("InvalidPortletId", new PortletInfoSupport());
+ container.addInternalPortlet("InvalidPortletId", new
PortletInfoSupport());
PortletContext popContext = getSinglePOP().getContext();
container.setValid("InvalidPortletId", false);
return popContext;
@@ -137,11 +138,21 @@
protected PortletContext createLocalClone(PortletContext portletRef) throws Exception
{
stateManagementPolicy.setPersistLocally(true);
- PortletContext cloneRef = consumer.createClone((PortletContext)portletRef);
+ PortletContext cloneRef = consumer.createClone(portletRef);
stateManagementPolicy.setPersistLocally(persistLocally);
return cloneRef;
}
+ protected void addPreference(PortletContext popRef, String key, Value defaultValue)
+ {
+ container.getInternalPortlet(popRef.getId()).addPreference(key, defaultValue);
+ }
+
+ protected void addPreference(PortletContext popRef, String key, Value defaultValue,
Boolean readOnly)
+ {
+ container.getInternalPortlet(popRef.getId()).addPreference(key, defaultValue,
readOnly);
+ }
+
protected void destroyClone(PortletContext portletRef) throws Exception
{
assertEquals(Collections.EMPTY_LIST,
consumer.destroyClones(Collections.singletonList(portletRef)));
@@ -154,23 +165,23 @@
protected PortletContext createClone(PortletContext portletRef) throws
PortletInvokerException
{
- return consumer.createClone((PortletContext)portletRef);
+ return consumer.createClone(portletRef);
}
protected PortletContext setProperties(PortletContext portletRef, PropertyChange[]
changes) throws PortletInvokerException
{
- consumer.setProperties((PortletContext)portletRef, changes);
+ consumer.setProperties(portletRef, changes);
return portletRef;
}
protected PropertyMap getProperties(PortletContext portletRef) throws
PortletInvokerException
{
- return consumer.getProperties((PortletContext)portletRef);
+ return consumer.getProperties(portletRef);
}
protected PropertyMap getProperties(PortletContext portletRef, Set keys) throws
PortletInvokerException
{
- return consumer.getProperties((PortletContext)portletRef, keys);
+ return consumer.getProperties(portletRef, keys);
}
protected List destroyClones(List portletRefs) throws PortletInvokerException
@@ -180,7 +191,7 @@
protected String getPortletId(PortletContext portletRef) throws
PortletInvokerException
{
- return ((PortletContext)portletRef).getId();
+ return (portletRef).getId();
}
protected void invoke(PortletInvocation invocation) throws PortletInvokerException
Modified:
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/state/ProducerStatefulPortletInvokerTestCase.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -39,6 +39,7 @@
import org.jboss.portal.portlet.test.support.PortletInvokerSupport;
import org.jboss.portal.portlet.test.support.PortletSupport;
import org.jboss.portal.portlet.support.info.PortletInfoSupport;
+import org.jboss.portal.common.value.Value;
import java.util.Collections;
import java.util.List;
@@ -99,22 +100,22 @@
protected PortletContext createPOPRef(PortletSupport portletSupport) throws
PortletInvokerException
{
- container.addPortlet("PortletId", portletSupport);
+ container.addInternalPortlet("PortletId", portletSupport);
Portlet portlet = getSinglePOP();
return portlet.getContext();
}
protected PortletContext createNonExistingPOPRef()
{
- container.addPortlet("NonExistingPortletId", new PortletInfoSupport());
+ container.addInternalPortlet("NonExistingPortletId", new
PortletInfoSupport());
PortletContext popCtx = getSinglePOP().getContext();
- container.removePortlet("NonExistingPortletId");
+ container.removeInternalPortlet("NonExistingPortletId");
return popCtx;
}
protected PortletContext createInvalidPOPRef()
{
- container.addPortlet("InvalidPortletId", new PortletInfoSupport());
+ container.addInternalPortlet("InvalidPortletId", new
PortletInfoSupport());
PortletContext popCtx = getSinglePOP().getContext();
container.setValid("InvalidPortletId", false);
return popCtx;
@@ -123,11 +124,21 @@
protected PortletContext createLocalClone(PortletContext portletRef) throws Exception
{
stateManagementPolicy.setPersistLocally(true);
- PortletContext cloneContext = producer.createClone((PortletContext)portletRef);
+ PortletContext cloneContext = producer.createClone(portletRef);
stateManagementPolicy.setPersistLocally(persistLocally);
return cloneContext;
}
+ protected void addPreference(PortletContext popRef, String key, Value defaultValue)
+ {
+ container.getInternalPortlet(popRef.getId()).addPreference(key, defaultValue);
+ }
+
+ protected void addPreference(PortletContext popRef, String key, Value defaultValue,
Boolean readOnly)
+ {
+ container.getInternalPortlet(popRef.getId()).addPreference(key, defaultValue,
readOnly);
+ }
+
protected void destroyClone(PortletContext portletRef) throws Exception
{
assertEquals(Collections.EMPTY_LIST,
producer.destroyClones(Collections.singletonList(portletRef)));
Modified:
trunk/portlet-federation/src/main/org/jboss/portal/test/portlet/federation/FederatingPortletInvokerTestCase.java
===================================================================
---
trunk/portlet-federation/src/main/org/jboss/portal/test/portlet/federation/FederatingPortletInvokerTestCase.java 2007-02-18
14:40:32 UTC (rev 6330)
+++
trunk/portlet-federation/src/main/org/jboss/portal/test/portlet/federation/FederatingPortletInvokerTestCase.java 2007-02-19
12:26:51 UTC (rev 6331)
@@ -73,7 +73,7 @@
fooInfo.getMetaSupport().setDisplayName("FooPortlet");
// Wire
- federatedInvoker.addPortlet("MyPortlet", federatedPortlet);
+ federatedInvoker.addInternalPortlet("MyPortlet", federatedPortlet);
federatingInvoker.registerInvoker(new
PortletInvokerRegistrationImpl("foo", federatedInvoker));
// Basic setup