Author: julien(a)jboss.com
Date: 2008-04-12 06:36:56 -0400 (Sat, 12 Apr 2008)
New Revision: 10547
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestDecoder.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestEncoder.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestDecoderTestCase.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestEncoderTestCase.java
Log:
start to add support for resource serving
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestDecoder.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestDecoder.java 2008-04-11
22:45:56 UTC (rev 10546)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestDecoder.java 2008-04-12
10:36:56 UTC (rev 10547)
@@ -28,6 +28,7 @@
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.OpaqueStateString;
+import org.jboss.portal.portlet.cache.CacheLevel;
import java.util.Map;
@@ -41,18 +42,30 @@
public class PortletRequestDecoder
{
+ /** The action phase. */
+ public static final int ACTION_PHASE = 1;
+
+ /** The render phase. */
+ public static final int RENDER_PHASE = 2;
+
+ /** The resource phase. */
+ public static final int RESOURCE_PHASE = 3;
+
/** The mask for action. */
- public static final int ACTION_MASK = 0x00000001;
+ public static final int PHASE_MASK = 0x00000003;
- /** The mask for render. */
- public static final int RENDER_MASK = 0x00000002;
-
/** The mask for mode. */
public static final int MODE_MASK = 0x00000004;
+ /** The mask for resource id. */
+ public static final int RESOURCE_ID_MASK = 0x00000004;
+
/** The mask for window state. */
public static final int WINDOW_STATE_MASK = 0x00000008;
+ /** The mask for cacheability. */
+ public static final int CACHEABILITY_MASK = 0x00000008;
+
/** The mask for opacity. */
public static final int OPAQUE_MASK = 0x00000010;
@@ -68,6 +81,15 @@
/** The name of the URL parameter containing the navigational state. */
public static final String NAVIGATIONAL_STATE_PARAMETER = "ns";
+ /** The name of the URL parameter containing the resource state. */
+ public static final String RESOURCE_STATE_PARAMETER = "rs";
+
+ /** The name of the URL parameter containing the cacheability. */
+ public static final String CACHEABILITY_PARAMETER = "cacheability";
+
+ /** The name of the URL parameter containing the resource id. */
+ public static final String RESOURCE_ID_PARAMETER = "id";
+
/** The name of the URL parameter containing the meta information. */
public static final String META_PARAMETER = "action";
@@ -81,25 +103,45 @@
public static final int NAV_TYPE = 2;
/** . */
+ public static final int RESOURCE_TYPE = 3;
+
+ /** . */
private Mode mode;
/** . */
private WindowState windowState;
/** . */
- private StateString navigationalstate;
+ private StateString navigationalState;
/** . */
private StateString interactionState;
/** . */
+ private StateString resourceState;
+
+ /** . */
private ParameterMap form;
/** . */
+ private String resourceId;
+
+ /** . */
+ private CacheLevel cacheability;
+
+ /** . */
private int type;
public void decode(Map<String, String[]> queryParams, Map<String,
String[]> bodyParams) throws IllegalArgumentException
{
+ mode = null;
+ windowState = null;
+ navigationalState = null;
+ interactionState = null;
+ form = null;
+ resourceId = null;
+ cacheability = null;
+
// The meta info from the URL
int meta = 0;
String[] metaParam = queryParams.get(META_PARAMETER);
@@ -116,55 +158,76 @@
}
//
- if ((meta & (ACTION_MASK | RENDER_MASK)) != 0)
+ int phase = meta & PHASE_MASK;
+
+ //
+ if (phase != 0)
{
- // Check validity
- if ((meta & (ACTION_MASK | RENDER_MASK)) == (ACTION_MASK | RENDER_MASK))
+ switch (phase)
{
- throw new IllegalArgumentException("Cannot have both action and render
in the mask at the same time");
+ case ACTION_PHASE:
+ type = ACTION_TYPE;
+ break;
+ case RENDER_PHASE:
+ type = RENDER_TYPE;
+ break;
+ case RESOURCE_PHASE:
+ type = RESOURCE_TYPE;
+ break;
+ default:
+ throw new AssertionError();
}
//
- if ((meta & ACTION_MASK) != 0)
+ if (type == RESOURCE_TYPE)
{
- type = ACTION_TYPE;
- }
- else
- {
- type = RENDER_TYPE;
- }
+ // Get the resource id from the parameters if it exists
+ if ((meta & RESOURCE_ID_MASK) != 0)
+ {
+ String[] resourceIdParam = queryParams.get(RESOURCE_ID_PARAMETER);
+ if (resourceIdParam == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ resourceId = resourceIdParam[0];
+ }
- // Get the mode from the parameters if it exists
- if ((meta & MODE_MASK) != 0)
- {
- String[] modeParam = queryParams.get(MODE_PARAMETER);
- if (modeParam == null)
+ // Get the resource id from the parameters if it exists
+ if ((meta & CACHEABILITY_MASK) != 0)
{
- throw new IllegalArgumentException();
+ String[] cacheabilityParam = queryParams.get(CACHEABILITY_PARAMETER);
+ if (cacheabilityParam == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ cacheability = CacheLevel.valueOf(cacheabilityParam[0]);
}
- mode = Mode.create(modeParam[0]);
}
else
{
- mode = null;
- }
+ // Get the mode from the parameters if it exists
+ if ((meta & MODE_MASK) != 0)
+ {
+ String[] modeParam = queryParams.get(MODE_PARAMETER);
+ if (modeParam == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ mode = Mode.create(modeParam[0]);
+ }
- // Get the window state from the parameters if it exists
- if ((meta & WINDOW_STATE_MASK) != 0)
- {
- String[] windowStateParam = queryParams.get(WINDOW_STATE_PARAMETER);
- if (windowStateParam == null)
+ // Get the window state from the parameters if it exists
+ if ((meta & WINDOW_STATE_MASK) != 0)
{
- throw new IllegalArgumentException();
+ String[] windowStateParam = queryParams.get(WINDOW_STATE_PARAMETER);
+ if (windowStateParam == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ windowState = WindowState.create(windowStateParam[0]);
}
- windowState = WindowState.create(windowStateParam[0]);
}
- else
- {
- windowState = null;
- }
- //
boolean opaque = (meta & OPAQUE_MASK) != 0;
if (!opaque)
{
@@ -207,18 +270,20 @@
}
//
- if (type == ACTION_TYPE)
+ switch (type)
{
- this.navigationalstate = null;
- this.interactionState = query;
- this.form = form;
+ case ACTION_TYPE:
+ this.interactionState = query;
+ this.form = form;
+ break;
+ case RENDER_TYPE:
+ this.navigationalState = query;
+ break;
+ case RESOURCE_TYPE:
+ this.resourceState = query;
+ this.form = form;
+ break;
}
- else
- {
- this.navigationalstate = query;
- this.interactionState = null;
- this.form = null;
- }
}
else
{
@@ -226,12 +291,8 @@
String[] ns = queryParams.get(NAVIGATIONAL_STATE_PARAMETER);
if (ns != null)
{
- navigationalstate = new OpaqueStateString(ns[0]);
+ navigationalState = new OpaqueStateString(ns[0]);
}
- else
- {
- navigationalstate = null;
- }
// Decode more if we have an action
if (type == ACTION_TYPE)
@@ -242,10 +303,6 @@
{
interactionState = new OpaqueStateString(is[0]);
}
- else
- {
- interactionState = null;
- }
//
form = new ParameterMap();
@@ -254,11 +311,6 @@
form.putAll(bodyParams);
}
}
- else
- {
- interactionState = null;
- form = null;
- }
}
}
else
@@ -272,10 +324,6 @@
{
mode = Mode.create(modeParam[0]);
}
- else
- {
- mode = null;
- }
// Get the window state from the parameters if it exists
String[] windowStateParam = queryParams.get(WINDOW_STATE_PARAMETER);
@@ -283,10 +331,6 @@
{
windowState = WindowState.create(windowStateParam[0]);
}
- else
- {
- windowState = null;
- }
}
}
@@ -302,7 +346,7 @@
public StateString getNavigationalState()
{
- return navigationalstate;
+ return navigationalState;
}
public StateString getInteractionState()
@@ -319,4 +363,19 @@
{
return type;
}
+
+ public String getResourceId()
+ {
+ return resourceId;
+ }
+
+ public CacheLevel getCacheability()
+ {
+ return cacheability;
+ }
+
+ public StateString getResourceState()
+ {
+ return resourceState;
+ }
}
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestEncoder.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestEncoder.java 2008-04-11
22:45:56 UTC (rev 10546)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestEncoder.java 2008-04-12
10:36:56 UTC (rev 10547)
@@ -26,7 +26,9 @@
import org.jboss.portal.WindowState;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.NotYetImplemented;
import java.util.Map;
@@ -64,6 +66,46 @@
this(new ParameterMap());
}
+ public void encodeResource(
+ CacheLevel cacheability,
+ String resourceId,
+ StateString resourceState)
+ {
+ queryParameters.clear();
+
+ //
+ int meta = PortletRequestDecoder.RESOURCE_PHASE;
+
+ //
+ if (resourceState != null)
+ {
+ if (resourceState instanceof ParametersStateString)
+ {
+ // Add the parameters
+ Map<String, String[]> parameters =
((ParametersStateString)resourceState).getParameters();
+ configure(parameters);
+ }
+ else
+ {
+ throw new NotYetImplemented("We do not implement resource serving for
wsrp");
+ }
+ }
+
+ //
+ meta |= PortletRequestDecoder.CACHEABILITY_MASK;
+ setMetaParameter(PortletRequestDecoder.CACHEABILITY_PARAMETER,
cacheability.toString());
+
+ //
+ if (resourceId != null)
+ {
+ meta |= PortletRequestDecoder.RESOURCE_ID_MASK;
+ setMetaParameter(PortletRequestDecoder.RESOURCE_ID_PARAMETER, resourceId);
+ }
+
+ //
+ setMetaParameter(PortletRequestDecoder.META_PARAMETER, Integer.toHexString(meta));
+ }
+
public void encodeAction(
StateString navigationalState,
StateString interactionState,
@@ -73,7 +115,7 @@
queryParameters.clear();
//
- int meta = PortletRequestDecoder.ACTION_MASK;
+ int meta = PortletRequestDecoder.ACTION_PHASE;
//
if (interactionState != null)
@@ -118,7 +160,7 @@
//
if (navigationalState != null)
{
- int meta = PortletRequestDecoder.RENDER_MASK;
+ int meta = PortletRequestDecoder.RENDER_PHASE;
//
if (navigationalState instanceof ParametersStateString)
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestDecoderTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestDecoderTestCase.java 2008-04-11
22:45:56 UTC (rev 10546)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestDecoderTestCase.java 2008-04-12
10:36:56 UTC (rev 10547)
@@ -57,22 +57,10 @@
Map bodyParams = new HashMap();
PortletRequestDecoder o = new PortletRequestDecoder();
- // Action + Render
- try
- {
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK |
PortletRequestDecoder.ACTION_MASK)));
- o.decode(queryParams, null);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- queryParams.clear();
- }
-
// Action + Mode
try
{
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.MODE_MASK |
PortletRequestDecoder.ACTION_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE |
PortletRequestDecoder.MODE_MASK)));
o.decode(queryParams, null);
fail();
}
@@ -82,7 +70,7 @@
}
try
{
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.MODE_MASK |
PortletRequestDecoder.ACTION_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE |
PortletRequestDecoder.MODE_MASK)));
bodyParams.put(PortletRequestDecoder.MODE_PARAMETER,
asStringArray(Mode.VIEW.toString()));
o.decode(queryParams, bodyParams);
fail();
@@ -96,7 +84,7 @@
// Action + WindowState
try
{
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.WINDOW_STATE_MASK |
PortletRequestDecoder.ACTION_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE |
PortletRequestDecoder.WINDOW_STATE_MASK)));
o.decode(queryParams, null);
fail();
}
@@ -106,7 +94,7 @@
}
try
{
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.WINDOW_STATE_MASK |
PortletRequestDecoder.ACTION_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE |
PortletRequestDecoder.WINDOW_STATE_MASK)));
bodyParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER,
asStringArray(WindowState.NORMAL.toString()));
o.decode(queryParams, bodyParams);
fail();
@@ -120,7 +108,7 @@
// Render + Mode
try
{
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.MODE_MASK |
PortletRequestDecoder.RENDER_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE |
PortletRequestDecoder.MODE_MASK)));
o.decode(queryParams, null);
fail();
}
@@ -130,7 +118,7 @@
}
try
{
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.MODE_MASK |
PortletRequestDecoder.ACTION_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE |
PortletRequestDecoder.MODE_MASK)));
bodyParams.put(PortletRequestDecoder.MODE_PARAMETER,
asStringArray(Mode.VIEW.toString()));
o.decode(queryParams, bodyParams);
fail();
@@ -144,7 +132,7 @@
// Render + WindowState
try
{
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.WINDOW_STATE_MASK |
PortletRequestDecoder.RENDER_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE |
PortletRequestDecoder.WINDOW_STATE_MASK)));
o.decode(queryParams, bodyParams);
fail();
}
@@ -154,7 +142,7 @@
}
try
{
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.WINDOW_STATE_MASK |
PortletRequestDecoder.ACTION_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE |
PortletRequestDecoder.WINDOW_STATE_MASK)));
bodyParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER,
asStringArray(WindowState.NORMAL.toString()));
o.decode(queryParams, bodyParams);
fail();
@@ -259,7 +247,7 @@
PortletRequestDecoder o = new PortletRequestDecoder();
// Empty
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE)));
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
@@ -270,7 +258,7 @@
queryParams.clear();
// Query mode
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK |
PortletRequestDecoder.MODE_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE |
PortletRequestDecoder.MODE_MASK)));
queryParams.put(PortletRequestDecoder.MODE_PARAMETER,
asStringArray(Mode.VIEW.toString()));
o.decode(queryParams, null);
assertNull(o.getForm());
@@ -282,7 +270,7 @@
queryParams.clear();
// Query window state
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK |
PortletRequestDecoder.WINDOW_STATE_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE |
PortletRequestDecoder.WINDOW_STATE_MASK)));
queryParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER,
asStringArray(WindowState.NORMAL.toString()));
o.decode(queryParams, null);
assertNull(o.getForm());
@@ -303,7 +291,7 @@
ParametersStateString navState = ParametersStateString.create();
// Query parameter
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE)));
queryParams.put("foo", asStringArray("bar"));
o.decode(queryParams, null);
assertNull(o.getForm());
@@ -317,7 +305,7 @@
queryParams.clear();
// Query meta parameter
- queryParams.put(PortletRequestDecoder.META_PARAMETER, new
String[]{Integer.toHexString(PortletRequestDecoder.RENDER_MASK), "bar"});
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, new
String[]{Integer.toHexString(PortletRequestDecoder.RENDER_PHASE), "bar"});
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
@@ -330,7 +318,7 @@
queryParams.clear();
// Query window state parameter + window state meta parameter
- queryParams.put(PortletRequestDecoder.META_PARAMETER, new
String[]{Integer.toHexString(PortletRequestDecoder.RENDER_MASK |
PortletRequestDecoder.WINDOW_STATE_MASK)});
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, new
String[]{Integer.toHexString(PortletRequestDecoder.RENDER_PHASE |
PortletRequestDecoder.WINDOW_STATE_MASK)});
queryParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, new
String[]{WindowState.NORMAL.toString(), "bar"});
o.decode(queryParams, null);
assertNull(o.getForm());
@@ -344,7 +332,7 @@
queryParams.clear();
// Query window state parameter
- queryParams.put(PortletRequestDecoder.META_PARAMETER, new
String[]{Integer.toHexString(PortletRequestDecoder.RENDER_MASK)});
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, new
String[]{Integer.toHexString(PortletRequestDecoder.RENDER_PHASE)});
queryParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, new
String[]{"bar"});
o.decode(queryParams, null);
assertNull(o.getForm());
@@ -358,7 +346,7 @@
queryParams.clear();
// Query mode parameter + mode meta parameter
- queryParams.put(PortletRequestDecoder.META_PARAMETER, new
String[]{Integer.toHexString(PortletRequestDecoder.RENDER_MASK |
PortletRequestDecoder.MODE_MASK)});
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, new
String[]{Integer.toHexString(PortletRequestDecoder.RENDER_PHASE |
PortletRequestDecoder.MODE_MASK)});
queryParams.put(PortletRequestDecoder.MODE_PARAMETER, new
String[]{Mode.VIEW.toString(), "bar"});
o.decode(queryParams, null);
assertNull(o.getForm());
@@ -372,7 +360,7 @@
queryParams.clear();
// Query mode parameter
- queryParams.put(PortletRequestDecoder.META_PARAMETER, new
String[]{Integer.toHexString(PortletRequestDecoder.RENDER_MASK)});
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, new
String[]{Integer.toHexString(PortletRequestDecoder.RENDER_PHASE)});
queryParams.put(PortletRequestDecoder.MODE_PARAMETER, new
String[]{"bar"});
o.decode(queryParams, null);
assertNull(o.getForm());
@@ -386,7 +374,7 @@
queryParams.clear();
// Body parameter
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE)));
bodyParams.put("foo", asStringArray("bar2"));
o.decode(queryParams, bodyParams);
assertNull(o.getForm());
@@ -400,7 +388,7 @@
bodyParams.clear();
// Query multivalued parameter
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE)));
queryParams.put("foo", new String[]{"bar1",
"bar2"});
o.decode(queryParams, null);
assertNull(o.getForm());
@@ -414,7 +402,7 @@
queryParams.clear();
// Query + Body parameter
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE)));
queryParams.put("foo", new String[]{"bar1"});
bodyParams.put("foo", new String[]{"bar2"});
o.decode(queryParams, bodyParams);
@@ -438,7 +426,7 @@
PortletRequestDecoder o = new PortletRequestDecoder();
// Empty
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK |
PortletRequestDecoder.OPAQUE_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE |
PortletRequestDecoder.OPAQUE_MASK)));
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
@@ -449,7 +437,7 @@
queryParams.clear();
// Query nav state
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK |
PortletRequestDecoder.OPAQUE_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE |
PortletRequestDecoder.OPAQUE_MASK)));
queryParams.put(PortletRequestDecoder.NAVIGATIONAL_STATE_PARAMETER,
asStringArray("navstatevalue"));
o.decode(queryParams, bodyParams);
assertNull(o.getForm());
@@ -461,7 +449,7 @@
queryParams.clear();
// Body nav state
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK |
PortletRequestDecoder.OPAQUE_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE |
PortletRequestDecoder.OPAQUE_MASK)));
bodyParams.put(PortletRequestDecoder.NAVIGATIONAL_STATE_PARAMETER,
asStringArray("navstatevalue"));
o.decode(queryParams, bodyParams);
assertNull(o.getForm());
@@ -474,7 +462,7 @@
bodyParams.clear();
// Query int state is ignored
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK |
PortletRequestDecoder.OPAQUE_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE |
PortletRequestDecoder.OPAQUE_MASK)));
queryParams.put(PortletRequestDecoder.INTERACTION_STATE_PARAMETER,
asStringArray("intstatevalue"));
o.decode(queryParams, null);
assertNull(o.getForm());
@@ -486,7 +474,7 @@
queryParams.clear();
// Body int state is ignored
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_MASK |
PortletRequestDecoder.OPAQUE_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE |
PortletRequestDecoder.OPAQUE_MASK)));
bodyParams.put(PortletRequestDecoder.INTERACTION_STATE_PARAMETER,
asStringArray("intstatevalue"));
o.decode(queryParams, bodyParams);
assertNull(o.getForm());
@@ -506,7 +494,7 @@
PortletRequestDecoder o = new PortletRequestDecoder();
// Empty
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE)));
o.decode(queryParams, null);
assertEquals(new ParameterMap(), o.getForm());
assertEquals(ParametersStateString.create(), o.getInteractionState());
@@ -517,7 +505,7 @@
queryParams.clear();
// Query mode
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK |
PortletRequestDecoder.MODE_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE |
PortletRequestDecoder.MODE_MASK)));
queryParams.put(PortletRequestDecoder.MODE_PARAMETER,
asStringArray(Mode.VIEW.toString()));
o.decode(queryParams, null);
assertEquals(new ParameterMap(), o.getForm());
@@ -529,7 +517,7 @@
queryParams.clear();
// Query window state
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK |
PortletRequestDecoder.WINDOW_STATE_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE |
PortletRequestDecoder.WINDOW_STATE_MASK)));
queryParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER,
asStringArray(WindowState.NORMAL.toString()));
o.decode(queryParams, null);
assertEquals(new ParameterMap(), o.getForm());
@@ -551,7 +539,7 @@
ParameterMap form = new ParameterMap();
// Query parameter
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE)));
queryParams.put("foo", asStringArray("bar"));
o.decode(queryParams, null);
assertEquals(form, o.getForm());
@@ -566,7 +554,7 @@
form.clear();
// Query multivalued parameter
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE)));
queryParams.put("foo", new String[]{"bar1",
"bar2"});
o.decode(queryParams, null);
assertEquals(form, o.getForm());
@@ -581,7 +569,7 @@
form.clear();
// Body parameter
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE)));
bodyParams.put("foo", asStringArray("bar"));
o.decode(queryParams, bodyParams);
form.setValue("foo", "bar");
@@ -597,7 +585,7 @@
form.clear();
// Body multivalued parameter
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE)));
bodyParams.put("foo", new String[]{"bar1", "bar2"});
o.decode(queryParams, bodyParams);
form.setValues("foo", new String[]{"bar1", "bar2"});
@@ -621,7 +609,7 @@
PortletRequestDecoder o = new PortletRequestDecoder();
// Empty
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK |
PortletRequestDecoder.OPAQUE_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE |
PortletRequestDecoder.OPAQUE_MASK)));
o.decode(queryParams, null);
assertEquals(new ParameterMap(), o.getForm());
assertNull(o.getInteractionState());
@@ -632,7 +620,7 @@
queryParams.clear();
// Query nav state
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK |
PortletRequestDecoder.OPAQUE_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE |
PortletRequestDecoder.OPAQUE_MASK)));
queryParams.put(PortletRequestDecoder.NAVIGATIONAL_STATE_PARAMETER,
asStringArray("navstatevalue"));
o.decode(queryParams, null);
assertEquals(new ParameterMap(), o.getForm());
@@ -644,7 +632,7 @@
queryParams.clear();
// Query int state
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK |
PortletRequestDecoder.OPAQUE_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE |
PortletRequestDecoder.OPAQUE_MASK)));
queryParams.put(PortletRequestDecoder.INTERACTION_STATE_PARAMETER,
asStringArray("intstatevalue"));
o.decode(queryParams, null);
assertEquals(new ParameterMap(), o.getForm());
@@ -656,7 +644,7 @@
queryParams.clear();
// Body parameters
- queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_MASK |
PortletRequestDecoder.OPAQUE_MASK)));
+ queryParams.put(PortletRequestDecoder.META_PARAMETER,
asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE |
PortletRequestDecoder.OPAQUE_MASK)));
bodyParams.put("foo1", asStringArray("bar1"));
bodyParams.put("foo2", new String[]{"bar2",
"bar3"});
queryParams.put("foo3", new String[]{"bar4"});
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestEncoderTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestEncoderTestCase.java 2008-04-11
22:45:56 UTC (rev 10546)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestEncoderTestCase.java 2008-04-12
10:36:56 UTC (rev 10547)
@@ -25,6 +25,7 @@
import org.jboss.portal.core.portlet.PortletRequestEncoder;
import org.jboss.portal.core.portlet.PortletRequestDecoder;
import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.util.Tools;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
@@ -64,13 +65,13 @@
public void testEncodeRender()
{
- _testEncodeRender(RENDER, PortletRequestDecoder.RENDER_MASK);
+ _testEncodeRender(RENDER, PortletRequestDecoder.RENDER_PHASE);
}
public void testEncodeAction()
{
- _testEncodeRender(ACTION, PortletRequestDecoder.ACTION_MASK);
+ _testEncodeRender(ACTION, PortletRequestDecoder.ACTION_PHASE);
}
public void _testEncodeRender(int lifecycle, int lifecycleMask)
@@ -213,6 +214,14 @@
void _assertEquals(String[] expected, String[] actual)
{
- assertEquals(expected, actual);
+ if (expected == null)
+ {
+ assertNull(actual);
+ }
+ else
+ {
+ assertNotNull((actual));
+ assertEquals(Tools.toList(expected), Tools.toList(actual));
+ }
}
}
\ No newline at end of file