Author: julien(a)jboss.com
Date: 2008-01-23 10:58:49 -0500 (Wed, 23 Jan 2008)
New Revision: 9579
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
Log:
- added constant class for URL parameter constants
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-23
15:35:57 UTC (rev 9578)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-23
15:58:49 UTC (rev 9579)
@@ -39,6 +39,7 @@
import org.jboss.portal.web.Body;
import org.jboss.portal.web.IllegalRequestException;
import org.jboss.portal.web.WebRequest;
+import static org.jboss.portal.portlet.test.URLParameterConstants.*;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -100,7 +101,7 @@
WebRequest ri = new WebRequest(req);
// Unmarshall portal navigational state if it is provided
- String context = req.getParameter("context");
+ String context = req.getParameter(PAGE_STATE);
if (context != null)
{
byte[] bytes = Tools.fromHexString(context);
@@ -109,20 +110,20 @@
//
Mode mode = null;
- if (req.getParameter("mode") != null)
+ if (req.getParameter(MODE) != null)
{
- mode = Mode.create(req.getParameter("mode"));
+ mode = Mode.create(req.getParameter(MODE));
}
//
WindowState windowState = null;
- if (req.getParameter("windowstate") != null)
+ if (req.getParameter(WINDOW_STATE) != null)
{
- windowState = WindowState.create(req.getParameter("windowstate"));
+ windowState = WindowState.create(req.getParameter(WINDOW_STATE));
}
//
- String navigationalStateString =
req.getParameter("navigationalstate");
+ String navigationalStateString = req.getParameter(NAVIGATIONAL_STATE);
StateString navigationalState = null;
if (navigationalStateString != null)
{
@@ -130,11 +131,11 @@
}
//
- String type = req.getParameter("type");
- if ("resource".equals(type))
+ String type = req.getParameter(LIFECYCLE_TYPE);
+ if (RESOURCE_LIFECYCLE.equals(type))
{
- StateString resourceState =
ParametersStateString.create(req.getParameter("resourcestate"));
- String resourceId = req.getParameter("id");
+ StateString resourceState =
ParametersStateString.create(req.getParameter(RESOURCE_STATE));
+ String resourceId = req.getParameter(RESOURCE_ID);
//
@@ -145,7 +146,7 @@
}
//
- CacheabilityType resourceCacheabilityType =
CacheabilityType.valueOf(req.getParameter("cacheability"));
+ CacheabilityType resourceCacheabilityType =
CacheabilityType.valueOf(req.getParameter(RESOURCE_CACHEABILITY));
//
switch (resourceCacheabilityType)
@@ -182,7 +183,7 @@
}
else
{
- if ("action".equals(type))
+ if (ACTION_LIFECYCLE.equals(type))
{
ParameterMap formParameters = null;
if (ri.getBody() instanceof Body.Form)
@@ -191,7 +192,7 @@
}
//
- StateString interactionState =
ParametersStateString.create(req.getParameter("interactionstate"));
+ StateString interactionState =
ParametersStateString.create(req.getParameter(INTERACTION_STATE));
//
request = new PortletController.PortletActionRequest(
@@ -205,11 +206,9 @@
}
else
{
+ Map<String, String[]> publicNavigationalStateChanges =
(Map<String,
String[]>)IOTools.unserialize(Tools.fromHexString(req.getParameter(PAGE_NAVIGATIONAL_STATE_CHANGES)));
//
- Map<String, String[]> publicNavigationalStateChanges =
(Map<String,
String[]>)IOTools.unserialize(Tools.fromHexString(req.getParameter("publicnavigationalstatechanges")));
-
- //
request = new PortletController.PortletRenderRequest(
targetId,
navigationalState,
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-23
15:35:57 UTC (rev 9578)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-23
15:58:49 UTC (rev 9579)
@@ -34,6 +34,7 @@
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.io.IOTools;
+import static org.jboss.portal.portlet.test.URLParameterConstants.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -96,29 +97,29 @@
String type;
if (containerURL instanceof ActionURL)
{
- type = "action";
+ type = ACTION_LIFECYCLE;
}
else if (containerURL instanceof RenderURL)
{
- type = "render";
+ type = RENDER_LIFECYCLE;
}
else if (containerURL instanceof ResourceURL)
{
- type = "resource";
+ type = RESOURCE_LIFECYCLE;
}
else
{
throw new Error();
}
- parameters.put("type", type);
+ parameters.put(LIFECYCLE_TYPE, type);
//
- String context;
+ String pageState;
try
{
byte[] bytes = PageNavigationalState.serialize(pageNS);
String ns = Tools.toHexString(bytes);
- context = ns;
+ pageState = ns;
}
catch (IOException e)
{
@@ -132,17 +133,17 @@
if (portletURL.getMode() != null)
{
- parameters.put("mode", portletURL.getMode().toString());
+ parameters.put(MODE, portletURL.getMode().toString());
}
//
if (portletURL.getWindowState() != null)
{
- parameters.put("windowstate",
portletURL.getWindowState().toString());
+ parameters.put(WINDOW_STATE, portletURL.getWindowState().toString());
}
//
- parameters.put("context", context);
+ parameters.put(PAGE_STATE, pageState);
//
if (containerURL instanceof ActionURL)
@@ -155,13 +156,13 @@
StateString portletNS = windowNS.getPortletNavigationalState();
if (portletNS != null)
{
- parameters.put("navigationalstate",
windowNS.getPortletNavigationalState().getStringValue());
+ parameters.put(NAVIGATIONAL_STATE,
windowNS.getPortletNavigationalState().getStringValue());
}
}
//
StateString interactionState = actionURL.getInteractionState();
- parameters.put("interactionstate",
interactionState.getStringValue());
+ parameters.put(INTERACTION_STATE, interactionState.getStringValue());
}
else
{
@@ -174,7 +175,7 @@
HashMap<String, String[]> serialiableChanges = new
HashMap<String, String[]>(changes);
byte[] bytes = IOTools.serialize(serialiableChanges);
String ns = Tools.toHexString(bytes);
- parameters.put("publicnavigationalstatechanges", ns);
+ parameters.put(PAGE_NAVIGATIONAL_STATE_CHANGES, ns);
}
catch (IOException e)
{
@@ -183,7 +184,7 @@
//
StateString navigationalState = renderURL.getNavigationalState();
- parameters.put("navigationalstate",
navigationalState.getStringValue());
+ parameters.put(NAVIGATIONAL_STATE, navigationalState.getStringValue());
}
}
else
@@ -192,18 +193,18 @@
//
StateString resourceState = resourceURL.getResourceState();
- parameters.put("resourcestate", resourceState.getStringValue());
+ parameters.put(RESOURCE_STATE, resourceState.getStringValue());
//
String resourceId = resourceURL.getResourceId();
if (resourceId != null)
{
- parameters.put("id", resourceId);
+ parameters.put(RESOURCE_ID, resourceId);
}
//
CacheabilityType cacheability = resourceURL.getCacheability();
- parameters.put("cacheability", cacheability.name());
+ parameters.put(RESOURCE_CACHEABILITY, cacheability.name());
//
if (cacheability != CacheabilityType.FULL)
@@ -213,19 +214,19 @@
StateString portletNS = windowNS.getPortletNavigationalState();
if (portletNS != null)
{
- parameters.put("navigationalstate",
windowNS.getPortletNavigationalState().getStringValue());
+ parameters.put(NAVIGATIONAL_STATE,
windowNS.getPortletNavigationalState().getStringValue());
}
//
- parameters.put("mode", windowNS.getMode().toString());
+ parameters.put(MODE, windowNS.getMode().toString());
//
- parameters.put("windowstate",
windowNS.getWindowState().toString());
+ parameters.put(WINDOW_STATE, windowNS.getWindowState().toString());
//
if (cacheability == CacheabilityType.PAGE)
{
- parameters.put("context", context);
+ parameters.put(PAGE_STATE, pageState);
}
}
}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java 2008-01-23
15:58:49 UTC (rev 9579)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public final class URLParameterConstants
+{
+
+ private URLParameterConstants()
+ {
+ }
+
+ public static final String LIFECYCLE_TYPE = "type";
+
+ public static final String MODE = "mode";
+ public static final String WINDOW_STATE = "windowstate";
+ public static final String NAVIGATIONAL_STATE = "navigationalstate";
+ public static final String RESOURCE_STATE = "resourcestate";
+ public static final String INTERACTION_STATE = "interactionstate";
+
+ public static final String PAGE_STATE = "pagestate";
+ public static final String PAGE_NAVIGATIONAL_STATE_CHANGES =
"pagenavigationalstatechanges";
+
+ public static final String RESOURCE_ID = "id";
+ public static final String RESOURCE_CACHEABILITY = "resourcecacheability";
+
+ public static final String ACTION_LIFECYCLE = "action";
+ public static final String RENDER_LIFECYCLE = "render";
+ public static final String RESOURCE_LIFECYCLE = "resource";
+
+}