Author: julien(a)jboss.com
Date: 2008-02-29 12:35:48 -0500 (Fri, 29 Feb 2008)
New Revision: 10159
Added:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/AbstractPortletControllerContext.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/PortletURLRenderer.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/TestPortletInvocationContext.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/URLParameterConstants.java
Removed:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.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/PortletURLRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortalContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java
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/controller/AbstractRendererContext.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/RendererContextImpl.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/PortalRenderResponse.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/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/TCKServlet.java
Log:
moved a couple of class to the controller module that will make them easier to reuse
Copied:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/AbstractPortletControllerContext.java
(from rev 10156,
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java)
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/AbstractPortletControllerContext.java
(rev 0)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/AbstractPortletControllerContext.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -0,0 +1,192 @@
+/******************************************************************************
+ * 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.controller.impl;
+
+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.impl.spi.AbstractClientContext;
+import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
+import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
+import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
+import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
+import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
+import org.jboss.portal.portlet.impl.spi.AbstractInstanceContext;
+import org.jboss.portal.portlet.impl.spi.AbstractPortalContext;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.portlet.spi.PortalContext;
+import org.jboss.portal.web.IllegalRequestException;
+import org.apache.log4j.Logger;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractPortletControllerContext implements
PortletControllerContext
+{
+
+ /** . */
+ private static Logger log = Logger.getLogger(AbstractPortletControllerContext.class);
+
+ /** . */
+ public static final PortalContext PORTAL_CONTEXT = new
AbstractPortalContext(Collections.singletonMap("javax.portlet.markup.head.element.support",
"true"));
+
+ /** . */
+ public static final MarkupInfo MARKUP_INFO = new MarkupInfo(MediaType.HTML,
"UTF8");
+
+ /** . */
+ public static final int NAV_SCOPE = 0;
+
+ /** . */
+ public static final int SESSION_SCOPE = 1;
+
+ /** . */
+ private final HttpServletRequest req;
+
+ /** . */
+ private final HttpServletResponse resp;
+
+ public AbstractPortletControllerContext(HttpServletRequest req, HttpServletResponse
resp
+ )
+ throws IllegalRequestException, IOException
+ {
+ this.req = req;
+ this.resp = resp;
+ }
+
+ public HttpServletRequest getClientRequest()
+ {
+ return req;
+ }
+
+ public HttpServletResponse getClientResponse()
+ {
+ return resp;
+ }
+
+ public PortletInfo getPortletInfo(String windowId)
+ {
+ try
+ {
+ return getPortlet(windowId).getInfo();
+ }
+ catch (PortletInvokerException e)
+ {
+ log.error("Could not access portlet invoker for locating window " +
windowId, e);
+
+ //
+ return null;
+ }
+ }
+
+ protected abstract Portlet getPortlet(String windowId) throws
PortletInvokerException;
+
+ protected abstract PortletInvocationResponse invoke(PortletInvocation invocation)
throws PortletInvokerException;
+
+ protected abstract Serialization<PageNavigationalState>
getPageNavigationalStateSerialization();
+
+ public PortletInvocationResponse invoke(ActionInvocation actionInvocation) throws
PortletInvokerException
+ {
+
+ TestPortletInvocationContext context =
(TestPortletInvocationContext)actionInvocation.getContext();
+ String windowId = context.getWindowId();
+
+ Portlet portlet = getPortlet(windowId);
+
+ actionInvocation.setClientContext(new AbstractClientContext(req));
+ actionInvocation.setServerContext(new AbstractServerContext(req, resp));
+ actionInvocation.setInstanceContext(new
AbstractInstanceContext(portlet.getContext().getId()));
+ actionInvocation.setUserContext(new AbstractUserContext(req));
+ actionInvocation.setWindowContext(new AbstractWindowContext(windowId));
+ actionInvocation.setPortalContext(PORTAL_CONTEXT);
+ actionInvocation.setSecurityContext(new AbstractSecurityContext(req));
+ actionInvocation.setRequestContext(new AbstractRequestContext(req));
+ actionInvocation.setTarget(portlet.getContext());
+
+ return invoke((PortletInvocation)actionInvocation);
+ }
+
+ public PortletInvocationResponse invoke(List<Cookie> requestCookies,
EventInvocation eventInvocation) throws PortletInvokerException
+ {
+ TestPortletInvocationContext context =
(TestPortletInvocationContext)eventInvocation.getContext();
+ String windowId = context.getWindowId();
+
+ Portlet portlet = getPortlet(windowId);
+
+ eventInvocation.setClientContext(new AbstractClientContext(req, requestCookies));
+ eventInvocation.setServerContext(new AbstractServerContext(req, resp));
+ eventInvocation.setInstanceContext(new
AbstractInstanceContext(portlet.getContext().getId()));
+ eventInvocation.setUserContext(new AbstractUserContext(req));
+ eventInvocation.setWindowContext(new AbstractWindowContext(windowId));
+ eventInvocation.setPortalContext(PORTAL_CONTEXT);
+ eventInvocation.setSecurityContext(new AbstractSecurityContext(req));
+ eventInvocation.setTarget(portlet.getContext());
+
+ return invoke(eventInvocation);
+ }
+
+ public PortletInvocationResponse invoke(ResourceInvocation resourceInvocation) throws
PortletInvokerException
+ {
+ TestPortletInvocationContext context =
(TestPortletInvocationContext)resourceInvocation.getContext();
+ String windowId = context.getWindowId();
+
+ Portlet portlet = getPortlet(windowId);
+
+ resourceInvocation.setClientContext(new AbstractClientContext(req));
+ resourceInvocation.setServerContext(new AbstractServerContext(req, resp));
+ resourceInvocation.setInstanceContext(new
AbstractInstanceContext(portlet.getContext().getId()));
+ resourceInvocation.setUserContext(new AbstractUserContext(req));
+ resourceInvocation.setWindowContext(new AbstractWindowContext(windowId));
+ resourceInvocation.setPortalContext(PORTAL_CONTEXT);
+ resourceInvocation.setSecurityContext(new AbstractSecurityContext(req));
+ resourceInvocation.setRequestContext(new AbstractRequestContext(req));
+ resourceInvocation.setTarget(portlet.getContext());
+
+ //
+ return invoke((PortletInvocation)resourceInvocation);
+ }
+
+ public PortletInvocationContext createPortletInvocationContext(String windowId,
PageNavigationalState pageNavigationalState)
+ {
+ return new TestPortletInvocationContext(getPageNavigationalStateSerialization(),
req, resp, windowId, pageNavigationalState, MARKUP_INFO);
+ }
+}
\ No newline at end of file
Copied:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/PortletURLRenderer.java
(from rev 10146,
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java)
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/PortletURLRenderer.java
(rev 0)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/PortletURLRenderer.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -0,0 +1,152 @@
+/******************************************************************************
+ * 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.controller.impl;
+
+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.impl.request.ControllerRequestParameterNames;
+import
org.jboss.portal.portlet.controller.impl.request.ControllerRequestParameterMapFactory;
+import static org.jboss.portal.portlet.controller.impl.URLParameterConstants.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+import java.util.Collections;
+
+/**
+ * A class that is able to create portlet URL
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletURLRenderer
+{
+
+ /** . */
+ final Serialization<PageNavigationalState> serialization;
+
+ /** . */
+ final HttpServletRequest clientReq;
+
+ /** . */
+ final HttpServletResponse clientResp;
+
+ /** . */
+ final PageNavigationalState pageNS;
+
+ public PortletURLRenderer(
+ PageNavigationalState pageNS,
+ HttpServletRequest clientReq,
+ HttpServletResponse clientResp,
+ Serialization<PageNavigationalState> serialization)
+ {
+ this.pageNS = pageNS;
+ this.clientReq = clientReq;
+ this.clientResp = clientResp;
+ this.serialization = serialization;
+ }
+
+ private String renderURL(Map<String, String> parameters, URLFormat format)
+ {
+ CharBuffer buffer = new CharBuffer();
+ buffer.append(clientReq.getScheme());
+ buffer.append("://");
+ buffer.append(clientReq.getServerName());
+ buffer.append(':');
+ buffer.append(Integer.toString(clientReq.getServerPort()));
+ buffer.append(clientReq.getContextPath());
+ buffer.append(clientReq.getServletPath());
+
+ //
+ if (clientReq.getPathInfo() != null)
+ {
+ buffer.append(clientReq.getPathInfo());
+ }
+
+ //
+ String parameterSeparator = format.getWantEscapeXML() == Boolean.TRUE ?
"&" : "&";
+
+ //
+ boolean first = true;
+ for (Map.Entry<String, String> entry : parameters.entrySet())
+ {
+ String name = entry.getKey();
+ String value = entry.getValue();
+ buffer.append(first ? "?" : parameterSeparator);
+ buffer.append(name, FastURLEncoder.getUTF8Instance());
+ buffer.append('=');
+ buffer.append(value, FastURLEncoder.getUTF8Instance());
+ first = false;
+ }
+
+ //
+ String url = buffer.asString();
+ return clientResp.encodeURL(url);
+ }
+
+ public String renderURL(URLFormat format)
+ {
+ String pageNavigationalState = null;
+ if (pageNS != null)
+ {
+ byte[] bytes = IOTools.serialize(serialization, SerializationFilter.COMPRESSOR,
pageNS);
+ pageNavigationalState = Base64.encodeBytes(bytes, true);
+ }
+
+ //
+ Map<String, String> parameters;
+ if (pageNavigationalState != null)
+ {
+ parameters =
Collections.singletonMap(ControllerRequestParameterNames.PAGE_NAVIGATIONAL_STATE,
pageNavigationalState);
+ }
+ else
+ {
+ parameters = Collections.emptyMap();
+ }
+
+ //
+ return renderURL(parameters, format);
+ }
+
+ public String renderURL(String windowId, ContainerURL containerURL, URLFormat format)
+ {
+ ControllerRequestParameterMapFactory factory = new
ControllerRequestParameterMapFactory(serialization);
+
+ //
+ Map<String, String> parameters = factory.blah(pageNS, windowId,
containerURL);
+
+ //
+ parameters.put(TYPE, PORTLET_TYPE);
+
+ //
+ return renderURL(parameters, format);
+ }
+}
Copied:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/TestPortletInvocationContext.java
(from rev 10146,
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java)
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/TestPortletInvocationContext.java
(rev 0)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/TestPortletInvocationContext.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -0,0 +1,101 @@
+/******************************************************************************
+ * 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.controller.impl;
+
+import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
+import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
+import org.jboss.portal.common.invocation.resolver.RequestAttributeResolver;
+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.impl.PortletURLRenderer;
+import org.jboss.portal.portlet.impl.spi.AbstractPortletInvocationContext;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestPortletInvocationContext extends AbstractPortletInvocationContext
+{
+
+ /** . */
+ private final PortletURLRenderer urlRenderer;
+
+ /** . */
+ private final String windowId;
+
+ /** . */
+ private final HttpServletRequest clientRequest;
+
+ /** . */
+ private final HttpServletResponse clientResponse;
+
+ public TestPortletInvocationContext(
+ Serialization<PageNavigationalState> serialization,
+ HttpServletRequest clientRequest,
+ HttpServletResponse clientResponse,
+ String windowId,
+ PageNavigationalState pageNavigationalState,
+ MarkupInfo markupInfo)
+ {
+ super(markupInfo);
+
+ //
+ this.clientRequest = clientRequest;
+ this.clientResponse = clientResponse;
+ this.windowId = windowId;
+ this.urlRenderer = new PortletURLRenderer(pageNavigationalState, clientRequest,
clientResponse, serialization);
+
+ //
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, new
PrincipalAttributeResolver(clientRequest));
+ addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_SCOPE, new
RequestAttributeResolver(clientRequest));
+ }
+
+ public String getWindowId()
+ {
+ return windowId;
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return clientRequest;
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return clientResponse;
+ }
+
+ public String renderURL(ContainerURL containerURL, URLFormat format)
+ {
+ return urlRenderer.renderURL(windowId, containerURL, format);
+ }
+}
Copied:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/URLParameterConstants.java
(from rev 10138,
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java)
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/URLParameterConstants.java
(rev 0)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/URLParameterConstants.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * 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.controller.impl;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public final class URLParameterConstants
+{
+
+ private URLParameterConstants()
+ {
+ }
+
+ /**
+ * The type of request. The goal is to allow other types of invocation to be used by
the controller context.
+ * The controller context itself only works on the portlet type.
+ */
+ public static final String TYPE = "type";
+
+ /**
+ * The portlet type.
+ */
+ public static final String PORTLET_TYPE = "portlet";
+
+}
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-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -24,6 +24,7 @@
import org.jboss.portal.portlet.controller.PortletController;
import org.jboss.portal.portlet.controller.impl.request.ControllerRequestFactory;
+import org.jboss.portal.portlet.controller.impl.URLParameterConstants;
import org.jboss.portal.portlet.controller.request.ControllerRequest;
import org.jboss.portal.portlet.controller.response.ControllerResponse;
import org.jboss.portal.portlet.invocation.response.ResponseProperties;
Deleted:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java 2008-02-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -1,47 +0,0 @@
-/******************************************************************************
- * 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;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public final class URLParameterConstants
-{
-
- private URLParameterConstants()
- {
- }
-
- /**
- * The type of request. The goal is to allow other types of invocation to be used by
the controller context.
- * The controller context itself only works on the portlet type.
- */
- public static final String TYPE = "type";
-
- /**
- * The portlet type.
- */
- public static final String PORTLET_TYPE = "portlet";
-
-}
Deleted:
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-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -1,188 +0,0 @@
-/******************************************************************************
- * 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.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;
-import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
-import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
-import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
-import org.jboss.portal.portlet.impl.spi.AbstractInstanceContext;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.invocation.ActionInvocation;
-import org.jboss.portal.portlet.invocation.EventInvocation;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.ResourceInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.spi.PortletInvocationContext;
-import org.jboss.portal.web.IllegalRequestException;
-import org.apache.log4j.Logger;
-
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class AbstractPortletControllerContext implements
PortletControllerContext
-{
-
- /** . */
- private static Logger log = Logger.getLogger(AbstractPortletControllerContext.class);
-
- /** . */
- public static final MarkupInfo MARKUP_INFO = new MarkupInfo(MediaType.HTML,
"UTF8");
-
- /** . */
- public static final int NAV_SCOPE = 0;
-
- /** . */
- public static final int SESSION_SCOPE = 1;
-
- /** . */
- private final HttpServletRequest req;
-
- /** . */
- private final HttpServletResponse resp;
-
- public AbstractPortletControllerContext(HttpServletRequest req, HttpServletResponse
resp
- )
- throws IllegalRequestException, IOException
- {
- this.req = req;
- this.resp = resp;
- }
-
- public HttpServletRequest getClientRequest()
- {
- return req;
- }
-
- public HttpServletResponse getClientResponse()
- {
- return resp;
- }
-
- public PortletInfo getPortletInfo(String windowId)
- {
- try
- {
- return getPortlet(windowId).getInfo();
- }
- catch (PortletInvokerException e)
- {
- log.error("Could not access portlet invoker for locating window " +
windowId, e);
-
- //
- return null;
- }
- }
-
- protected abstract Portlet getPortlet(String windowId) throws
PortletInvokerException;
-
- protected abstract PortletInvocationResponse invoke(PortletInvocation invocation)
throws PortletInvokerException;
-
- protected abstract Serialization<PageNavigationalState>
getPageNavigationalStateSerialization();
-
- public PortletInvocationResponse invoke(ActionInvocation actionInvocation) throws
PortletInvokerException
- {
-
- TestPortletInvocationContext context =
(TestPortletInvocationContext)actionInvocation.getContext();
- String windowId = context.getWindowId();
-
- Portlet portlet = getPortlet(windowId);
-
- actionInvocation.setClientContext(new AbstractClientContext(req));
- actionInvocation.setServerContext(new AbstractServerContext(req, resp));
- actionInvocation.setInstanceContext(new
AbstractInstanceContext(portlet.getContext().getId()));
- actionInvocation.setUserContext(new AbstractUserContext(req));
- actionInvocation.setWindowContext(new AbstractWindowContext(windowId));
- actionInvocation.setPortalContext(new TestPortalContext());
- actionInvocation.setSecurityContext(new AbstractSecurityContext(req));
- actionInvocation.setRequestContext(new AbstractRequestContext(req));
- actionInvocation.setTarget(portlet.getContext());
-
- return invoke((PortletInvocation)actionInvocation);
- }
-
- public PortletInvocationResponse invoke(List<Cookie> requestCookies,
EventInvocation eventInvocation) throws PortletInvokerException
- {
- TestPortletInvocationContext context =
(TestPortletInvocationContext)eventInvocation.getContext();
- String windowId = context.getWindowId();
-
- Portlet portlet = getPortlet(windowId);
-
-// TestInstanceContext instanceContext = new TestInstanceContext(req,
portlet.getContext(), true);
-
- eventInvocation.setClientContext(new AbstractClientContext(req, requestCookies));
- eventInvocation.setServerContext(new AbstractServerContext(req, resp));
- eventInvocation.setInstanceContext(new
AbstractInstanceContext(portlet.getContext().getId()));
- eventInvocation.setUserContext(new AbstractUserContext(req));
- eventInvocation.setWindowContext(new AbstractWindowContext(windowId));
- eventInvocation.setPortalContext(new TestPortalContext());
- eventInvocation.setSecurityContext(new AbstractSecurityContext(req));
- eventInvocation.setTarget(portlet.getContext());
-
- return invoke(eventInvocation);
- }
-
- public PortletInvocationResponse invoke(ResourceInvocation resourceInvocation) throws
PortletInvokerException
- {
- TestPortletInvocationContext context =
(TestPortletInvocationContext)resourceInvocation.getContext();
- String windowId = context.getWindowId();
-
- Portlet portlet = getPortlet(windowId);
-
- resourceInvocation.setClientContext(new AbstractClientContext(req));
- resourceInvocation.setServerContext(new AbstractServerContext(req, resp));
- resourceInvocation.setInstanceContext(new
AbstractInstanceContext(portlet.getContext().getId()));
- resourceInvocation.setUserContext(new AbstractUserContext(req));
- resourceInvocation.setWindowContext(new AbstractWindowContext(windowId));
- resourceInvocation.setPortalContext(new TestPortalContext());
- resourceInvocation.setSecurityContext(new AbstractSecurityContext(req));
- resourceInvocation.setRequestContext(new AbstractRequestContext(req));
- resourceInvocation.setTarget(portlet.getContext());
-
- //
- return invoke((PortletInvocation)resourceInvocation);
- }
-
- public PortletInvocationContext createPortletInvocationContext(String windowId,
PageNavigationalState pageNavigationalState)
- {
- return new TestPortletInvocationContext(getPageNavigationalStateSerialization(),
req, resp, windowId, pageNavigationalState, MARKUP_INFO);
- }
-}
\ No newline at end of file
Modified:
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 2008-02-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractRendererContext.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -23,9 +23,11 @@
package org.jboss.portal.portlet.test.controller;
import org.jboss.portal.portlet.controller.PortletControllerContext;
+import org.jboss.portal.portlet.controller.impl.AbstractPortletControllerContext;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletInvoker;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -40,9 +42,13 @@
/** . */
private final AbstractPortletControllerContext portletControllerContext;
- public AbstractRendererContext(AbstractPortletControllerContext
portletControllerContext)
+ /** . */
+ private final PortletInvoker portletInvoker;
+
+ protected AbstractRendererContext(AbstractPortletControllerContext
portletControllerContext, PortletInvoker portletInvoker)
{
this.portletControllerContext = portletControllerContext;
+ this.portletInvoker = portletInvoker;
}
public HttpServletRequest getClientRequest()
@@ -62,6 +68,6 @@
public PortletInvocationResponse render(RenderInvocation render) throws
PortletInvokerException
{
- return portletControllerContext.invoke(render);
+ return portletInvoker.invoke(render);
}
}
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-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -45,6 +45,7 @@
import org.jboss.portal.portlet.invocation.response.ContentResponse;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.impl.AbstractPortletControllerContext;
import org.w3c.dom.Element;
import javax.servlet.http.HttpServletRequest;
@@ -230,7 +231,7 @@
render.setInstanceContext(new
AbstractInstanceContext(portlet.getContext().getId()));
render.setUserContext(new AbstractUserContext(req));
render.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- render.setPortalContext(new TestPortalContext());
+ render.setPortalContext(AbstractPortletControllerContext.PORTAL_CONTEXT);
render.setSecurityContext(new AbstractSecurityContext(req));
render.setTarget(portlet.getContext());
render.setMode(mode);
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-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -30,6 +30,7 @@
import org.jboss.portal.portlet.controller.event.EventControllerContext;
import org.jboss.portal.portlet.controller.impl.event.EventControllerContextImpl;
import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
+import org.jboss.portal.portlet.controller.impl.AbstractPortletControllerContext;
import org.jboss.portal.portlet.controller.state.StateControllerContext;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
@@ -52,7 +53,7 @@
{
/** . */
- private final PortletInvoker invoker;
+ private final PortletInvoker portletInvoker;
/** . */
private final EventControllerContext eventControllerContext;
@@ -69,15 +70,20 @@
super(req, resp);
//
- this.invoker =
(PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
- this.eventControllerContext = new EventControllerContextImpl(invoker);
+ this.portletInvoker =
(PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
+ this.eventControllerContext = new EventControllerContextImpl(portletInvoker);
this.stateControllerContext = new StateControllerContextImpl(this);
this.serialization = new
PageNavigationalStateSerialization(stateControllerContext);
}
+ public PortletInvoker getPortletInvoker()
+ {
+ return portletInvoker;
+ }
+
protected Portlet getPortlet(String windowId) throws PortletInvokerException
{
- return invoker.getPortlet(PortletContext.createPortletContext(windowId));
+ return portletInvoker.getPortlet(PortletContext.createPortletContext(windowId));
}
public StateControllerContext getStateControllerContext()
@@ -87,7 +93,7 @@
public PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
{
- return invoker.invoke(invocation);
+ return portletInvoker.invoke(invocation);
}
public EventControllerContext getEventControllerContext()
@@ -97,7 +103,7 @@
public Collection<Portlet> getPortlets() throws PortletInvokerException
{
- return invoker.getPortlets();
+ return portletInvoker.getPortlets();
}
public Serialization<PageNavigationalState>
getPageNavigationalStateSerialization()
Deleted:
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-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -1,150 +0,0 @@
-/******************************************************************************
- * 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.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.impl.request.ControllerRequestParameterNames;
-import
org.jboss.portal.portlet.controller.impl.request.ControllerRequestParameterMapFactory;
-import static org.jboss.portal.portlet.test.URLParameterConstants.*;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.Map;
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletURLRenderer
-{
-
- /** . */
- final Serialization<PageNavigationalState> serialization;
-
- /** . */
- final HttpServletRequest clientReq;
-
- /** . */
- final HttpServletResponse clientResp;
-
- /** . */
- final PageNavigationalState pageNS;
-
- public PortletURLRenderer(
- PageNavigationalState pageNS,
- HttpServletRequest clientReq,
- HttpServletResponse clientResp,
- Serialization<PageNavigationalState> serialization)
- {
- this.pageNS = pageNS;
- this.clientReq = clientReq;
- this.clientResp = clientResp;
- this.serialization = serialization;
- }
-
- private String renderURL(Map<String, String> parameters, URLFormat format)
- {
- CharBuffer buffer = new CharBuffer();
- buffer.append(clientReq.getScheme());
- buffer.append("://");
- buffer.append(clientReq.getServerName());
- buffer.append(':');
- buffer.append(Integer.toString(clientReq.getServerPort()));
- buffer.append(clientReq.getContextPath());
- buffer.append(clientReq.getServletPath());
-
- //
- if (clientReq.getPathInfo() != null)
- {
- buffer.append(clientReq.getPathInfo());
- }
-
- //
- String parameterSeparator = format.getWantEscapeXML() == Boolean.TRUE ?
"&" : "&";
-
- //
- boolean first = true;
- for (Map.Entry<String, String> entry : parameters.entrySet())
- {
- String name = entry.getKey();
- String value = entry.getValue();
- buffer.append(first ? "?" : parameterSeparator);
- buffer.append(name, FastURLEncoder.getUTF8Instance());
- buffer.append('=');
- buffer.append(value, FastURLEncoder.getUTF8Instance());
- first = false;
- }
-
- //
- String url = buffer.asString();
- return clientResp.encodeURL(url);
- }
-
- public String renderURL(URLFormat format)
- {
- String pageNavigationalState = null;
- if (pageNS != null)
- {
- byte[] bytes = IOTools.serialize(serialization, SerializationFilter.COMPRESSOR,
pageNS);
- pageNavigationalState = Base64.encodeBytes(bytes, true);
- }
-
- //
- Map<String, String> parameters;
- if (pageNavigationalState != null)
- {
- parameters =
Collections.singletonMap(ControllerRequestParameterNames.PAGE_NAVIGATIONAL_STATE,
pageNavigationalState);
- }
- else
- {
- parameters = Collections.emptyMap();
- }
-
- //
- return renderURL(parameters, format);
- }
-
- public String renderURL(String windowId, ContainerURL containerURL, URLFormat format)
- {
- ControllerRequestParameterMapFactory factory = new
ControllerRequestParameterMapFactory(serialization);
-
- //
- Map<String, String> parameters = factory.blah(pageNS, windowId,
containerURL);
-
- //
- parameters.put(TYPE, PORTLET_TYPE);
-
- //
- return renderURL(parameters, format);
- }
-}
Modified:
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 2008-02-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RendererContextImpl.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -39,7 +39,7 @@
public RendererContextImpl(PortletControllerContextImpl portletControllerContext)
throws PortletInvokerException
{
- super(portletControllerContext);
+ super(portletControllerContext, portletControllerContext.getPortletInvoker());
//
this.portlets = portletControllerContext.getPortlets();
Deleted:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortalContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortalContext.java 2008-02-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortalContext.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -1,40 +0,0 @@
-/******************************************************************************
- * 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.impl.spi.AbstractPortalContext;
-
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class TestPortalContext extends AbstractPortalContext
-{
- public TestPortalContext()
- {
-
super(Collections.singletonMap("javax.portlet.markup.head.element.support",
"true"));
- }
-}
Deleted:
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-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -1,100 +0,0 @@
-/******************************************************************************
- * 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.common.invocation.resolver.MapAttributeResolver;
-import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
-import org.jboss.portal.common.invocation.resolver.RequestAttributeResolver;
-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.impl.spi.AbstractPortletInvocationContext;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class TestPortletInvocationContext extends AbstractPortletInvocationContext
-{
-
- /** . */
- private final PortletURLRenderer urlRenderer;
-
- /** . */
- private final String windowId;
-
- /** . */
- private final HttpServletRequest clientRequest;
-
- /** . */
- private final HttpServletResponse clientResponse;
-
- public TestPortletInvocationContext(
- Serialization<PageNavigationalState> serialization,
- HttpServletRequest clientRequest,
- HttpServletResponse clientResponse,
- String windowId,
- PageNavigationalState pageNavigationalState,
- MarkupInfo markupInfo)
- {
- super(markupInfo);
-
- //
- this.clientRequest = clientRequest;
- this.clientResponse = clientResponse;
- this.windowId = windowId;
- this.urlRenderer = new PortletURLRenderer(pageNavigationalState, clientRequest,
clientResponse, serialization);
-
- //
- addResolver(PortletInvocation.PRINCIPAL_SCOPE, new
PrincipalAttributeResolver(clientRequest));
- addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
- addResolver(PortletInvocation.REQUEST_SCOPE, new
RequestAttributeResolver(clientRequest));
- }
-
- public String getWindowId()
- {
- return windowId;
- }
-
- public HttpServletRequest getClientRequest() throws IllegalStateException
- {
- return clientRequest;
- }
-
- public HttpServletResponse getClientResponse() throws IllegalStateException
- {
- return clientResponse;
- }
-
- public String renderURL(ContainerURL containerURL, URLFormat format)
- {
- return urlRenderer.renderURL(windowId, containerURL, format);
- }
-}
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-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp;
-import org.jboss.portal.portlet.test.controller.PortletURLRenderer;
-import org.jboss.portal.portlet.test.URLParameterConstants;
+import org.jboss.portal.portlet.controller.impl.PortletURLRenderer;
+import org.jboss.portal.portlet.controller.impl.URLParameterConstants;
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.URLFormat;
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-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -32,7 +32,7 @@
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.portlet.controller.impl.AbstractPortletControllerContext;
import org.jboss.portal.web.IllegalRequestException;
import org.jboss.portal.common.io.Serialization;
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalRenderResponse.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalRenderResponse.java 2008-02-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalRenderResponse.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp;
-import org.jboss.portal.portlet.test.controller.TestPortalContext;
+import org.jboss.portal.portlet.controller.impl.AbstractPortletControllerContext;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
@@ -171,7 +171,7 @@
render.setInstanceContext(new
AbstractInstanceContext(portlet.getContext().getId()));
render.setUserContext(new
AbstractUserContext(portletControllerContext.getClientRequest()));
render.setWindowContext(new AbstractWindowContext(windowId));
- render.setPortalContext(new TestPortalContext());
+ render.setPortalContext(AbstractPortletControllerContext.PORTAL_CONTEXT);
render.setSecurityContext(new
AbstractSecurityContext(portletControllerContext.getClientRequest()));
render.setTarget(portlet.getContext());
render.setMode(mode);
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-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -26,7 +26,7 @@
import org.jboss.portal.WindowState;
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.PortletURLRenderer;
import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.URLFormat;
Modified:
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 2008-02-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPortletControllerContext.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.test.tck;
-import org.jboss.portal.portlet.test.controller.AbstractPortletControllerContext;
+import org.jboss.portal.portlet.controller.impl.AbstractPortletControllerContext;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.PortletInvoker;
@@ -41,7 +41,6 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
import java.io.IOException;
-import java.util.Map;
import java.util.Set;
/**
@@ -52,7 +51,7 @@
{
/** . */
- private final PortletInvoker invoker;
+ private final PortletInvoker portletInvoker;
/** . */
private final TCKStateControllerContext stateControllerContext;
@@ -71,25 +70,30 @@
super(req, resp);
//
- this.invoker =
(PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
+ this.portletInvoker =
(PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
this.stateControllerContext = new TCKStateControllerContext(new
StateControllerContextImpl(this));
- this.eventControllerContext = new EventControllerContextImpl(invoker);
+ this.eventControllerContext = new EventControllerContextImpl(portletInvoker);
this.serialization = new
TCKPageNavigationalStateSerialization(stateControllerContext);
}
+ public PortletInvoker getPortletInvoker()
+ {
+ return portletInvoker;
+ }
+
public Set<Portlet> getPortlets() throws PortletInvokerException
{
- return invoker.getPortlets();
+ return portletInvoker.getPortlets();
}
protected Portlet getPortlet(String windowId) throws PortletInvokerException
{
- return invoker.getPortlet(PortletContext.createPortletContext(windowId));
+ return portletInvoker.getPortlet(PortletContext.createPortletContext(windowId));
}
protected PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
{
- return invoker.invoke(invocation);
+ return portletInvoker.invoke(invocation);
}
protected Serialization<PageNavigationalState>
getPageNavigationalStateSerialization()
Modified:
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 2008-02-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKRendererContext.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -26,6 +26,7 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.NoSuchPortletException;
+import org.jboss.portal.portlet.PortletInvoker;
import java.util.Collection;
import java.util.ArrayList;
@@ -44,7 +45,7 @@
TCKPortletControllerContext portletControllerContext,
TCKPageNavigationalState tckPageNavigationalState) throws PortletInvokerException
{
- super(portletControllerContext);
+ super(portletControllerContext, portletControllerContext.getPortletInvoker());
//
Collection<Portlet> involvedPortlets = new ArrayList<Portlet>();
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-29
17:00:22 UTC (rev 10158)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKServlet.java 2008-02-29
17:35:48 UTC (rev 10159)
@@ -25,7 +25,7 @@
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.URLParameterConstants;
+import org.jboss.portal.portlet.controller.impl.URLParameterConstants;
import org.jboss.portal.portlet.controller.PortletController;
import org.jboss.portal.portlet.controller.response.ControllerResponse;
import org.jboss.portal.portlet.controller.request.ControllerRequest;