Author: julien(a)jboss.com
Date: 2008-01-23 09:39:46 -0500 (Wed, 23 Jan 2008)
New Revision: 9576
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/CacheabilityType.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ResourceRequestParametersTestCase.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PageNavigationalState.java
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Cacheability.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ActionURL.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP4.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/portletrequests/ActionRequestUseFormTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/portletrequests/ActionRequestUseInputStreamTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/portletrequests/ActionRequestUseReaderTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletActionTestAction.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletEventTestAction.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletRenderTestAction.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java
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
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml
Log:
- renamed PortalNavigationalState -> PageNavigationalState
- changed page NS life cycle management in order to implement correctly resource
cacheability feature
- started to add test case for resource cacheability
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ActionURL.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ActionURL.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ActionURL.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -34,11 +34,4 @@
* @return the interaction state
*/
StateString getInteractionState();
-
- /**
- * Return the navigational state.
- *
- * @return the navigational state
- */
- StateString getNavigationalState();
}
Deleted:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Cacheability.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Cacheability.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Cacheability.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -1,34 +0,0 @@
-/******************************************************************************
- * 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;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public enum Cacheability
-{
-
- FULL, PORTLET, PAGE
-
-}
Copied:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/CacheabilityType.java
(from rev 9550,
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Cacheability.java)
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/CacheabilityType.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/CacheabilityType.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public enum CacheabilityType
+{
+
+ FULL, PORTLET, PAGE
+
+}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -29,19 +29,25 @@
public interface ResourceURL extends ContainerURL
{
- String getId();
+ /**
+ * Returns the resource id
+ *
+ * @return the resource id
+ */
+ String getResourceId();
/**
- * Return the resource state.
+ * Returns the resource state.
*
* @return the resource state
*/
StateString getResourceState();
/**
- * Returs the resource cacheability.
+ * Returns the resource cacheability.
*
* @return the resource cacheability
*/
- Cacheability getCacheability();
+ CacheabilityType getCacheability();
+
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -37,7 +37,6 @@
import javax.portlet.WindowState;
import javax.portlet.WindowStateException;
import java.util.Map;
-import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -48,8 +47,7 @@
public static PortletURLImpl createActionURL(PortletInvocation invocation,
PortletRequestImpl preq)
{
- StateString navigationalState = invocation.getContext().getNavigationalState();
- InternalActionURL url = new InternalActionURL(navigationalState);
+ InternalActionURL url = new InternalActionURL();
return new PortletURLImpl(invocation, preq, url);
}
@@ -149,14 +147,10 @@
{
/** . */
- private final StateString navigationalState;
-
- /** . */
private final ParametersStateString interactionState;
- private InternalActionURL(StateString navigationalState)
+ private InternalActionURL()
{
- this.navigationalState = navigationalState;
this.interactionState = ParametersStateString.create();
}
@@ -165,11 +159,6 @@
return interactionState;
}
- public StateString getNavigationalState()
- {
- return navigationalState;
- }
-
protected void setParameter(String name, String value)
{
interactionState.setValue(name, value);
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -24,7 +24,6 @@
import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.spi.ResourceInvocationContext;
-import org.jboss.portal.portlet.Cacheability;
import org.jboss.portal.portlet.impl.jsr168.ResourceRequestParameterMap;
import javax.portlet.ResourceRequest;
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -24,10 +24,9 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.ResourceInvocation;
-import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.CacheabilityType;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ParametersStateString;
-import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
import javax.portlet.ResourceURL;
import java.util.Map;
@@ -41,26 +40,26 @@
{
/** . */
- private static final Map<String, Cacheability> jsr168ToType = new
HashMap<String, Cacheability>();
+ private static final Map<String, CacheabilityType> jsr168ToType = new
HashMap<String, CacheabilityType>();
/** . */
- private static final Map<Cacheability, String> typetoJSR168 = new
HashMap<Cacheability, String>();
+ private static final Map<CacheabilityType, String> typetoJSR168 = new
HashMap<CacheabilityType, String>();
static
{
- jsr168ToType.put(ResourceURL.FULL, Cacheability.FULL);
- jsr168ToType.put(ResourceURL.PAGE, Cacheability.PAGE);
- jsr168ToType.put(ResourceURL.PORTLET, Cacheability.PORTLET);
+ jsr168ToType.put(ResourceURL.FULL, CacheabilityType.FULL);
+ jsr168ToType.put(ResourceURL.PAGE, CacheabilityType.PAGE);
+ jsr168ToType.put(ResourceURL.PORTLET, CacheabilityType.PORTLET);
//
- typetoJSR168.put(Cacheability.FULL, ResourceURL.FULL);
- typetoJSR168.put(Cacheability.PAGE, ResourceURL.PAGE);
- typetoJSR168.put(Cacheability.PORTLET, ResourceURL.PORTLET);
+ typetoJSR168.put(CacheabilityType.FULL, ResourceURL.FULL);
+ typetoJSR168.put(CacheabilityType.PAGE, ResourceURL.PAGE);
+ typetoJSR168.put(CacheabilityType.PORTLET, ResourceURL.PORTLET);
}
- public static String toJSR168(Cacheability cacheability)
+ public static String toJSR168(CacheabilityType cacheabilityType)
{
- return typetoJSR168.get(cacheability);
+ return typetoJSR168.get(cacheabilityType);
}
/** . */
@@ -79,7 +78,7 @@
//
if (invocation instanceof ResourceInvocation)
{
- url.parentCacheability =
((ResourceInvocation)invocation).getContext().getCacheability();
+ url.parentCacheabilityType =
((ResourceInvocation)invocation).getContext().getCacheability();
}
}
@@ -93,41 +92,41 @@
public String getCacheability()
{
- Cacheability cacheability = url.getCacheability();
+ CacheabilityType cacheabilityType = url.getCacheability();
//
- return typetoJSR168.get(cacheability);
+ return typetoJSR168.get(cacheabilityType);
}
public void setCacheability(String s)
{
- Cacheability cacheability = jsr168ToType.get(s);
+ CacheabilityType cacheabilityType = jsr168ToType.get(s);
//
- if (cacheability != null)
+ if (cacheabilityType != null)
{
- if (url.parentCacheability == null)
+ if (url.parentCacheabilityType == null)
{
- url.cacheability = cacheability;
+ url.cacheabilityType = cacheabilityType;
}
else
{
- switch (url.parentCacheability)
+ switch (url.parentCacheabilityType)
{
case FULL:
- if (cacheability != Cacheability.FULL)
+ if (cacheabilityType != CacheabilityType.FULL)
{
throw new IllegalStateException();
}
break;
case PORTLET:
- if (cacheability == Cacheability.PAGE)
+ if (cacheabilityType == CacheabilityType.PAGE)
{
throw new IllegalStateException();
}
break;
}
- url.cacheability = cacheability;
+ url.cacheabilityType = cacheabilityType;
}
}
}
@@ -144,10 +143,10 @@
private String id;
/** The cacheability constraining the url cacheability. */
- private Cacheability parentCacheability;
+ private CacheabilityType parentCacheabilityType;
/** . */
- private Cacheability cacheability;
+ private CacheabilityType cacheabilityType;
/** . */
private ParametersStateString parameters;
@@ -177,26 +176,26 @@
return parameters;
}
- public String getId()
+ public String getResourceId()
{
return id;
}
- public Cacheability getCacheability()
+ public CacheabilityType getCacheability()
{
- if (cacheability != null)
+ if (cacheabilityType != null)
{
- return cacheability;
+ return cacheabilityType;
}
else
{
- if (parentCacheability != null)
+ if (parentCacheabilityType != null)
{
- return parentCacheability;
+ return parentCacheabilityType;
}
else
{
- return Cacheability.PAGE;
+ return CacheabilityType.PAGE;
}
}
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -27,7 +27,7 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.CacheabilityType;
import org.jboss.portal.portlet.spi.ResourceInvocationContext;
/**
@@ -41,7 +41,7 @@
private final String resourceId;
/** . */
- private final Cacheability cacheability;
+ private final CacheabilityType cacheabilityType;
/** . */
private final StateString resourceState;
@@ -51,7 +51,7 @@
public AbstractResourceContext(
String resourceId,
- Cacheability cacheability,
+ CacheabilityType cacheabilityType,
Mode mode,
WindowState windowState,
StateString navigationalState,
@@ -64,7 +64,7 @@
//
this.resourceId = resourceId;
- this.cacheability = cacheability;
+ this.cacheabilityType = cacheabilityType;
this.resourceState = resourceState;
this.form = form;
}
@@ -74,9 +74,9 @@
return resourceId;
}
- public Cacheability getCacheability()
+ public CacheabilityType getCacheability()
{
- return cacheability;
+ return cacheabilityType;
}
public StateString getResourceState()
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -27,9 +27,9 @@
import org.jboss.portal.common.invocation.InvocationContext;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.PortletURL;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ContainerURL;
+import org.jboss.portal.portlet.CacheabilityType;
/**
* Contract that defines what input/services the caller of a portlet container must
provide.
@@ -40,23 +40,28 @@
public interface PortletInvocationContext extends InvocationContext
{
/**
- * Returns the navigational state for this invocation.
+ * Returns the navigational state provided to the portlet.
*
* @return the navigational state
*/
StateString getNavigationalState();
+ /**
+ * Returns the public navigational state provided to the portlet.
+ *
+ * @return the public navigational state
+ */
ParameterMap getPublicNavigationalState();
/**
- * Returns the mode for this invocation.
+ * Returns the mode provided to the portlet.
*
* @return the mode
*/
Mode getMode();
/**
- * Returns the window state for this invocation.
+ * Returns the window state provided to the portlet.
*
* @return the window state
*/
@@ -93,9 +98,5 @@
* @param relative if the url should be relative
* @return the rendered url
*/
- String renderURL(
- ContainerURL containerURL,
- Boolean wantSecure,
- Boolean wantAuthenticated,
- boolean relative);
+ String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative);
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.spi;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.CacheabilityType;
import org.jboss.portal.common.util.ParameterMap;
/**
@@ -45,7 +45,7 @@
*
* @return the cacheability
*/
- Cacheability getCacheability();
+ CacheabilityType getCacheability();
/**
* Returns the resource state of the request.
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP4.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP4.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP4.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -46,6 +46,8 @@
public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_ACTION);
+ public final static JoinPoint RESOURCE_JOIN_POINT = new JoinPoint(NAME,
JoinPointType.PORTLET_RESOURCE);
+
/** Resets helper variables */
public void reset()
{
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/portletrequests/ActionRequestUseFormTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/portletrequests/ActionRequestUseFormTestCase.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/portletrequests/ActionRequestUseFormTestCase.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -27,11 +27,11 @@
import org.jboss.portal.unit.actions.PortletRenderTestAction;
import org.jboss.portal.unit.actions.PortletActionTestAction;
import org.jboss.portal.test.portlet.framework.UTP1;
-import org.jboss.portal.common.http.HttpRequest;
import org.jboss.portal.unit.annotations.TestCase;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.EndTestResponse;
import org.jboss.unit.remote.driver.handler.http.response.InvokePostResponse;
+import org.jboss.unit.remote.http.HttpRequest;
import static org.jboss.unit.api.Assert.assertEquals;
import static org.jboss.unit.api.Assert.fail;
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/portletrequests/ActionRequestUseInputStreamTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/portletrequests/ActionRequestUseInputStreamTestCase.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/portletrequests/ActionRequestUseInputStreamTestCase.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -27,12 +27,12 @@
import org.jboss.portal.unit.actions.PortletRenderTestAction;
import org.jboss.portal.unit.actions.PortletActionTestAction;
import org.jboss.portal.test.portlet.framework.UTP1;
-import org.jboss.portal.common.http.HttpRequest;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.unit.annotations.TestCase;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.EndTestResponse;
import org.jboss.unit.remote.driver.handler.http.response.InvokePostResponse;
+import org.jboss.unit.remote.http.HttpRequest;
import static org.jboss.unit.api.Assert.assertEquals;
import static org.jboss.unit.api.Assert.fail;
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/portletrequests/ActionRequestUseReaderTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/portletrequests/ActionRequestUseReaderTestCase.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/portletrequests/ActionRequestUseReaderTestCase.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -27,13 +27,13 @@
import org.jboss.portal.unit.actions.PortletRenderTestAction;
import org.jboss.portal.unit.actions.PortletActionTestAction;
import org.jboss.portal.test.portlet.framework.UTP1;
-import org.jboss.portal.common.http.HttpRequest;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.unit.annotations.TestCase;
import org.jboss.portal.unit.PortletTestContext;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.EndTestResponse;
import org.jboss.unit.remote.driver.handler.http.response.InvokePostResponse;
+import org.jboss.unit.remote.http.HttpRequest;
import static org.jboss.unit.api.Assert.assertEquals;
import static org.jboss.unit.api.Assert.fail;
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ResourceRequestParametersTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ResourceRequestParametersTestCase.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ResourceRequestParametersTestCase.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -0,0 +1,123 @@
+/******************************************************************************
+ * 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.test.portlet.jsr286.ext.portletrequests;
+
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP4;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.ResourceURL;
+import javax.portlet.PortletURL;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * For serveResource requests the portlet must receive any resource parameters that were
+ * explicitly set on the ResourceURL that triggered the request. If the cacheability
level of
+ * that resource URL (see PLT.13.7) was PORTLET or PAGE, the portlet must also receive
the
+ * render parameters present in the request in which the URL was created
+ *
+ * If a resource parameter is set that has the same name as a render parameter, the
render
+ * parameter must be the last entry in the parameter value array.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class ResourceRequestParametersTestCase
+{
+ public ResourceRequestParametersTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ PortletURL renderURL = response.createRenderURL();
+ renderURL.setParameter("foo", new
String[]{"render_foo_value1","render_foo_value2"});
+ return new InvokeGetResponse(renderURL.toString());
+ }
+ });
+ seq.bindAction(1, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ ResourceURL resourceURL = response.createResourceURL();
+ resourceURL.setParameter("foo", new
String[]{"resource_foo_value1","resource_foo_value2"});
+ return new InvokeGetResponse(resourceURL.toString());
+ }
+ });
+ seq.bindAction(2, UTP4.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request,
ResourceResponse response, PortletTestContext context) throws PortletException,
IOException
+ {
+ Map<String, String[]> expectedPageParameters = new HashMap<String,
String[]>();
+ expectedPageParameters.put("foo", new
String[]{"resource_foo_value1","resource_foo_value2","render_foo_value1","render_foo_value2"});
+ assertParameterMap(expectedPageParameters, request);
+
+ //
+ response.setContentType("text/html");
+ Writer writer = response.getWriter();
+ writer.close();
+
+ //
+ ResourceURL resourceURL = response.createResourceURL();
+ resourceURL.setCacheability(ResourceURL.PORTLET);
+ resourceURL.setParameter("foo", new
String[]{"resource_foo_value3","resource_foo_value4"});
+ return new InvokeGetResponse(resourceURL.toString());
+ }
+ });
+ seq.bindAction(3, UTP4.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request,
ResourceResponse response, PortletTestContext context) throws PortletException,
IOException
+ {
+ Map<String, String[]> expectedPageParameters = new HashMap<String,
String[]>();
+ expectedPageParameters.put("foo", new
String[]{"resource_foo_value3","resource_foo_value4","render_foo_value1","render_foo_value2"});
+ assertParameterMap(expectedPageParameters, request);
+
+ //
+ response.setContentType("text/html");
+ Writer writer = response.getWriter();
+ writer.close();
+
+ //
+ return new EndTestResponse();
+ }
+ });
+
+
+ }
+}
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -31,11 +31,11 @@
import org.jboss.portal.unit.actions.PortletEventTestAction;
import org.jboss.portal.unit.actions.PortletResourceTestAction;
import org.jboss.portal.test.portlet.framework.UTP5;
-import org.jboss.portal.common.http.HttpRequest;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.EndTestResponse;
import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
import org.jboss.unit.remote.driver.handler.http.response.InvokePostResponse;
+import org.jboss.unit.remote.http.HttpRequest;
import static org.jboss.unit.api.Assert.*;
import javax.portlet.Portlet;
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -30,6 +30,7 @@
import static org.jboss.unit.api.Assert.*;
import org.jboss.portal.common.util.Tools;
+import org.apache.log4j.Logger;
/**
* @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
@@ -38,6 +39,18 @@
public abstract class TestAction
{
+ /** . */
+ private Logger log = null;
+
+ protected final Logger getLogger()
+ {
+ if (log == null)
+ {
+ log = Logger.getLogger(getClass());
+ }
+ return log;
+ }
+
/**
* Check that the parameter map contains the value expected. The check is done with
the different
* ways that the <code>PortletRequest</code> API provides:
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletActionTestAction.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletActionTestAction.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletActionTestAction.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -24,6 +24,7 @@
import org.jboss.portal.unit.PortletTestContext;
import org.jboss.portal.unit.TestAction;
+import org.jboss.portal.common.NotYetImplemented;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.Failure;
@@ -52,6 +53,9 @@
}
catch (AssertionError t)
{
+ getLogger().error("The test case failed", t);
+
+ //
return new FailureResponse(Failure.createFailure(t));
}
}
@@ -76,6 +80,8 @@
}
}
- protected abstract void run(Portlet portlet, ActionRequest request, ActionResponse
response, PortletTestContext context) throws PortletException, IOException;
-
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response,
PortletTestContext context) throws PortletException, IOException
+ {
+ throw new NotYetImplemented();
+ }
}
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletEventTestAction.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletEventTestAction.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletEventTestAction.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -24,6 +24,7 @@
import org.jboss.portal.unit.PortletTestContext;
import org.jboss.portal.unit.TestAction;
+import org.jboss.portal.common.NotYetImplemented;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.Failure;
@@ -52,6 +53,9 @@
}
catch (AssertionError t)
{
+ getLogger().error("The test case failed", t);
+
+ //
return new FailureResponse(Failure.createFailure(t));
}
}
@@ -78,5 +82,6 @@
protected void run(Portlet portlet, EventRequest request, EventResponse response,
PortletTestContext context) throws PortletException, IOException
{
+ throw new NotYetImplemented();
}
}
\ No newline at end of file
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletRenderTestAction.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletRenderTestAction.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletRenderTestAction.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -25,6 +25,7 @@
import org.jboss.portal.unit.TestAction;
import org.jboss.portal.unit.PortletTestContext;
import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.common.NotYetImplemented;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.Failure;
@@ -33,6 +34,8 @@
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
import java.io.IOException;
/**
@@ -42,12 +45,27 @@
public abstract class PortletRenderTestAction extends TestAction
{
- public DriverResponse execute(Portlet servlet, RenderRequest request, RenderResponse
response, PortletTestContext context) throws PortletException, IOException
+ public DriverResponse execute(Portlet portlet, RenderRequest request, RenderResponse
response, PortletTestContext context) throws PortletException, IOException
{
try
{
- return run(servlet, request, response, context);
+ return runWithRuntimeException(portlet, request, response, context);
}
+ catch (AssertionError t)
+ {
+ getLogger().error("The test case failed", t);
+
+ //
+ return new FailureResponse(Failure.createFailure(t));
+ }
+ }
+
+ protected DriverResponse runWithRuntimeException(Portlet portlet, RenderRequest
request, RenderResponse response, PortletTestContext context) throws PortletException,
IOException
+ {
+ try
+ {
+ return run(portlet, request, response, context);
+ }
catch (Exception e)
{
if (e instanceof PortletException)
@@ -58,13 +76,12 @@
{
throw (IOException)e;
}
- return new FailureResponse(Failure.createAssertionFailure(e));
+ throw new AssertionError(e);
}
- catch (AssertionError t)
- {
- return new FailureResponse(Failure.createFailure(t));
- }
}
- protected abstract DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException,
IOException;
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse
response, PortletTestContext context) throws PortletException, IOException
+ {
+ throw new NotYetImplemented();
+ }
}
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -24,9 +24,11 @@
import org.jboss.portal.unit.TestAction;
import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.common.NotYetImplemented;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.Failure;
+import org.apache.log4j.Logger;
import javax.portlet.Portlet;
import javax.portlet.PortletException;
@@ -41,12 +43,27 @@
public abstract class PortletResourceTestAction extends TestAction
{
- public DriverResponse execute(Portlet servlet, ResourceRequest request,
ResourceResponse response, PortletTestContext context) throws PortletException,
IOException
+ public DriverResponse execute(Portlet portlet, ResourceRequest request,
ResourceResponse response, PortletTestContext context) throws PortletException,
IOException
{
try
{
- return run(servlet, request, response, context);
+ return runWithRuntimeException(portlet, request, response, context);
}
+ catch (AssertionError t)
+ {
+ getLogger().error("The test case failed", t);
+
+ //
+ return new FailureResponse(Failure.createFailure(t));
+ }
+ }
+
+ protected DriverResponse runWithRuntimeException(Portlet portlet, ResourceRequest
request, ResourceResponse response, PortletTestContext context) throws PortletException,
IOException
+ {
+ try
+ {
+ return run(portlet, request, response, context);
+ }
catch (Exception e)
{
if (e instanceof PortletException)
@@ -57,13 +74,12 @@
{
throw (IOException)e;
}
- return new FailureResponse(Failure.createAssertionFailure(e));
+ throw new AssertionError(e);
}
- catch (AssertionError t)
- {
- return new FailureResponse(Failure.createFailure(t));
- }
}
- protected abstract DriverResponse run(Portlet portlet, ResourceRequest request,
ResourceResponse response, PortletTestContext context) throws PortletException,
IOException;
+ protected DriverResponse run(Portlet portlet, ResourceRequest request,
ResourceResponse response, PortletTestContext context) throws PortletException,
IOException
+ {
+ throw new NotYetImplemented();
+ }
}
\ No newline at end of file
Copied:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PageNavigationalState.java
(from rev 9550,
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java)
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PageNavigationalState.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PageNavigationalState.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -0,0 +1,110 @@
+/******************************************************************************
+ * 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;
+
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.ParameterInfo;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.zip.GZIPOutputStream;
+import java.util.zip.GZIPInputStream;
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PageNavigationalState implements Serializable
+{
+
+ /** . */
+ private final Map<String, WindowNavigationalState> windows = new
HashMap<String, WindowNavigationalState>();
+
+ /** . */
+ private final Map<QName, String[]> page = new HashMap<QName, String[]>();
+
+ public WindowNavigationalState getWindowNavigationalState(String windowId)
+ {
+ return windows.get(windowId);
+ }
+
+ public void setWindowNavigationalState(String windowId, WindowNavigationalState
windowNS)
+ {
+ windows.put(windowId, windowNS);
+ }
+
+ public Map<QName, String[]> getPageNavigationalState()
+ {
+ return page;
+ }
+
+ public ParameterMap getPublicNavigationalState(Portlet portlet)
+ {
+ PortletInfo portletInfo = portlet.getInfo();
+ Map<QName, String[]> pm = page;
+ ParameterMap publicNavigationalState = null;
+ for (ParameterInfo parameterInfo :
portletInfo.getNavigation().getPublicParameters())
+ {
+ String[] parameterValue = pm.get(parameterInfo.getName());
+ if (parameterValue != null)
+ {
+ String parameterId = parameterInfo.getId();
+ if (publicNavigationalState == null)
+ {
+ publicNavigationalState = new ParameterMap();
+ }
+
+ //
+ publicNavigationalState.put(parameterId, parameterValue);
+ }
+ }
+ return publicNavigationalState;
+ }
+
+ public static byte[] serialize(PageNavigationalState object) throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ GZIPOutputStream zos = new GZIPOutputStream(baos);
+ ObjectOutputStream oos = new ObjectOutputStream(zos);
+ oos.writeObject(object);
+ oos.close();
+ return baos.toByteArray();
+ }
+
+ public static PageNavigationalState unserialize(byte[] bytes) throws IOException,
ClassNotFoundException
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ GZIPInputStream zis = new GZIPInputStream(bais);
+ ObjectInputStream ois = new ObjectInputStream(zis);
+ return (PageNavigationalState)ois.readObject();
+ }
+}
Deleted:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -1,82 +0,0 @@
-/******************************************************************************
- * 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;
-
-import javax.xml.namespace.QName;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.zip.GZIPOutputStream;
-import java.util.zip.GZIPInputStream;
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInputStream;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortalNavigationalState implements Serializable
-{
-
- /** . */
- private final Map<String, WindowNavigationalState> windows = new
HashMap<String, WindowNavigationalState>();
-
- /** . */
- private final Map<QName, String[]> page = new HashMap<QName, String[]>();
-
- public WindowNavigationalState getWindowNavigationalState(String windowId)
- {
- return windows.get(windowId);
- }
-
- public void setWindowNavigationalState(String windowId, WindowNavigationalState
windowNS)
- {
- windows.put(windowId, windowNS);
- }
-
- public Map<QName, String[]> getPageNavigationalState()
- {
- return page;
- }
-
- public static byte[] serialize(PortalNavigationalState object) throws IOException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- GZIPOutputStream zos = new GZIPOutputStream(baos);
- ObjectOutputStream oos = new ObjectOutputStream(zos);
- oos.writeObject(object);
- oos.close();
- return baos.toByteArray();
- }
-
- public static PortalNavigationalState unserialize(byte[] bytes) throws IOException,
ClassNotFoundException
- {
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- GZIPInputStream zis = new GZIPInputStream(bais);
- ObjectInputStream ois = new ObjectInputStream(zis);
- return (PortalNavigationalState)ois.readObject();
- }
-}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -25,7 +25,7 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.CacheabilityType;
import org.jboss.portal.portlet.spi.ResourceInvocationContext;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.EventInfo;
@@ -68,6 +68,7 @@
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Map;
+import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -90,40 +91,11 @@
log = Logger.getLogger(PortletController.class);
}
- private ParameterMap getPublicNavigationalState(
- PortletControllerContext context,
- Portlet portlet)
- {
- PortletInfo portletInfo = portlet.getInfo();
- PortalNavigationalState portalNS = context.getNavigationalState();
- Map<QName, String[]> pm = portalNS.getPageNavigationalState();
- ParameterMap publicNavigationalState = null;
- for (ParameterInfo parameterInfo :
portletInfo.getNavigation().getPublicParameters())
- {
- String[] parameterValue = pm.get(parameterInfo.getName());
- if (parameterValue != null)
- {
- String parameterId = parameterInfo.getId();
- if (publicNavigationalState == null)
- {
- publicNavigationalState = new ParameterMap();
- }
-
- //
- publicNavigationalState.put(parameterId, parameterValue);
- }
- }
- return publicNavigationalState;
- }
-
private PortletInvocationResponse handle(PortletControllerContext context,
ContainerRequest containerRequest) throws PortletInvokerException, IOException
{
Portlet portlet = context.getPortlet(containerRequest.portletId);
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
- PortalNavigationalState portalNS = context.getNavigationalState();
- WindowNavigationalState windowNS =
portalNS.getWindowNavigationalState(containerRequest.portletId);
- PortletURLRenderer renderer = new PortletURLRenderer(portalNS, windowNS, portlet,
req, resp);
//
if (containerRequest instanceof PortletRenderRequest)
@@ -145,11 +117,10 @@
PortletActionRequest portletActionRequest =
(PortletActionRequest)containerRequest;
//
+ PageNavigationalState pageNS = portletActionRequest.pageState;
+
+ //
Mode mode = portletActionRequest.mode;
- if (mode == null && windowNS != null && windowNS.getMode() !=
null)
- {
- mode = windowNS.getMode();
- }
if (mode == null)
{
mode = Mode.VIEW;
@@ -157,19 +128,21 @@
//
WindowState windowState = portletActionRequest.windowState;
- if (windowState == null && windowNS != null &&
windowNS.getWindowState() != null)
- {
- windowState = windowNS.getWindowState();
- }
if (windowState == null)
{
windowState = WindowState.NORMAL;
}
//
- ParameterMap publicNS = getPublicNavigationalState(context, portlet);
+ WindowNavigationalState windowNS = new
WindowNavigationalState(portletActionRequest.navigationalState, mode, windowState);
//
+ ParameterMap publicNS = pageNS.getPublicNavigationalState(portlet);
+
+ //
+ PortletURLRenderer renderer = new PortletURLRenderer(pageNS, windowNS, portlet,
req, resp);
+
+ //
TestInstanceContext instanceContext = new TestInstanceContext(req,
portlet.getContext(), true);
TestActionContext actionContext = new TestActionContext(
renderer,
@@ -207,39 +180,57 @@
PortletResourceRequest portletResourceRequest =
(PortletResourceRequest)containerRequest;
//
- Mode mode = Mode.VIEW;
- if (mode == null && windowNS != null && windowNS.getMode() !=
null)
+ Mode mode;
+ WindowState windowState;
+ CacheabilityType cacheability;
+ ParameterMap publicNS;
+ StateString portletNS;
+ PageNavigationalState pageNS;
+ if (portletResourceRequest instanceof PortletScopedPortletResourceRequest)
{
- mode = windowNS.getMode();
+ PortletScopedPortletResourceRequest portletScopedRequest =
(PortletScopedPortletResourceRequest)portletResourceRequest;
+ mode = portletScopedRequest.mode;
+ windowState = portletScopedRequest.windowState;
+ portletNS = portletScopedRequest.navigationalState;
+ if (portletResourceRequest instanceof PageScopedFullPortletResourceRequest)
+ {
+ PageScopedFullPortletResourceRequest pageScopedRequest =
(PageScopedFullPortletResourceRequest)portletResourceRequest;
+ pageNS = pageScopedRequest.pageState;
+ publicNS = pageNS.getPublicNavigationalState(portlet);
+ cacheability = CacheabilityType.PAGE;
+ }
+ else
+ {
+ publicNS = new ParameterMap();
+ cacheability = CacheabilityType.PORTLET;
+ pageNS = null;
+ }
}
- if (mode == null)
+ else
{
+ publicNS = new ParameterMap();
+ cacheability = CacheabilityType.FULL;
mode = Mode.VIEW;
+ windowState = WindowState.NORMAL;
+ portletNS = null;
+ pageNS = null;
}
//
- WindowState windowState = WindowState.NORMAL;
- if (windowState == null && windowNS != null &&
windowNS.getWindowState() != null)
- {
- windowState = windowNS.getWindowState();
- }
- if (windowState == null)
- {
- windowState = WindowState.NORMAL;
- }
+ WindowNavigationalState windowNS = new WindowNavigationalState(portletNS, mode,
windowState);
//
- ParameterMap publicNS = getPublicNavigationalState(context, portlet);
+ PortletURLRenderer renderer = new PortletURLRenderer(pageNS, windowNS, portlet,
req, resp);
//
TestInstanceContext instanceContext = new TestInstanceContext(req,
portlet.getContext(), true);
ResourceInvocationContext resourceInvocationContext = new ResourceTestContext(
portletResourceRequest.resourceId,
- portletResourceRequest.resourceCacheability,
+ cacheability,
renderer,
mode,
windowState,
- portletResourceRequest.navigationalState,
+ portletNS,
publicNS,
portletResourceRequest.resourceState,
portletResourceRequest.bodyParameters != null ?
ParameterMap.clone(portletResourceRequest.bodyParameters) : null,
@@ -271,13 +262,13 @@
private PortletInvocationResponse deliverEvent(
PortletControllerContext context,
Portlet portlet,
- StateResponse.Event event)
+ StateResponse.Event event,
+ PageNavigationalState pageNS)
{
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
- PortalNavigationalState navState = context.getNavigationalState();
- WindowNavigationalState windowNS =
navState.getWindowNavigationalState(portlet.getContext().getId());
- PortletURLRenderer renderer = new PortletURLRenderer(navState, windowNS, portlet,
req, resp);
+ WindowNavigationalState windowNS =
pageNS.getWindowNavigationalState(portlet.getContext().getId());
+ PortletURLRenderer renderer = new PortletURLRenderer(pageNS, windowNS, portlet,
req, resp);
//
if (windowNS == null)
@@ -286,7 +277,7 @@
}
//
- ParameterMap publicNS = getPublicNavigationalState(context, portlet);
+ ParameterMap publicNS = pageNS.getPublicNavigationalState(portlet);
//
TestInstanceContext instanceContext = new TestInstanceContext(req,
portlet.getContext(), true);
@@ -328,7 +319,7 @@
{
if (controllerRequest == null)
{
- render(context);
+ render(context, new PageNavigationalState());
}
else if (controllerRequest instanceof ContainerRequest)
{
@@ -340,11 +331,13 @@
{
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
- PortalNavigationalState portalNS = context.getNavigationalState();
//
if (containerRequest instanceof PortletRequest)
{
+ PortletRequest portletRequest = (PortletRequest)containerRequest;
+
+ //
PortletInvocationResponse response = handle(context, containerRequest);
//
@@ -372,7 +365,11 @@
// Update portlet NS
if (response instanceof UpdateNavigationalStateResponse)
{
- updateNavigationalState(context, containerRequest.portletId,
(UpdateNavigationalStateResponse)response);
+ updateNavigationalState(
+ context,
+ containerRequest.portletId,
+ (UpdateNavigationalStateResponse)response,
+ portletRequest.pageState);
}
// Create event list and feed it with the events that may have been produced
@@ -403,7 +400,7 @@
//
for (Portlet consumer : consumers)
{
- PortletInvocationResponse eventResponse = deliverEvent(context,
consumer, event);
+ PortletInvocationResponse eventResponse = deliverEvent(context,
consumer, event, portletRequest.pageState);
//
if (eventResponse instanceof UpdateNavigationalStateResponse)
@@ -411,7 +408,7 @@
UpdateNavigationalStateResponse update =
(UpdateNavigationalStateResponse)eventResponse;
// Update ns
- updateNavigationalState(context, consumer.getContext().getId(),
update);
+ updateNavigationalState(context, consumer.getContext().getId(),
update, portletRequest.pageState);
// Add events if any
queue.addAll(update.getEvents());
@@ -476,7 +473,7 @@
*/
//
- render(context);
+ render(context, portletRequest.pageState);
}
else if (containerRequest instanceof PortletResourceRequest)
{
@@ -535,11 +532,10 @@
}
}
- private void render(PortletControllerContext context) throws IOException
+ private void render(PortletControllerContext context, PageNavigationalState pageNS)
throws IOException
{
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
- PortalNavigationalState portalNS = context.getNavigationalState();
//
resp.setContentType("text/html");
@@ -554,10 +550,10 @@
writer.print("<div><div>" + portlet.getContext() +
"</div>");
//
- WindowNavigationalState windowNS =
portalNS.getWindowNavigationalState(portlet.getContext().getId());
+ WindowNavigationalState windowNS =
pageNS.getWindowNavigationalState(portlet.getContext().getId());
//
- PortletURLRenderer renderer = new PortletURLRenderer(portalNS, windowNS,
portlet, req, resp);
+ PortletURLRenderer renderer = new PortletURLRenderer(pageNS, windowNS,
portlet, req, resp);
//
Mode mode = Mode.VIEW;
@@ -582,7 +578,7 @@
}
//
- ParameterMap publicNS = getPublicNavigationalState(context, portlet);
+ ParameterMap publicNS = pageNS.getPublicNavigationalState(portlet);
//
TestInstanceContext instanceContext = new TestInstanceContext(req,
portlet.getContext(), false);
@@ -625,13 +621,13 @@
private void updateNavigationalState(
PortletControllerContext context,
String portletId,
- UpdateNavigationalStateResponse update) throws PortletInvokerException
+ UpdateNavigationalStateResponse update,
+ PageNavigationalState pageState) throws PortletInvokerException
{
Portlet portlet = context.getPortlet(portletId);
- PortalNavigationalState portalNS = context.getNavigationalState();
//
- WindowNavigationalState windowNS = portalNS.getWindowNavigationalState(portletId);
+ WindowNavigationalState windowNS =
pageState.getWindowNavigationalState(portletId);
//
if (windowNS == null)
@@ -656,14 +652,14 @@
portletNS = update.getNavigationalState();
}
windowNS = new WindowNavigationalState(portletNS, mode, windowState);
- portalNS.setWindowNavigationalState(portletId, windowNS);
+ pageState.setWindowNavigationalState(portletId, windowNS);
// Now update shared state scoped at page
Map<String, String[]> publicNS = update.getPublicNavigationalStateUpdates();
if (publicNS != null)
{
NavigationInfo navigationInfo = portlet.getInfo().getNavigation();
- Map<QName, String[]> pageNS = portalNS.getPageNavigationalState();
+ Map<QName, String[]> pageNS = pageState.getPageNavigationalState();
for (Map.Entry<String, String[]> entry : publicNS.entrySet())
{
String id = entry.getKey();
@@ -706,31 +702,45 @@
{
/** . */
+ final PageNavigationalState pageState;
+
+ /** . */
+ final StateString navigationalState;
+
+ /** . */
final Mode mode;
/** . */
final WindowState windowState;
- PortletRequest(String portletId, Mode mode, WindowState windowState)
+ PortletRequest(String portletId, Mode mode, WindowState windowState, StateString
navigationalState, PageNavigationalState pageState)
{
super(portletId);
+
+ //
this.mode = mode;
this.windowState = windowState;
+ this.navigationalState = navigationalState;
+ this.pageState = pageState;
}
}
- static class PortletResourceRequest extends ContainerRequest
+ static abstract class PortletResourceRequest extends ContainerRequest
{
/** . */
- final String resourceId;
+ private static final Map<Class, CacheabilityType> cacheability = new
HashMap<Class, CacheabilityType>();
- /** . */
- final Cacheability resourceCacheability;
+ static
+ {
+ cacheability.put(FullScopedCacheablePortletResourceRequest.class,
CacheabilityType.FULL);
+ cacheability.put(PortletScopedPortletResourceRequest.class,
CacheabilityType.PORTLET);
+ cacheability.put(PageScopedFullPortletResourceRequest.class,
CacheabilityType.PAGE);
+ }
/** . */
- final StateString navigationalState;
+ final String resourceId;
/** . */
final StateString resourceState;
@@ -741,28 +751,89 @@
PortletResourceRequest(
String portletId,
String resourceId,
- Cacheability resourceCacheability,
StateString resourceState,
- ParameterMap bodyParameters,
- StateString navigationalState
+ ParameterMap bodyParameters
)
{
super(portletId);
+
+ //
this.resourceId = resourceId;
- this.resourceCacheability = resourceCacheability;
- this.navigationalState = navigationalState;
this.resourceState = resourceState;
this.bodyParameters = bodyParameters;
}
+
+ public CacheabilityType getCacheabilityType()
+ {
+ return cacheability.get(getClass());
+ }
}
- static class PortletActionRequest extends PortletRequest
+ static class FullScopedCacheablePortletResourceRequest extends PortletResourceRequest
{
+ FullScopedCacheablePortletResourceRequest(String portletId, String resourceId,
StateString resourceState, ParameterMap bodyParameters)
+ {
+ super(portletId, resourceId, resourceState, bodyParameters);
+ }
+ }
+ static class PortletScopedPortletResourceRequest extends
FullScopedCacheablePortletResourceRequest
+ {
+
/** . */
final StateString navigationalState;
/** . */
+ final Mode mode;
+
+ /** . */
+ final WindowState windowState;
+
+ PortletScopedPortletResourceRequest(
+ String portletId,
+ String resourceId,
+ StateString resourceState,
+ ParameterMap bodyParameters,
+ StateString navigationalState,
+ Mode mode,
+ WindowState windowState)
+ {
+ super(portletId, resourceId, resourceState, bodyParameters);
+
+ //
+ this.mode = mode;
+ this.windowState = windowState;
+ this.navigationalState = navigationalState;
+ }
+ }
+
+ static class PageScopedFullPortletResourceRequest extends
PortletScopedPortletResourceRequest
+ {
+
+ /** . */
+ private final PageNavigationalState pageState;
+
+ PageScopedFullPortletResourceRequest(
+ String portletId,
+ String resourceId,
+ StateString resourceState,
+ ParameterMap bodyParameters,
+ StateString navigationalState,
+ PageNavigationalState pageState,
+ Mode mode,
+ WindowState windowState)
+ {
+ super(portletId, resourceId, resourceState, bodyParameters, navigationalState,
mode, windowState);
+
+ //
+ this.pageState = pageState;
+ }
+ }
+
+ static class PortletActionRequest extends PortletRequest
+ {
+
+ /** . */
final StateString interactionState;
/** . */
@@ -774,12 +845,12 @@
ParameterMap bodyParameters,
StateString navigationalState,
Mode mode,
- WindowState windowState)
+ WindowState windowState,
+ PageNavigationalState pageState)
{
- super(portletId, mode, windowState);
+ super(portletId, mode, windowState, navigationalState, pageState);
//
- this.navigationalState = navigationalState;
this.interactionState = interactionState;
this.bodyParameters = bodyParameters;
}
@@ -789,8 +860,6 @@
{
/** . */
- final StateString navigationalState;
-
final Map<String, String[]> publicNavigationalStateChanges;
public PortletRenderRequest(
@@ -798,12 +867,12 @@
StateString navigationalState,
Map<String, String[]> publicNavigationalStateChanges,
Mode mode,
- WindowState windowState)
+ WindowState windowState,
+ PageNavigationalState pageState)
{
- super(portletId, mode, windowState);
+ super(portletId, mode, windowState, navigationalState, pageState);
//
- this.navigationalState = navigationalState;
this.publicNavigationalStateChanges = publicNavigationalStateChanges;
}
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -39,8 +39,6 @@
public interface PortletControllerContext
{
- PortalNavigationalState getNavigationalState();
-
ServletContext getServletContext();
HttpServletRequest getClientRequest();
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
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -33,7 +33,7 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.CacheabilityType;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.web.Body;
@@ -70,9 +70,6 @@
private final ServletContext servletContext;
/** . */
- private final PortalNavigationalState navState;
-
- /** . */
private final PortletController.ControllerRequest request;
/** . */
@@ -86,39 +83,59 @@
{
PortletInvoker invoker =
(PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
- PortalNavigationalState navState;
- PortletController.ControllerRequest request;
+ // The nav state provided with the request
+ PageNavigationalState pageState = null;
- // decode request
+ // The request decoded if not null
+ PortletController.ControllerRequest request = null;
+
+ // Process
String pathInfo = req.getPathInfo();
if (pathInfo != null && pathInfo.startsWith("/") &&
pathInfo.length() > 1)
{
+ // Get the target portlet
String targetId = StringCodec.decode(pathInfo.substring(1));
+ // Helper
WebRequest ri = new WebRequest(req);
- // Unmarshall portal navigational state
+ // Unmarshall portal navigational state if it is provided
String context = req.getParameter("context");
- byte[] bytes = Tools.fromHexString(context);
- navState = PortalNavigationalState.unserialize(bytes);
+ if (context != null)
+ {
+ byte[] bytes = Tools.fromHexString(context);
+ pageState = PageNavigationalState.unserialize(bytes);
+ }
//
- String type = req.getParameter("type");
+ Mode mode = null;
+ if (req.getParameter("mode") != null)
+ {
+ mode = Mode.create(req.getParameter("mode"));
+ }
+ //
+ WindowState windowState = null;
+ if (req.getParameter("windowstate") != null)
+ {
+ windowState = WindowState.create(req.getParameter("windowstate"));
+ }
//
+ String navigationalStateString =
req.getParameter("navigationalstate");
+ StateString navigationalState = null;
+ if (navigationalStateString != null)
+ {
+ navigationalState = ParametersStateString.create(navigationalStateString);
+ }
+
+ //
+ String type = req.getParameter("type");
if ("resource".equals(type))
{
StateString resourceState =
ParametersStateString.create(req.getParameter("resourcestate"));
String resourceId = req.getParameter("id");
- //
- String navigationalStateString =
req.getParameter("navigationalstate");
- StateString navigationalState = null;
- if (navigationalStateString != null)
- {
- navigationalState =
ParametersStateString.create(navigationalStateString);
- }
//
ParameterMap formParameters = null;
@@ -128,34 +145,43 @@
}
//
- Cacheability resourceCacheability =
Cacheability.valueOf(req.getParameter("cacheability"));
+ CacheabilityType resourceCacheabilityType =
CacheabilityType.valueOf(req.getParameter("cacheability"));
//
- request = new PortletController.PortletResourceRequest(
- targetId,
- resourceId,
- resourceCacheability,
- resourceState,
- formParameters,
- navigationalState);
+ switch (resourceCacheabilityType)
+ {
+ case FULL:
+ request = new
PortletController.FullScopedCacheablePortletResourceRequest(
+ targetId,
+ resourceId,
+ resourceState,
+ formParameters);
+ break;
+ case PORTLET:
+ request = new PortletController.PortletScopedPortletResourceRequest(
+ targetId,
+ resourceId,
+ resourceState,
+ formParameters,
+ navigationalState,
+ mode,
+ windowState);
+ break;
+ case PAGE:
+ request = new PortletController.PageScopedFullPortletResourceRequest(
+ targetId,
+ resourceId,
+ resourceState,
+ formParameters,
+ navigationalState,
+ pageState,
+ mode,
+ windowState);
+ break;
+ }
}
else
{
- //
- Mode mode = null;
- if (req.getParameter("mode") != null)
- {
- mode = Mode.create(req.getParameter("mode"));
- }
-
- //
- WindowState windowState = null;
- if (req.getParameter("windowstate") != null)
- {
- windowState =
WindowState.create(req.getParameter("windowstate"));
- }
-
- //
if ("action".equals(type))
{
ParameterMap formParameters = null;
@@ -165,39 +191,37 @@
}
//
- String navigationalStateString =
req.getParameter("navigationalstate");
- StateString navigationalState = null;
- if (navigationalStateString != null)
- {
- navigationalState =
ParametersStateString.create(navigationalStateString);
- }
-
- //
StateString interactionState =
ParametersStateString.create(req.getParameter("interactionstate"));
//
- request = new PortletController.PortletActionRequest(targetId,
interactionState, formParameters, navigationalState, mode, windowState);
+ request = new PortletController.PortletActionRequest(
+ targetId,
+ interactionState,
+ formParameters,
+ navigationalState,
+ mode,
+ windowState,
+ pageState);
}
else
{
- StateString navigationalState =
ParametersStateString.create(req.getParameter("navigationalstate"));
//
Map<String, String[]> publicNavigationalStateChanges =
(Map<String,
String[]>)IOTools.unserialize(Tools.fromHexString(req.getParameter("publicnavigationalstatechanges")));
//
- request = new PortletController.PortletRenderRequest(targetId,
navigationalState, publicNavigationalStateChanges, mode, windowState);
+ request = new PortletController.PortletRenderRequest(
+ targetId,
+ navigationalState,
+ publicNavigationalStateChanges,
+ mode,
+ windowState,
+ pageState);
}
}
}
- else
- {
- navState = new PortalNavigationalState();
- request = null;
- }
//
- this.navState = navState;
this.request = request;
this.req = req;
this.resp = resp;
@@ -210,11 +234,6 @@
return request;
}
- public PortalNavigationalState getNavigationalState()
- {
- return navState;
- }
-
public ServletContext getServletContext()
{
return servletContext;
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
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -29,6 +29,7 @@
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ResourceURL;
import org.jboss.portal.portlet.ContainerURL;
+import org.jboss.portal.portlet.CacheabilityType;
import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.Tools;
@@ -60,16 +61,16 @@
final HttpServletResponse clientResp;
/** . */
- final PortalNavigationalState portalNS;
+ final PageNavigationalState pageNS;
public PortletURLRenderer(
- PortalNavigationalState portalNS,
+ PageNavigationalState pageNS,
WindowNavigationalState windowNS,
Portlet portlet,
HttpServletRequest clientReq,
HttpServletResponse clientResp)
{
- this.portalNS = portalNS;
+ this.pageNS = pageNS;
this.windowNS = windowNS;
this.portlet = portlet;
this.clientReq = clientReq;
@@ -112,11 +113,12 @@
parameters.put("type", type);
//
+ String context;
try
{
- byte[] bytes = PortalNavigationalState.serialize(portalNS);
+ byte[] bytes = PageNavigationalState.serialize(pageNS);
String ns = Tools.toHexString(bytes);
- parameters.put("context", ns);
+ context = ns;
}
catch (IOException e)
{
@@ -140,15 +142,21 @@
}
//
+ parameters.put("context", context);
+
+ //
if (containerURL instanceof ActionURL)
{
ActionURL actionURL = (ActionURL)containerURL;
//
- StateString navigationalState = actionURL.getNavigationalState();
- if (navigationalState != null)
+ if (windowNS != null)
{
- parameters.put("navigationalstate",
navigationalState.getStringValue());
+ StateString portletNS = windowNS.getPortletNavigationalState();
+ if (portletNS != null)
+ {
+ parameters.put("navigationalstate",
windowNS.getPortletNavigationalState().getStringValue());
+ }
}
//
@@ -187,25 +195,36 @@
parameters.put("resourcestate", resourceState.getStringValue());
//
- String resourceId = resourceURL.getId();
+ String resourceId = resourceURL.getResourceId();
if (resourceId != null)
{
parameters.put("id", resourceId);
}
//
- parameters.put("cacheability", resourceURL.getCacheability().name());
- switch (resourceURL.getCacheability())
+ CacheabilityType cacheability = resourceURL.getCacheability();
+ parameters.put("cacheability", cacheability.name());
+
+ //
+ if (cacheability != CacheabilityType.FULL)
{
- case FULL:
- // todo
- break;
- case PORTLET:
- // todo
- break;
- case PAGE:
- // todo
- break;
+ StateString portletNS = windowNS.getPortletNavigationalState();
+ if (portletNS != null)
+ {
+ parameters.put("navigationalstate",
windowNS.getPortletNavigationalState().getStringValue());
+ }
+
+ //
+ parameters.put("mode", windowNS.getMode().toString());
+
+ //
+ parameters.put("windowstate",
windowNS.getWindowState().toString());
+
+ //
+ if (cacheability == CacheabilityType.PAGE)
+ {
+ parameters.put("context", context);
+ }
}
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java 2008-01-23
14:39:46 UTC (rev 9576)
@@ -24,7 +24,7 @@
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ContainerURL;
-import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.CacheabilityType;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.impl.spi.AbstractResourceContext;
import org.jboss.portal.Mode;
@@ -49,7 +49,7 @@
public ResourceTestContext(
String resourceId,
- Cacheability resourceCacheability,
+ CacheabilityType resourceCacheabilityType,
PortletURLRenderer urlRenderer,
Mode mode,
WindowState windowState,
@@ -61,7 +61,7 @@
{
super(
resourceId,
- resourceCacheability,
+ resourceCacheabilityType,
mode,
windowState,
navigationalState,
Modified:
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml
===================================================================
---
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml 2008-01-23
13:57:05 UTC (rev 9575)
+++
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml 2008-01-23
14:39:46 UTC (rev 9576)
@@ -60,6 +60,14 @@
<supported-public-render-parameter>foo</supported-public-render-parameter>
</portlet>
+ <portlet>
+ <portlet-name>UniversalTestPortletD</portlet-name>
+
<portlet-class>org.jboss.portal.test.portlet.framework.UTP4</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ </portlet>
+
<event-definition>
<name>Event</name>
</event-definition>