Author: julien(a)jboss.com
Date: 2008-02-25 21:47:19 -0500 (Mon, 25 Feb 2008)
New Revision: 10116
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractRendererContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RendererContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RendererContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalStateSerialization.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKRendererContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKStateControllerContext.java
Removed:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageRenderer.java
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterMapFactory.java
modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerContextSupport.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractMarkupRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ErrorResponseRenderer.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/RedirectResponseRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/Renderer.java
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/jsp/ControllerFilter.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKServlet.java
modules/portlet/trunk/test/src/test/build.xml
Log:
improve TCK stuff
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.portlet.controller.impl.request;
-import org.jboss.portal.portlet.controller.state.StateControllerContext;
-import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.portlet.controller.request.ControllerRequest;
@@ -55,15 +53,11 @@
{
/** . */
- private final StateControllerContext stateControllerContext;
+ private final Serialization<PageNavigationalState> serialization;
- /** . */
- private final PageNavigationalStateSerialization serialization;
-
- public ControllerRequestFactory(StateControllerContext stateControllerContext)
+ public ControllerRequestFactory(Serialization<PageNavigationalState>
serialization)
{
- this.stateControllerContext = stateControllerContext;
- this.serialization = new
PageNavigationalStateSerialization(stateControllerContext);
+ this.serialization = serialization;
}
public ControllerRequest createRequest(WebRequest req)
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterMapFactory.java
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterMapFactory.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterMapFactory.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.portlet.controller.impl.request;
-import org.jboss.portal.portlet.controller.state.StateControllerContext;
-import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.ActionURL;
@@ -48,15 +46,11 @@
{
/** . */
- private final StateControllerContext stateControllerContext;
+ private final Serialization<PageNavigationalState> serialization;
- /** . */
- private final PageNavigationalStateSerialization serialization;
-
- public ControllerRequestParameterMapFactory(StateControllerContext
stateControllerContext)
+ public ControllerRequestParameterMapFactory(Serialization<PageNavigationalState>
serialization)
{
- this.stateControllerContext = stateControllerContext;
- this.serialization = new
PageNavigationalStateSerialization(stateControllerContext);
+ this.serialization = serialization;
}
public Map<String, String> blah(PageNavigationalState pageNS, String windowId,
ContainerURL containerURL)
Modified:
modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerContextSupport.java
===================================================================
---
modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerContextSupport.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerContextSupport.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -33,16 +33,12 @@
import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.support.info.PortletInfoSupport;
import org.jboss.portal.portlet.support.PortletInvokerSupport;
import org.jboss.portal.portlet.support.PortletSupport;
import javax.servlet.http.Cookie;
import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -31,6 +31,8 @@
import org.jboss.portal.portlet.test.controller.PageRenderer;
import org.jboss.portal.portlet.test.controller.PortletControllerContextImpl;
import org.jboss.portal.portlet.test.controller.Renderer;
+import org.jboss.portal.portlet.test.controller.AbstractRendererContext;
+import org.jboss.portal.portlet.test.controller.RendererContextImpl;
import org.jboss.portal.web.WebRequest;
import javax.servlet.ServletException;
@@ -83,7 +85,7 @@
if (URLParameterConstants.PORTLET_TYPE.equals(type))
{
WebRequest wr = new WebRequest(req);
- ControllerRequestFactory factory = new
ControllerRequestFactory(context.getStateControllerContext());
+ ControllerRequestFactory factory = new
ControllerRequestFactory(context.getPageNavigationalStateSerialization());
ControllerRequest request = factory.createRequest(wr);
//
@@ -93,7 +95,7 @@
Renderer renderer = ControllerResponseRendererFactory.getRenderer(response);
//
- renderer.render(context);
+ renderer.render(new RendererContextImpl(context));
}
else
{
@@ -101,7 +103,7 @@
PageRenderer renderer = new PageRenderer(new ResponseProperties(),
context.getStateControllerContext().createPageState(false));
//
- renderer.render(context);
+ renderer.render(new RendererContextImpl(context));
}
}
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractMarkupRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractMarkupRenderer.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractMarkupRenderer.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -47,7 +47,7 @@
this.properties = properties;
}
- public void render(PortletControllerContextImpl context) throws IOException
+ public void render(RendererContext context) throws IOException
{
prepareRendering(context);
HttpServletResponse resp = context.getClientResponse();
@@ -85,7 +85,7 @@
}
}
- protected void prepareRendering(PortletControllerContextImpl context)
+ protected void prepareRendering(RendererContext context)
{
// default behavior does nothing
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -25,10 +25,12 @@
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.util.MediaType;
+import org.jboss.portal.common.io.Serialization;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.controller.PortletControllerContext;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
@@ -113,6 +115,8 @@
protected abstract PortletInvocationResponse invoke(PortletInvocation invocation)
throws PortletInvokerException;
+ protected abstract Serialization<PageNavigationalState>
getPageNavigationalStateSerialization();
+
public PortletInvocationResponse invoke(ActionInvocation actionInvocation) throws
PortletInvokerException
{
@@ -182,6 +186,6 @@
public PortletInvocationContext createPortletInvocationContext(String windowId,
PageNavigationalState pageState)
{
- return new TestPortletInvocationContext(getStateControllerContext(), req, resp,
windowId, pageState, MARKUP_INFO);
+ return new TestPortletInvocationContext(getPageNavigationalStateSerialization(),
req, resp, windowId, pageState, MARKUP_INFO);
}
}
\ No newline at end of file
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractRendererContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractRendererContext.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractRendererContext.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * 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.portlet.test.controller;
+
+import org.jboss.portal.portlet.controller.PortletControllerContext;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.PortletInvokerException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class AbstractRendererContext implements RendererContext
+{
+
+ /** . */
+ private final AbstractPortletControllerContext portletControllerContext;
+
+ public AbstractRendererContext(AbstractPortletControllerContext
portletControllerContext)
+ {
+ this.portletControllerContext = portletControllerContext;
+ }
+
+ public HttpServletRequest getClientRequest()
+ {
+ return portletControllerContext.getClientRequest();
+ }
+
+ public HttpServletResponse getClientResponse()
+ {
+ return portletControllerContext.getClientResponse();
+ }
+
+ public PortletControllerContext getPortletControllerContext()
+ {
+ return portletControllerContext;
+ }
+
+ public PortletInvocationResponse render(RenderInvocation render) throws
PortletInvokerException
+ {
+ return portletControllerContext.invoke(render);
+ }
+}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ErrorResponseRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ErrorResponseRenderer.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ErrorResponseRenderer.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -46,7 +46,7 @@
this.response = response;
}
- public void render(PortletControllerContextImpl context) throws IOException
+ public void render(RendererContext context) throws IOException
{
if (response.getCause() != null)
{
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-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -44,7 +44,6 @@
import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
-import org.jboss.portal.portlet.controller.PortletControllerContext;
import org.w3c.dom.Element;
import javax.servlet.http.HttpServletRequest;
@@ -125,7 +124,7 @@
writer.print("</body></html>");
}
- protected void prepareRendering(PortletControllerContextImpl context)
+ protected void prepareRendering(RendererContext context)
{
// What we collect during the different renders
@@ -134,90 +133,88 @@
ResponseProperties renderProperties = new ResponseProperties();
//
- try
- {
- Collection<Portlet> portlets =
((PortletControllerContextImpl)context).getPortlets();
+ Collection<Portlet> portlets = context.getPortlets();
- int capacity = portlets.size();
- fragments = new ArrayList<FragmentResponse>(capacity);
- errors = new ArrayList<ErrorResponse>(capacity);
+ int capacity = portlets.size();
+ fragments = new ArrayList<FragmentResponse>(capacity);
+ errors = new ArrayList<ErrorResponse>(capacity);
- for (Portlet portlet : portlets)
- {
- WindowNavigationalState windowNS =
pageState.getWindowNavigationalState(portlet.getContext().getId());
+ for (Portlet portlet : portlets)
+ {
+ WindowNavigationalState windowNS =
pageState.getWindowNavigationalState(portlet.getContext().getId());
- //
- Mode mode = Mode.VIEW;
- WindowState windowState = WindowState.NORMAL;
- StateString portletNS = null;
+ //
+ Mode mode = Mode.VIEW;
+ WindowState windowState = WindowState.NORMAL;
+ StateString portletNS = null;
- //
- if (windowNS != null)
+ //
+ if (windowNS != null)
+ {
+ if (windowNS.getMode() != null)
{
- if (windowNS.getMode() != null)
- {
- mode = windowNS.getMode();
- }
- if (windowNS.getWindowState() != null)
- {
- windowState = windowNS.getWindowState();
- }
- if (windowNS.getPortletNavigationalState() != null)
- {
- portletNS = windowNS.getPortletNavigationalState();
- }
+ mode = windowNS.getMode();
}
+ if (windowNS.getWindowState() != null)
+ {
+ windowState = windowNS.getWindowState();
+ }
+ if (windowNS.getPortletNavigationalState() != null)
+ {
+ portletNS = windowNS.getPortletNavigationalState();
+ }
+ }
- //
- ParameterMap publicNS =
pageState.getPublicNavigationalState(portlet.getContext().getId());
+ //
+ ParameterMap publicNS =
pageState.getPublicNavigationalState(portlet.getContext().getId());
- RenderInvocation render = createRenderInvocation(context, properties,
pageState, portlet, windowNS, mode, windowState, portletNS, publicNS);
+ RenderInvocation render = createRenderInvocation(context, properties, pageState,
portlet, windowNS, mode, windowState, portletNS, publicNS);
- //
- try
+ //
+ try
+ {
+ PortletInvocationResponse response = context.render(render);
+
+ if (response instanceof FragmentResponse)
{
- PortletInvocationResponse response =
((PortletControllerContextImpl)context).invoke(render);
+ FragmentResponse fragment = (FragmentResponse)response;
- if (response instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)response;
+ //
+ fragments.add(fragment);
- //
- fragments.add(fragment);
-
- //
- ResponseProperties fragmentProperties = fragment.getProperties();
- if (fragmentProperties != null)
- {
- renderProperties.append(fragmentProperties);
- }
- }
- else if (response instanceof ErrorResponse)
+ //
+ ResponseProperties fragmentProperties = fragment.getProperties();
+ if (fragmentProperties != null)
{
- ErrorResponse error = (ErrorResponse)response;
- errors.add(error);
+ renderProperties.append(fragmentProperties);
}
-
}
- catch (PortletInvokerException e)
+ else if (response instanceof ErrorResponse)
{
- e.printStackTrace();
+ ErrorResponse error = (ErrorResponse)response;
+ errors.add(error);
}
}
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
}
- catch (PortletInvokerException e)
- {
- // todo
- e.printStackTrace();
- }
// Now we combine the render properties with the page properties
properties.append(renderProperties);
}
protected RenderInvocation createRenderInvocation(
- PortletControllerContextImpl context, ResponseProperties pageProperties,
PageNavigationalState pageNS, Portlet portlet,
- WindowNavigationalState windowNS, Mode mode, WindowState windowState, StateString
portletNS, ParameterMap publicNS)
+ RendererContext context,
+ ResponseProperties pageProperties,
+ PageNavigationalState pageNS,
+ Portlet portlet,
+ WindowNavigationalState windowNS,
+ Mode mode,
+ WindowState windowState,
+ StateString portletNS,
+ ParameterMap publicNS)
{
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
@@ -225,7 +222,7 @@
//
TestInstanceContext instanceContext = new TestInstanceContext(req,
portlet.getContext(), false);
- PortletInvocationContext renderContext =
context.createPortletInvocationContext(portlet.getContext().getId(), pageNS);
+ PortletInvocationContext renderContext =
context.getPortletControllerContext().createPortletInvocationContext(portlet.getContext().getId(),
pageNS);
//
RenderInvocation render = new RenderInvocation(renderContext);
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-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -31,9 +31,12 @@
import org.jboss.portal.portlet.controller.impl.event.EventControllerContextImpl;
import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
import org.jboss.portal.portlet.controller.state.StateControllerContext;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.web.IllegalRequestException;
+import org.jboss.portal.common.io.Serialization;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -57,6 +60,9 @@
/** . */
private final StateControllerContext stateControllerContext;
+ /** . */
+ private final Serialization<PageNavigationalState> serialization;
+
public PortletControllerContextImpl(HttpServletRequest req, HttpServletResponse resp,
ServletContext servletContext)
throws IllegalRequestException, IOException, ClassNotFoundException
{
@@ -66,6 +72,7 @@
this.invoker =
(PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
this.eventControllerContext = new EventControllerContextImpl(invoker);
this.stateControllerContext = new StateControllerContextImpl(this);
+ this.serialization = new
PageNavigationalStateSerialization(stateControllerContext);
}
protected Portlet getPortlet(String windowId) throws PortletInvokerException
@@ -93,4 +100,8 @@
return invoker.getPortlets();
}
+ public Serialization<PageNavigationalState>
getPageNavigationalStateSerialization()
+ {
+ return serialization;
+ }
}
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-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -25,14 +25,13 @@
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.common.io.SerializationFilter;
+import org.jboss.portal.common.io.Serialization;
import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.Base64;
import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.URLFormat;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
-import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
-import org.jboss.portal.portlet.controller.state.StateControllerContext;
import org.jboss.portal.portlet.controller.impl.request.ControllerRequestParameterNames;
import
org.jboss.portal.portlet.controller.impl.request.ControllerRequestParameterMapFactory;
import static org.jboss.portal.portlet.test.URLParameterConstants.*;
@@ -50,12 +49,9 @@
{
/** . */
- final StateControllerContext stateContext;
+ final Serialization<PageNavigationalState> serialization;
/** . */
- final PageNavigationalStateSerialization serialization;
-
- /** . */
final HttpServletRequest clientReq;
/** . */
@@ -65,16 +61,15 @@
final PageNavigationalState pageNS;
public PortletURLRenderer(
- StateControllerContext stateContext,
PageNavigationalState pageNS,
HttpServletRequest clientReq,
- HttpServletResponse clientResp)
+ HttpServletResponse clientResp,
+ Serialization<PageNavigationalState> serialization)
{
- this.stateContext = stateContext;
this.pageNS = pageNS;
this.clientReq = clientReq;
this.clientResp = clientResp;
- this.serialization = new PageNavigationalStateSerialization(stateContext);
+ this.serialization = serialization;
}
private String renderURL(Map<String, String> parameters, URLFormat format)
@@ -141,7 +136,7 @@
public String renderURL(String windowId, ContainerURL containerURL, URLFormat format)
{
- ControllerRequestParameterMapFactory factory = new
ControllerRequestParameterMapFactory(stateContext);
+ ControllerRequestParameterMapFactory factory = new
ControllerRequestParameterMapFactory(serialization);
//
Map<String, String> parameters = factory.blah(pageNS, windowId,
containerURL);
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RedirectResponseRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RedirectResponseRenderer.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RedirectResponseRenderer.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -42,7 +42,7 @@
this.response = response;
}
- public void render(PortletControllerContextImpl context) throws IOException
+ public void render(RendererContext context) throws IOException
{
context.getClientResponse().sendRedirect(response.getLocation());
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/Renderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/Renderer.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/Renderer.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -33,5 +33,5 @@
*/
public interface Renderer
{
- void render(PortletControllerContextImpl context) throws IOException;
+ void render(RendererContext context) throws IOException;
}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RendererContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RendererContext.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RendererContext.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * 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.portlet.test.controller;
+
+import org.jboss.portal.portlet.controller.PortletControllerContext;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface RendererContext
+{
+
+ HttpServletRequest getClientRequest();
+
+ HttpServletResponse getClientResponse();
+
+ PortletControllerContext getPortletControllerContext();
+
+ Collection<Portlet> getPortlets();
+
+ PortletInvocationResponse render(RenderInvocation render) throws
PortletInvokerException;
+
+}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RendererContextImpl.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RendererContextImpl.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RendererContextImpl.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * 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.portlet.test.controller;
+
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class RendererContextImpl extends AbstractRendererContext
+{
+
+ /** . */
+ private final Collection<Portlet> portlets;
+
+ public RendererContextImpl(PortletControllerContextImpl portletControllerContext)
throws PortletInvokerException
+ {
+ super(portletControllerContext);
+
+ //
+ this.portlets = portletControllerContext.getPortlets();
+ }
+
+ public Collection<Portlet> getPortlets()
+ {
+ return portlets;
+ }
+}
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-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -26,10 +26,10 @@
import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.io.Serialization;
import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.URLFormat;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
-import org.jboss.portal.portlet.controller.state.StateControllerContext;
import org.jboss.portal.portlet.impl.spi.AbstractPortletInvocationContext;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -44,25 +44,19 @@
{
/** . */
- private final StateControllerContext stateContext;
-
- /** . */
private final PortletURLRenderer urlRenderer;
/** . */
private final String windowId;
/** . */
- private final PageNavigationalState pageState;
-
- /** . */
private final HttpServletRequest clientRequest;
/** . */
private final HttpServletResponse clientResponse;
public TestPortletInvocationContext(
- StateControllerContext stateContext,
+ Serialization<PageNavigationalState> serialization,
HttpServletRequest clientRequest,
HttpServletResponse clientResponse,
String windowId,
@@ -72,12 +66,10 @@
super(markupInfo);
//
- this.stateContext = stateContext;
this.clientRequest = clientRequest;
this.clientResponse = clientResponse;
this.windowId = windowId;
- this.pageState = pageState;
- this.urlRenderer = new PortletURLRenderer(stateContext, pageState, clientRequest,
clientResponse);
+ this.urlRenderer = new PortletURLRenderer(pageState, clientRequest, clientResponse,
serialization);
//
addResolver(PortletInvocation.PRINCIPAL_SCOPE, new
PrincipalAttributeResolver(clientRequest));
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -35,7 +35,6 @@
import org.jboss.portal.portlet.controller.impl.request.ControllerRequestFactory;
import org.jboss.portal.portlet.controller.request.ControllerRequest;
import org.jboss.portal.portlet.controller.impl.request.ControllerRequestParameterNames;
-import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
import org.jboss.portal.portlet.controller.response.ControllerResponse;
import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
import org.jboss.portal.portlet.controller.response.ResourceResponse;
@@ -114,7 +113,7 @@
if (URLParameterConstants.PORTLET_TYPE.equals(type))
{
WebRequest wr = new WebRequest(req);
- ControllerRequestFactory factory = new
ControllerRequestFactory(context.getStateControllerContext());
+ ControllerRequestFactory factory = new
ControllerRequestFactory(context.getPageNavigationalStateSerialization());
ControllerRequest request = factory.createRequest(wr);
ControllerResponse controllerResponse;
@@ -137,10 +136,10 @@
{
//
PortletURLRenderer renderer = new PortletURLRenderer(
- (StateControllerContextImpl)context.getStateControllerContext(),
pageUpdate.getPageState(),
context.getClientRequest(),
- context.getClientResponse());
+ context.getClientResponse(),
+ context.getPageNavigationalStateSerialization());
//
String url = renderer.renderURL(new URLFormat(null, null, true, null));
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -28,11 +28,14 @@
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.controller.event.EventControllerContext;
import org.jboss.portal.portlet.controller.state.StateControllerContext;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.test.controller.AbstractPortletControllerContext;
import org.jboss.portal.web.IllegalRequestException;
+import org.jboss.portal.common.io.Serialization;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -56,6 +59,9 @@
private final StateControllerContext stateControllerContext;
/** . */
+ private final Serialization<PageNavigationalState> serialization;
+
+ /** . */
private final PortalPrepareResponse prepareResponse;
/** . */
@@ -91,6 +97,7 @@
this.prepareResponse = prepareResponse;
this.stateControllerContext = new StateControllerContextImpl(this);
this.eventControllerContext = new PageEventControllerContext(this,
prepareResponse);
+ this.serialization = new
PageNavigationalStateSerialization(stateControllerContext);
}
public Portlet findPortlet(String applicationName, String portletName)
@@ -121,6 +128,11 @@
return stateControllerContext;
}
+ public Serialization<PageNavigationalState>
getPageNavigationalStateSerialization()
+ {
+ return serialization;
+ }
+
private static class Key
{
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -27,7 +27,6 @@
import org.jboss.portal.portlet.test.jsp.PortalRenderResponse;
import org.jboss.portal.portlet.test.jsp.PagePortletControllerContext;
import org.jboss.portal.portlet.test.controller.PortletURLRenderer;
-import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.URLFormat;
@@ -95,10 +94,10 @@
}
PortletURLRenderer renderer = new PortletURLRenderer(
- context.getStateControllerContext(),
renderResponse.getPageState(),
context.getClientRequest(),
- context.getClientResponse());
+ context.getClientResponse(),
+ context.getPageNavigationalStateSerialization());
final WindowState ws = windowState;
final Mode md = mode;
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalState.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalState.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalState.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -24,39 +24,79 @@
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
-import org.jboss.portal.portlet.controller.impl.state.PageNavigationalStateImpl;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.info.ParameterInfo;
-import org.jboss.portal.portlet.info.NavigationInfo;
-import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.common.util.ParameterMap;
import javax.xml.namespace.QName;
-import java.io.Serializable;
import java.util.Map;
+import java.util.Set;
import java.util.HashMap;
-import java.util.Set;
-import java.util.List;
-import java.util.Collection;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
* @version : 0.1 $
*/
-public class TCKPageNavigationalState extends PageNavigationalStateImpl
+public class TCKPageNavigationalState implements PageNavigationalState
{
- Collection<Portlet> involvedPortlets;
+ /** . */
+ final PageNavigationalState defaultState;
- public TCKPageNavigationalState(StateControllerContextImpl context, boolean
modifiable, Collection<Portlet> involvedPortlets)
+ /** . */
+ final Set<String> involvedPortlets;
+
+ public TCKPageNavigationalState(PageNavigationalState defaultState, Set<String>
involvedPortlets)
{
- super(context, modifiable);
+ this.defaultState = defaultState;
this.involvedPortlets = involvedPortlets;
}
- public Collection<Portlet> getInvolvedPortlets()
+ public Set<String> getInvolvedPortlets()
{
return involvedPortlets;
}
+
+ public Set<String> getWindowIds()
+ {
+ return defaultState.getWindowIds();
+ }
+
+ public WindowNavigationalState getWindowNavigationalState(String windowId) throws
IllegalArgumentException
+ {
+ return defaultState.getWindowNavigationalState(windowId);
+ }
+
+ public void setWindowNavigationalState(String windowId, WindowNavigationalState
windowState) throws IllegalArgumentException, IllegalStateException
+ {
+ defaultState.setWindowNavigationalState(windowId, windowState);
+ }
+
+ public ParameterMap getPublicNavigationalState(String windowId) throws
IllegalArgumentException
+ {
+ return defaultState.getPublicNavigationalState(windowId);
+ }
+
+ public Set<QName> getPublicNames()
+ {
+ return defaultState.getPublicNames();
+ }
+
+ public void setPublicNavigationalState(String windowId, Map<String, String[]>
update) throws IllegalArgumentException, IllegalStateException
+ {
+ defaultState.setPublicNavigationalState(windowId, update);
+ }
+
+ public String[] getPublicNavigationalState(QName name) throws
IllegalArgumentException
+ {
+ return defaultState.getPublicNavigationalState(name);
+ }
+
+ public void setPublicNavigationalState(QName name, String[] value) throws
IllegalArgumentException, IllegalStateException
+ {
+ defaultState.setPublicNavigationalState(name, value);
+ }
+
+ public void removePublicNavigationalState(QName name) throws IllegalArgumentException,
IllegalStateException
+ {
+ defaultState.removePublicNavigationalState(name);
+ }
}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalStateSerialization.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalStateSerialization.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalStateSerialization.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -0,0 +1,93 @@
+/******************************************************************************
+ * 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.portlet.test.tck;
+
+import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.common.io.Serialization;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.DataOutputStream;
+import java.io.DataInputStream;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class TCKPageNavigationalStateSerialization implements
Serialization<PageNavigationalState>
+{
+
+ /** . */
+ private final PageNavigationalStateSerialization defaultSerialization;
+
+ public TCKPageNavigationalStateSerialization(TCKStateControllerContext context)
+ {
+ this.defaultSerialization = new
PageNavigationalStateSerialization(context.defaultStateControllerContext);
+ }
+
+ public void serialize(PageNavigationalState pageNavigationalState, OutputStream out)
throws IOException, IllegalArgumentException
+ {
+ TCKPageNavigationalState tckPageNavigationalState =
(TCKPageNavigationalState)pageNavigationalState;
+
+ //
+ DataOutputStream data = out instanceof DataOutputStream ? (DataOutputStream)out :
new DataOutputStream(out);
+
+ //
+ defaultSerialization.serialize(tckPageNavigationalState.defaultState, out);
+
+ //
+ data.writeInt(tckPageNavigationalState.involvedPortlets.size());
+ for (String involvedPortlet : tckPageNavigationalState.involvedPortlets)
+ {
+ data.writeUTF(involvedPortlet);
+ }
+
+ // Need a flush
+ data.flush();
+ }
+
+ public PageNavigationalState unserialize(InputStream in) throws IOException,
IllegalArgumentException
+ {
+ //
+ DataInputStream data = in instanceof DataInputStream ? (DataInputStream)in : new
DataInputStream(in);
+
+ //
+ PageNavigationalState defaultState = defaultSerialization.unserialize(in);
+
+ //
+ int size = data.readInt();
+ Set<String> involvedPortlets = new HashSet<String>(size);
+ while (size-- > 0)
+ {
+ String involvedPortlet = data.readUTF();
+ involvedPortlets.add(involvedPortlet);
+ }
+
+ //
+ return new TCKPageNavigationalState(defaultState, involvedPortlets);
+ }
+}
Deleted:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageRenderer.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageRenderer.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -1,146 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-
-package org.jboss.portal.portlet.test.tck;
-
-import org.jboss.portal.portlet.test.controller.PageRenderer;
-import org.jboss.portal.portlet.test.controller.PortletControllerContextImpl;
-import org.jboss.portal.portlet.invocation.response.ResponseProperties;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.controller.state.PageNavigationalState;
-import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.ParameterMap;
-
-import java.util.Collection;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
- * @version : 0.1 $
- */
-public class TCKPageRenderer extends PageRenderer
-{
- TCKPageNavigationalState tckPageState;
-
- public TCKPageRenderer(ResponseProperties properties, TCKPageNavigationalState
pageState)
- {
- super(properties, pageState);
- tckPageState = pageState;
- }
-
- protected void prepareRendering(PortletControllerContextImpl context)
- {
- // What we collect during the different renders
- // we don't reuse the render properties argument since we want to avoid that
- // a portlet rendition affects another rendition of a portlet on the same page
- ResponseProperties renderProperties = new ResponseProperties();
-
- //
- try
- {
- Collection<Portlet> portlets = tckPageState.getInvolvedPortlets();
-
- int capacity = portlets.size();
- fragments = new ArrayList<FragmentResponse>(capacity);
- errors = new ArrayList<ErrorResponse>(capacity);
-
- for (Portlet portlet : portlets)
- {
- WindowNavigationalState windowNS =
pageState.getWindowNavigationalState(portlet.getContext().getId());
-
- //
- Mode mode = Mode.VIEW;
- WindowState windowState = WindowState.NORMAL;
- StateString portletNS = null;
-
- //
- if (windowNS != null)
- {
- if (windowNS.getMode() != null)
- {
- mode = windowNS.getMode();
- }
- if (windowNS.getWindowState() != null)
- {
- windowState = windowNS.getWindowState();
- }
- if (windowNS.getPortletNavigationalState() != null)
- {
- portletNS = windowNS.getPortletNavigationalState();
- }
- }
-
- //
- ParameterMap publicNS =
pageState.getPublicNavigationalState(portlet.getContext().getId());
-
- RenderInvocation render = createRenderInvocation(context, properties,
pageState, portlet, windowNS, mode, windowState, portletNS, publicNS);
-
- //
- try
- {
- PortletInvocationResponse response = context.invoke(render);
-
- if (response instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)response;
-
- //
- fragments.add(fragment);
-
- //
- ResponseProperties fragmentProperties = fragment.getProperties();
- if (fragmentProperties != null)
- {
- renderProperties.append(fragmentProperties);
- }
- }
- else if (response instanceof ErrorResponse)
- {
- ErrorResponse error = (ErrorResponse)response;
- errors.add(error);
- }
-
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
- }
- }
- catch (Exception e)
- {
- // todo
- e.printStackTrace();
- }
-
- // Now we combine the render properties with the page properties
- properties.append(renderProperties);
- }
-}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPortletControllerContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPortletControllerContext.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPortletControllerContext.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -0,0 +1,109 @@
+/******************************************************************************
+ * 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.portlet.test.tck;
+
+import org.jboss.portal.portlet.test.controller.AbstractPortletControllerContext;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.controller.event.EventControllerContext;
+import org.jboss.portal.portlet.controller.state.StateControllerContext;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
+import org.jboss.portal.portlet.controller.impl.event.EventControllerContextImpl;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.web.IllegalRequestException;
+import org.jboss.portal.common.io.Serialization;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class TCKPortletControllerContext extends AbstractPortletControllerContext
+{
+
+ /** . */
+ private final PortletInvoker invoker;
+
+ /** . */
+ private final TCKStateControllerContext stateControllerContext;
+
+ /** . */
+ private final EventControllerContext eventControllerContext;
+
+ /** . */
+ private final Serialization<PageNavigationalState> serialization;
+
+ public TCKPortletControllerContext(
+ HttpServletRequest req,
+ HttpServletResponse resp,
+ ServletContext servletContext) throws IllegalRequestException, IOException
+ {
+ super(req, resp);
+
+ //
+ this.invoker =
(PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
+ this.stateControllerContext = new TCKStateControllerContext(new
StateControllerContextImpl(this));
+ this.eventControllerContext = new EventControllerContextImpl(invoker);
+ this.serialization = new
TCKPageNavigationalStateSerialization(stateControllerContext);
+ }
+
+ public Set<Portlet> getPortlets() throws PortletInvokerException
+ {
+ return invoker.getPortlets();
+ }
+
+ protected Portlet getPortlet(String windowId) throws PortletInvokerException
+ {
+ return invoker.getPortlet(PortletContext.createPortletContext(windowId));
+ }
+
+ protected PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
+ {
+ return invoker.invoke(invocation);
+ }
+
+ protected Serialization<PageNavigationalState>
getPageNavigationalStateSerialization()
+ {
+ return serialization;
+ }
+
+ public EventControllerContext getEventControllerContext()
+ {
+ return eventControllerContext;
+ }
+
+ public StateControllerContext getStateControllerContext()
+ {
+ return stateControllerContext;
+ }
+}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKRendererContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKRendererContext.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKRendererContext.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * 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.portlet.test.tck;
+
+import org.jboss.portal.portlet.test.controller.AbstractRendererContext;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+
+import java.util.Collection;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class TCKRendererContext extends AbstractRendererContext
+{
+
+ /** . */
+ private final Collection<Portlet> involvedPortlets;
+
+ public TCKRendererContext(
+ TCKPortletControllerContext portletControllerContext,
+ TCKPageNavigationalState pageState) throws PortletInvokerException
+ {
+ super(portletControllerContext);
+
+ //
+ Collection<Portlet> involvedPortlets = new ArrayList<Portlet>();
+ for (String involvedPortletId : pageState.getInvolvedPortlets())
+ {
+ Portlet involvedPortlet =
portletControllerContext.getPortlet(involvedPortletId);
+ involvedPortlets.add(involvedPortlet);
+ }
+
+ //
+ this.involvedPortlets = involvedPortlets;
+ }
+
+ public Collection<Portlet> getPortlets()
+ {
+ return involvedPortlets;
+ }
+}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKServlet.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKServlet.java 2008-02-26
00:52:13 UTC (rev 10115)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKServlet.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -22,16 +22,15 @@
package org.jboss.portal.portlet.test.tck;
-import org.jboss.portal.portlet.test.controller.PortletControllerContextImpl;
import org.jboss.portal.portlet.test.controller.Renderer;
import org.jboss.portal.portlet.test.controller.ControllerResponseRendererFactory;
import org.jboss.portal.portlet.test.controller.PageRenderer;
+import org.jboss.portal.portlet.test.controller.AbstractRendererContext;
import org.jboss.portal.portlet.test.URLParameterConstants;
import org.jboss.portal.portlet.controller.PortletController;
import org.jboss.portal.portlet.controller.response.ControllerResponse;
import org.jboss.portal.portlet.controller.request.ControllerRequest;
import org.jboss.portal.portlet.controller.impl.request.ControllerRequestFactory;
-import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.web.WebRequest;
@@ -43,9 +42,7 @@
import java.io.IOException;
import java.util.Collection;
import java.util.Set;
-import java.util.HashSet;
-import java.util.List;
-import java.util.LinkedList;
+import java.util.LinkedHashSet;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
@@ -82,20 +79,24 @@
protected void _service(HttpServletRequest req, HttpServletResponse resp) throws
Exception
{
- PortletControllerContextImpl context = new PortletControllerContextImpl(req, resp,
getServletContext());
+ TCKPortletControllerContext context = new TCKPortletControllerContext(req, resp,
getServletContext());
//
PortletController controller = new PortletController();
+ //
String type = req.getParameter(URLParameterConstants.TYPE);
//
if (URLParameterConstants.PORTLET_TYPE.equals(type))
{
WebRequest wr = new WebRequest(req);
- ControllerRequestFactory factory = new
ControllerRequestFactory(context.getStateControllerContext());
+ ControllerRequestFactory factory = new
ControllerRequestFactory(context.getPageNavigationalStateSerialization());
ControllerRequest request = factory.createRequest(wr);
+ // We must have one!!!
+ TCKPageNavigationalState tckPageState =
(TCKPageNavigationalState)request.getPageState();
+
//
ControllerResponse response = controller.process(context, request);
@@ -103,32 +104,26 @@
Renderer renderer = ControllerResponseRendererFactory.getRenderer(response);
//
- renderer.render(context);
+ renderer.render(new TCKRendererContext(context, tckPageState));
}
else
{
-
String[] tckParamers = req.getParameterValues(TCK_PORTLET_NAME);
-
Collection<Portlet> portlets = context.getPortlets();
-
- List<Portlet> involvedPortlets = new LinkedList<Portlet>();
-
- for (int i = 0; i < tckParamers.length; i++)
+ Set<String> involvedPortlets = new LinkedHashSet<String>();
+ for (String tckParamer : tckParamers)
{
- String tckParamer = tckParamers[i];
-
String[] parts = tckParamer.split("/");
-
String portletAppName = parts[0];
String portletName = parts[1];
+ //
for (Portlet portlet : portlets)
{
if (portlet.getInfo().getApplicationName().equals(portletAppName)
- && portlet.getInfo().getName().equals(portletName))
+ && portlet.getInfo().getName().equals(portletName))
{
- involvedPortlets.add(portlet);
+ involvedPortlets.add(portlet.getContext().getId());
}
}
}
@@ -138,12 +133,13 @@
throw new IllegalStateException("Portlets requested by TCK were not
found");
}
- TCKPageNavigationalState tckPageState = new
TCKPageNavigationalState((StateControllerContextImpl)context.getStateControllerContext(),
false, involvedPortlets);
+ TCKPageNavigationalState tckPageState = new
TCKPageNavigationalState(context.getStateControllerContext().createPageState(false),
involvedPortlets);
- PageRenderer renderer = new TCKPageRenderer(new ResponseProperties(),
tckPageState);
+ //
+ PageRenderer renderer = new PageRenderer(new ResponseProperties(),
tckPageState);
//
- renderer.render(context);
+ renderer.render(new TCKRendererContext(context, tckPageState));
}
}
}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKStateControllerContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKStateControllerContext.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKStateControllerContext.java 2008-02-26
02:47:19 UTC (rev 10116)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * 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.portlet.test.tck;
+
+import org.jboss.portal.portlet.controller.state.StateControllerContext;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class TCKStateControllerContext implements StateControllerContext
+{
+
+ final StateControllerContext defaultStateControllerContext;
+
+ public TCKStateControllerContext(StateControllerContext
defaultStateControllerContext)
+ {
+ this.defaultStateControllerContext = defaultStateControllerContext;
+ }
+
+ public PageNavigationalState clonePageState(PageNavigationalState pageState, boolean
modifiable)
+ {
+ TCKPageNavigationalState tckPageState = (TCKPageNavigationalState)pageState;
+
+ //
+ return new TCKPageNavigationalState(
+ defaultStateControllerContext.clonePageState(tckPageState.defaultState,
modifiable),
+ new HashSet<String>(tckPageState.involvedPortlets));
+ }
+
+ public PageNavigationalState createPageState(boolean modifiable)
+ {
+ return new
TCKPageNavigationalState(defaultStateControllerContext.createPageState(modifiable), new
HashSet<String>());
+ }
+}
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-02-26 00:52:13 UTC (rev 10115)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-02-26 02:47:19 UTC (rev 10116)
@@ -754,7 +754,6 @@
<path refid="mc.jboss_xb"/>
<path refid="mc.jboss_aop"/>
<path refid="mc.jboss_microcontainer"/>
- <path refid="mc.jaxb-api"/>
</copy>
@@ -772,7 +771,8 @@
<path location="${dependency.portal-common-portal.jar}"/>
<path location="${dependency.portal-portlet.jar}"/>
<path location="${dependency.portal-web.jar}"/>
- <!--<path location="${dependency.jsr168api.jar}"/>-->
+ <path location="${dependency.jsr168api.jar}"/>
+ <path location="${dependency.jaxb-api.jar}"/>
<path location="${dependency.jboss-unit.jar}"/>
<path location="${dependency.jboss-unit-remote.jar}"/>
@@ -780,13 +780,7 @@
</copy>
- <copy todir="${tck}" flatten="true">
- <path location="${dependency.jsr168api.jar}"/>
-
- </copy>
-
-
<delete file="${target}/portlet-test-lib.jar"/>
</target>