Author: julien(a)jboss.com
Date: 2008-02-05 12:52:29 -0500 (Tue, 05 Feb 2008)
New Revision: 9781
Removed:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/MutablePageNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/event/EventControllerContextImpl.java
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/MutablePageNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java
Log:
use window id in PageNavigationalState instead of "Portlet" for the public
render parameter retrieval
Deleted:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/MutablePageNavigationalState.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/MutablePageNavigationalState.java 2008-02-05
17:17:28 UTC (rev 9780)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/MutablePageNavigationalState.java 2008-02-05
17:52:29 UTC (rev 9781)
@@ -1,60 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.controller;
-
-import org.jboss.portal.portlet.controller.WindowNavigationalState;
-
-import javax.xml.namespace.QName;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class MutablePageNavigationalState extends PageNavigationalState
-{
-
- public MutablePageNavigationalState()
- {
- }
-
- public MutablePageNavigationalState(PageNavigationalState original)
- {
- super(original);
- }
-
- public void setWindowNavigationalState(String windowId, WindowNavigationalState
windowNS)
- {
- windows.put(windowId, windowNS);
- }
-
- public void setPublicNavigationalState(QName name, String[] value)
- {
- // We clone the value in order to keep the state not mutated by a side effect
- page.put(name, value.clone());
- }
-
- public void removePublicNavigationalState(QName name)
- {
- page.remove(name);
- }
-}
\ No newline at end of file
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java 2008-02-05
17:17:28 UTC (rev 9780)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java 2008-02-05
17:52:29 UTC (rev 9781)
@@ -206,7 +206,7 @@
}
//
- ParameterMap publicNS = pageState.getPublicNavigationalState(portlet);
+ ParameterMap publicNS =
pageState.getPublicNavigationalState(portletRequest.getWindowId());
PortletInvocationContext portletInvocationContext =
context.createPortletInvocationContext(portletRequest.getWindowId(), pageState);
ActionInvocation actionInvocation = new
ActionInvocation(portletInvocationContext);
@@ -239,7 +239,7 @@
}
//
- ParameterMap publicNS = pageState.getPublicNavigationalState(portlet);
+ ParameterMap publicNS = pageState.getPublicNavigationalState(event.getWindowId());
//
PortletInvocationContext portletInvocationContext =
context.createPortletInvocationContext(event.getWindowId(), pageState);
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java 2008-02-05
17:17:28 UTC (rev 9780)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java 2008-02-05
17:52:29 UTC (rev 9781)
@@ -95,7 +95,7 @@
//
if (pageState != null)
{
- publicNS = pageState.getPublicNavigationalState(portlet);
+ publicNS =
pageState.getPublicNavigationalState(portletResourceRequest.getWindowId());
}
}
else
Deleted:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/event/EventControllerContextImpl.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/event/EventControllerContextImpl.java 2008-02-05
17:17:28 UTC (rev 9780)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/event/EventControllerContextImpl.java 2008-02-05
17:52:29 UTC (rev 9781)
@@ -1,73 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.controller.event;
-
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.info.PortletInfo;
-
-import java.util.List;
-import java.util.Collections;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class EventControllerContextImpl implements EventControllerContext
-{
-
- /** . */
- private PortletInvoker invoker;
-
- public EventControllerContextImpl(PortletInvoker invoker)
- {
- this.invoker = invoker;
- }
-
- public List<Event> getConsumedEvents(Event producedEvent)
- {
- try
- {
- ArrayList<Event> consumedEvents = new ArrayList<Event>();
- for (Portlet portlet : invoker.getPortlets())
- {
- PortletInfo portletInfo = portlet.getInfo();
- if
(portletInfo.getEventing().getConsumedEvents().containsKey(producedEvent.getName()))
- {
- Event consumedEvent = new Event(producedEvent.getName(),
producedEvent.getPayload(), portlet.getContext().getId());
- consumedEvents.add(consumedEvent);
- }
- }
- return consumedEvents;
- }
- catch (PortletInvokerException e)
- {
- System.out.println("e = " + e);
-
- //
- return Collections.emptyList();
- }
- }
-}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/MutablePageNavigationalState.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/MutablePageNavigationalState.java 2008-02-05
17:17:28 UTC (rev 9780)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/MutablePageNavigationalState.java 2008-02-05
17:52:29 UTC (rev 9781)
@@ -33,8 +33,9 @@
class MutablePageNavigationalState extends PageNavigationalStateImpl
{
- public MutablePageNavigationalState()
+ MutablePageNavigationalState(StateControllerContextImpl context)
{
+ super(context);
}
public MutablePageNavigationalState(PageNavigationalStateImpl original)
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-02-05
17:17:28 UTC (rev 9780)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-02-05
17:52:29 UTC (rev 9781)
@@ -27,18 +27,12 @@
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import org.jboss.portal.portlet.PortletInvokerException;
import javax.xml.namespace.QName;
import java.util.Map;
import java.util.HashMap;
-import java.util.zip.GZIPOutputStream;
-import java.util.zip.GZIPInputStream;
import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInputStream;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -47,20 +41,25 @@
class PageNavigationalStateImpl implements PageNavigationalState, Serializable
{
+ /** We don't save it. */
+ protected transient StateControllerContextImpl context;
+
/** . */
protected final Map<String, WindowNavigationalState> windows;
/** . */
protected final Map<QName, String[]> page;
- public PageNavigationalStateImpl()
+ public PageNavigationalStateImpl(StateControllerContextImpl context)
{
+ this.context = context;
this.windows = new HashMap<String, WindowNavigationalState>();
this.page = new HashMap<QName, String[]>();
}
public PageNavigationalStateImpl(PageNavigationalStateImpl original)
{
+ this.context = original.context;
this.windows = new HashMap<String,
WindowNavigationalState>(original.windows);
this.page = new HashMap<QName, String[]>(original.page);
}
@@ -70,28 +69,36 @@
return windows.get(windowId);
}
- public ParameterMap getPublicNavigationalState(PortletInfo portlet)
+ public ParameterMap getPublicNavigationalState(String windowId)
{
ParameterMap publicNavigationalState = null;
- for (ParameterInfo parameterInfo : portlet.getNavigation().getPublicParameters())
+ try
{
- String[] parameterValue = page.get(parameterInfo.getName());
-
- //
- if (parameterValue != null)
+ PortletInfo info = context.portletControllerContext.getPortletInfo(windowId);
+ for (ParameterInfo parameterInfo : info.getNavigation().getPublicParameters())
{
- String parameterId = parameterInfo.getId();
+ String[] parameterValue = page.get(parameterInfo.getName());
- // Lazy create
- if (publicNavigationalState == null)
+ //
+ if (parameterValue != null)
{
- publicNavigationalState = new ParameterMap();
+ String parameterId = parameterInfo.getId();
+
+ // Lazy create
+ if (publicNavigationalState == null)
+ {
+ publicNavigationalState = new ParameterMap();
+ }
+
+ // We clone the value here so we keep the internal state not potentially
changed
+ publicNavigationalState.put(parameterId, parameterValue.clone());
}
-
- // We clone the value here so we keep the internal state not potentially
changed
- publicNavigationalState.put(parameterId, parameterValue.clone());
}
}
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
//
return publicNavigationalState;
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java 2008-02-05
17:17:28 UTC (rev 9780)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java 2008-02-05
17:52:29 UTC (rev 9781)
@@ -24,6 +24,7 @@
import org.jboss.portal.portlet.controller.state.StateControllerContext;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.PortletControllerContext;
import java.io.IOException;
import java.io.ByteArrayOutputStream;
@@ -40,6 +41,14 @@
public class StateControllerContextImpl implements StateControllerContext
{
+ /** . */
+ protected final PortletControllerContext portletControllerContext;
+
+ public StateControllerContextImpl(PortletControllerContext portletControllerContext)
+ {
+ this.portletControllerContext = portletControllerContext;
+ }
+
public PageNavigationalState clonePageState(PageNavigationalState pageState)
{
return new MutablePageNavigationalState((PageNavigationalStateImpl)pageState);
@@ -47,10 +56,10 @@
public PageNavigationalState createPageState()
{
- return new MutablePageNavigationalState();
+ return new MutablePageNavigationalState(this);
}
- public static byte[] serialize(PageNavigationalState object) throws IOException
+ public byte[] serialize(PageNavigationalState object) throws IOException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream zos = new GZIPOutputStream(baos);
@@ -60,11 +69,13 @@
return baos.toByteArray();
}
- public static PageNavigationalState unserialize(byte[] bytes) throws IOException,
ClassNotFoundException
+ public PageNavigationalState unserialize(byte[] bytes) throws IOException,
ClassNotFoundException
{
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
GZIPInputStream zis = new GZIPInputStream(bais);
ObjectInputStream ois = new ObjectInputStream(zis);
- return (PageNavigationalState)ois.readObject();
+ PageNavigationalStateImpl state = (PageNavigationalStateImpl)ois.readObject();
+ state.context = this;
+ return state;
}
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java 2008-02-05
17:17:28 UTC (rev 9780)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java 2008-02-05
17:52:29 UTC (rev 9781)
@@ -36,7 +36,7 @@
WindowNavigationalState getWindowNavigationalState(String windowId);
- ParameterMap getPublicNavigationalState(PortletInfo portlet);
+ ParameterMap getPublicNavigationalState(String windowId);
void setWindowNavigationalState(String windowId, WindowNavigationalState windowNS)
throws UnsupportedOperationException;
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java 2008-02-05
17:17:28 UTC (rev 9780)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java 2008-02-05
17:52:29 UTC (rev 9781)
@@ -169,7 +169,7 @@
}
//
- ParameterMap publicNS =
pageState.getPublicNavigationalState(portlet.getInfo());
+ ParameterMap publicNS =
pageState.getPublicNavigationalState(portlet.getContext().getId());
RenderInvocation render = createRenderInvocation(context, properties,
pageState, portlet, windowNS, mode, windowState, portletNS, publicNS);
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java 2008-02-05
17:17:28 UTC (rev 9780)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java 2008-02-05
17:52:29 UTC (rev 9781)
@@ -113,7 +113,7 @@
private final EventControllerContext eventControllerContext;
/** . */
- private final StateControllerContext stateControllerContext;
+ private final StateControllerContextImpl stateControllerContext;
public PortletControllerContextImpl(
HttpServletRequest req,
@@ -123,6 +123,9 @@
{
PortletInvoker invoker =
(PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
+ //
+ StateControllerContextImpl tmp = new StateControllerContextImpl(this);
+
// The nav state provided with the request
PageNavigationalState pageState = null;
@@ -144,7 +147,7 @@
if (context != null)
{
byte[] bytes = Tools.fromHexString(context);
- pageState = StateControllerContextImpl.unserialize(bytes);
+ pageState = tmp.unserialize(bytes);
}
//
@@ -265,7 +268,7 @@
this.servletContext = servletContext;
this.invoker = invoker;
this.eventControllerContext = new EventControllerContextImpl(invoker);
- this.stateControllerContext = new StateControllerContextImpl();
+ this.stateControllerContext = tmp;
}
public ControllerRequest getRequest()
@@ -320,7 +323,7 @@
public String renderURL(String windowId, PageNavigationalState pageState, ContainerURL
containerURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
{
- PortletURLRenderer renderer = new PortletURLRenderer(pageState, windowId, req,
resp);
+ PortletURLRenderer renderer = new PortletURLRenderer(stateControllerContext,
pageState, windowId, req, resp);
//
return renderer.renderURL(containerURL, wantSecure, wantAuthenticated, relative);
@@ -385,6 +388,6 @@
public PortletInvocationContext createPortletInvocationContext(String windowId,
PageNavigationalState pageState)
{
- return new TestPortletInvocationContext(req, resp, windowId, pageState,
MARKUP_INFO);
+ return new TestPortletInvocationContext(stateControllerContext, req, resp,
windowId, pageState, MARKUP_INFO);
}
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-05
17:17:28 UTC (rev 9780)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-05
17:52:29 UTC (rev 9781)
@@ -52,6 +52,9 @@
{
/** . */
+ final StateControllerContextImpl stateContext;
+
+ /** . */
final String windowId;
/** . */
@@ -64,11 +67,13 @@
final PageNavigationalState pageNS;
public PortletURLRenderer(
+ StateControllerContextImpl stateContext,
PageNavigationalState pageNS,
String windowId,
HttpServletRequest clientReq,
HttpServletResponse clientResp)
{
+ this.stateContext = stateContext;
this.pageNS = pageNS;
this.windowId = windowId;
this.clientReq = clientReq;
@@ -114,7 +119,7 @@
String pageState;
try
{
- byte[] bytes = StateControllerContextImpl.serialize(pageNS);
+ byte[] bytes = stateContext.serialize(pageNS);
pageState = Tools.toHexString(bytes);
}
catch (IOException e)
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java 2008-02-05
17:17:28 UTC (rev 9780)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java 2008-02-05
17:52:29 UTC (rev 9781)
@@ -24,6 +24,7 @@
import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
import org.jboss.portal.portlet.test.controller.PortletURLRenderer;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.impl.spi.AbstractPortletInvocationContext;
@@ -42,6 +43,9 @@
{
/** . */
+ private final StateControllerContextImpl stateContext;
+
+ /** . */
private final PortletURLRenderer urlRenderer;
/** . */
@@ -57,6 +61,7 @@
private final HttpServletResponse clientResponse;
public TestPortletInvocationContext(
+ StateControllerContextImpl stateContext,
HttpServletRequest clientRequest,
HttpServletResponse clientResponse,
String windowId,
@@ -66,11 +71,12 @@
super(markupInfo);
//
+ this.stateContext = stateContext;
this.clientRequest = clientRequest;
this.clientResponse = clientResponse;
this.windowId = windowId;
this.pageState = pageState;
- this.urlRenderer = new PortletURLRenderer(pageState, windowId, clientRequest,
clientResponse);
+ this.urlRenderer = new PortletURLRenderer(stateContext, pageState, windowId,
clientRequest, clientResponse);
//
addResolver(PortletInvocation.PRINCIPAL_SCOPE, new
PrincipalAttributeResolver(clientRequest));