JBoss Portal SVN: r10557 - in branches/JBoss_Portal_Branch_2_7: core/src/main/org/jboss/portal/core/impl/portlet/info and 4 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-13 13:33:04 -0400 (Sun, 13 Apr 2008)
New Revision: 10557
Removed:
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/jboss-app.xml
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/jboss-portlet.xml
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/info/CoreInfoBuilder.java
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/JBossApplicationMetaDataFactory.java
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/metadata/JBossApplicationMetaData.java
Log:
JBPORTAL-1985 : Replace jboss-app.xml with an app-id element in jboss-portlet.xml but keep jboss-app.xml for legacy
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java 2008-04-13 16:45:00 UTC (rev 10556)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/deployment/jboss/PortletAppDeployment.java 2008-04-13 17:33:04 UTC (rev 10557)
@@ -82,6 +82,9 @@
/** . */
private PortletAppDeploymentFactory factory;
+ /** . */
+ private String appId;
+
public PortletAppDeployment(URL url, PortalWebApp pwa, ManagedObjectRegistryEventListener listener, MBeanServer mbeanServer, PortletAppDeploymentFactory factory)
{
super(url, pwa, listener, mbeanServer, factory);
@@ -461,7 +464,7 @@
private String resolvePortletRef(String ref)
{
- return "local." + pwa.getId() + "." + ref;
+ return "local." + getAppId() + "." + ref;
}
private class InstanceMetaDataContext
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/info/CoreInfoBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/info/CoreInfoBuilder.java 2008-04-13 16:45:00 UTC (rev 10556)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/portlet/info/CoreInfoBuilder.java 2008-04-13 17:33:04 UTC (rev 10557)
@@ -44,6 +44,7 @@
import org.jboss.portal.portlet.impl.jsr168.ContainerInfoBuilderContextImpl;
import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
import org.jboss.portal.portlet.info.PortletInfo;
+import org.apache.log4j.Logger;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -54,19 +55,29 @@
*/
public class CoreInfoBuilder implements InfoBuilder
{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(CoreInfoBuilder.class);
+
+ /** . */
private JBossApplicationMetaData jbossApplicationMetaData;
+ /** . */
private PortletApplication10MetaData portletApplicationMD;
+ /** . */
private CoreInfoBuilderContext builderContext;
+ /** . */
private LinkedHashMap<String, PortletInfo> portlets;
+ /** . */
private ContainerPortletApplicationInfo application;
-
- public CoreInfoBuilder(JBossApplicationMetaData jbossApplicationMetaData, PortletApplication10MetaData portletApplicationMD,
- CoreInfoBuilderContext builderContext)
+ public CoreInfoBuilder(
+ JBossApplicationMetaData jbossApplicationMetaData,
+ PortletApplication10MetaData portletApplicationMD,
+ CoreInfoBuilderContext builderContext)
{
this.portletApplicationMD = portletApplicationMD;
this.jbossApplicationMetaData = jbossApplicationMetaData;
@@ -86,11 +97,20 @@
public void build()
{
+
//
+ String contextPath = builderContext.getWebApp().getContextPath();
+ String id = jbossApplicationMetaData.getId();
+
+ //
+ log.debug("Going to build portlet application metadata for application with context path '" + contextPath + "' with id '" + id + "'");
+
+ //
ContainerInfoBuilderContext containerBuilderContext = new ContainerInfoBuilderContextImpl(portletApplicationMD, builderContext.getWebApp());
- ContainerInfoBuilder builder = new ContainerInfoBuilder(builderContext.getWebApp().getContextPath(), portletApplicationMD, containerBuilderContext);
+ ContainerInfoBuilder builder = new ContainerInfoBuilder(id, portletApplicationMD, containerBuilderContext);
builder.build();
+ //
this.application = builder.getApplication();
//
Modified: branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd 2008-04-13 16:45:00 UTC (rev 10556)
+++ branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd 2008-04-13 17:33:04 UTC (rev 10557)
@@ -40,9 +40,14 @@
It is also possible to inject services in the portlet context of the application
using the service elements.
-->
-<!ELEMENT portlet-app (remotable?,portlet*,service*)>
+<!ELEMENT portlet-app (app-id?, remotable?,portlet*,service*)>
<!--
+The portlet application id that will be used by the portlet container instead of the context path.
+-->
+<!ELEMENT app-id (#PCDATA)>
+
+<!--
Additional configuration for a portlet.
The portlet-name defines the name of the portlet. It must match a portlet defined already
Deleted: branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/jboss-app.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/jboss-app.xml 2008-04-13 16:45:00 UTC (rev 10556)
+++ branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/jboss-app.xml 2008-04-13 17:33:04 UTC (rev 10557)
@@ -1,26 +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. ~
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-
-<jboss-app>
- <app-name>samples</app-name>
-</jboss-app>
\ No newline at end of file
Modified: branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/jboss-portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/jboss-portlet.xml 2008-04-13 16:45:00 UTC (rev 10556)
+++ branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/jboss-portlet.xml 2008-04-13 17:33:04 UTC (rev 10557)
@@ -26,6 +26,7 @@
"http://www.jboss.org/portal/dtd/jboss-portlet_2_6.dtd">
<portlet-app>
+ <app-id>samples</app-id>
<remotable>true</remotable>
<portlet>
<portlet-name>PortletSessionPortlet</portlet-name>
Modified: branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/JBossApplicationMetaDataFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/JBossApplicationMetaDataFactory.java 2008-04-13 16:45:00 UTC (rev 10556)
+++ branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/JBossApplicationMetaDataFactory.java 2008-04-13 17:33:04 UTC (rev 10557)
@@ -141,8 +141,12 @@
if (object instanceof JBossApplicationMetaData)
{
JBossApplicationMetaData app = (JBossApplicationMetaData)object;
- if ("remotable".equals(localName))
+ if ("app-id".equals(localName))
{
+ app.setId(value);
+ }
+ else if ("remotable".equals(localName))
+ {
if ("true".equalsIgnoreCase(value))
{
app.setRemotable(Boolean.TRUE);
Modified: branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java 2008-04-13 16:45:00 UTC (rev 10556)
+++ branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java 2008-04-13 17:33:04 UTC (rev 10557)
@@ -85,8 +85,12 @@
/** . */
private PortletApplicationLifeCycle portletApplicationLifeCycle;
+ /** . */
private ManagedObjectRegistryEventListener listener;
+ /** . */
+ private String appId;
+
public PortletAppDeployment(URL url, PortalWebApp pwa, ManagedObjectRegistryEventListener listener, MBeanServer mbeanServer, PortletAppDeploymentFactory factory)
{
super(url, pwa, mbeanServer);
@@ -104,6 +108,16 @@
portletAppMD = buildPortletApplicationMetaData();
jbossAppMD = buildJBossApplicationMetaData();
+ //
+ if (jbossAppMD.getId() == null)
+ {
+ log.debug("The portlet application does not have an explicit id value, will use the value provided by the jboss-app.xml instead");
+ jbossAppMD.setId(pwa.getId());
+ }
+
+ //
+ appId = jbossAppMD.getId();
+
// Merge or provide defaults
JBossApplicationMetaData standardJBossAppMD = factory.getStandardJBossApplicationMetaData();
if (standardJBossAppMD != null)
@@ -405,4 +419,9 @@
}
return jbossAppMD;
}
+
+ public String getAppId()
+ {
+ return appId;
+ }
}
Modified: branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/metadata/JBossApplicationMetaData.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/metadata/JBossApplicationMetaData.java 2008-04-13 16:45:00 UTC (rev 10556)
+++ branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/metadata/JBossApplicationMetaData.java 2008-04-13 17:33:04 UTC (rev 10557)
@@ -35,6 +35,9 @@
/** . */
protected Boolean remotable;
+ /** The application id that overrides the context path. */
+ protected String id;
+
/** . */
protected Map<String, JBossPortletMetaData> portlets;
@@ -57,4 +60,14 @@
{
this.remotable = remotable;
}
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
}
18 years
JBoss Portal SVN: r10556 - in branches/JBoss_Portal_Branch_2_7: core/src/main/org/jboss/portal/core/model/portal and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-13 12:45:00 -0400 (Sun, 13 Apr 2008)
New Revision: 10556
Added:
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PublicParametersPortlet.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/default-object.xml
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/portlet-instances.xml
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/portlet.xml
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
Log:
- fixes a few bugs
- embryo of a public parameter portlet to show various use cases
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java 2008-04-13 12:59:04 UTC (rev 10555)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java 2008-04-13 16:45:00 UTC (rev 10556)
@@ -30,6 +30,7 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.core.navstate.NavigationalStateContext;
import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.PortalObjectId;
import javax.xml.namespace.QName;
import java.util.Set;
@@ -172,16 +173,20 @@
Window window = controllerContext.getWindow(windowName);
//
- org.jboss.portal.core.model.portal.navstate.WindowNavigationalState wns = navigationalStateContext.getWindowNavigationalState(window.getId().toString());
+ if (window != null)
+ {
+ String windowId = window.getId().toString();
+ org.jboss.portal.core.model.portal.navstate.WindowNavigationalState wns = navigationalStateContext.getWindowNavigationalState(windowId);
- //
- if (wns == null)
- {
- return null;
+ //
+ if (wns != null)
+ {
+ return new WindowNavigationalState(wns.getContentState(), wns.getMode(), wns.getWindowState());
+ }
}
//
- return new WindowNavigationalState(wns.getContentState(), wns.getMode(), wns.getWindowState());
+ return null;
}
public void setWindowNavigationalState(String windowName, WindowNavigationalState windowNavigationalState) throws IllegalArgumentException, IllegalStateException
@@ -192,13 +197,17 @@
}
//
- if (updates == null)
+ Window window = controllerContext.getWindow(windowName);
+ if (window != null)
{
- updates = new HashMap<String, WindowNavigationalState>();
+ if (updates == null)
+ {
+ updates = new HashMap<String, WindowNavigationalState>();
+ }
+
+ //
+ updates.put(windowName, windowNavigationalState);
}
-
- //
- updates.put(windowName, windowNavigationalState);
}
/**
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2008-04-13 12:59:04 UTC (rev 10555)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2008-04-13 16:45:00 UTC (rev 10556)
@@ -150,7 +150,7 @@
//
Mode mode = ipwCmd.getMode();
WindowState windowState = ipwCmd.getWindowState();
- StateString navigationalState = ((InvokePortletWindowRenderCommand)iwCmd).getNavigationalState();
+ StateString navigationalState = ((InvokePortletWindowCommand)iwCmd).getNavigationalState();
//
if (iwCmd instanceof InvokePortletWindowActionCommand)
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2008-04-13 12:59:04 UTC (rev 10555)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2008-04-13 16:45:00 UTC (rev 10556)
@@ -49,9 +49,6 @@
private static final CommandInfo info = new ActionCommandInfo(false);
/** . */
- private StateString navigationalState;
-
- /** . */
private StateString interactionState;
/** . */
@@ -69,19 +66,13 @@
ParameterMap formParameters)
throws IllegalArgumentException
{
- super(windowId, mode, windowState);
+ super(windowId, mode, windowState, navigationalState);
//
- this.navigationalState = navigationalState;
this.interactionState = interactionState;
this.formParameters = formParameters;
}
- public StateString getNavigationalState()
- {
- return navigationalState;
- }
-
public StateString getInteractionState()
{
return interactionState;
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowCommand.java 2008-04-13 12:59:04 UTC (rev 10555)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowCommand.java 2008-04-13 16:45:00 UTC (rev 10556)
@@ -24,6 +24,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.portlet.StateString;
import org.jboss.portal.core.model.portal.PortalObjectId;
/**
@@ -39,7 +40,14 @@
/** . */
protected final WindowState windowState;
- protected InvokePortletWindowCommand(PortalObjectId windowId, Mode mode, WindowState windowState)
+ /** . */
+ protected final StateString navigationalState;
+
+ protected InvokePortletWindowCommand(
+ PortalObjectId windowId,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState)
throws IllegalArgumentException
{
super(windowId);
@@ -47,8 +55,14 @@
//
this.mode = mode;
this.windowState = windowState;
+ this.navigationalState = navigationalState;
}
+ public StateString getNavigationalState()
+ {
+ return navigationalState;
+ }
+
public Mode getMode()
{
return mode;
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-04-13 12:59:04 UTC (rev 10555)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-04-13 16:45:00 UTC (rev 10556)
@@ -62,9 +62,6 @@
private static final CommandInfo info = new ActionCommandInfo(true);
/** . */
- protected final StateString navigationalState;
-
- /** . */
protected NavigationInfo navigationInfo;
public InvokePortletWindowRenderCommand(
@@ -74,10 +71,7 @@
StateString navigationalState)
throws IllegalArgumentException
{
- super(windowId, mode, windowState);
-
- //
- this.navigationalState = navigationalState;
+ super(windowId, mode, windowState, navigationalState);
}
public InvokePortletWindowRenderCommand(
@@ -86,17 +80,9 @@
WindowState windowState)
throws IllegalArgumentException
{
- super(windowId, mode, windowState);
-
- //
- this.navigationalState = null;
+ super(windowId, mode, windowState, null);
}
- public StateString getNavigationalState()
- {
- return navigationalState;
- }
-
public CommandInfo getInfo()
{
return info;
Added: branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PublicParametersPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PublicParametersPortlet.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PublicParametersPortlet.java 2008-04-13 16:45:00 UTC (rev 10556)
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.samples.basic;
+
+import javax.portlet.Portlet;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletURL;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PublicParametersPortlet implements Portlet
+{
+
+ /** . */
+ private PortletConfig config;
+
+ public void init(PortletConfig config) throws PortletException
+ {
+ this.config = config;
+ }
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws PortletException, IOException
+ {
+ Map<String, String[]> publicParameters = req.getPublicParameterMap();
+ for (Map.Entry<String, String[]> actionParameter : req.getPrivateParameterMap().entrySet())
+ {
+ String parameterName = actionParameter.getKey();
+ String parameterValue = actionParameter.getValue()[0];
+ String[] publicValues = publicParameters.get(parameterName);
+
+ //
+ if (parameterValue.length() > 0)
+ {
+ if (publicValues == null && !publicValues[0].equals(parameterValue))
+ {
+ resp.setRenderParameter(parameterName, parameterValue);
+ }
+ }
+ else if (publicValues != null)
+ {
+ resp.removePublicRenderParameter(parameterName);
+ }
+ }
+ }
+
+ public void render(RenderRequest req, RenderResponse resp) throws PortletException, IOException
+ {
+
+ PrintWriter writer = resp.getWriter();
+
+ PortletURL actionURL = resp.createActionURL();
+
+ writer.print("<form action=\"" + actionURL + "\" method=\"POST\"><table>");
+
+ for (Enumeration<String> e = config.getPublicRenderParameterNames();e.hasMoreElements();)
+ {
+ String parameterName = e.nextElement();
+
+ //
+ String parameterValue = req.getParameter(parameterName);
+
+ //
+ writer.print("<tr><td>" + parameterName + "</td><td>");
+
+ if (parameterValue != null)
+ {
+ writer.print("<input type=\"text\" width=\"36\" value=\"" + parameterValue + "\"/>");
+ }
+ else
+ {
+ writer.print("<input type=\"text\" width=\"36\" value=\"\"/>");
+ }
+ writer.println();
+
+ writer.println("</td>");
+
+ }
+
+ writer.println("<input type=\"submit\" value=\"Update\"/>");
+
+ writer.print("</table></form>");
+
+ //
+ writer.close();
+ }
+
+ public void destroy()
+ {
+ this.config = null;
+ }
+}
Modified: branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/default-object.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/default-object.xml 2008-04-13 12:59:04 UTC (rev 10555)
+++ branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/default-object.xml 2008-04-13 16:45:00 UTC (rev 10556)
@@ -621,6 +621,27 @@
<height>0</height>
</window>
</page>
+ <page>
+ <page-name>public parameters test</page-name>
+ <window>
+ <window-name>PublicParametersPortletWindow1</window-name>
+ <instance-ref>PublicParametersPortletInstance1</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>PublicParametersPortletWindow2</window-name>
+ <instance-ref>PublicParametersPortletInstance2</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>PublicParametersPortletWindow3</window-name>
+ <instance-ref>PublicParametersPortletInstance3</instance-ref>
+ <region>center</region>
+ <height>1</height>
+ </window>
+ </page>
</page>
</deployment>
</deployments>
Modified: branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/portlet-instances.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/portlet-instances.xml 2008-04-13 12:59:04 UTC (rev 10555)
+++ branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/portlet-instances.xml 2008-04-13 16:45:00 UTC (rev 10556)
@@ -157,4 +157,22 @@
<portlet-ref>WindowIDPortlet</portlet-ref>
</instance>
</deployment>
+ <deployment>
+ <instance>
+ <instance-id>PublicParametersPortletInstance1</instance-id>
+ <portlet-ref>PublicParametersPortlet1</portlet-ref>
+ </instance>
+ </deployment>
+ <deployment>
+ <instance>
+ <instance-id>PublicParametersPortletInstance2</instance-id>
+ <portlet-ref>PublicParametersPortlet2</portlet-ref>
+ </instance>
+ </deployment>
+ <deployment>
+ <instance>
+ <instance-id>PublicParametersPortletInstance3</instance-id>
+ <portlet-ref>PublicParametersPortlet3</portlet-ref>
+ </instance>
+ </deployment>
</deployments>
\ No newline at end of file
Modified: branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/portlet.xml 2008-04-13 12:59:04 UTC (rev 10555)
+++ branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-basic-samples-war/WEB-INF/portlet.xml 2008-04-13 16:45:00 UTC (rev 10556)
@@ -22,11 +22,10 @@
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-<portlet-app
- xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
- version="1.0">
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ version="2.0">
<portlet>
<description>Mode Portlet</description>
<portlet-name>ModePortlet</portlet-name>
@@ -353,9 +352,72 @@
<keywords>sample,test</keywords>
</portlet-info>
</portlet>
+ <portlet>
+ <description>Portlet that manipulates its public render parameters</description>
+ <portlet-name>PublicParametersPortlet1</portlet-name>
+ <display-name>Public Parameters Portlet 1</display-name>
+ <portlet-class>org.jboss.portal.core.samples.basic.PublicParametersPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title>Public Parameters Portlet</title>
+ <keywords>sample,test</keywords>
+ </portlet-info>
+ <supported-public-render-parameter>foo</supported-public-render-parameter>
+ <supported-public-render-parameter>bar</supported-public-render-parameter>
+ </portlet>
+ <portlet>
+ <description>Portlet that manipulates its public render parameters</description>
+ <portlet-name>PublicParametersPortlet2</portlet-name>
+ <display-name>Public Parameters Portlet 2</display-name>
+ <portlet-class>org.jboss.portal.core.samples.basic.PublicParametersPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title>Public Parameters Portlet</title>
+ <keywords>sample,test</keywords>
+ </portlet-info>
+ <supported-public-render-parameter>foo</supported-public-render-parameter>
+ <supported-public-render-parameter>juu</supported-public-render-parameter>
+ </portlet>
+ <portlet>
+ <description>Portlet that manipulates its public render parameters</description>
+ <portlet-name>PublicParametersPortlet3</portlet-name>
+ <display-name>Public Parameters Portlet 3</display-name>
+ <portlet-class>org.jboss.portal.core.samples.basic.PublicParametersPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title>Public Parameters Portlet</title>
+ <keywords>sample,test</keywords>
+ </portlet-info>
+ <supported-public-render-parameter>bar</supported-public-render-parameter>
+ <supported-public-render-parameter>juu</supported-public-render-parameter>
+ </portlet>
+
+ <public-render-parameter>
+ <name>foo</name>
+ <identifier>foo</identifier>
+ </public-render-parameter>
+
+ <public-render-parameter>
+ <name>bar</name>
+ <identifier>bar</identifier>
+ </public-render-parameter>
+
+ <public-render-parameter>
+ <name>juu</name>
+ <identifier>juu</identifier>
+ </public-render-parameter>
+
+ <!--
<custom-portlet-mode>
<name>ADMIN</name>
</custom-portlet-mode>
+-->
<user-attribute>
<name>user.name.nickName</name>
</user-attribute>
18 years
JBoss Portal SVN: r10555 - in branches/JBoss_Portal_Branch_2_7: portlet-server and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-13 08:59:04 -0400 (Sun, 13 Apr 2008)
New Revision: 10555
Modified:
branches/JBoss_Portal_Branch_2_7/faces/build.xml
branches/JBoss_Portal_Branch_2_7/portlet-server/build.xml
branches/JBoss_Portal_Branch_2_7/widget/build.xml
branches/JBoss_Portal_Branch_2_7/wsrp/build.xml
Log:
make 2.7 use jsr286 api jar for build
Modified: branches/JBoss_Portal_Branch_2_7/faces/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/faces/build.xml 2008-04-13 12:32:41 UTC (rev 10554)
+++ branches/JBoss_Portal_Branch_2_7/faces/build.xml 2008-04-13 12:59:04 UTC (rev 10555)
@@ -88,6 +88,7 @@
<!-- Configure thirdparty libraries -->
&libraries;
<path id="library.classpath">
+ <path refid="portlet.portlet.classpath"/>
<path refid="jboss.portal/modules/common.classpath"/>
<path refid="jboss.portal/modules/portlet.classpath"/>
<path refid="sun.servlet.classpath"/>
Modified: branches/JBoss_Portal_Branch_2_7/portlet-server/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/portlet-server/build.xml 2008-04-13 12:32:41 UTC (rev 10554)
+++ branches/JBoss_Portal_Branch_2_7/portlet-server/build.xml 2008-04-13 12:59:04 UTC (rev 10555)
@@ -88,6 +88,7 @@
<!-- Configure thirdparty libraries -->
&libraries;
<path id="library.classpath">
+ <path refid="portlet.portlet.classpath"/>
<path refid="jboss.portal/modules/common.classpath"/>
<path refid="jboss.portal/modules/web.classpath"/>
<path refid="jboss.portal/modules/portlet.classpath"/>
Modified: branches/JBoss_Portal_Branch_2_7/widget/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/widget/build.xml 2008-04-13 12:32:41 UTC (rev 10554)
+++ branches/JBoss_Portal_Branch_2_7/widget/build.xml 2008-04-13 12:59:04 UTC (rev 10555)
@@ -88,6 +88,7 @@
<!-- Configure thirdparty libraries -->
&libraries;
<path id="library.classpath">
+ <path refid="portlet.portlet.classpath"/>
<path refid="jboss.portal/modules/common.classpath"/>
<path refid="jboss.portal/modules/portlet.classpath"/>
<path refid="jbossas/core.libs.classpath"/>
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/build.xml 2008-04-13 12:32:41 UTC (rev 10554)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/build.xml 2008-04-13 12:59:04 UTC (rev 10555)
@@ -94,6 +94,7 @@
<!-- Libraries required to compile -->
<path id="library.classpath">
+ <path refid="portlet.portlet.classpath"/>
<path refid="jboss.portal/modules/common.classpath"/>
<path refid="jboss.portal/modules/portlet.classpath"/>
<path refid="jboss.portal/modules/test.classpath"/>
18 years
JBoss Portal SVN: r10554 - in modules/portlet/trunk: controller/src/main/java/org/jboss/portal/portlet/controller and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-13 08:32:41 -0400 (Sun, 13 Apr 2008)
New Revision: 10554
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java
modules/portlet/trunk/releaseLibs.sh
Log:
remove the automatic export of jsr168 jar
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java 2008-04-13 12:24:28 UTC (rev 10553)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java 2008-04-13 12:32:41 UTC (rev 10554)
@@ -36,6 +36,7 @@
import org.jboss.portal.portlet.controller.response.ControllerResponse;
import org.jboss.portal.portlet.controller.response.ResourceResponse;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
@@ -71,10 +72,16 @@
if (scope instanceof PortletResourceRequest.PortletScope)
{
PortletResourceRequest.PortletScope portletScope = (PortletResourceRequest.PortletScope)scope;
- mode = portletScope.getWindowNavigationalState().getMode();
- windowState = portletScope.getWindowNavigationalState().getWindowState();
- portletNS = portletScope.getWindowNavigationalState().getPortletNavigationalState();
+ WindowNavigationalState navigationalState = portletScope.getWindowNavigationalState();
+ //
+ if (navigationalState != null)
+ {
+ mode = navigationalState.getMode();
+ windowState = navigationalState.getWindowState();
+ portletNS = navigationalState.getPortletNavigationalState();
+ }
+
//
if (scope instanceof PortletResourceRequest.PageScope)
{
Modified: modules/portlet/trunk/releaseLibs.sh
===================================================================
--- modules/portlet/trunk/releaseLibs.sh 2008-04-13 12:24:28 UTC (rev 10553)
+++ modules/portlet/trunk/releaseLibs.sh 2008-04-13 12:32:41 UTC (rev 10554)
@@ -24,6 +24,6 @@
cp bridge/target/portlet-bridge-2.0.0-SNAPSHOT.jar $loc/portal-portlet-bridge-lib.jar
cp controller/target/portlet-controller-2.0.0-SNAPSHOT.jar $loc/portal-portlet-controller-lib.jar
cp federation/target/portlet-federation-2.0.0-SNAPSHOT.jar $loc/portal-portlet-federation-lib.jar
-cp jsr168api/target/portlet-jsr168api-2.0.0-SNAPSHOT.jar $loc/portal-portlet-jsr168api-lib.jar
cp management/target/portlet-management-2.0.0-SNAPSHOT.jar $loc/portal-portlet-management-lib.jar
cp portlet/target/portlet-portlet-2.0.0-SNAPSHOT.jar $loc/portal-portlet-lib.jar
+cp samples/target/portlet-samples-2.0.0-SNAPSHOT.jar $loc/portal-portlet-samples-lib.jar
18 years
JBoss Portal SVN: r10553 - in branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core: controller/portlet and 7 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-13 08:24:28 -0400 (Sun, 13 Apr 2008)
New Revision: 10553
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
Log:
early implementation of implicit render parameter sharing
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2008-04-12 15:06:58 UTC (rev 10552)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2008-04-13 12:24:28 UTC (rev 10553)
@@ -29,6 +29,7 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.portlet.ControllerPortletControllerContext;
import org.jboss.portal.core.controller.handler.AjaxResponse;
import org.jboss.portal.core.controller.handler.CommandForward;
import org.jboss.portal.core.controller.handler.HandlerResponse;
@@ -55,6 +56,8 @@
import org.jboss.portal.core.navstate.NavigationalStateObjectChange;
import org.jboss.portal.core.theme.WindowContextFactory;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.controller.PortletControllerContext;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PageService;
@@ -280,12 +283,16 @@
WindowContextFactory wcf = new WindowContextFactory(controllerContext);
//
+ PortletControllerContext portletControllerContext = new ControllerPortletControllerContext(controllerContext, page);
+ PageNavigationalState pageNavigationalState = portletControllerContext.getStateControllerContext().createPageNavigationalState(true);
+
+ //
for (Iterator i = refreshedWindows.iterator(); i.hasNext() && !fullRefresh;)
{
try
{
Window refreshedWindow = (Window)i.next();
- RenderWindowCommand rwc = new RenderWindowCommand(refreshedWindow.getId());
+ RenderWindowCommand rwc = new RenderWindowCommand(pageNavigationalState, refreshedWindow.getId());
WindowRendition rendition = rwc.render(controllerContext);
//
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java 2008-04-12 15:06:58 UTC (rev 10552)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java 2008-04-13 12:24:28 UTC (rev 10553)
@@ -80,11 +80,11 @@
/** . */
private final String pageId;
- public ControllerPortletControllerContext(
- ControllerContext controllerContext,
- Page page,
- InstanceContainer instanceContainer)
+ public ControllerPortletControllerContext(ControllerContext controllerContext, Page page)
{
+ InstanceContainer instanceContainer = controllerContext.getController().getInstanceContainer();
+
+ //
Map<String, PortletInfo> infos = new HashMap<String, PortletInfo>();
Map<String, Instance> instances = new HashMap<String, Instance>();
Map<String, Window> windows = new HashMap<String, Window>();
@@ -161,7 +161,7 @@
Window window = windows.get(s);
//
- return PortletInvocationFactory.createInvocationContext(controllerContext, window);
+ return PortletInvocationFactory.createInvocationContext(controllerContext, window, pageNavigationalState);
}
public PortletInvocationResponse invoke(ActionInvocation actionInvocation) throws PortletInvokerException
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-04-12 15:06:58 UTC (rev 10552)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-04-13 12:24:28 UTC (rev 10553)
@@ -42,6 +42,8 @@
import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ResourceURL;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.impl.spi.AbstractPortletInvocationContext;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -52,6 +54,8 @@
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
+import java.util.Map;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -65,9 +69,12 @@
/** Remove me / flawed. */
public static ThreadLocal<UserContext> userContextTL = new ThreadLocal<UserContext>();
- public static InvokePortletCommandFactory createInvokePortletCommandFactory(ControllerContext controllerContext, Window window)
+ public static InvokePortletCommandFactory createInvokePortletCommandFactory(
+ ControllerContext controllerContext,
+ Window window,
+ PageNavigationalState pageNavigationalState)
{
- return new InternalInvokePortletCommandFactory(window, controllerContext);
+ return new InternalInvokePortletCommandFactory(window, controllerContext, pageNavigationalState);
}
public static PortletInvocationContext createInvocationContext(ControllerContext controllerContext, InvokePortletCommandFactory cpc)
@@ -76,9 +83,12 @@
return new ControllerPortletInvocationContext(cpc, controllerContext, markupInfo);
}
- public static PortletInvocationContext createInvocationContext(ControllerContext controllerContext, Window window)
+ public static PortletInvocationContext createInvocationContext(
+ ControllerContext controllerContext,
+ Window window,
+ PageNavigationalState pageNavigationalState)
{
- InvokePortletCommandFactory ipcf = createInvokePortletCommandFactory(controllerContext, window);
+ InvokePortletCommandFactory ipcf = createInvokePortletCommandFactory(controllerContext, window, pageNavigationalState);
return createInvocationContext(controllerContext, ipcf);
}
@@ -90,10 +100,11 @@
StateString interactionState,
ParameterMap form,
Window window,
- Portal portal)
+ Portal portal,
+ PageNavigationalState pageNavigationalState)
{
PortletContextFactory cf = new PortletContextFactory(controllerContext, portal, window);
- InvokePortletCommandFactory cpc = createInvokePortletCommandFactory(controllerContext, window);
+ InvokePortletCommandFactory cpc = createInvokePortletCommandFactory(controllerContext, window, pageNavigationalState);
return createAction(controllerContext, mode, windowState, navigationalState, interactionState, form, cf, cpc);
}
@@ -132,11 +143,14 @@
WindowState windowState,
StateString navigationalState,
Window window,
- Portal portal)
+ Portal portal,
+ PageNavigationalState pageNavigationalState)
{
PortletContextFactory cf = new PortletContextFactory(controllerContext, portal, window);
- InvokePortletCommandFactory cpc = createInvokePortletCommandFactory(controllerContext, window);
- return createRender(controllerContext, mode, windowState, navigationalState, cf, cpc);
+ InvokePortletCommandFactory cpc = createInvokePortletCommandFactory(controllerContext, window, pageNavigationalState);
+ RenderInvocation render = createRender(controllerContext, mode, windowState, navigationalState, cf, cpc);
+ render.setPublicNavigationalState(pageNavigationalState.getPublicNavigationalState(window.getName()));
+ return render;
}
public static RenderInvocation createRender(
@@ -156,7 +170,7 @@
render.setMode(mode);
render.setWindowState(windowState);
render.setNavigationalState(navigationalState);
-
+
//
contextualize(controllerContext, cf, render);
@@ -217,53 +231,6 @@
contextualize(cpic.controllerContext, new PortletContextFactory(cpic.controllerContext, window.getPage().getPortal(), window), action);
}
- public static String renderURL(
- ControllerContext controllerContext,
- InvokePortletCommandFactory factory,
- ContainerURL containerURL,
- Boolean wantSecure,
- Boolean wantAuthenticated,
- boolean relative)
- {
- ControllerCommand cmd = null;
-
- //
- if (containerURL instanceof ActionURL)
- {
- cmd = factory.createInvokeActionCommand((ActionURL)containerURL);
- }
- else if (containerURL instanceof RenderURL)
- {
- cmd = factory.createInvokeRenderCommand((RenderURL)containerURL);
- }
- else if (containerURL instanceof ResourceURL)
- {
- cmd = factory.createInvokeResourceCommand((ResourceURL)containerURL);
- }
-
- if (cmd == null)
- {
- throw new IllegalArgumentException("No container url such as " + containerURL + " can be rendered by the core");
- }
-
- //
- boolean secure = controllerContext.getServerInvocation().getServerContext().getURLContext().isSecure();
- if (wantSecure != null)
- {
- secure = wantSecure;
- }
-
- //
- boolean authenticated = controllerContext.getServerInvocation().getServerContext().getURLContext().isAuthenticated();
- if (wantAuthenticated != null)
- {
- authenticated = wantAuthenticated;
- }
-
- URLContext info = URLContext.newInstance(secure, authenticated);
- return controllerContext.renderURL(cmd, info, URLFormat.newInstance(relative, true));
- }
-
public static class ControllerPortletInvocationContext extends AbstractPortletInvocationContext
{
@@ -302,7 +269,52 @@
public String renderURL(ContainerURL containerURL, org.jboss.portal.portlet.URLFormat urlFormat)
{
- return PortletInvocationFactory.renderURL(controllerContext, cmdFactory, containerURL, urlFormat.getWantSecure(), urlFormat.getWantAuthenticated(), urlFormat.getWantRelative());
+ ControllerCommand cmd = null;
+
+ //
+ if (containerURL instanceof ActionURL)
+ {
+ cmd = cmdFactory.createInvokeActionCommand((ActionURL)containerURL);
+ }
+ else if (containerURL instanceof RenderURL)
+ {
+ cmd = cmdFactory.createInvokeRenderCommand((RenderURL)containerURL);
+ }
+ else if (containerURL instanceof ResourceURL)
+ {
+ cmd = cmdFactory.createInvokeResourceCommand((ResourceURL)containerURL);
+ }
+
+ //
+ if (cmd == null)
+ {
+ throw new IllegalArgumentException("No container url such as " + containerURL + " can be rendered by the core");
+ }
+
+ //
+ boolean secure = controllerContext.getServerInvocation().getServerContext().getURLContext().isSecure();
+ if (urlFormat.getWantSecure() != null)
+ {
+ secure = urlFormat.getWantSecure();
+ }
+
+ //
+ boolean authenticated = controllerContext.getServerInvocation().getServerContext().getURLContext().isAuthenticated();
+ if (urlFormat.getWantAuthenticated() != null)
+ {
+ authenticated = urlFormat.getWantAuthenticated();
+ }
+
+ //
+ boolean relative = true;
+ if (urlFormat.getWantRelative() != null)
+ {
+ relative = urlFormat.getWantRelative();
+ }
+
+ //
+ URLContext info = URLContext.newInstance(secure, authenticated);
+ return controllerContext.renderURL(cmd, info, URLFormat.newInstance(relative, true));
}
}
@@ -315,20 +327,95 @@
/** . */
ControllerContext controllerContext;
- public InternalInvokePortletCommandFactory(Window window, ControllerContext controllerContext)
+ /** The existing public navigational state of the portlet. */
+ Map<String, String[]> publicNavigationalState;
+
+ public InternalInvokePortletCommandFactory(
+ Window window,
+ ControllerContext controllerContext,
+ PageNavigationalState pageNavigationalState)
{
this.controllerContext = controllerContext;
this.window = window;
+ this.publicNavigationalState = pageNavigationalState.getPublicNavigationalState(window.getName());
}
public ControllerCommand createInvokeActionCommand(ActionURL actionURL)
{
- return new InvokePortletWindowActionCommand(window.getId(), actionURL.getMode(), actionURL.getWindowState(), null, actionURL.getInteractionState(), null);
+ return new InvokePortletWindowActionCommand(
+ window.getId(),
+ actionURL.getMode(),
+ actionURL.getWindowState(),
+ null,
+ actionURL.getInteractionState(),
+ null);
}
public ControllerCommand createInvokeRenderCommand(RenderURL renderURL)
{
- return new InvokePortletWindowRenderCommand(window.getId(), renderURL.getMode(), renderURL.getWindowState(), renderURL.getNavigationalState());
+ StateString navigationalState = renderURL.getNavigationalState();
+
+ //
+ if (navigationalState instanceof ParametersStateString)
+ {
+ ParametersStateString navigationalParameters = (ParametersStateString)navigationalState;
+
+ //
+ ParameterMap parameters = navigationalParameters.getParameters();
+
+ // We add the changes desired by the portlet
+ Map<String, String[]> publicChanges = renderURL.getPublicNavigationalStateChanges();
+ if (publicChanges != null && publicChanges.size() > 0)
+ {
+ for (Map.Entry<String, String[]> entry : publicChanges.entrySet())
+ {
+ if (entry.getValue().length > 0)
+ {
+ parameters.put(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ // Complete with previous public portion of navigational state
+ if (publicNavigationalState != null && publicNavigationalState.size() > 0)
+ {
+ for (Map.Entry<String, String[]> entry : publicNavigationalState.entrySet())
+ {
+ String name = entry.getKey();
+
+ //
+ if (parameters.containsKey(name))
+ {
+ continue;
+ }
+
+ //
+ if (publicChanges != null)
+ {
+ String[] value = publicChanges.get(name);
+
+ //
+ if (value.length == 0)
+ {
+ continue;
+ }
+ }
+
+ //
+ parameters.put(name, entry.getValue());
+ }
+ }
+
+ //
+ navigationalState = ParametersStateString.create(parameters);
+ }
+
+ //
+ return new InvokePortletWindowRenderCommand(
+ window.getId(),
+ renderURL.getMode(),
+ renderURL.getWindowState(),
+ navigationalState);
}
public ControllerCommand createInvokeResourceCommand(ResourceURL resourceURL)
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2008-04-12 15:06:58 UTC (rev 10552)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2008-04-13 12:24:28 UTC (rev 10553)
@@ -28,6 +28,7 @@
import org.jboss.portal.common.util.MultiValuedPropertyMap;
import org.jboss.portal.core.aspects.portlet.AjaxInterceptor;
import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.portlet.ControllerPortletControllerContext;
import org.jboss.portal.core.controller.command.response.SecurityErrorResponse;
import org.jboss.portal.core.controller.command.response.UnavailableResourceResponse;
import org.jboss.portal.core.model.content.Content;
@@ -42,9 +43,9 @@
import org.jboss.portal.core.model.portal.content.ContentRenderer;
import org.jboss.portal.core.model.portal.content.ContentRendererContext;
import org.jboss.portal.core.model.portal.content.WindowRendition;
-import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
import org.jboss.portal.portlet.info.ModeInfo;
import org.jboss.portal.portlet.info.WindowStateInfo;
@@ -179,7 +180,7 @@
//
if (windowNS == null)
{
- windowNS = new WindowNavigationalState(window.getInitialWindowState(), window.getInitialMode(), null);
+ windowNS = new WindowNavigationalState(null, window.getInitialMode(), window.getInitialWindowState());
rendererContext.setNavigationalState(windowNS);
}
@@ -209,7 +210,7 @@
}
// Create invocation
- RenderInvocation invocation = rendererContext.createRenderInvocation(new WindowNavigationalState(windowState, mode, windowNS.getContentState()));
+ RenderInvocation invocation = rendererContext.createRenderInvocation(new WindowNavigationalState(windowNS.getPortletNavigationalState(), mode, windowState));
//
List<WindowState> supportedWindowStates = Collections.emptyList();
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2008-04-12 15:06:58 UTC (rev 10552)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2008-04-13 12:24:28 UTC (rev 10553)
@@ -38,8 +38,8 @@
import org.jboss.portal.core.model.portal.command.response.MarkupResponse;
import org.jboss.portal.core.model.portal.content.WindowRendition;
import org.jboss.portal.core.model.portal.content.ContentRendererContext;
-import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import java.util.Iterator;
import java.util.Map;
@@ -194,8 +194,8 @@
String uri = content.getURI();
state.setValue("uri", uri);
- //
- rendererContext.setNavigationalState(WindowNavigationalState.bilto(navigationalState, null, null, state));
+ // Julien : to redo!!!!
+ // rendererContext.setNavigationalState(WindowNavigationalState.bilto(navigationalState, null, null, state));
}
//
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java 2008-04-12 15:06:58 UTC (rev 10552)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java 2008-04-13 12:24:28 UTC (rev 10553)
@@ -67,6 +67,7 @@
// Get portal object
target = context.getController().getPortalObjectContainer().getObject(targetId);
+ //
if (target == null)
{
throw new NoSuchResourceException(targetId.toString());
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-04-12 15:06:58 UTC (rev 10552)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-04-13 12:24:28 UTC (rev 10553)
@@ -24,16 +24,27 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
+import org.jboss.portal.core.controller.NoSuchResourceException;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.impl.model.content.portlet.PortletContent;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.info.NavigationInfo;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.ParameterInfo;
import org.jboss.portal.portlet.controller.request.PortletRenderRequest;
import org.jboss.portal.portlet.controller.request.ContainerRequest;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import java.util.HashMap;
+import java.util.Map;
+import java.util.Collections;
/**
* Simply update the navigational state of the window. No invocation to the underlying is done.
@@ -45,11 +56,17 @@
{
/** . */
+ private static final String[] REMOVED_PARAMETER = new String[0];
+
+ /** . */
private static final CommandInfo info = new ActionCommandInfo(true);
/** . */
protected final StateString navigationalState;
+ /** . */
+ protected NavigationInfo navigationInfo;
+
public InvokePortletWindowRenderCommand(
PortalObjectId windowId,
Mode mode,
@@ -85,6 +102,30 @@
return info;
}
+ public void acquireResources() throws NoSuchResourceException
+ {
+ super.acquireResources();
+
+ //
+ try
+ {
+ PortletContent portletContent = (PortletContent)window.getContent();
+ Instance instance = context.getController().getInstanceContainer().getDefinition(portletContent.getInstanceRef());
+ PortletInfo info = instance.getPortlet().getInfo();
+ navigationInfo = info.getNavigation();
+ }
+ catch (PortletInvokerException e)
+ {
+ log.error("Not able to get portlet meta data for window " + targetId, e);
+
+ //
+ if (target == null)
+ {
+ throw new NoSuchResourceException(targetId.toString());
+ }
+ }
+ }
+
protected ContainerRequest createPortletRequest(PageNavigationalState pageNS, WindowNavigationalState windowNS)
{
Mode newMode = null;
@@ -113,11 +154,47 @@
newNavigationalState = navigationalState;
}
+ // Compute the public navigational state changes
+ Map<String, String[]> publicChanges = Collections.emptyMap();
+
//
+ if (navigationalState instanceof ParametersStateString)
+ {
+ ParametersStateString navigationalParameters = (ParametersStateString)navigationalState;
+
+ //
+ ParameterMap parameters = navigationalParameters.getParameters();
+
+ //
+ for (ParameterInfo parameterInfo : navigationInfo.getPublicParameters())
+ {
+ String key = parameterInfo.getId();
+
+ //
+ String[] values = parameters.remove(key);
+
+ //
+ if (values == null)
+ {
+ values = REMOVED_PARAMETER;
+ }
+
+ // Lazy create
+ if (publicChanges.isEmpty())
+ {
+ publicChanges = new HashMap<String, String[]>();
+ }
+
+ //
+ publicChanges.put(key, values);
+ }
+ }
+
+ //
return new PortletRenderRequest(
window.getName(),
new WindowNavigationalState(newNavigationalState, newMode, newWindowState),
- new HashMap<String, String[]>(),
+ publicChanges,
pageNS
);
}
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java 2008-04-12 15:06:58 UTC (rev 10552)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java 2008-04-13 12:24:28 UTC (rev 10553)
@@ -101,6 +101,14 @@
{
PortletResourceRequest.Scope scope;
+ // todo
+ // added because of a bug in portlet controller that will throw NPE if the portlet
+ // does not provide window NS during resource serving.
+ if (windowNS == null)
+ {
+ windowNS = new WindowNavigationalState();
+ }
+
//
switch (cacheability)
{
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java 2008-04-12 15:06:58 UTC (rev 10552)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java 2008-04-13 12:24:28 UTC (rev 10553)
@@ -22,11 +22,8 @@
******************************************************************************/
package org.jboss.portal.core.model.portal.command.action;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-import org.jboss.portal.portlet.controller.request.PortletRequest;
import org.jboss.portal.portlet.controller.request.ContainerRequest;
import org.jboss.portal.portlet.controller.PortletController;
import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
@@ -62,8 +59,7 @@
{
ControllerPortletControllerContext cpcc = new ControllerPortletControllerContext(
context,
- page,
- context.getController().getInstanceContainer()
+ page
);
//
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2008-04-12 15:06:58 UTC (rev 10552)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2008-04-13 12:24:28 UTC (rev 10553)
@@ -28,6 +28,8 @@
import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.NoSuchResourceException;
import org.jboss.portal.core.controller.SecurityException;
+import org.jboss.portal.core.controller.portlet.ControllerPortletControllerContext;
+import org.jboss.portal.core.controller.portlet.ControllerPageNavigationalState;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.model.portal.Page;
@@ -50,6 +52,8 @@
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.ThemeService;
import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.portlet.controller.PortletControllerContext;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -132,17 +136,20 @@
{
try
{
- //
PageService pageService = context.getController().getPageService();
ThemeService themeService = pageService.getThemeService();
LayoutService layoutService = pageService.getLayoutService();
+
//
-
PortalLayout layout = getLayout(layoutService, page);
// The theme for the page
PortalTheme theme = null;
+ //
+ ControllerPortletControllerContext portletControllerContext = new ControllerPortletControllerContext(context, page);
+ PageNavigationalState pageNavigationalState = portletControllerContext.getStateControllerContext().createPageNavigationalState(true);
+
// Determine theme
if (personalizable)
{
@@ -190,7 +197,7 @@
if (po instanceof Window)
{
Window window = (Window)po;
- RenderWindowCommand renderCmd = new RenderWindowCommand(window.getId());
+ RenderWindowCommand renderCmd = new RenderWindowCommand(pageNavigationalState, window.getId());
//
WindowRendition rendition = null;
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java 2008-04-12 15:06:58 UTC (rev 10552)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java 2008-04-13 12:24:28 UTC (rev 10553)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portal.core.model.portal.command.render;
-import org.jboss.portal.common.invocation.AttributeResolver;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ControllerResponse;
@@ -37,11 +36,13 @@
import org.jboss.portal.core.model.portal.content.ContentRendererRegistry;
import org.jboss.portal.core.model.portal.content.WindowRendition;
import org.jboss.portal.core.model.portal.control.page.PageControlContext;
-import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
-import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import java.util.Map;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -55,9 +56,15 @@
/** . */
private WindowRendition rendition;
- public RenderWindowCommand(PortalObjectId windowId) throws IllegalArgumentException
+ /** . */
+ private PageNavigationalState pageNavigationalState;
+
+ public RenderWindowCommand(PageNavigationalState pageNavigationalState, PortalObjectId windowId) throws IllegalArgumentException
{
super(windowId);
+
+ //
+ this.pageNavigationalState = pageNavigationalState;
}
public CommandInfo getInfo()
@@ -102,18 +109,21 @@
return null;
}
+ public Map<String, String[]> getPublicNavigationalState()
+ {
+ return pageNavigationalState.getPublicNavigationalState(window.getName());
+ }
+
public WindowNavigationalState getNavigationalState()
{
- AttributeResolver nsResolver = context.getAttributeResolver(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE);
- NavigationalStateKey nsKey = new NavigationalStateKey(WindowNavigationalState.class, window.getId());
- return (WindowNavigationalState)nsResolver.getAttribute(nsKey);
+ return pageNavigationalState.getWindowNavigationalState(window.getName());
}
public void setNavigationalState(WindowNavigationalState navigationalState)
{
- AttributeResolver nsResolver = context.getAttributeResolver(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE);
- NavigationalStateKey nsKey = new NavigationalStateKey(WindowNavigationalState.class, window.getId());
- nsResolver.setAttribute(nsKey, navigationalState);
+ pageNavigationalState.setWindowNavigationalState(window.getName(), navigationalState);
+
+ // probably call flush
}
public User getUser()
@@ -127,8 +137,9 @@
context,
navigationalState.getMode(),
navigationalState.getWindowState(),
- navigationalState.getContentState(),
+ navigationalState.getPortletNavigationalState(),
window,
- portal);
+ portal,
+ pageNavigationalState);
}
}
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java 2008-04-12 15:06:58 UTC (rev 10552)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java 2008-04-13 12:24:28 UTC (rev 10553)
@@ -23,10 +23,12 @@
package org.jboss.portal.core.model.portal.content;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import java.util.Map;
+
/**
* Abstract the services provided to a content renderer for the render phase.
*
@@ -42,6 +44,8 @@
void setNavigationalState(WindowNavigationalState navigationalState);
+ Map<String, String[]> getPublicNavigationalState();
+
User getUser();
RenderInvocation createRenderInvocation(WindowNavigationalState navigationalState);
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2008-04-12 15:06:58 UTC (rev 10552)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2008-04-13 12:24:28 UTC (rev 10553)
@@ -97,19 +97,19 @@
return store.getAttribute(id.toString());
}
- public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
+ public void setAttribute(Object attrKey, Object newNS) throws IllegalArgumentException
{
NavigationalStateKey wantedKey = (NavigationalStateKey)attrKey;
//
Class typeClass = wantedKey.getType();
- if (typeClass != WindowNavigationalState.class)
+ if (typeClass != WindowNavigationalState.class && typeClass != PageNavigationalState.class)
{
- throw new IllegalArgumentException("Can only set WindowNavigationalSate attributes, was given " + typeClass.getName());
+ throw new IllegalArgumentException("Can only set WindowNavigationalSate or PageNavigationalState attributes, was given " + typeClass.getName());
}
//
- WindowNavigationalState oldNS = null;
+ Object oldNS = null;
// Look first the old ns in the changes
if (changes != null)
@@ -125,7 +125,7 @@
{
case NavigationalStateObjectChange.CREATE:
case NavigationalStateObjectChange.UPDATE:
- oldNS = (WindowNavigationalState)change.getOldValue();
+ oldNS = change.getOldValue();
}
}
}
@@ -133,12 +133,12 @@
// If we don't have the old ns then we try the store
if (oldNS == null)
{
- oldNS = (WindowNavigationalState)store.getAttribute(wantedKey);
+ oldNS = store.getAttribute(wantedKey);
}
//
NavigationalStateObjectChange change;
- if (attrValue == null)
+ if (newNS == null)
{
if (oldNS != null)
{
@@ -152,9 +152,6 @@
}
else
{
- WindowNavigationalState newNS = (WindowNavigationalState)attrValue;
-
- //
if (oldNS != null)
{
change = NavigationalStateObjectChange.newUpdate(wantedKey, oldNS, newNS);
18 years
JBoss Portal SVN: r10552 - branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-12 11:06:58 -0400 (Sat, 12 Apr 2008)
New Revision: 10552
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
Log:
unecessary unboxing
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-04-12 14:59:26 UTC (rev 10551)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-04-12 15:06:58 UTC (rev 10552)
@@ -250,14 +250,14 @@
boolean secure = controllerContext.getServerInvocation().getServerContext().getURLContext().isSecure();
if (wantSecure != null)
{
- secure = wantSecure.booleanValue();
+ secure = wantSecure;
}
//
boolean authenticated = controllerContext.getServerInvocation().getServerContext().getURLContext().isAuthenticated();
if (wantAuthenticated != null)
{
- authenticated = wantAuthenticated.booleanValue();
+ authenticated = wantAuthenticated;
}
URLContext info = URLContext.newInstance(secure, authenticated);
18 years
JBoss Portal SVN: r10551 - in branches/JBoss_Portal_Branch_2_7: core/src/main/org/jboss/portal/core/controller/command/response and 5 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-12 10:59:26 -0400 (Sat, 12 Apr 2008)
New Revision: 10551
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowCommand.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/default-object.xml
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet-instances.xml
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet.xml
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/classic/OtherResponseHandler.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java
Log:
support for resource serving
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/classic/OtherResponseHandler.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/classic/OtherResponseHandler.java 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/classic/OtherResponseHandler.java 2008-04-12 14:59:26 UTC (rev 10551)
@@ -126,7 +126,15 @@
else if (controllerResponse instanceof StreamContentResponse)
{
StreamContentResponse scr = (StreamContentResponse)controllerResponse;
- return HTTPResponse.sendBinary(scr.getContentType(), scr.getLastModified(), scr.getInputStream());
+
+ if (scr.getInputStream() != null)
+ {
+ return HTTPResponse.sendBinary(scr.getContentType(), scr.getLastModified(), scr.getInputStream());
+ }
+ else
+ {
+ return HTTPResponse.sendBinary(scr.getContentType(), scr.getLastModified(), scr.getReader());
+ }
}
else if (controllerResponse instanceof SecurityErrorResponse)
{
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java 2008-04-12 14:59:26 UTC (rev 10551)
@@ -25,6 +25,7 @@
import org.jboss.portal.core.controller.ControllerResponse;
import java.io.InputStream;
+import java.io.Reader;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -34,17 +35,22 @@
{
/** . */
- private String contentType;
+ private final String contentType;
/**
* The time the content was last modified, measured in milliseconds since
- * the epoch (00:00:00 GMT, January 1, 1970).
+ * the epoch (00:00:00 GMT, January 1, 1970). If the value is not greater than zero then
+ * the last modified field does not represent a valid last modified date and it is left
+ * up to the streamer to interpret it.
*/
- private long lastModified;
+ private final long lastModified;
/** . */
- private InputStream inputStream;
+ private final InputStream inputStream;
+ /** . */
+ private final Reader reader;
+
public StreamContentResponse(String contentType, long lastModified, InputStream inputStream)
{
if (contentType == null)
@@ -55,11 +61,32 @@
{
throw new IllegalArgumentException();
}
+
+ //
this.contentType = contentType;
this.lastModified = lastModified;
this.inputStream = inputStream;
+ this.reader = null;
}
+ public StreamContentResponse(String contentType, long lastModified, Reader reader)
+ {
+ if (contentType == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (reader == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.contentType = contentType;
+ this.lastModified = lastModified;
+ this.inputStream = null;
+ this.reader = reader;
+ }
+
public String getContentType()
{
return contentType;
@@ -74,4 +101,9 @@
{
return inputStream;
}
+
+ public Reader getReader()
+ {
+ return reader;
+ }
}
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java 2008-04-12 14:59:26 UTC (rev 10551)
@@ -30,6 +30,8 @@
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
+import java.io.Reader;
+import java.io.Writer;
/**
* Response that sends a response to the http layer.
@@ -61,19 +63,22 @@
public void sendResponse(ServerInvocationContext ctx) throws IOException
{
HttpServletResponse resp = ctx.getClientResponse();
+
+ //
resp.setContentType(contentType);
- resp.addDateHeader("Last-Modified", lastModified);
+
+ //
+ if (lastModified > 0)
+ {
+ resp.addDateHeader("Last-Modified", lastModified);
+ }
+
+ //
ServletOutputStream sout = null;
try
{
sout = resp.getOutputStream();
- byte[] buf = new byte[2048];
- int len;
- while ((len = in.read(buf)) > 0)
- {
- sout.write(buf, 0, len);
- }
- sout.flush();
+ IOTools.copy(in, sout);
}
finally
{
@@ -84,6 +89,39 @@
};
}
+ public static HTTPResponse sendBinary(final String contentType, final long lastModified, final Reader reader)
+ {
+ return new HTTPResponse()
+ {
+ public void sendResponse(ServerInvocationContext ctx) throws IOException
+ {
+ HttpServletResponse resp = ctx.getClientResponse();
+
+ //
+ resp.setContentType(contentType);
+
+ //
+ if (lastModified > 0)
+ {
+ resp.addDateHeader("Last-Modified", lastModified);
+ }
+
+ //
+ Writer writer = null;
+ try
+ {
+ writer = resp.getWriter();
+ IOTools.copy(reader, writer);
+ }
+ finally
+ {
+ IOTools.safeClose(reader);
+ IOTools.safeClose(writer);
+ }
+ }
+ };
+ }
+
public static HTTPResponse sendForbidden()
{
return sendStatus(HttpServletResponse.SC_FORBIDDEN);
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java 2008-04-12 14:59:26 UTC (rev 10551)
@@ -166,7 +166,7 @@
public PortletInvocationResponse invoke(ActionInvocation actionInvocation) throws PortletInvokerException
{
- PortletInvocationFactory.contextualizeAction(actionInvocation);
+ PortletInvocationFactory.contextualize(actionInvocation);
//
Window window = PortletInvocationFactory.getTargetWindow(actionInvocation);
@@ -185,7 +185,16 @@
public PortletInvocationResponse invoke(ResourceInvocation resourceInvocation) throws PortletInvokerException
{
- throw new NotYetImplemented();
+ PortletInvocationFactory.contextualize(resourceInvocation);
+
+ //
+ Window window = PortletInvocationFactory.getTargetWindow(resourceInvocation);
+
+ //
+ Instance instance = instances.get(window.getName());
+
+ //
+ return instance.invoke(resourceInvocation);
}
public EventControllerContext getEventControllerContext()
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java 2008-04-12 14:59:26 UTC (rev 10551)
@@ -25,12 +25,14 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.FixMe;
+import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.command.response.ErrorResponse;
import org.jboss.portal.core.controller.command.response.RedirectionResponse;
import org.jboss.portal.core.controller.command.response.SecurityErrorResponse;
import org.jboss.portal.core.controller.command.response.SignOutResponse;
import org.jboss.portal.core.controller.command.response.UnavailableResourceResponse;
+import org.jboss.portal.core.controller.command.response.StreamContentResponse;
import org.jboss.portal.core.model.instance.command.response.PortletInstanceActionResponse;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.command.response.PortletWindowActionResponse;
@@ -38,7 +40,11 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
+import java.io.ByteArrayInputStream;
+import java.io.StringReader;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -123,6 +129,30 @@
org.jboss.portal.portlet.invocation.response.SecurityErrorResponse ser = (org.jboss.portal.portlet.invocation.response.SecurityErrorResponse)response;
return new SecurityErrorResponse(ser.getThrowable(), SecurityErrorResponse.NOT_AUTHORIZED, false);
}
+ else if (response instanceof ContentResponse)
+ {
+ ContentResponse contentResponse = (ContentResponse)response;
+
+ //
+ if (contentResponse.getType() == ContentResponse.TYPE_EMPTY)
+ {
+ throw new NotYetImplemented("todo");
+ }
+ else
+ {
+ String contentType = contentResponse.getContentType();
+
+ //
+ if (contentResponse.getType() == ContentResponse.TYPE_BYTES)
+ {
+ return new StreamContentResponse(contentType, -1, new ByteArrayInputStream(contentResponse.getBytes()));
+ }
+ else
+ {
+ return new StreamContentResponse(contentType, -1, new StringReader(contentResponse.getChars()));
+ }
+ }
+ }
else
{
throw new FixMe("Undefined response mapping for " + response);
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-04-12 14:59:26 UTC (rev 10551)
@@ -46,6 +46,7 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.server.request.URLContext;
@@ -57,8 +58,11 @@
*/
public class PortletInvocationFactory
{
+
+ /** Remove me / flawed. */
public static ThreadLocal<ControllerContext> controllerContextTL = new ThreadLocal<ControllerContext>();
+ /** Remove me / flawed. */
public static ThreadLocal<UserContext> userContextTL = new ThreadLocal<UserContext>();
public static InvokePortletCommandFactory createInvokePortletCommandFactory(ControllerContext controllerContext, Window window)
@@ -78,19 +82,6 @@
return createInvocationContext(controllerContext, ipcf);
}
- public static RenderInvocation createRender(
- ControllerContext controllerContext,
- Mode mode,
- WindowState windowState,
- StateString navigationalState,
- Window window,
- Portal portal)
- {
- PortletContextFactory cf = new PortletContextFactory(controllerContext, portal, window);
- InvokePortletCommandFactory cpc = createInvokePortletCommandFactory(controllerContext, window);
- return createRender(controllerContext, mode, windowState, navigationalState, cf, cpc);
- }
-
public static ActionInvocation createAction(
ControllerContext controllerContext,
Mode mode,
@@ -117,7 +108,7 @@
InvokePortletCommandFactory cpc)
{
PortletInvocationContext portletInvocationContext = createInvocationContext(controllerContext, cpc);
-
+
//
ActionInvocation action = new ActionInvocation(portletInvocationContext);
@@ -129,7 +120,7 @@
action.setInteractionState(interactionState);
//
- contextualizeAction(controllerContext, cf, action);
+ contextualize(controllerContext, cf, action);
//
return action;
@@ -140,6 +131,19 @@
Mode mode,
WindowState windowState,
StateString navigationalState,
+ Window window,
+ Portal portal)
+ {
+ PortletContextFactory cf = new PortletContextFactory(controllerContext, portal, window);
+ InvokePortletCommandFactory cpc = createInvokePortletCommandFactory(controllerContext, window);
+ return createRender(controllerContext, mode, windowState, navigationalState, cf, cpc);
+ }
+
+ public static RenderInvocation createRender(
+ ControllerContext controllerContext,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
PortletContextFactory cf,
InvokePortletCommandFactory cpc)
{
@@ -154,15 +158,18 @@
render.setNavigationalState(navigationalState);
//
- return contextualizeRender(controllerContext, cf, render);
+ contextualize(controllerContext, cf, render);
+
+ //
+ return render;
}
- public static RenderInvocation contextualizeRender(
+ public static void contextualize(
ControllerContext controllerContext,
PortletContextFactory cf,
- RenderInvocation render)
+ PortletInvocation invocation)
{
- render.setAttribute(PortletInvocation.INVOCATION_SCOPE, "controller_context", controllerContext);
+ invocation.setAttribute(PortletInvocation.INVOCATION_SCOPE, "controller_context", controllerContext);
//
UserContext userContext = cf.createUserContext();
@@ -172,52 +179,44 @@
userContextTL.set(userContext);
// Contextualize
- render.setSecurityContext(cf.createSecurityContext());
- render.setPortalContext(cf.createPortalContext());
- render.setWindowContext(cf.createWindowContext());
- render.setUserContext(cf.createUserContext());
- render.setServerContext(cf.createServerContext());
- render.setClientContext(cf.createClientContext());
+ invocation.setSecurityContext(cf.createSecurityContext());
+ invocation.setPortalContext(cf.createPortalContext());
+ invocation.setWindowContext(cf.createWindowContext());
+ invocation.setUserContext(cf.createUserContext());
+ invocation.setServerContext(cf.createServerContext());
+ invocation.setClientContext(cf.createClientContext());
//
- return render;
+ if (invocation instanceof ActionInvocation)
+ {
+ ActionInvocation action = (ActionInvocation)invocation;
+
+ //
+ action.setRequestContext(cf.createRequestContext());
+ }
+ else if (invocation instanceof ResourceInvocation)
+ {
+ ResourceInvocation resource = (ResourceInvocation)invocation;
+
+ //
+ resource.setRequestContext(cf.createRequestContext());
+ }
}
- public static Window getTargetWindow(ActionInvocation action)
+ public static Window getTargetWindow(PortletInvocation action)
{
ControllerPortletInvocationContext cpic = (ControllerPortletInvocationContext)action.getContext();
InternalInvokePortletCommandFactory iipcf = (InternalInvokePortletCommandFactory)cpic.cmdFactory;
return iipcf.window;
}
- public static void contextualizeAction(ActionInvocation action)
+ public static void contextualize(PortletInvocation action)
{
ControllerPortletInvocationContext cpic = (ControllerPortletInvocationContext)action.getContext();
Window window = getTargetWindow(action);
- contextualizeAction(cpic.controllerContext, new PortletContextFactory(cpic.controllerContext, window.getPage().getPortal(), window), action);
+ contextualize(cpic.controllerContext, new PortletContextFactory(cpic.controllerContext, window.getPage().getPortal(), window), action);
}
- public static void contextualizeAction(
- ControllerContext controllerContext,
- PortletContextFactory cf,
- ActionInvocation action)
- {
- UserContext userContext = cf.createUserContext();
-
- //
- controllerContextTL.set(controllerContext);
- userContextTL.set(userContext);
-
- // Contextualize
- action.setSecurityContext(cf.createSecurityContext());
- action.setRequestContext(cf.createRequestContext());
- action.setPortalContext(cf.createPortalContext());
- action.setWindowContext(cf.createWindowContext());
- action.setUserContext(userContext);
- action.setServerContext(cf.createServerContext());
- action.setClientContext(cf.createClientContext());
- }
-
public static String renderURL(
ControllerContext controllerContext,
InvokePortletCommandFactory factory,
@@ -336,8 +335,6 @@
{
return new InvokePortletWindowResourceCommand(
window.getId(),
- resourceURL.getMode(),
- resourceURL.getWindowState(),
resourceURL.getCacheability(),
resourceURL.getResourceId(),
resourceURL.getResourceState(),
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2008-04-12 14:59:26 UTC (rev 10551)
@@ -31,6 +31,7 @@
import org.jboss.portal.core.model.portal.command.action.ImportPageToDashboardCommand;
import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowActionCommand;
import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
+import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowResourceCommand;
import org.jboss.portal.core.model.portal.command.mapping.PortalObjectPathMapper;
import org.jboss.portal.core.model.portal.command.view.ViewContextCommand;
import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
@@ -78,7 +79,7 @@
ParameterMap queryParams = invocation.getServerContext().getQueryParameterMap();
//
- ControllerCommand cmd = null;
+ ControllerCommand cmd;
if (target instanceof Window)
{
Window window = (Window)target;
@@ -87,41 +88,55 @@
PortletRequestDecoder decoder = new PortletRequestDecoder();
decoder.decode(queryParams, invocation.getServerContext().getBodyParameterMap());
- // Get the window navigational state
- NavigationalStateKey nsKey = new NavigationalStateKey(WindowNavigationalState.class, window.getId());
- WindowNavigationalState windowNavState = (WindowNavigationalState)controllerContext.getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, nsKey);
- if (windowNavState == null)
+ if (decoder.getType() == PortletRequestDecoder.RESOURCE_TYPE)
{
- windowNavState = WindowNavigationalState.create();
- controllerContext.setAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, nsKey, windowNavState);
+ cmd = new InvokePortletWindowResourceCommand(
+ window.getId(),
+ decoder.getCacheability(),
+ decoder.getResourceId(),
+ decoder.getResourceState(),
+ decoder.getForm());
}
-
- //
- WindowState windowState = decoder.getWindowState();
- if (windowState == null)
+ else
{
- windowState = windowNavState.getWindowState();
- }
+ // Get the window navigational state
+ NavigationalStateKey nsKey = new NavigationalStateKey(WindowNavigationalState.class, window.getId());
+ WindowNavigationalState windowNavState = (WindowNavigationalState)controllerContext.getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, nsKey);
+ if (windowNavState == null)
+ {
+ windowNavState = WindowNavigationalState.create();
+ controllerContext.setAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, nsKey, windowNavState);
+ }
- //
- Mode mode = decoder.getMode();
- if (mode == null)
- {
- mode = windowNavState.getMode();
- }
+ //
+ WindowState windowState = decoder.getWindowState();
+ if (windowState == null)
+ {
+ windowState = windowNavState.getWindowState();
+ }
- //
- switch (decoder.getType())
- {
- case PortletRequestDecoder.NAV_TYPE:
- cmd = new InvokePortletWindowRenderCommand(window.getId(), mode, windowState);
- break;
- case PortletRequestDecoder.ACTION_TYPE:
- cmd = new InvokePortletWindowActionCommand(window.getId(), mode, windowState, decoder.getNavigationalState(), decoder.getInteractionState(), decoder.getForm());
- break;
- case PortletRequestDecoder.RENDER_TYPE:
- cmd = new InvokePortletWindowRenderCommand(window.getId(), mode, windowState, decoder.getNavigationalState());
- break;
+ //
+ Mode mode = decoder.getMode();
+ if (mode == null)
+ {
+ mode = windowNavState.getMode();
+ }
+
+ //
+ switch (decoder.getType())
+ {
+ case PortletRequestDecoder.NAV_TYPE:
+ cmd = new InvokePortletWindowRenderCommand(window.getId(), mode, windowState);
+ break;
+ case PortletRequestDecoder.ACTION_TYPE:
+ cmd = new InvokePortletWindowActionCommand(window.getId(), mode, windowState, decoder.getNavigationalState(), decoder.getInteractionState(), decoder.getForm());
+ break;
+ case PortletRequestDecoder.RENDER_TYPE:
+ cmd = new InvokePortletWindowRenderCommand(window.getId(), mode, windowState, decoder.getNavigationalState());
+ break;
+ default:
+ throw new AssertionError();
+ }
}
}
else
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2008-04-12 14:59:26 UTC (rev 10551)
@@ -32,11 +32,14 @@
import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowActionCommand;
import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
import org.jboss.portal.core.model.portal.command.action.InvokeWindowCommand;
+import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowCommand;
+import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowResourceCommand;
import org.jboss.portal.core.model.portal.command.mapping.PortalObjectPathMapper;
import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
import org.jboss.portal.core.model.portal.command.view.ViewPortalCommand;
import org.jboss.portal.core.portlet.PortletRequestEncoder;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.server.AbstractServerURL;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerURL;
@@ -134,24 +137,45 @@
}
else if (cmd instanceof InvokeWindowCommand)
{
- InvokeWindowCommand iwaCmd = (InvokeWindowCommand)cmd;
+ InvokeWindowCommand iwCmd = (InvokeWindowCommand)cmd;
- Mode mode = iwaCmd.getMode();
- WindowState windowState = iwaCmd.getWindowState();
+ //
+ PortletRequestEncoder encoder = new PortletRequestEncoder(url.getParameterMap());
//
- if (iwaCmd instanceof InvokePortletWindowActionCommand)
+ if (cmd instanceof InvokePortletWindowCommand)
{
- StateString interactionState = ((InvokePortletWindowActionCommand)iwaCmd).getInteractionState();
- StateString navigationalState = ((InvokePortletWindowActionCommand)iwaCmd).getNavigationalState();
- PortletRequestEncoder encoder = new PortletRequestEncoder(url.getParameterMap());
- encoder.encodeAction(navigationalState, interactionState, mode, windowState);
+ InvokePortletWindowCommand ipwCmd = (InvokePortletWindowCommand)iwCmd;
+
+ //
+ Mode mode = ipwCmd.getMode();
+ WindowState windowState = ipwCmd.getWindowState();
+ StateString navigationalState = ((InvokePortletWindowRenderCommand)iwCmd).getNavigationalState();
+
+ //
+ if (iwCmd instanceof InvokePortletWindowActionCommand)
+ {
+ StateString interactionState = ((InvokePortletWindowActionCommand)iwCmd).getInteractionState();
+
+ //
+ encoder.encodeAction(navigationalState, interactionState, mode, windowState);
+ }
+ else
+ {
+ encoder.encodeRender(navigationalState, mode, windowState);
+ }
}
else
{
- StateString navigationalState = ((InvokePortletWindowRenderCommand)iwaCmd).getNavigationalState();
- PortletRequestEncoder encoder = new PortletRequestEncoder(url.getParameterMap());
- encoder.encodeRender(navigationalState, mode, windowState);
+ InvokePortletWindowResourceCommand ipwrCmd = (InvokePortletWindowResourceCommand)iwCmd;
+
+ //
+ StateString resourceState = ipwrCmd.getResourceState();
+ String resourceId = ipwrCmd.getResourceId();
+ CacheLevel cacheability = ipwrCmd.getCacheability();
+
+ //
+ encoder.encodeResource(cacheability, resourceId, resourceState);
}
}
else if (cmd instanceof ImportPageToDashboardCommand)
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2008-04-12 14:59:26 UTC (rev 10551)
@@ -43,7 +43,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class InvokePortletWindowActionCommand extends InvokeWindowCommand
+public class InvokePortletWindowActionCommand extends InvokePortletWindowCommand
{
/** . */
private static final CommandInfo info = new ActionCommandInfo(false);
Added: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowCommand.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowCommand.java 2008-04-12 14:59:26 UTC (rev 10551)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.model.portal.command.action;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class InvokePortletWindowCommand extends InvokeWindowCommand
+{
+
+ /** . */
+ protected final Mode mode;
+
+ /** . */
+ protected final WindowState windowState;
+
+ protected InvokePortletWindowCommand(PortalObjectId windowId, Mode mode, WindowState windowState)
+ throws IllegalArgumentException
+ {
+ super(windowId);
+
+ //
+ this.mode = mode;
+ this.windowState = windowState;
+ }
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+
+}
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-04-12 14:59:26 UTC (rev 10551)
@@ -41,7 +41,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class InvokePortletWindowRenderCommand extends InvokeWindowCommand
+public class InvokePortletWindowRenderCommand extends InvokePortletWindowCommand
{
/** . */
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java 2008-04-12 14:59:26 UTC (rev 10551)
@@ -25,8 +25,6 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.controller.request.PortletResourceRequest;
import org.jboss.portal.portlet.controller.request.ContainerRequest;
@@ -46,7 +44,7 @@
private static final CommandInfo info = new ActionCommandInfo(true);
/** . */
- private final CacheLevel cacheLevel;
+ private final CacheLevel cacheability;
/** . */
private final String resourceId;
@@ -59,22 +57,41 @@
public InvokePortletWindowResourceCommand(
PortalObjectId windowId,
- Mode mode,
- WindowState windowState,
- CacheLevel cacheLevel,
+ CacheLevel cacheability,
String resourceId,
StateString resourceState,
ParameterMap resourceForm) throws IllegalArgumentException
{
- super(windowId, mode, windowState);
+ super(windowId);
//
- this.cacheLevel = cacheLevel;
+ if (cacheability == null)
+ {
+ throw new IllegalArgumentException("No null cache level accepted");
+ }
+
+ //
+ this.cacheability = cacheability;
this.resourceId = resourceId;
this.resourceState = resourceState;
this.resourceForm = resourceForm;
}
+ public CacheLevel getCacheability()
+ {
+ return cacheability;
+ }
+
+ public String getResourceId()
+ {
+ return resourceId;
+ }
+
+ public StateString getResourceState()
+ {
+ return resourceState;
+ }
+
public CommandInfo getInfo()
{
return info;
@@ -83,7 +100,9 @@
protected ContainerRequest createPortletRequest(PageNavigationalState pageNS, WindowNavigationalState windowNS)
{
PortletResourceRequest.Scope scope;
- switch (cacheLevel)
+
+ //
+ switch (cacheability)
{
case FULL:
scope = new PortletResourceRequest.FullScope();
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java 2008-04-12 14:59:26 UTC (rev 10551)
@@ -31,6 +31,7 @@
import org.jboss.portal.portlet.controller.PortletController;
import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
import org.jboss.portal.portlet.controller.response.PortletResponse;
+import org.jboss.portal.portlet.controller.response.ResourceResponse;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.command.WindowCommand;
@@ -48,31 +49,11 @@
public abstract class InvokeWindowCommand extends WindowCommand
{
- /** . */
- protected final Mode mode;
-
- /** . */
- protected final WindowState windowState;
-
- public InvokeWindowCommand(PortalObjectId windowId, Mode mode, WindowState windowState) throws IllegalArgumentException
+ public InvokeWindowCommand(PortalObjectId windowId) throws IllegalArgumentException
{
super(windowId);
-
- //
- this.mode = mode;
- this.windowState = windowState;
}
- public Mode getMode()
- {
- return mode;
- }
-
- public WindowState getWindowState()
- {
- return windowState;
- }
-
protected abstract ContainerRequest createPortletRequest(PageNavigationalState pageNS, WindowNavigationalState windowNS);
public ControllerResponse execute() throws ControllerException
@@ -114,13 +95,20 @@
//
return new UpdatePageResponse(page.getId());
}
- else
+ else if (cr instanceof PortletResponse)
{
PortletResponse portletResponse = (PortletResponse)cr;
//
return ControllerResponseFactory.createActionResponse(targetId, portletResponse.getResponse());
}
+ else
+ {
+ ResourceResponse resourceResponse = (ResourceResponse)cr;
+
+ //
+ return ControllerResponseFactory.createActionResponse(targetId, resourceResponse.getResponse());
+ }
}
catch (PortletInvokerException e)
{
Modified: branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/default-object.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/default-object.xml 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/default-object.xml 2008-04-12 14:59:26 UTC (rev 10551)
@@ -66,6 +66,12 @@
<region>center</region>
<height>4</height>
</window>
+ <window>
+ <window-name>RemoteControlPortletWindow</window-name>
+ <instance-ref>RemoteControlPortletInstance</instance-ref>
+ <region>center</region>
+ <height>5</height>
+ </window>
</page>
</deployment>
</deployments>
Modified: branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet-instances.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet-instances.xml 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet-instances.xml 2008-04-12 14:59:26 UTC (rev 10551)
@@ -41,4 +41,11 @@
<portlet-ref>GoogleWeather</portlet-ref>
</instance>
</deployment>
+ <deployment>
+ <instance>
+ <display-name xml:lang="en">Remote Controler</display-name>
+ <instance-id>RemoteControlPortletInstance</instance-id>
+ <portlet-ref>RemoteControl</portlet-ref>
+ </instance>
+ </deployment>
</deployments>
\ No newline at end of file
Modified: branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet.xml 2008-04-12 13:54:23 UTC (rev 10550)
+++ branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet.xml 2008-04-12 14:59:26 UTC (rev 10551)
@@ -94,6 +94,29 @@
</portlet>
<portlet>
+ <description>Portlet controlling display of other portlets</description>
+ <portlet-name>RemoteControl</portlet-name>
+ <display-name>Remote Control Portlet</display-name>
+ <portlet-class>org.jboss.portal.portlet.samples.remotecontroller.RemoteControllerPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Remote Control Portlet</title>
+ <keywords>sample,resource,remotecontrol</keywords>
+ </portlet-info>
+ <portlet-preferences>
+ <preference>
+ <name>color</name>
+ <value>ffe</value>
+ <read-only>false</read-only>
+ </preference>
+ </portlet-preferences>
+ <supported-public-render-parameter>zipcode</supported-public-render-parameter>
+ </portlet>
+
+ <portlet>
<description>Cart Portlet</description>
<portlet-name>Cart</portlet-name>
<display-name>Cart Portlet</display-name>
@@ -121,9 +144,4 @@
<qname xmlns:g="urn:jboss:portal:simple:google">g:zipcode</qname>
</public-render-parameter>
- <public-render-parameter>
- <identifier>zipcode</identifier>
- <qname xmlns:g="urn:jboss:portal:simple:google">g:zipcode</qname>
- </public-render-parameter>
-
</portlet-app>
18 years
JBoss Portal SVN: r10550 - in branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal: test/core/portlet and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-12 09:54:23 -0400 (Sat, 12 Apr 2008)
New Revision: 10550
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestEncoder.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestEncoderTestCase.java
Log:
add test cases for resource url encoding
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestEncoder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestEncoder.java 2008-04-12 13:04:55 UTC (rev 10549)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestEncoder.java 2008-04-12 13:54:23 UTC (rev 10550)
@@ -92,8 +92,11 @@
}
//
- meta |= PortletRequestDecoder.CACHEABILITY_MASK;
- setMetaParameter(PortletRequestDecoder.CACHEABILITY_PARAMETER, cacheability.toString());
+ if (cacheability != null)
+ {
+ meta |= PortletRequestDecoder.CACHEABILITY_MASK;
+ setMetaParameter(PortletRequestDecoder.CACHEABILITY_PARAMETER, cacheability.toString());
+ }
//
if (resourceId != null)
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestEncoderTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestEncoderTestCase.java 2008-04-12 13:04:55 UTC (rev 10549)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestEncoderTestCase.java 2008-04-12 13:54:23 UTC (rev 10550)
@@ -27,6 +27,7 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import junit.framework.TestCase;
@@ -39,12 +40,6 @@
{
/** . */
- public static final int RENDER = 0;
-
- /** . */
- public static final int ACTION = 1;
-
- /** . */
private ParameterMap params;
/** . */
@@ -65,143 +60,232 @@
public void testEncodeRender()
{
- _testEncodeRender(RENDER, PortletRequestDecoder.RENDER_PHASE);
+ Blah blah = new Blah<Mode, WindowState>(
+ Mode.VIEW,
+ WindowState.NORMAL,
+ PortletRequestDecoder.RENDER_PHASE,
+ PortletRequestDecoder.MODE_PARAMETER,
+ PortletRequestDecoder.WINDOW_STATE_PARAMETER,
+ PortletRequestDecoder.MODE_MASK,
+ PortletRequestDecoder.WINDOW_STATE_MASK)
+ {
+ protected void encodeBlah(ParametersStateString params, Mode view, WindowState normal)
+ {
+ encodeRender(params, view, normal);
+ }
+ };
+
+ //
+ blah.test();
}
public void testEncodeAction()
{
- _testEncodeRender(ACTION, PortletRequestDecoder.ACTION_PHASE);
+ Blah blah = new Blah<Mode, WindowState>(
+ Mode.VIEW,
+ WindowState.NORMAL,
+ PortletRequestDecoder.ACTION_PHASE,
+ PortletRequestDecoder.MODE_PARAMETER,
+ PortletRequestDecoder.WINDOW_STATE_PARAMETER,
+ PortletRequestDecoder.MODE_MASK,
+ PortletRequestDecoder.WINDOW_STATE_MASK)
+ {
+ protected void encodeBlah(ParametersStateString params, Mode view, WindowState normal)
+ {
+ encodeAction(params, view, normal);
+ }
+ };
+
+ //
+ blah.test();
}
- public void _testEncodeRender(int lifecycle, int lifecycleMask)
+ public void testEncodeResource()
{
- ParametersStateString pp = ParametersStateString.create();
- encode(pp, null, null, lifecycle);
- assertEquals(1, params.size());
- _assertEquals(lifecycleMask, params.getValues(PortletRequestDecoder.META_PARAMETER));
+ Blah blah = new Blah<String, CacheLevel>(
+ "resource_id",
+ CacheLevel.PAGE,
+ PortletRequestDecoder.RESOURCE_PHASE,
+ PortletRequestDecoder.RESOURCE_ID_PARAMETER,
+ PortletRequestDecoder.CACHEABILITY_PARAMETER,
+ PortletRequestDecoder.RESOURCE_ID_MASK,
+ PortletRequestDecoder.CACHEABILITY_MASK)
+ {
+ protected void encodeBlah(ParametersStateString params, String view, CacheLevel normal)
+ {
+ encodeResource(params, view, normal);
+ }
+ };
//
- pp = ParametersStateString.create();
- pp.setValue(PortletRequestDecoder.META_PARAMETER, "foo");
- encode(pp, null, null, lifecycle);
- assertEquals(1, params.size());
- _assertEquals(new String[]{Integer.toHexString(lifecycleMask),"foo"}, params.getValues(PortletRequestDecoder.META_PARAMETER));
+ blah.test();
+ }
- //
- pp = ParametersStateString.create();
- pp.setValue("foo", "bar");
- encode(pp, null, null, lifecycle);
- assertEquals(2, params.size());
- _assertEquals(lifecycleMask, params.getValues(PortletRequestDecoder.META_PARAMETER));
- _assertEquals("bar", params.getValues("foo"));
+ private abstract class Blah<A,B>
+ {
- //
- pp = ParametersStateString.create();
- encode(pp, Mode.VIEW, null, lifecycle);
- assertEquals(2, params.size());
- _assertEquals(lifecycleMask | PortletRequestDecoder.MODE_MASK, params.getValues(PortletRequestDecoder.META_PARAMETER));
- _assertEquals(Mode.VIEW, params.getValues(PortletRequestDecoder.MODE_PARAMETER));
+ /** . */
+ protected final A a;
- //
- pp = ParametersStateString.create();
- pp.setValue(PortletRequestDecoder.MODE_PARAMETER, "foo");
- encode(pp, Mode.VIEW, null, lifecycle);
- assertEquals(2, params.size());
- _assertEquals(lifecycleMask | PortletRequestDecoder.MODE_MASK, params.getValues(PortletRequestDecoder.META_PARAMETER));
- _assertEquals(new String[]{Mode.VIEW.toString(),"foo"}, params.getValues(PortletRequestDecoder.MODE_PARAMETER));
+ /** . */
+ protected final B b;
- //
- pp = ParametersStateString.create();
- pp.setValue("foo", "bar");
- encode(pp, Mode.VIEW, null, lifecycle);
- assertEquals(3, params.size());
- _assertEquals(lifecycleMask | PortletRequestDecoder.MODE_MASK, params.getValues(PortletRequestDecoder.META_PARAMETER));
- _assertEquals(Mode.VIEW, params.getValues(PortletRequestDecoder.MODE_PARAMETER));
- _assertEquals("bar", params.getValues("foo"));
+ /** . */
+ protected final int lifecycleValue;
- //
- pp = ParametersStateString.create();
- encode(pp, null, WindowState.NORMAL, lifecycle);
- assertEquals(2, params.size());
- _assertEquals(lifecycleMask | PortletRequestDecoder.WINDOW_STATE_MASK, params.getValues(PortletRequestDecoder.META_PARAMETER));
- _assertEquals(WindowState.NORMAL, params.getValues(PortletRequestDecoder.WINDOW_STATE_PARAMETER));
+ /** . */
+ protected final String aParamName;
- //
- pp = ParametersStateString.create();
- pp.setValue(PortletRequestDecoder.WINDOW_STATE_PARAMETER, "foo");
- encode(pp, null, WindowState.NORMAL, lifecycle);
- assertEquals(2, params.size());
- _assertEquals(lifecycleMask | PortletRequestDecoder.WINDOW_STATE_MASK, params.getValues(PortletRequestDecoder.META_PARAMETER));
- _assertEquals(new String[]{WindowState.NORMAL.toString(),"foo"}, params.getValues(PortletRequestDecoder.WINDOW_STATE_PARAMETER));
+ /** . */
+ protected final String bParamName;
- //
- pp = ParametersStateString.create();
- pp.setValue("foo", "bar");
- encode(pp, null, WindowState.NORMAL, lifecycle);
- assertEquals(3, params.size());
- _assertEquals(lifecycleMask | PortletRequestDecoder.WINDOW_STATE_MASK, params.getValues(PortletRequestDecoder.META_PARAMETER));
- _assertEquals(WindowState.NORMAL, params.getValues(PortletRequestDecoder.WINDOW_STATE_PARAMETER));
- _assertEquals("bar", params.getValues("foo"));
+ /** . */
+ protected final int aParamMask;
- //
- pp = ParametersStateString.create();
- encode(pp, Mode.VIEW, WindowState.NORMAL, lifecycle);
- assertEquals(3, params.size());
- _assertEquals(lifecycleMask | PortletRequestDecoder.MODE_MASK | PortletRequestDecoder.WINDOW_STATE_MASK, params.getValues(PortletRequestDecoder.META_PARAMETER));
- _assertEquals(Mode.VIEW, params.getValues(PortletRequestDecoder.MODE_PARAMETER));
- _assertEquals(WindowState.NORMAL, params.getValues(PortletRequestDecoder.WINDOW_STATE_PARAMETER));
+ /** . */
+ protected final int bParamMask;
- //
- pp = ParametersStateString.create();
- pp.setValue("foo", "bar");
- encode(pp, Mode.VIEW, WindowState.NORMAL, lifecycle);
- assertEquals(4, params.size());
- _assertEquals(lifecycleMask | PortletRequestDecoder.MODE_MASK | PortletRequestDecoder.WINDOW_STATE_MASK, params.getValues(PortletRequestDecoder.META_PARAMETER));
- _assertEquals(Mode.VIEW, params.getValues(PortletRequestDecoder.MODE_PARAMETER));
- _assertEquals(WindowState.NORMAL, params.getValues(PortletRequestDecoder.WINDOW_STATE_PARAMETER));
- _assertEquals("bar", params.getValues("foo"));
+ protected Blah(A a, B b, int lifecycleValue, String aParamName, String bParamName, int aParamMask, int bParamMask)
+ {
+ this.a = a;
+ this.b = b;
+ this.lifecycleValue = lifecycleValue;
+ this.aParamName = aParamName;
+ this.bParamName = bParamName;
+ this.aParamMask = aParamMask;
+ this.bParamMask = bParamMask;
+ }
+
+ protected abstract void encodeBlah(ParametersStateString params, A view, B normal);
+
+ public void test()
+ {
+ ParametersStateString pp = ParametersStateString.create();
+ encodeBlah(pp, null, null);
+ assertEquals(1, params.size());
+ _assertEquals(lifecycleValue, params.getValues(PortletRequestDecoder.META_PARAMETER));
+
+ //
+ pp = ParametersStateString.create();
+ pp.setValue(PortletRequestDecoder.META_PARAMETER, "foo");
+ encodeBlah(pp, null, null);
+ assertEquals(1, params.size());
+ _assertEquals(new String[]{Integer.toHexString(lifecycleValue),"foo"}, params.getValues(PortletRequestDecoder.META_PARAMETER));
+
+ //
+ pp = ParametersStateString.create();
+ pp.setValue("foo", "bar");
+ encodeBlah(pp, null, null);
+ assertEquals(2, params.size());
+ _assertEquals(lifecycleValue, params.getValues(PortletRequestDecoder.META_PARAMETER));
+ _assertEquals("bar", params.getValues("foo"));
+
+ //
+ pp = ParametersStateString.create();
+ encodeBlah(pp, a, null);
+ assertEquals(2, params.size());
+ _assertEquals(lifecycleValue | aParamMask, params.getValues(PortletRequestDecoder.META_PARAMETER));
+ _assertEquals(a, params.getValues(aParamName));
+
+ //
+ pp = ParametersStateString.create();
+ pp.setValue(aParamName, "foo");
+ encodeBlah(pp, a, null);
+ assertEquals(2, params.size());
+ _assertEquals(lifecycleValue | aParamMask, params.getValues(PortletRequestDecoder.META_PARAMETER));
+ _assertEquals(new String[]{a.toString(),"foo"}, params.getValues(aParamName));
+
+ //
+ pp = ParametersStateString.create();
+ pp.setValue("foo", "bar");
+ encodeBlah(pp, a, null);
+ assertEquals(3, params.size());
+ _assertEquals(lifecycleValue | aParamMask, params.getValues(PortletRequestDecoder.META_PARAMETER));
+ _assertEquals(a, params.getValues(aParamName));
+ _assertEquals("bar", params.getValues("foo"));
+
+ //
+ pp = ParametersStateString.create();
+ encodeBlah(pp, null, b);
+ assertEquals(2, params.size());
+ _assertEquals(lifecycleValue | bParamMask, params.getValues(PortletRequestDecoder.META_PARAMETER));
+ _assertEquals(b, params.getValues(bParamName));
+
+ //
+ pp = ParametersStateString.create();
+ pp.setValue(bParamName, "foo");
+ encodeBlah(pp, null, b);
+ assertEquals(2, params.size());
+ _assertEquals(lifecycleValue | bParamMask, params.getValues(PortletRequestDecoder.META_PARAMETER));
+ _assertEquals(new String[]{b.toString(),"foo"}, params.getValues(bParamName));
+
+ //
+ pp = ParametersStateString.create();
+ pp.setValue("foo", "bar");
+ encodeBlah(pp, null, b);
+ assertEquals(3, params.size());
+ _assertEquals(lifecycleValue | bParamMask, params.getValues(PortletRequestDecoder.META_PARAMETER));
+ _assertEquals(b, params.getValues(bParamName));
+ _assertEquals("bar", params.getValues("foo"));
+
+ //
+ pp = ParametersStateString.create();
+ encodeBlah(pp, a, b);
+ assertEquals(3, params.size());
+ _assertEquals(lifecycleValue | aParamMask | bParamMask, params.getValues(PortletRequestDecoder.META_PARAMETER));
+ _assertEquals(a, params.getValues(aParamName));
+ _assertEquals(b, params.getValues(bParamName));
+
+ //
+ pp = ParametersStateString.create();
+ pp.setValue("foo", "bar");
+ encodeBlah(pp, a, b);
+ assertEquals(4, params.size());
+ _assertEquals(lifecycleValue | aParamMask | bParamMask, params.getValues(PortletRequestDecoder.META_PARAMETER));
+ _assertEquals(a, params.getValues(aParamName));
+ _assertEquals(b, params.getValues(bParamName));
+ _assertEquals("bar", params.getValues("foo"));
+ }
}
-
public void testEncodeNav()
{
- encode(null, null, null, RENDER);
+ encodeRender(null, null, null);
assertEquals(0, params.size());
//
- encode(null, Mode.VIEW, null, RENDER);
+ encodeRender(null, Mode.VIEW, null);
assertEquals(1, params.size());
_assertEquals(Mode.VIEW, params.getValues(PortletRequestDecoder.MODE_PARAMETER));
//
- encode(null, null, WindowState.NORMAL, RENDER);
+ encodeRender(null, null, WindowState.NORMAL);
assertEquals(1, params.size());
_assertEquals(WindowState.NORMAL, params.getValues(PortletRequestDecoder.WINDOW_STATE_PARAMETER));
//
- encode(null, Mode.VIEW, WindowState.NORMAL, RENDER);
+ encodeRender(null, Mode.VIEW, WindowState.NORMAL);
assertEquals(2, params.size());
_assertEquals(Mode.VIEW, params.getValues(PortletRequestDecoder.MODE_PARAMETER));
_assertEquals(WindowState.NORMAL, params.getValues(PortletRequestDecoder.WINDOW_STATE_PARAMETER));
}
- private void encode(ParametersStateString params, Mode view, WindowState normal, int lifecycle)
+ private void encodeRender(ParametersStateString params, Mode view, WindowState normal)
{
- if (lifecycle == RENDER)
- {
- encoder.encodeRender(params, view, normal);
- }
- else if (lifecycle == ACTION)
- {
- encoder.encodeAction(null, params, view, normal);
- }
- else
- {
- fail();
- }
+ encoder.encodeRender(params, view, normal);
}
+ private void encodeAction(ParametersStateString params, Mode view, WindowState normal)
+ {
+ encoder.encodeAction(null, params, view, normal);
+ }
+
+ private void encodeResource(ParametersStateString params, String resourceId, CacheLevel cacheability)
+ {
+ encoder.encodeResource(cacheability, resourceId, params);
+ }
+
void _assertEquals(int expected, String[] actual)
{
_assertEquals(new String[]{Integer.toHexString(expected)}, actual);
18 years
JBoss Portal SVN: r10549 - in branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal: test/core/portlet and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-12 09:04:55 -0400 (Sat, 12 Apr 2008)
New Revision: 10549
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestDecoder.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestDecoderTestCase.java
Log:
add test cases for resource url decoding
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestDecoder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestDecoder.java 2008-04-12 12:49:44 UTC (rev 10548)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/portlet/PortletRequestDecoder.java 2008-04-12 13:04:55 UTC (rev 10549)
@@ -244,13 +244,27 @@
{
index = 1;
}
- else if ((meta & MODE_MASK) != 0 && MODE_PARAMETER.equals(name))
+ else if (type == RESOURCE_TYPE)
{
- index = 1;
+ if ((meta & RESOURCE_ID_MASK) != 0 && RESOURCE_ID_PARAMETER.equals(name))
+ {
+ index = 1;
+ }
+ else if ((meta & CACHEABILITY_MASK) != 0 && CACHEABILITY_PARAMETER.equals(name))
+ {
+ index = 1;
+ }
}
- else if ((meta & WINDOW_STATE_MASK) != 0 && WINDOW_STATE_PARAMETER.equals(name))
+ else
{
- index = 1;
+ if ((meta & MODE_MASK) != 0 && MODE_PARAMETER.equals(name))
+ {
+ index = 1;
+ }
+ else if ((meta & WINDOW_STATE_MASK) != 0 && WINDOW_STATE_PARAMETER.equals(name))
+ {
+ index = 1;
+ }
}
// We have interaction param(s) in the query string
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestDecoderTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestDecoderTestCase.java 2008-04-12 12:49:44 UTC (rev 10548)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestDecoderTestCase.java 2008-04-12 13:04:55 UTC (rev 10549)
@@ -29,6 +29,7 @@
import org.jboss.portal.portlet.OpaqueStateString;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.cache.CacheLevel;
import java.util.HashMap;
import java.util.Map;
@@ -46,9 +47,9 @@
{
}
- private String[] asStringArray(String s)
+ private String[] asStringArray(Object s)
{
- return new String[]{s};
+ return new String[]{s.toString()};
}
public void testCorruped()
@@ -342,7 +343,6 @@
queryParams.clear();
}
-
public void testActionNonOpaque()
{
Map queryParams = new HashMap();
@@ -394,7 +394,6 @@
form.clear();
}
-
public void testActionOpaque()
{
Map queryParams = new HashMap();
@@ -437,6 +436,104 @@
bodyParams.clear();
}
+ public void testResource()
+ {
+ Map queryParams = new HashMap();
+ PortletRequestDecoder o = new PortletRequestDecoder();
+
+ // Empty
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RESOURCE_TYPE)));
+ o.decode(queryParams, null);
+ assertResource(o, null, ParametersStateString.create(), new ParameterMap(), null);
+ queryParams.clear();
+
+ // Query mode
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RESOURCE_TYPE | PortletRequestDecoder.RESOURCE_ID_MASK)));
+ queryParams.put(PortletRequestDecoder.RESOURCE_ID_PARAMETER, asStringArray("resource_id"));
+ o.decode(queryParams, null);
+ assertResource(o, "resource_id", ParametersStateString.create(), new ParameterMap(), null);
+ queryParams.clear();
+
+ // Query window state
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RESOURCE_TYPE | PortletRequestDecoder.CACHEABILITY_MASK)));
+ queryParams.put(PortletRequestDecoder.CACHEABILITY_PARAMETER, asStringArray(CacheLevel.PAGE));
+ o.decode(queryParams, null);
+ assertResource(o, null, ParametersStateString.create(), new ParameterMap(), CacheLevel.PAGE);
+ queryParams.clear();
+ }
+
+ public void testResourceNonOpaque()
+ {
+ Map queryParams = new HashMap();
+ Map bodyParams = new HashMap();
+ PortletRequestDecoder o = new PortletRequestDecoder();
+ ParametersStateString resState = ParametersStateString.create();
+ ParameterMap form = new ParameterMap();
+
+ // Query parameter
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RESOURCE_PHASE)));
+ queryParams.put("foo", asStringArray("bar"));
+ o.decode(queryParams, null);
+ resState.setValue("foo", "bar");
+ assertResource(o, null, resState, form, null);
+ resState.clear();
+ queryParams.clear();
+ form.clear();
+
+ // Query multivalued parameter
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RESOURCE_PHASE)));
+ queryParams.put("foo", new String[]{"bar1", "bar2"});
+ o.decode(queryParams, null);
+ resState.setValues("foo", new String[]{"bar1", "bar2"});
+ assertResource(o, null, resState, form, null);
+ resState.clear();
+ queryParams.clear();
+ form.clear();
+
+ // Body parameter
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RESOURCE_PHASE)));
+ bodyParams.put("foo", asStringArray("bar"));
+ o.decode(queryParams, bodyParams);
+ form.setValue("foo", "bar");
+ assertResource(o, null, resState, form, null);
+ form.clear();
+ queryParams.clear();
+ bodyParams.clear();
+ form.clear();
+
+ // Body multivalued parameter
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RESOURCE_PHASE)));
+ bodyParams.put("foo", new String[]{"bar1", "bar2"});
+ o.decode(queryParams, bodyParams);
+ form.setValues("foo", new String[]{"bar1", "bar2"});
+ assertResource(o, null, resState, form, null);
+ form.clear();
+ queryParams.clear();
+ bodyParams.clear();
+ form.clear();
+ }
+
+ private void assertResource(
+ PortletRequestDecoder decoder,
+ String expectedResourceId,
+ StateString expectedResourceState,
+ ParameterMap expectedForm,
+ CacheLevel expectedCacheability
+ )
+ {
+ assertEquals(PortletRequestDecoder.RESOURCE_TYPE, decoder.getType());
+ assertEquals(expectedResourceId, decoder.getResourceId());
+ assertEquals(expectedResourceState, decoder.getResourceState());
+ assertEquals(expectedForm, decoder.getForm());
+ assertEquals(expectedCacheability, decoder.getCacheability());
+
+ //
+ assertNull(decoder.getNavigationalState());
+ assertNull( decoder.getInteractionState());
+ assertNull(decoder.getMode());
+ assertNull(decoder.getWindowState());
+ }
+
private void assertAction(
PortletRequestDecoder decoder,
StateString expectedNavigationalState,
@@ -456,9 +553,9 @@
//
assertNull(decoder.getResourceId());
assertNull(decoder.getResourceState());
+ assertNull(decoder.getCacheability());
}
-
private void assertRender(
PortletRequestDecoder decoder,
StateString expectedNavigationalState,
@@ -476,6 +573,7 @@
assertNull(decoder.getInteractionState());
assertNull(decoder.getResourceId());
assertNull(decoder.getResourceState());
+ assertNull(decoder.getCacheability());
}
private void assertNav(
@@ -494,6 +592,7 @@
assertNull(decoder.getInteractionState());
assertNull(decoder.getResourceId());
assertNull(decoder.getResourceState());
+ assertNull(decoder.getCacheability());
}
private void assertFail(
18 years
JBoss Portal SVN: r10548 - branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-12 08:49:44 -0400 (Sat, 12 Apr 2008)
New Revision: 10548
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestDecoderTestCase.java
Log:
refactored PortletRequestDecoderTestCase
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestDecoderTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestDecoderTestCase.java 2008-04-12 10:36:56 UTC (rev 10547)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/portlet/PortletRequestDecoderTestCase.java 2008-04-12 12:49:44 UTC (rev 10548)
@@ -28,6 +28,7 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.OpaqueStateString;
import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.StateString;
import java.util.HashMap;
import java.util.Map;
@@ -50,7 +51,6 @@
return new String[]{s};
}
-
public void testCorruped()
{
Map queryParams = new HashMap();
@@ -58,103 +58,55 @@
PortletRequestDecoder o = new PortletRequestDecoder();
// Action + Mode
- try
- {
- queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.MODE_MASK)));
- o.decode(queryParams, null);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- queryParams.clear();
- }
- try
- {
- queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.MODE_MASK)));
- bodyParams.put(PortletRequestDecoder.MODE_PARAMETER, asStringArray(Mode.VIEW.toString()));
- o.decode(queryParams, bodyParams);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- queryParams.clear();
- bodyParams.clear();
- }
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.MODE_MASK)));
+ assertFail(o, queryParams, null);
+ queryParams.clear();
+ //
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.MODE_MASK)));
+ bodyParams.put(PortletRequestDecoder.MODE_PARAMETER, asStringArray(Mode.VIEW.toString()));
+ assertFail(o, queryParams, bodyParams);
+ queryParams.clear();
+ bodyParams.clear();
+
// Action + WindowState
- try
- {
- queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.WINDOW_STATE_MASK)));
- o.decode(queryParams, null);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- queryParams.clear();
- }
- try
- {
- queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.WINDOW_STATE_MASK)));
- bodyParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, asStringArray(WindowState.NORMAL.toString()));
- o.decode(queryParams, bodyParams);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- queryParams.clear();
- bodyParams.clear();
- }
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.WINDOW_STATE_MASK)));
+ assertFail(o, queryParams, null);
+ queryParams.clear();
+ //
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.WINDOW_STATE_MASK)));
+ bodyParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, asStringArray(WindowState.NORMAL.toString()));
+ assertFail(o, queryParams, bodyParams);
+ queryParams.clear();
+ bodyParams.clear();
+
// Render + Mode
- try
- {
- queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.MODE_MASK)));
- o.decode(queryParams, null);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- queryParams.clear();
- }
- try
- {
- queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.MODE_MASK)));
- bodyParams.put(PortletRequestDecoder.MODE_PARAMETER, asStringArray(Mode.VIEW.toString()));
- o.decode(queryParams, bodyParams);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- queryParams.clear();
- bodyParams.clear();
- }
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.MODE_MASK)));
+ assertFail(o, queryParams, null);
+ queryParams.clear();
+ //
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.MODE_MASK)));
+ bodyParams.put(PortletRequestDecoder.MODE_PARAMETER, asStringArray(Mode.VIEW.toString()));
+ assertFail(o, queryParams, bodyParams);
+ queryParams.clear();
+ bodyParams.clear();
+
// Render + WindowState
- try
- {
- queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.WINDOW_STATE_MASK)));
- o.decode(queryParams, bodyParams);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- queryParams.clear();
- }
- try
- {
- queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.WINDOW_STATE_MASK)));
- bodyParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, asStringArray(WindowState.NORMAL.toString()));
- o.decode(queryParams, bodyParams);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- queryParams.clear();
- bodyParams.clear();
- }
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.WINDOW_STATE_MASK)));
+ assertFail(o, queryParams, bodyParams);
+ queryParams.clear();
+
+ //
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.WINDOW_STATE_MASK)));
+ bodyParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, asStringArray(WindowState.NORMAL.toString()));
+ assertFail(o, queryParams, bodyParams);
+ queryParams.clear();
+ bodyParams.clear();
}
-
+
public void testNav()
{
Map queryParams = new HashMap();
@@ -163,84 +115,48 @@
// Empty
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertNav(o, null, null);
queryParams.clear();
// Query mode
queryParams.put(PortletRequestDecoder.MODE_PARAMETER, asStringArray(Mode.VIEW.toString()));
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
- assertEquals(Mode.VIEW, o.getMode());
- assertNull(o.getWindowState());
+ assertNav(o, Mode.VIEW, null);
queryParams.clear();
// Query mode two values
queryParams.put(PortletRequestDecoder.MODE_PARAMETER, new String[]{Mode.VIEW.toString(), Mode.EDIT.toString()});
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
- assertEquals(Mode.VIEW, o.getMode());
- assertNull(o.getWindowState());
+ assertNav(o, Mode.VIEW, null);
queryParams.clear();
// Body mode
bodyParams.put(PortletRequestDecoder.MODE_PARAMETER, asStringArray(Mode.VIEW.toString()));
o.decode(queryParams, bodyParams);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertNav(o, null, null);
bodyParams.clear();
// Query mode + Body mode
queryParams.put(PortletRequestDecoder.MODE_PARAMETER, new String[]{Mode.VIEW.toString()});
bodyParams.put(PortletRequestDecoder.MODE_PARAMETER, new String[]{Mode.EDIT.toString()});
o.decode(queryParams, bodyParams);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
- assertEquals(Mode.VIEW, o.getMode());
- assertNull(o.getWindowState());
+ assertNav(o, Mode.VIEW, null);
queryParams.clear();
bodyParams.clear();
// Query window state
queryParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, asStringArray(WindowState.NORMAL.toString()));
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
- assertNull(o.getMode());
- assertEquals(WindowState.NORMAL, o.getWindowState());
+ assertNav(o, null, WindowState.NORMAL);
queryParams.clear();
// Body window state
bodyParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, asStringArray(WindowState.NORMAL.toString()));
o.decode(queryParams, bodyParams);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertNav(o, null, null);
bodyParams.clear();
}
-
public void testRender()
{
Map queryParams = new HashMap();
@@ -249,40 +165,24 @@
// Empty
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE)));
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertEquals(ParametersStateString.create(), o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, ParametersStateString.create(), null, null);
queryParams.clear();
// Query mode
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.MODE_MASK)));
queryParams.put(PortletRequestDecoder.MODE_PARAMETER, asStringArray(Mode.VIEW.toString()));
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertEquals(ParametersStateString.create(), o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertEquals(Mode.VIEW, o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, ParametersStateString.create(), Mode.VIEW, null);
queryParams.clear();
// Query window state
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.WINDOW_STATE_MASK)));
queryParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, asStringArray(WindowState.NORMAL.toString()));
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertEquals(ParametersStateString.create(), o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertEquals(WindowState.NORMAL, o.getWindowState());
+ assertRender(o, ParametersStateString.create(), null, WindowState.NORMAL);
queryParams.clear();
}
-
public void testRenderNonOpaque()
{
Map queryParams = new HashMap();
@@ -294,26 +194,16 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE)));
queryParams.put("foo", asStringArray("bar"));
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
navState.setValue("foo", "bar");
- assertEquals(navState, o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, navState, null, null);
navState.clear();
queryParams.clear();
// Query meta parameter
queryParams.put(PortletRequestDecoder.META_PARAMETER, new String[]{Integer.toHexString(PortletRequestDecoder.RENDER_PHASE), "bar"});
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
navState.setValue(PortletRequestDecoder.META_PARAMETER, "bar");
- assertEquals(navState, o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, navState, null, null);
navState.clear();
queryParams.clear();
@@ -321,13 +211,8 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, new String[]{Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.WINDOW_STATE_MASK)});
queryParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, new String[]{WindowState.NORMAL.toString(), "bar"});
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
navState.setValue(PortletRequestDecoder.WINDOW_STATE_PARAMETER, "bar");
- assertEquals(navState, o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertEquals(WindowState.NORMAL, o.getWindowState());
+ assertRender(o, navState, null, WindowState.NORMAL);
navState.clear();
queryParams.clear();
@@ -335,13 +220,8 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, new String[]{Integer.toHexString(PortletRequestDecoder.RENDER_PHASE)});
queryParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, new String[]{"bar"});
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
navState.setValue(PortletRequestDecoder.WINDOW_STATE_PARAMETER, "bar");
- assertEquals(navState, o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, navState, null, null);
navState.clear();
queryParams.clear();
@@ -349,13 +229,8 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, new String[]{Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.MODE_MASK)});
queryParams.put(PortletRequestDecoder.MODE_PARAMETER, new String[]{Mode.VIEW.toString(), "bar"});
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
navState.setValue(PortletRequestDecoder.MODE_PARAMETER, "bar");
- assertEquals(navState, o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertEquals(Mode.VIEW, o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, navState, Mode.VIEW, null);
navState.clear();
queryParams.clear();
@@ -363,13 +238,8 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, new String[]{Integer.toHexString(PortletRequestDecoder.RENDER_PHASE)});
queryParams.put(PortletRequestDecoder.MODE_PARAMETER, new String[]{"bar"});
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
navState.setValue(PortletRequestDecoder.MODE_PARAMETER, "bar");
- assertEquals(navState, o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, navState, null, null);
navState.clear();
queryParams.clear();
@@ -377,12 +247,7 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE)));
bodyParams.put("foo", asStringArray("bar2"));
o.decode(queryParams, bodyParams);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertEquals(navState, o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, navState, null, null);
navState.clear();
queryParams.clear();
bodyParams.clear();
@@ -391,13 +256,8 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE)));
queryParams.put("foo", new String[]{"bar1", "bar2"});
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
navState.setValues("foo", new String[]{"bar1", "bar2"});
- assertEquals(navState, o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, navState, null, null);
navState.clear();
queryParams.clear();
@@ -406,19 +266,13 @@
queryParams.put("foo", new String[]{"bar1"});
bodyParams.put("foo", new String[]{"bar2"});
o.decode(queryParams, bodyParams);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
navState.setValue("foo", "bar1");
- assertEquals(navState, o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, navState, null, null);
navState.clear();
queryParams.clear();
bodyParams.clear();
}
-
public void testRenderOpaque()
{
Map queryParams = new HashMap();
@@ -428,36 +282,21 @@
// Empty
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.OPAQUE_MASK)));
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, null, null, null);
queryParams.clear();
// Query nav state
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.OPAQUE_MASK)));
queryParams.put(PortletRequestDecoder.NAVIGATIONAL_STATE_PARAMETER, asStringArray("navstatevalue"));
o.decode(queryParams, bodyParams);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertEquals(new OpaqueStateString("navstatevalue"), o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, new OpaqueStateString("navstatevalue"), null, null);
queryParams.clear();
// Body nav state
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.OPAQUE_MASK)));
bodyParams.put(PortletRequestDecoder.NAVIGATIONAL_STATE_PARAMETER, asStringArray("navstatevalue"));
o.decode(queryParams, bodyParams);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, null, null, null);
queryParams.clear();
bodyParams.clear();
@@ -465,29 +304,18 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.OPAQUE_MASK)));
queryParams.put(PortletRequestDecoder.INTERACTION_STATE_PARAMETER, asStringArray("intstatevalue"));
o.decode(queryParams, null);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, null, null, null);
queryParams.clear();
// Body int state is ignored
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.RENDER_PHASE | PortletRequestDecoder.OPAQUE_MASK)));
bodyParams.put(PortletRequestDecoder.INTERACTION_STATE_PARAMETER, asStringArray("intstatevalue"));
o.decode(queryParams, bodyParams);
- assertNull(o.getForm());
- assertNull(o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertRender(o, null, null, null);
queryParams.clear();
bodyParams.clear();
}
-
public void testAction()
{
Map queryParams = new HashMap();
@@ -496,36 +324,21 @@
// Empty
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE)));
o.decode(queryParams, null);
- assertEquals(new ParameterMap(), o.getForm());
- assertEquals(ParametersStateString.create(), o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertAction(o, null, ParametersStateString.create(), new ParameterMap(), null, null);
queryParams.clear();
// Query mode
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.MODE_MASK)));
queryParams.put(PortletRequestDecoder.MODE_PARAMETER, asStringArray(Mode.VIEW.toString()));
o.decode(queryParams, null);
- assertEquals(new ParameterMap(), o.getForm());
- assertEquals(ParametersStateString.create(), o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
- assertEquals(Mode.VIEW, o.getMode());
- assertNull(o.getWindowState());
+ assertAction(o, null, ParametersStateString.create(), new ParameterMap(), Mode.VIEW, null);
queryParams.clear();
// Query window state
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.WINDOW_STATE_MASK)));
queryParams.put(PortletRequestDecoder.WINDOW_STATE_PARAMETER, asStringArray(WindowState.NORMAL.toString()));
o.decode(queryParams, null);
- assertEquals(new ParameterMap(), o.getForm());
- assertEquals(ParametersStateString.create(), o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
- assertNull(o.getMode());
- assertEquals(WindowState.NORMAL, o.getWindowState());
+ assertAction(o, null, ParametersStateString.create(), new ParameterMap(), null, WindowState.NORMAL);
queryParams.clear();
}
@@ -542,13 +355,8 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE)));
queryParams.put("foo", asStringArray("bar"));
o.decode(queryParams, null);
- assertEquals(form, o.getForm());
intState.setValue("foo", "bar");
- assertEquals(intState, o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertAction(o, null, intState, form, null, null);
intState.clear();
queryParams.clear();
form.clear();
@@ -557,13 +365,8 @@
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE)));
queryParams.put("foo", new String[]{"bar1", "bar2"});
o.decode(queryParams, null);
- assertEquals(form, o.getForm());
intState.setValues("foo", new String[]{"bar1", "bar2"});
- assertEquals(intState, o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertAction(o, null, intState, form, null, null);
intState.clear();
queryParams.clear();
form.clear();
@@ -573,12 +376,7 @@
bodyParams.put("foo", asStringArray("bar"));
o.decode(queryParams, bodyParams);
form.setValue("foo", "bar");
- assertEquals(form, o.getForm());
- assertEquals(intState, o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertAction(o, null, intState, form, null, null);
form.clear();
queryParams.clear();
bodyParams.clear();
@@ -589,12 +387,7 @@
bodyParams.put("foo", new String[]{"bar1", "bar2"});
o.decode(queryParams, bodyParams);
form.setValues("foo", new String[]{"bar1", "bar2"});
- assertEquals(form, o.getForm());
- assertEquals(intState, o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertAction(o, null, intState, form, null, null);
form.clear();
queryParams.clear();
bodyParams.clear();
@@ -611,36 +404,21 @@
// Empty
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.OPAQUE_MASK)));
o.decode(queryParams, null);
- assertEquals(new ParameterMap(), o.getForm());
- assertNull(o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertAction(o, null, null, new ParameterMap(), null, null);
queryParams.clear();
// Query nav state
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.OPAQUE_MASK)));
queryParams.put(PortletRequestDecoder.NAVIGATIONAL_STATE_PARAMETER, asStringArray("navstatevalue"));
o.decode(queryParams, null);
- assertEquals(new ParameterMap(), o.getForm());
- assertNull(o.getInteractionState());
- assertEquals(new OpaqueStateString("navstatevalue"), o.getNavigationalState());
- assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertAction(o, new OpaqueStateString("navstatevalue"), null, new ParameterMap(), null, null);
queryParams.clear();
// Query int state
queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.OPAQUE_MASK)));
queryParams.put(PortletRequestDecoder.INTERACTION_STATE_PARAMETER, asStringArray("intstatevalue"));
o.decode(queryParams, null);
- assertEquals(new ParameterMap(), o.getForm());
- assertEquals(new OpaqueStateString("intstatevalue"), o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertAction(o, null, new OpaqueStateString("intstatevalue"), new ParameterMap(), null, null);
queryParams.clear();
// Body parameters
@@ -654,13 +432,83 @@
form.setValue("foo1", "bar1");
form.setValues("foo2", new String[]{"bar2", "bar3"});
form.setValues("foo3", new String[]{"bar5"});
- assertEquals(form, o.getForm());
- assertNull(o.getInteractionState());
- assertNull(o.getNavigationalState());
- assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
- assertNull(o.getMode());
- assertNull(o.getWindowState());
+ assertAction(o, null, null, form, null, null);
queryParams.clear();
bodyParams.clear();
}
+
+ private void assertAction(
+ PortletRequestDecoder decoder,
+ StateString expectedNavigationalState,
+ StateString expectedInteractionState,
+ ParameterMap expectedForm,
+ Mode expectedMode,
+ WindowState expectedWindowState
+ )
+ {
+ assertEquals(PortletRequestDecoder.ACTION_TYPE, decoder.getType());
+ assertEquals(expectedNavigationalState, decoder.getNavigationalState());
+ assertEquals(expectedInteractionState, decoder.getInteractionState());
+ assertEquals(expectedForm, decoder.getForm());
+ assertEquals(expectedMode, decoder.getMode());
+ assertEquals(expectedWindowState, decoder.getWindowState());
+
+ //
+ assertNull(decoder.getResourceId());
+ assertNull(decoder.getResourceState());
+ }
+
+
+ private void assertRender(
+ PortletRequestDecoder decoder,
+ StateString expectedNavigationalState,
+ Mode expectedMode,
+ WindowState expectedWindowState
+ )
+ {
+ assertEquals(PortletRequestDecoder.RENDER_TYPE, decoder.getType());
+ assertEquals(expectedNavigationalState, decoder.getNavigationalState());
+ assertEquals(expectedMode, decoder.getMode());
+ assertEquals(expectedWindowState, decoder.getWindowState());
+
+ //
+ assertNull(decoder.getForm());
+ assertNull(decoder.getInteractionState());
+ assertNull(decoder.getResourceId());
+ assertNull(decoder.getResourceState());
+ }
+
+ private void assertNav(
+ PortletRequestDecoder decoder,
+ Mode expectedMode,
+ WindowState expectedWindowState
+ )
+ {
+ assertEquals(PortletRequestDecoder.NAV_TYPE, decoder.getType());
+ assertEquals(expectedMode, decoder.getMode());
+ assertEquals(expectedWindowState, decoder.getWindowState());
+
+ //
+ assertNull(decoder.getNavigationalState());
+ assertNull(decoder.getForm());
+ assertNull(decoder.getInteractionState());
+ assertNull(decoder.getResourceId());
+ assertNull(decoder.getResourceState());
+ }
+
+ private void assertFail(
+ PortletRequestDecoder decoder,
+ Map queryParams,
+ Map bodyParams)
+ {
+ try
+ {
+ queryParams.put(PortletRequestDecoder.META_PARAMETER, asStringArray(Integer.toHexString(PortletRequestDecoder.ACTION_PHASE | PortletRequestDecoder.MODE_MASK)));
+ decoder.decode(queryParams, bodyParams);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
}
\ No newline at end of file
18 years