JBoss Portal SVN: r9577 - modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-23 10:23:47 -0500 (Wed, 23 Jan 2008)
New Revision: 9577
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/PortletURLRenderer.java
Log:
- fixed some state management bug for resource serving
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 14:39:46 UTC (rev 9576)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-23 15:23:47 UTC (rev 9577)
@@ -180,40 +180,52 @@
PortletResourceRequest portletResourceRequest = (PortletResourceRequest)containerRequest;
//
- Mode mode;
- WindowState windowState;
+ Mode mode = null;
+ WindowState windowState = null;
+ PageNavigationalState pageNS = null;
+ ParameterMap publicNS = null;
+ StateString portletNS = null;
CacheabilityType cacheability;
- ParameterMap publicNS;
- StateString portletNS;
- PageNavigationalState pageNS;
+
+ //
if (portletResourceRequest instanceof PortletScopedPortletResourceRequest)
{
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;
+
+ //
+ if (pageNS != null)
+ {
+ publicNS = pageNS.getPublicNavigationalState(portlet);
+ }
}
else
{
- publicNS = new ParameterMap();
cacheability = CacheabilityType.PORTLET;
- pageNS = null;
}
}
else
{
- publicNS = new ParameterMap();
cacheability = CacheabilityType.FULL;
+ }
+
+ //
+ if (mode == null)
+ {
mode = Mode.VIEW;
+ }
+ if (windowState == null)
+ {
windowState = WindowState.NORMAL;
- portletNS = null;
- pageNS = null;
}
//
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 14:39:46 UTC (rev 9576)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-23 15:23:47 UTC (rev 9577)
@@ -208,22 +208,25 @@
//
if (cacheability != CacheabilityType.FULL)
{
- StateString portletNS = windowNS.getPortletNavigationalState();
- if (portletNS != null)
+ if (windowNS != null)
{
- parameters.put("navigationalstate", windowNS.getPortletNavigationalState().getStringValue());
- }
+ StateString portletNS = windowNS.getPortletNavigationalState();
+ if (portletNS != null)
+ {
+ parameters.put("navigationalstate", windowNS.getPortletNavigationalState().getStringValue());
+ }
- //
- parameters.put("mode", windowNS.getMode().toString());
+ //
+ parameters.put("mode", windowNS.getMode().toString());
- //
- parameters.put("windowstate", windowNS.getWindowState().toString());
+ //
+ parameters.put("windowstate", windowNS.getWindowState().toString());
- //
- if (cacheability == CacheabilityType.PAGE)
- {
- parameters.put("context", context);
+ //
+ if (cacheability == CacheabilityType.PAGE)
+ {
+ parameters.put("context", context);
+ }
}
}
}
18 years, 3 months
JBoss Portal SVN: r9576 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api and 10 other directories.
by portal-commits@lists.jboss.org
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>
18 years, 3 months
JBoss Portal SVN: r9575 - modules/test/trunk/unit/src/main/java/org/jboss/unit/api.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-23 08:57:05 -0500 (Wed, 23 Jan 2008)
New Revision: 9575
Modified:
modules/test/trunk/unit/src/main/java/org/jboss/unit/api/Assert.java
Log:
fix assertion error creation message that was not correct
Modified: modules/test/trunk/unit/src/main/java/org/jboss/unit/api/Assert.java
===================================================================
--- modules/test/trunk/unit/src/main/java/org/jboss/unit/api/Assert.java 2008-01-23 02:59:20 UTC (rev 9574)
+++ modules/test/trunk/unit/src/main/java/org/jboss/unit/api/Assert.java 2008-01-23 13:57:05 UTC (rev 9575)
@@ -301,7 +301,7 @@
{
if (!Arrays.equals(expected, actual))
{
- fail(format(message, expected, expected));
+ fail(format(message, expected, actual));
}
}
18 years, 3 months
JBoss Portal SVN: r9574 - in branches/JBoss_Portal_Branch_2_6: core/src/main/org/jboss/portal/core/model/instance and 5 other directories.
by portal-commits@lists.jboss.org
Author: wesleyhales
Date: 2008-01-22 21:59:20 -0500 (Tue, 22 Jan 2008)
New Revision: 9574
Added:
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/DisplayNameBean.java
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalInstanceDisplayNameAction.java
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/css/style.css
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalObjectDisplayNameAction.java
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/showPortletDetails.xhtml
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceCustomization.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceDefinition.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/instance/Instance.java
Log:
JBPORTAL-1775 - Let a user define multiple display-name for a portlet-instance in the admin portlet
Modified: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceCustomization.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceCustomization.java 2008-01-22 21:53:15 UTC (rev 9573)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceCustomization.java 2008-01-23 02:59:20 UTC (rev 9574)
@@ -40,6 +40,7 @@
protected Long key;
protected PersistentInstanceDefinition relatedDefinition;
protected String customizationId;
+ protected LocalizedString displayName;
// Runtime fields
@@ -99,6 +100,11 @@
return owner.getDisplayName();
}
+ public void setDisplayName(LocalizedString localizedString)
+ {
+ this.displayName = localizedString;
+ }
+
public String getCustomizationId()
{
return customizationId;
Modified: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceDefinition.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceDefinition.java 2008-01-22 21:53:15 UTC (rev 9573)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceDefinition.java 2008-01-23 02:59:20 UTC (rev 9574)
@@ -119,6 +119,24 @@
return new LocalizedString(displayNames, Locale.ENGLISH);
}
+ public void setDisplayName(LocalizedString localizedString)
+ {
+ if (localizedString == null)
+ {
+ throw new IllegalArgumentException("No null display name accepted");
+ }
+
+ displayNames = new HashMap();
+
+ Map map = localizedString.getValues();
+ Iterator it = map.values().iterator();
+ while (it.hasNext())
+ {
+ LocalizedString.Value value = (LocalizedString.Value)it.next();
+ displayNames.put(value.getLocale(), value.getString());
+ }
+ }
+
// Hibernate ********************************************************************************************************
public Long getKey()
Modified: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/instance/Instance.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/instance/Instance.java 2008-01-22 21:53:15 UTC (rev 9573)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/instance/Instance.java 2008-01-23 02:59:20 UTC (rev 9574)
@@ -58,6 +58,13 @@
LocalizedString getDisplayName();
/**
+ * Set the display name
+ *
+ * @param localizedString
+ */
+ void setDisplayName(LocalizedString localizedString);
+
+ /**
* Return the runtime metadata for this portlet.
*
* @return the info
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/css/style.css
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/css/style.css 2008-01-22 21:53:15 UTC (rev 9573)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/css/style.css 2008-01-23 02:59:20 UTC (rev 9574)
@@ -56,6 +56,26 @@
padding: 4px;
}
+.admin-ui dl {
+
+}
+
+.admin-ui dt {
+
+}
+
+.admin-ui dd {
+ margin:0;
+}
+
+.admin-ui .panelGrid-basic{
+ width: 100%;
+}
+
+.admin-ui .panelGrid-basic td {
+ padding: 8px;
+}
+
/* Pagination. */
.admin-ui ul.pagination {
Added: branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/DisplayNameBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/DisplayNameBean.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/DisplayNameBean.java 2008-01-23 02:59:20 UTC (rev 9574)
@@ -0,0 +1,158 @@
+/******************************************************************************
+ * 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.core.admin.ui;
+
+
+import org.jboss.portal.common.i18n.LocaleManager;
+import org.jboss.portal.common.i18n.LocalizedString;
+
+import javax.faces.context.FacesContext;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * @author <a href="mailto:whales@redhat.com">Wesley Hales</a>
+ * @version $Revision: 630 $
+ */
+public class DisplayNameBean
+{
+
+
+ public Map createLocalizedStringMap(Locale locale, LocalizedString displayName, String name)
+ {
+ Map<Locale, String> map = new HashMap<Locale, String>();
+ if (displayName != null)
+ {
+ Map<Locale, LocalizedString.Value> oldMap = displayName.getValues();
+ Collection<LocalizedString.Value> values = oldMap.values();
+ for (LocalizedString.Value value : values)
+ {
+ map.put(value.getLocale(), value.getString());
+ }
+ }
+ map.put(locale, name);
+ return map;
+ }
+
+ public SortedMap getLocales()
+ {
+ SortedMap smap = new TreeMap();
+ Locale[] localList = (Locale[])LocaleManager.getLocales().toArray(new Locale[0]);
+
+ for (int i = 0; i < localList.length; i++)
+ {
+ Locale thisLocale = localList[i];
+ Locale requestedLocale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
+ smap.put(convertLocaleDisplayName(thisLocale.getDisplayLanguage(requestedLocale)), thisLocale.getLanguage());
+ }
+ return smap;
+ }
+
+ public List populateCurrentLocales(Map displayNames)
+ {
+ List tempList = new ArrayList();
+ Iterator it = displayNames.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry pairs = (Map.Entry)it.next();
+ Locale thisLocale = (Locale)pairs.getKey();
+ Locale requestedLocale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
+ tempList.add(new Value(thisLocale, convertLocaleDisplayName(thisLocale.getDisplayLanguage(requestedLocale)), getDisplayNameByLocale(thisLocale,displayNames)));
+
+ }
+ return tempList;
+ }
+
+ private String getDisplayNameByLocale(Locale locale, Map displayNames)
+ {
+ LocalizedString.Value lsv = (LocalizedString.Value)displayNames.get(locale);
+ return lsv.getString();
+ }
+
+ private String convertLocaleDisplayName(String str)
+ {
+ if (str.length() > 0)
+ {
+ return str.substring(0, 1).toUpperCase() + str.substring(1, str.length());
+ }
+ else
+ {
+ return str;
+ }
+ }
+
+ public class Value
+ {
+ private String localeDisplayName;
+
+ private Locale locale;
+
+ private String text;
+
+ public Value(Locale locale, String localeDisplayName, String text)
+ {
+ this.localeDisplayName = localeDisplayName;
+ this.locale = locale;
+ this.text = text;
+ }
+
+ public String getLocaleDisplayName()
+ {
+ return localeDisplayName;
+ }
+
+ public void setLocaleDisplayName(String localeDisplayName)
+ {
+ this.localeDisplayName = localeDisplayName;
+ }
+
+ public String getText()
+ {
+ return text;
+ }
+
+ public void setText(String text)
+ {
+ this.text = text;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ public void setLocale(Locale locale)
+ {
+ this.locale = locale;
+ }
+
+
+ }
+}
Added: branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalInstanceDisplayNameAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalInstanceDisplayNameAction.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalInstanceDisplayNameAction.java 2008-01-23 02:59:20 UTC (rev 9574)
@@ -0,0 +1,217 @@
+/******************************************************************************
+ * 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.core.admin.ui.actions;
+
+import org.jboss.portal.common.i18n.LocaleFormat;
+import org.jboss.portal.common.i18n.LocaleManager;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.util.ConversionException;
+import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
+import org.jboss.portal.core.admin.ui.PortletManagerBean;
+import org.jboss.portal.core.admin.ui.InstanceManagerBean;
+import org.jboss.portal.core.admin.ui.DisplayNameBean;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.portal.PortalObject;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * @author <a href="mailto:whales@redhat.com">Wesley Hales</a>
+ * @version $Revision: 630 $
+ */
+public class PortalInstanceDisplayNameAction
+{
+ private Instance selectedInstance;
+
+ public Object bean;
+
+ private String newLocale;
+
+ private String newText;
+
+ private SortedMap locales;
+
+ private String displayNameByLocale;
+
+ private InstanceManagerBean instanceManager;
+
+ private DisplayNameBean displayNameBean;
+
+ public void addDisplayName() throws ConversionException
+ {
+ if (newText != null)
+ {
+ Instance instance = getSelectedInstance();
+ Map map = getDisplayNameBean().createLocalizedStringMap(LocaleFormat.DEFAULT.getLocale(newLocale),instance.getDisplayName(),newText);
+ LocalizedString newLocalizedString = new LocalizedString(map, Locale.ENGLISH);
+ selectedInstance.setDisplayName(newLocalizedString);
+ }
+ else
+ {
+ FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "You must enter a name", "You must enter a name");
+ FacesContext.getCurrentInstance().addMessage("status", message);
+ }
+ }
+
+ public Instance getSelectedInstance()
+ {
+ if (instanceManager instanceof InstanceManagerBean)
+ {
+ selectedInstance = instanceManager.getSelectedInstance();
+ }
+ return selectedInstance;
+ }
+
+ public void setSelectedInstance(Instance selectedInstance)
+ {
+ this.selectedInstance = selectedInstance;
+ }
+
+ public String getNewText()
+ {
+ return newText;
+ }
+
+ public void setNewText(String newText)
+ {
+ this.newText = newText;
+ }
+
+ public SortedMap getLocales()
+ {
+ return getDisplayNameBean().getLocales();
+ }
+
+ public void setLocales(SortedMap locales)
+ {
+ this.locales = locales;
+ }
+
+ public String getNewLocale()
+ {
+ return newLocale;
+ }
+
+ public void setNewLocale(String newLocale)
+ {
+ this.newLocale = newLocale;
+ }
+
+ public List<DisplayNameBean.Value> getCurrentLocales()
+ {
+ selectedInstance = getSelectedInstance();
+ if (selectedInstance != null && selectedInstance.getDisplayName() != null)
+ {
+ List<DisplayNameBean.Value> currentLocales = getDisplayNameBean().populateCurrentLocales(selectedInstance.getDisplayName().getValues());
+
+ return currentLocales;
+ }
+ return null;
+ }
+
+ public void editDisplayName()
+ {
+ String locale = getFacesParam("locale");
+ String editAction = getFacesParam("editAction");
+
+ Instance selectedInstance = getSelectedInstance();
+ LocalizedString displayName = selectedInstance.getDisplayName();
+ Map<Locale, String> map = new HashMap<Locale, String>();
+ if (displayName != null)
+ {
+ Map<Locale, LocalizedString.Value> oldMap = displayName.getValues();
+ Collection<LocalizedString.Value> values = oldMap.values();
+ if (editAction.equals("delete"))
+ {
+ for (LocalizedString.Value value : values)
+ {
+ if (!value.getLocale().toString().equals(locale.toString()))
+ {
+ map.put(value.getLocale(), value.getString());
+ }
+ }
+ }
+ if (editAction.equals("rename"))
+ {
+ for (LocalizedString.Value value : values)
+ {
+ map.put(value.getLocale(), value.getString());
+ if (value.getLocale().toString().equals(locale.toString()))
+ {
+ newText = value.getString();
+ newLocale = value.getLocale().getLanguage();
+ }
+ }
+ }
+ }
+ LocalizedString newLocalizedString = new LocalizedString(map, Locale.ENGLISH);
+ selectedInstance.setDisplayName(newLocalizedString);
+ }
+
+
+ public String getFacesParam(String param)
+ {
+ return (String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(param);
+ }
+
+
+ public String editDisplayNames() throws ConversionException
+ {
+ getSelectedInstance();
+ getCurrentLocales();
+ return "editDisplayNames";
+ }
+
+ public InstanceManagerBean getInstanceManager()
+ {
+ return instanceManager;
+ }
+
+ public void setInstanceManager(InstanceManagerBean instanceManager)
+ {
+ this.instanceManager = instanceManager;
+ }
+
+ public DisplayNameBean getDisplayNameBean()
+ {
+ if(displayNameBean == null){
+ displayNameBean = new DisplayNameBean();
+ }
+ return displayNameBean;
+ }
+
+ public void setDisplayNameBean(DisplayNameBean displayNameBean)
+ {
+ this.displayNameBean = displayNameBean;
+ }
+}
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalObjectDisplayNameAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalObjectDisplayNameAction.java 2008-01-22 21:53:15 UTC (rev 9573)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalObjectDisplayNameAction.java 2008-01-23 02:59:20 UTC (rev 9574)
@@ -27,8 +27,10 @@
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.util.ConversionException;
import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
+import org.jboss.portal.core.admin.ui.DisplayNameBean;
import org.jboss.portal.core.impl.model.portal.PortalObjectImpl;
import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.instance.Instance;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
@@ -53,36 +55,25 @@
private String displayNameByLocale;
+ private DisplayNameBean displayNameBean;
+
public void addDisplayName() throws ConversionException
{
-
if (newText != null)
{
PortalObject portalObject = getSelectedObject();
- Locale locale = LocaleFormat.DEFAULT.getLocale(newLocale);
- LocalizedString displayName = portalObject.getDisplayName();
- Map<Locale, String> map = new HashMap<Locale, String>();
- if (displayName != null)
- {
- Map<Locale, LocalizedString.Value> oldMap = displayName.getValues();
- Collection<LocalizedString.Value> values = oldMap.values();
- for (LocalizedString.Value value : values)
- {
- map.put(value.getLocale(), value.getString());
- }
- }
- map.put(locale, newText);
+ Map map = getDisplayNameBean().createLocalizedStringMap(LocaleFormat.DEFAULT.getLocale(newLocale),portalObject.getDisplayName(),newText);
LocalizedString newLocalizedString = new LocalizedString(map, Locale.ENGLISH);
- selectedObject.setDisplayName(newLocalizedString);
+ portalObject.setDisplayName(newLocalizedString);
}
else
{
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "You must enter a name", "You must enter a name");
FacesContext.getCurrentInstance().addMessage("status", message);
}
-
}
+
public PortalObject getSelectedObject()
{
if (bean instanceof PortalObjectManagerBean)
@@ -107,51 +98,32 @@
this.newText = newText;
}
- public SortedMap getLocales()
+ public String getNewLocale()
{
- SortedMap smap = new TreeMap();
- Locale[] localList = (Locale[]) LocaleManager.getLocales().toArray(new Locale[0]);
-
- for (int i = 0; i < localList.length; i++)
- {
- Locale thisLocale = localList[i];
- Locale requestedLocale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
- smap.put(convertLocaleDisplayName(thisLocale.getDisplayLanguage(requestedLocale)), thisLocale.getLanguage());
- }
- return smap;
+ return newLocale;
}
- public void setLocales(SortedMap locales)
+ public void setNewLocale(String newLocale)
{
- this.locales = locales;
+ this.newLocale = newLocale;
}
- public String getNewLocale()
+ public SortedMap getLocales()
{
- return newLocale;
+ return getDisplayNameBean().getLocales();
}
- public void setNewLocale(String newLocale)
+ public void setLocales(SortedMap locales)
{
- this.newLocale = newLocale;
+ this.locales = locales;
}
- public List<Value> getCurrentLocales()
+ public List<DisplayNameBean.Value> getCurrentLocales()
{
selectedObject = getSelectedObject();
if (selectedObject != null && selectedObject.getDisplayName() != null)
{
- List<Value> currentLocales = new ArrayList<Value>();
- Map displayNames = selectedObject.getDisplayName().getValues();
- Iterator it = displayNames.entrySet().iterator();
- while (it.hasNext())
- {
- Map.Entry pairs = (Map.Entry) it.next();
- Locale thisLocale = (Locale)pairs.getKey();
- Locale requestedLocale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
- currentLocales.add(new Value(thisLocale, convertLocaleDisplayName(thisLocale.getDisplayLanguage(requestedLocale)),getDisplayNameByLocale(thisLocale)));
-
- }
+ List<DisplayNameBean.Value> currentLocales = getDisplayNameBean().populateCurrentLocales(selectedObject.getDisplayName().getValues());
return currentLocales;
}
return null;
@@ -196,23 +168,10 @@
selectedObject.setDisplayName(newLocalizedString);
}
-
public String getFacesParam(String param){
return (String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(param);
}
-/*
- public void setCurrentLocales(Map currentLocales)
- {
- this.currentLocales = currentLocales;
- }
-*/
- public String getDisplayNameByLocale(Locale locale)
- {
- Map displayNames = selectedObject.getDisplayName().getValues();
- LocalizedString.Value lsv = (LocalizedString.Value)displayNames.get(locale);
- return lsv.getString();
- }
public String editDisplayNames() throws ConversionException
{
@@ -221,66 +180,17 @@
return "editDisplayNames";
}
-
-
- private String convertLocaleDisplayName(String str)
+ public DisplayNameBean getDisplayNameBean()
{
- if (str.length() > 0)
- {
- return str.substring(0,1).toUpperCase() + str.substring(1, str.length());
+ if(displayNameBean == null){
+ displayNameBean = new DisplayNameBean();
}
- else
- {
- return str;
- }
+ return displayNameBean;
}
-
- public class Value
- {
- private String localeDisplayName;
-
- private Locale locale;
-
- private String text;
-
- public Value(Locale locale, String localeDisplayName, String text)
- {
- this.localeDisplayName = localeDisplayName;
- this.locale = locale;
- this.text = text;
- }
- public String getLocaleDisplayName()
- {
- return localeDisplayName;
- }
-
- public void setLocaleDisplayName(String localeDisplayName)
- {
- this.localeDisplayName = localeDisplayName;
- }
-
- public String getText()
- {
- return text;
- }
-
- public void setText(String text)
- {
- this.text = text;
- }
-
- public Locale getLocale()
- {
- return locale;
- }
-
- public void setLocale(Locale locale)
- {
- this.locale = locale;
- }
-
-
+ public void setDisplayNameBean(DisplayNameBean displayNameBean)
+ {
+ this.displayNameBean = displayNameBean;
}
}
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2008-01-22 21:53:15 UTC (rev 9573)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2008-01-23 02:59:20 UTC (rev 9574)
@@ -244,6 +244,8 @@
</managed-property>
</managed-bean>
+
+
<!--
| Dashboard beans
-->
@@ -316,6 +318,16 @@
</managed-bean>
<managed-bean>
+ <managed-bean-name>instanceDisplayNameAction</managed-bean-name>
+ <managed-bean-class>org.jboss.portal.core.admin.ui.actions.PortalInstanceDisplayNameAction</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ <managed-property>
+ <property-name>instanceManager</property-name>
+ <value>#{sessionScope.instancemgr}</value>
+ </managed-property>
+ </managed-bean>
+
+ <managed-bean>
<managed-bean-name>renameDashboardPageAction</managed-bean-name>
<managed-bean-class>org.jboss.portal.core.admin.ui.actions.RenameAction</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/showPortletDetails.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/showPortletDetails.xhtml 2008-01-22 21:53:15 UTC (rev 9573)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/showPortletDetails.xhtml 2008-01-23 02:59:20 UTC (rev 9574)
@@ -5,35 +5,114 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core">
- <table>
- <tr>
- <td class="portlet-form-field-label">Portlet name:</td>
- <td><h:form><h:commandLink
+ <h:form>
+ <p class="portlet-area-header">Portlet Instance Information</p>
+ <h:panelGrid columns="3" styleClass="panelGrid-basic">
+ <f:subview id="field1">
+ <dl>
+ <dt class="portlet-form-field-label">Portlet name:</dt>
+ <dd><h:commandLink
action="#{portletmgr.selectPortlet}">
<f:param name="id" value="#{portlet.context.id}"/>
<f:param name="plugin" value="manager"/>
#{portlet.name}
- </h:commandLink></h:form></td>
- </tr>
- <tr>
- <td class="portlet-form-field-label">Portlet description:</td>
- <td>#{portlet.description.value}</td>
- </tr>
- <tr>
- <td class="portlet-form-field-label">Portlet title:</td>
- <td>#{portlet.title.value}</td>
- </tr>
- <tr>
- <td class="portlet-form-field-label">Portlet keywords:</td>
- <td>#{portlet.keywords.value}</td>
- </tr>
- <c:if test="#{not empty portlet.locales}">
- <tr>
- <td class="portlet-form-field-label">Portlet locales:</td>
- <td>
- <c:forEach items="#{portlet.locales}" var="locale"> #{locale} </c:forEach>
- </td>
- </tr>
- </c:if>
- </table>
+ </h:commandLink></dd>
+ </dl>
+ </f:subview>
+ <f:subview id="field2">
+ <dl>
+ <dt class="portlet-form-field-label">Portlet description:</dt>
+ <dd>#{portlet.description.value}</dd>
+ </dl>
+ </f:subview>
+ <f:subview id="field3">
+ <dl>
+ <dt class="portlet-form-field-label">Portlet title:</dt>
+ <dd>#{portlet.title.value}</dd>
+ </dl>
+ </f:subview>
+ <f:subview id="field4">
+ <dl>
+ <dt class="portlet-form-field-label">Portlet keywords:</dt>
+ <dd>#{portlet.keywords.value}</dd>
+ </dl>
+ </f:subview>
+ <f:subview id="field5" rendered="#{not empty portlet.locales}">
+ <dl>
+ <dt class="portlet-form-field-label">Portlet locales:</dt>
+ <dd><c:forEach items="#{portlet.locales}" var="locale"> #{locale} </c:forEach></dd>
+ </dl>
+ </f:subview>
+ </h:panelGrid>
+ <br/>
+ <p class="portlet-area-header">Portlet Instance Display Names</p>
+ </h:form>
+
+ <div class="float-left third-width-pad5">
+ <h:form id="displayNameForm">
+ <h3 class="sectionTitle zero">Add Instance Display Names</h3>
+
+ <div class="portlet-area-body">
+ <h:inputText id="newName" value="#{instanceDisplayNameAction.newText}" required="true"/>
+ <h:selectOneMenu id="locales" value="#{instanceDisplayNameAction.newLocale}">
+ <f:selectItems value="#{instanceDisplayNameAction.locales}"/>
+ </h:selectOneMenu>
+ <h:commandButton value="#{instanceDisplayNameAction.newText ne null ? 'Modify' : 'Add'} Name" action="#{instanceDisplayNameAction.addDisplayName}"
+ styleClass="portlet-form-button"/>
+ </div>
+ </h:form>
+ </div>
+
+ <div class="float-left two-third-width-pad5">
+ <h:form>
+ <h3 class="sectionTitle zero">Current Instance Display Names</h3>
+
+ <div class="portlet-area-body">
+
+ <h:dataTable var="value" value="#{instanceDisplayNameAction.currentLocales}" styleClass="objectList datatable"
+ rowClasses="portlet-section-body,portlet-section-alternate"
+ columnClasses="objectNameColumn, objectActionColumn"
+ headerClass="portlet-section-header">
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Locale"/>
+ </f:facet>
+ #{value.localeDisplayName}
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Display Name"/>
+ </f:facet>
+ #{value.text}
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Delete"/>
+ </f:facet>
+
+ <div style="width:150px"><h:commandLink action="#{instanceDisplayNameAction.editDisplayName}">
+ <h:outputText styleClass="actionDelete" value="Delete"/>
+ <f:param name="locale" value="#{value.locale}"/>
+ <f:param name="editAction" value="delete"/>
+ </h:commandLink></div>
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="Rename"/>
+ </f:facet>
+
+ <div style="width:150px"><h:commandLink action="#{instanceDisplayNameAction.editDisplayName}">
+ <h:outputText styleClass="actionRename" value="Rename"/>
+ <f:param name="locale" value="#{value.locale}"/>
+ <f:param name="editAction" value="rename"/>
+ </h:commandLink></div>
+ </h:column>
+ </h:dataTable>
+
+ </div>
+ </h:form>
+
+ </div>
+
+
</div>
\ No newline at end of file
18 years, 3 months
JBoss Portal SVN: r9573 - modules/portlet/trunk/test/src/test/resources/test.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-22 16:53:15 -0500 (Tue, 22 Jan 2008)
New Revision: 9573
Modified:
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
rollback remote-jboss-unit.xml that was commited with commented test cases
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-22 21:45:20 UTC (rev 9572)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-22 21:53:15 UTC (rev 9573)
@@ -4,10 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
-<!--
- -->
-<!--Spec TCK Assertions tests-->
-<!--
+ <!--Spec TCK Assertions tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-tck-dispatcher.war"/>
@@ -53,9 +50,7 @@
<property name="archiveId" value="test-jsr168-tck-windowstates.war"/>
</generic>
- -->
-<!--API Tests-->
-<!--
+ <!--API Tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-api-actionrequest.war"/>
@@ -109,9 +104,7 @@
<property name="archiveId" value="test-jsr168-api-windowstate.war"/>
</generic>
- -->
-<!--Ext Tests-->
-<!--
+ <!--Ext Tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-dispatcher.war"/>
@@ -140,7 +133,6 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-session.war"/>
</generic>
--->
<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
@@ -155,11 +147,8 @@
<property name="archiveId" value="test-jsr168-ext-nocache.war"/>
</generic>
-->
-<!--
- -->
-<!--Spec TCK Assertions tests-->
-<!--
+ <!--Spec TCK Assertions tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portletconfig.war"/>
@@ -189,14 +178,11 @@
<property name="archiveId" value="test-jsr286-tck-resourceserving.war"/>
</generic>
- -->
-<!--Spec API Assertions tests-->
-<!--
+ <!--Spec API Assertions tests-->
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-api-event.war"/>
</generic>
--->
<!--Ext Assertions tests-->
<generic>
18 years, 3 months
JBoss Portal SVN: r9572 - in modules/portlet/trunk: test/src/test/resources/test and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-22 16:45:20 -0500 (Tue, 22 Jan 2008)
New Revision: 9572
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/RemovePublicRenderParameterWithPortletURLTestCase.java
Modified:
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
added test case for PortletURL.removePublicRenderParameter(String name) method
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/RemovePublicRenderParameterWithPortletURLTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/RemovePublicRenderParameterWithPortletURLTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/RemovePublicRenderParameterWithPortletURLTestCase.java 2008-01-22 21:45:20 UTC (rev 9572)
@@ -0,0 +1,165 @@
+/******************************************************************************
+ * 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.PortletActionTestAction;
+import org.jboss.portal.test.portlet.framework.UTP2;
+import org.jboss.portal.test.portlet.framework.UTP3;
+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.PortletURL;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Test that removePublicRenderParameter method on PortletURL removes the render parameter
+ * in the context of a render url and does nothing in the context of an action url.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class RemovePublicRenderParameterWithPortletURLTestCase
+{
+
+ /** . */
+ private final Map<String, String[]> expectedPublicRenderParameterMap = Collections.singletonMap("foo", new String[]{"foo_value"});
+
+ public RemovePublicRenderParameterWithPortletURLTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP2.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", "foo_value");
+ return new InvokeGetResponse(renderURL.toString());
+ }
+ });
+ seq.bindAction(1, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(expectedPublicRenderParameterMap, request);
+ assertParameterMap(new HashMap<String, String[]>(), request.getPrivateParameterMap());
+ assertParameterMap(expectedPublicRenderParameterMap, request.getPublicParameterMap());
+
+ //
+ PortletURL renderURL = response.createRenderURL();
+ renderURL.removePublicRenderParameter("foo");
+ return new InvokeGetResponse(renderURL.toString());
+ }
+ });
+ seq.bindAction(2, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(new HashMap<String, String[]>(), request);
+ assertParameterMap(new HashMap<String, String[]>(), request.getPrivateParameterMap());
+ assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());
+
+ //
+ PortletURL renderURL = response.createRenderURL();
+ renderURL.setParameter("foo", "foo_value");
+ return new InvokeGetResponse(renderURL.toString());
+ }
+ });
+ seq.bindAction(2, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(new HashMap<String, String[]>(), request);
+ assertParameterMap(new HashMap<String, String[]>(), request.getPrivateParameterMap());
+ assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());
+ return null;
+ }
+ });
+ seq.bindAction(3, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(expectedPublicRenderParameterMap, request);
+ assertParameterMap(new HashMap<String, String[]>(), request.getPrivateParameterMap());
+ assertParameterMap(expectedPublicRenderParameterMap, request.getPublicParameterMap());
+
+ //
+ PortletURL actionURL = response.createActionURL();
+ actionURL.removePublicRenderParameter("foo");
+ return new InvokeGetResponse(actionURL.toString());
+ }
+ });
+ seq.bindAction(3, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(expectedPublicRenderParameterMap, request);
+ assertParameterMap(new HashMap<String, String[]>(), request.getPrivateParameterMap());
+ assertParameterMap(expectedPublicRenderParameterMap, request.getPublicParameterMap());
+ return null;
+ }
+ });
+ seq.bindAction(4, UTP2.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(expectedPublicRenderParameterMap, request);
+ assertParameterMap(new HashMap<String, String[]>(), request.getPrivateParameterMap());
+ assertParameterMap(expectedPublicRenderParameterMap, request.getPublicParameterMap());
+ }
+ });
+ seq.bindAction(4, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(expectedPublicRenderParameterMap, request);
+ assertParameterMap(new HashMap<String, String[]>(), request.getPrivateParameterMap());
+ assertParameterMap(expectedPublicRenderParameterMap, request.getPublicParameterMap());
+ return new EndTestResponse();
+ }
+ });
+ seq.bindAction(4, UTP3.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertParameterMap(expectedPublicRenderParameterMap, request);
+ assertParameterMap(new HashMap<String, String[]>(), request.getPrivateParameterMap());
+ assertParameterMap(expectedPublicRenderParameterMap, request.getPublicParameterMap());
+ return null;
+ }
+ });
+ }
+}
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-22 21:44:40 UTC (rev 9571)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-22 21:45:20 UTC (rev 9572)
@@ -4,7 +4,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
- <!--Spec TCK Assertions tests-->
+<!--
+ -->
+<!--Spec TCK Assertions tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-tck-dispatcher.war"/>
@@ -50,7 +53,9 @@
<property name="archiveId" value="test-jsr168-tck-windowstates.war"/>
</generic>
- <!--API Tests-->
+ -->
+<!--API Tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-api-actionrequest.war"/>
@@ -104,7 +109,9 @@
<property name="archiveId" value="test-jsr168-api-windowstate.war"/>
</generic>
- <!--Ext Tests-->
+ -->
+<!--Ext Tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-dispatcher.war"/>
@@ -133,6 +140,7 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-session.war"/>
</generic>
+-->
<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
@@ -147,8 +155,11 @@
<property name="archiveId" value="test-jsr168-ext-nocache.war"/>
</generic>
-->
+<!--
- <!--Spec TCK Assertions tests-->
+ -->
+<!--Spec TCK Assertions tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portletconfig.war"/>
@@ -178,11 +189,14 @@
<property name="archiveId" value="test-jsr286-tck-resourceserving.war"/>
</generic>
- <!--Spec API Assertions tests-->
+ -->
+<!--Spec API Assertions tests-->
+<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-api-event.war"/>
</generic>
+-->
<!--Ext Assertions tests-->
<generic>
18 years, 3 months
JBoss Portal SVN: r9571 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/unit and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-22 16:44:40 -0500 (Tue, 22 Jan 2008)
New Revision: 9571
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/RemovePublicRenderParameterOnStateAwareResponseTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml
Log:
added test case for PortletURL.removePublicRenderParameter(String name) method
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/RemovePublicRenderParameterOnStateAwareResponseTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/RemovePublicRenderParameterOnStateAwareResponseTestCase.java 2008-01-22 21:16:42 UTC (rev 9570)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/RemovePublicRenderParameterOnStateAwareResponseTestCase.java 2008-01-22 21:44:40 UTC (rev 9571)
@@ -88,7 +88,7 @@
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
{
assertParameterMap(new HashMap<String, String[]>(), request);
- assertEquals(Collections.emptyMap(), request.getPublicParameterMap());
+ assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());
PortletURL url = response.createRenderURL();
url.setParameter("foo", new String[]{"foo_value1","foo_value2"});
return new InvokeGetResponse(url.toString());
@@ -121,7 +121,7 @@
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
{
assertParameterMap(new HashMap<String, String[]>(), request);
- assertEquals(Collections.emptyMap(), request.getPublicParameterMap());
+ assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());
return new EndTestResponse();
}
});
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-22 21:16:42 UTC (rev 9570)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java 2008-01-22 21:44:40 UTC (rev 9571)
@@ -82,6 +82,18 @@
//
Map<String, String[]> map = request.getParameterMap();
+ assertParameterMap(expectedMap, map);
+ }
+
+ /**
+ * Check that the two parameter maps are equals.
+ *
+ * @param expectedMap the expected map
+ * @param map the actual map
+ * @throws AssertionError if the provided map is not equals to the expected map
+ */
+ public final void assertParameterMap(Map<String, String[]> expectedMap, Map<String, String[]> map) throws AssertionError
+ {
assertNotNull(map);
assertEquals(expectedMap.size(), map.size());
for (Map.Entry<String, String[]> entry : expectedMap.entrySet())
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-22 21:16:42 UTC (rev 9570)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml 2008-01-22 21:44:40 UTC (rev 9571)
@@ -42,6 +42,24 @@
<supported-public-render-parameter>foo</supported-public-render-parameter>
</portlet>
+ <portlet>
+ <portlet-name>UniversalTestPortletB</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP2</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-public-render-parameter>foo</supported-public-render-parameter>
+ </portlet>
+
+ <portlet>
+ <portlet-name>UniversalTestPortletC</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP3</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-public-render-parameter>foo</supported-public-render-parameter>
+ </portlet>
+
<event-definition>
<name>Event</name>
</event-definition>
18 years, 3 months
JBoss Portal SVN: r9570 - modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-22 16:16:42 -0500 (Tue, 22 Jan 2008)
New Revision: 9570
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PortletDoesNotReceiveUnsupportedRenderParametersTestCase.java
Log:
update test case coverage as this test case covers other points
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PortletDoesNotReceiveUnsupportedRenderParametersTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PortletDoesNotReceiveUnsupportedRenderParametersTestCase.java 2008-01-22 21:15:21 UTC (rev 9569)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PortletDoesNotReceiveUnsupportedRenderParametersTestCase.java 2008-01-22 21:16:42 UTC (rev 9570)
@@ -57,14 +57,19 @@
import java.io.IOException;
/**
+ * lxxxii:
*
* The portlet container must only send those public render parameters to a portlet which the
* portlet has defined support for using supported-public-render-parameter element in the portlet.
*
+ * lxxxiii:
+ *
* The portlet container must only share those render parameters of a
* portlet which the portlet has declared as supported public render parameters using
* supported-public-render-parameter element in the portlet.xml
*
+ * lxxxiv:
+ *
* If the portlet was the target of a render URL and this render URL has set a specific public
* render parameter the portlet must receive at least this render parameter
*
18 years, 3 months
JBoss Portal SVN: r9569 - modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-22 16:15:21 -0500 (Tue, 22 Jan 2008)
New Revision: 9569
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java
Log:
update test case coverage as this test case covers other points
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-22 21:12:58 UTC (rev 9568)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java 2008-01-22 21:15:21 UTC (rev 9569)
@@ -56,6 +56,8 @@
import java.util.Collections;
/**
+ * lxxxv:
+ *
* A portlet can access the public render parameters in any lifecycle method via the
* getPublicParameterMap method of the portlet request. In addition the portlet can access
* public render parameters via the getParameter and getParameterMap methods. In the
@@ -64,6 +66,13 @@
* parameter has the same name as a public render parameter the public render parameter
* values must be the last entries in the parameter value array.
*
+ * lxxxiv:
+ *
+ * If the portlet was the target of a render URL and this render URL has set a specific public
+ * render parameter the portlet must receive at least this render parameter
+ *
+ * lxxxvi:
+ *
* Portlets can access a merged set of public and private parameters via the getParameter
* methods on the PortletRequest or separated as maps of private parameters via the
* getPrivateParameterMap method and public parameters via the
18 years, 3 months
JBoss Portal SVN: r9568 - modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-22 16:12:58 -0500 (Tue, 22 Jan 2008)
New Revision: 9568
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java
Log:
update test case coverage as this test case covers other points
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-22 21:11:06 UTC (rev 9567)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterAvailableInLifeCycleMethodTestCase.java 2008-01-22 21:12:58 UTC (rev 9568)
@@ -64,6 +64,11 @@
* parameter has the same name as a public render parameter the public render parameter
* values must be the last entries in the parameter value array.
*
+ * Portlets can access a merged set of public and private parameters via the getParameter
+ * methods on the PortletRequest or separated as maps of private parameters via the
+ * getPrivateParameterMap method and public parameters via the
+ * getPublicParameterMap method.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
18 years, 3 months