[jboss-svn-commits] JBoss Portal SVN: r5597 - in trunk: common/src/main/org/jboss/portal/common/invocation core/src/main/org/jboss/portal/core core/src/main/org/jboss/portal/core/aspects/controller/node core/src/main/org/jboss/portal/core/controller/command core/src/main/org/jboss/portal/core/controller/portlet core/src/main/org/jboss/portal/core/portlet/cms core/src/main/org/jboss/portal/core/portlet/cms/admin core/src/main/org/jboss/portal/core/ui core/src/main/org/jboss/portal/core/ui/configurator core/src/main/org/jboss/portlet portlet/src/main/org/jboss/portal/portlet/impl/jsr168 portlet/src/main/org/jboss/portal/portlet/impl/spi portlet/src/main/org/jboss/portal/portlet/invocation portlet/src/main/org/jboss/portal/portlet/test wsrp/src/main/org/jboss/portal/test/wsrp/framework/support wsrp/src/main/org/jboss/portal/wsrp/invocation
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Nov 7 17:16:55 EST 2006
Author: julien at jboss.com
Date: 2006-11-07 17:16:29 -0500 (Tue, 07 Nov 2006)
New Revision: 5597
Added:
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
trunk/core/src/main/org/jboss/portal/core/ui/
trunk/core/src/main/org/jboss/portal/core/ui/configurator/
trunk/core/src/main/org/jboss/portal/core/ui/configurator/ConfiguratorCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/ui/configurator/RenderPortletCommand.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractActionContext.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractRenderContext.java
Removed:
trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerActionContext.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletInvocationContext.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerRenderContext.java
Modified:
trunk/common/src/main/org/jboss/portal/common/invocation/Invocation.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactory.java
trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowActionCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/RenderWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/portlet/cms/CMSPortlet.java
trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
trunk/core/src/main/org/jboss/portlet/JBossActionRequest.java
trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java
trunk/core/src/main/org/jboss/portlet/JBossRenderRequest.java
trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderResponseImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractPortletInvocationContext.java
trunk/portlet/src/main/org/jboss/portal/portlet/invocation/PortletInvocation.java
trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/TestPortletInvocationContext.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/invocation/WSRPPortletInvocationContext.java
Log:
update the way that the core portal invoke portlet in order to make it more encapsulated in order to be able to create portlet invocations from a context which is not a window on a page.
Modified: trunk/common/src/main/org/jboss/portal/common/invocation/Invocation.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/invocation/Invocation.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/common/src/main/org/jboss/portal/common/invocation/Invocation.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -22,9 +22,6 @@
******************************************************************************/
package org.jboss.portal.common.invocation;
-import org.jboss.portal.common.invocation.Interceptor;
-import org.jboss.portal.common.invocation.InterceptorStack;
-
/**
* A generic invocation object.
*
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactory.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactory.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -24,13 +24,12 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
-import org.jboss.portal.core.controller.command.InvokeWindowRenderCommand;
-import org.jboss.portal.core.controller.command.RenderPageCommand;
-import org.jboss.portal.core.controller.portlet.ControllerPortletInvocationContext;
import org.jboss.portal.portlet.ParametersStateString;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.spi.SecurityContext;
import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.server.request.URLFormat;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.command.RenderPageCommand;
+import org.jboss.portal.core.controller.command.InvokeWindowRenderCommand;
/**
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
@@ -39,7 +38,7 @@
public class PortalNodeURLFactory
{
- public static PortalNodeURL createActionURL(PortalObjectNode node, PortletInvocation invocation)
+ public static PortalNodeURL createActionURL(PortalObjectNode node, ControllerContext controllerContext)
{
switch (node.getType())
{
@@ -53,14 +52,14 @@
}
}
- public static PortalNodeURL createRenderURL(PortalObjectNode node, PortletInvocation invocation)
+ public static PortalNodeURL createRenderURL(PortalObjectNode node, ControllerContext controllerContext)
{
switch (node.getType())
{
case PortalNode.TYPE_WINDOW:
- return new WindowURL(node.getRef(), invocation);
+ return new WindowURL(node.getRef(), controllerContext);
case PortalNode.TYPE_PAGE:
- return new PageURL(node.getRef(), invocation);
+ return new PageURL(node.getRef(), controllerContext);
case PortalNode.TYPE_PORTAL:
return null;
case PortalNode.TYPE_CONTEXT:
@@ -73,16 +72,16 @@
{
protected String handle;
- protected PortletInvocation invocation;
+ protected ControllerContext controllerContext;
protected ParametersStateString parameters;
protected Boolean wantSecure;
protected Boolean wantAuthenticated;
protected boolean relative;
- public AbstractPortalNodeURL(String handle, PortletInvocation invocation)
+ public AbstractPortalNodeURL(String handle, ControllerContext controllerContext)
{
this.handle = handle;
- this.invocation = invocation;
+ this.controllerContext = controllerContext;
this.relative = true;
this.parameters = new ParametersStateString();
}
@@ -114,24 +113,7 @@
protected URLContext getURLContext()
{
- SecurityContext securityContext = invocation.getSecurityContext();
-
- //
- boolean secure = securityContext.isSecure();
- if (wantSecure != null)
- {
- secure = wantSecure.booleanValue();
- }
-
- //
- boolean authenticated = securityContext.isAuthenticated();
- if (wantAuthenticated != null)
- {
- authenticated = wantAuthenticated.booleanValue();
- }
-
- //
- return URLContext.newInstance(secure, authenticated);
+ return controllerContext.getServerInvocation().getServerContext().getURLContext();
}
}
@@ -139,34 +121,32 @@
private static class WindowURL extends AbstractPortalNodeURL
{
- public WindowURL(String handle, PortletInvocation invocation)
+ public WindowURL(String handle, ControllerContext controllerContext)
{
- super(handle, invocation);
+ super(handle, controllerContext);
}
public String toString()
{
- ControllerPortletInvocationContext ctx = (ControllerPortletInvocationContext)invocation.getContext();
InvokeWindowRenderCommand cmd = new InvokeWindowRenderCommand(handle, null, null, parameters);
- URLContext info = getURLContext();
- return ctx.encodeURL(cmd, info, relative);
+ URLContext urlContext = getURLContext();
+ return controllerContext.encodeURL(cmd, urlContext, URLFormat.newInstance(relative, true));
}
}
private static class PageURL extends AbstractPortalNodeURL
{
- public PageURL(String handle, PortletInvocation invocation)
+ public PageURL(String handle, ControllerContext controllerContext)
{
- super(handle, invocation);
+ super(handle, controllerContext);
}
public String toString()
{
- ControllerPortletInvocationContext ctx = (ControllerPortletInvocationContext)invocation.getContext();
RenderPageCommand cmd = new RenderPageCommand(handle);
URLContext urlContext = getURLContext();
- return ctx.encodeURL(cmd, urlContext, relative);
+ return controllerContext.encodeURL(cmd, urlContext, URLFormat.newInstance(relative, true));
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowActionCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowActionCommand.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowActionCommand.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -25,20 +25,18 @@
import org.jboss.logging.Logger;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ResourceNotFoundException;
import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.response.PortletResponse;
-import org.jboss.portal.core.controller.portlet.ControllerActionContext;
+import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.Parameters;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.server.ServerInvocation;
/**
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
@@ -111,10 +109,15 @@
{
try
{
- ServerInvocation sinv = context.getServerInvocation();
- ControllerContext controllerCtx = (ControllerContext)getContext();
- ControllerActionContext actionCtx = new ControllerActionContext(controllerCtx, sinv, portal, navigationalState, getWindowState(), getMode(), interactionState, formParameters, window);
- PortletInvocation invocation = actionCtx.createInvocation();
+ PortletInvocation invocation = PortletInvocationFactory.createAction(
+ context,
+ mode,
+ windowState,
+ navigationalState,
+ interactionState,
+ formParameters,
+ window,
+ portal);
//
PortletInvocationResponse resp = instance.invoke(invocation);
Modified: trunk/core/src/main/org/jboss/portal/core/controller/command/RenderWindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/RenderWindowCommand.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/RenderWindowCommand.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -25,19 +25,17 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ResourceNotFoundException;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.controller.command.response.PortletResponse;
-import org.jboss.portal.core.controller.portlet.ControllerRenderContext;
+import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.theme.navigation.WindowNavigationalState;
/**
@@ -64,12 +62,9 @@
public Object execute() throws ControllerException
{
- ServerInvocation sinv = context.getServerInvocation();
+ StateString navigationalState = (StateString)getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, window.getInstanceRef());
//
- StateString ns = (StateString)getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, window.getInstanceRef());
-
- //
WindowNavigationalState windowNavState = (WindowNavigationalState)getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, targetId + "_window");
if (windowNavState == null)
{
@@ -84,12 +79,15 @@
WindowState windowState = windowNavState.getWindowState();
//
- ControllerRenderContext renderContext = new ControllerRenderContext((ControllerContext)getContext(), sinv, portal, ns, mode, windowState, window);
+ RenderInvocation invocation = PortletInvocationFactory.createRender(
+ context,
+ mode,
+ windowState,
+ navigationalState,
+ window,
+ portal);
//
- RenderInvocation invocation = (RenderInvocation)renderContext.createInvocation();
-
- //
try
{
PortletInvocationResponse resp = instance.invoke(invocation);
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerActionContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerActionContext.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerActionContext.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -1,110 +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.core.controller.portlet;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.core.model.portal.Portal;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.portlet.Parameters;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.invocation.ActionInvocation;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.spi.ActionContext;
-import org.jboss.portal.server.ServerInvocation;
-
-import javax.servlet.http.HttpServletRequest;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class ControllerActionContext extends ControllerPortletInvocationContext implements ActionContext
-{
-
- private HttpServletRequest req;
- private StateString interactionState;
- private Parameters form;
-
- public ControllerActionContext(
- ControllerContext controllerContext,
- ServerInvocation invocation,
- Portal portal,
- StateString navigationalState,
- WindowState windowState,
- Mode mode,
- StateString interactionState,
- Parameters form,
- Window window)
- {
- super(controllerContext, invocation, portal, navigationalState, mode, windowState, window);
- this.req = invocation.getServerContext().getClientRequest();
- this.interactionState = interactionState;
- this.form = form;
- }
-
-
- public String getCharacterEncoding()
- {
- return req.getCharacterEncoding();
- }
-
- public BufferedReader getReader() throws IOException
- {
- return req.getReader();
- }
-
- public InputStream getInputStream() throws IOException
- {
- return req.getInputStream();
- }
-
- public int getContentLength()
- {
- return req.getContentLength();
- }
-
- public String getContentType()
- {
- return req.getContentType();
- }
-
- public StateString getInteractionState()
- {
- return interactionState;
- }
-
- public Parameters getForm()
- {
- return form;
- }
-
- protected PortletInvocation newInvocation()
- {
- return new ActionInvocation(this);
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletInvocationContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletInvocationContext.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletInvocationContext.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -1,208 +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.core.controller.portlet;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.invocation.EmptyAttributeResolver;
-import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.core.controller.command.InvokeWindowActionCommand;
-import org.jboss.portal.core.controller.command.InvokeWindowRenderCommand;
-import org.jboss.portal.core.model.portal.Portal;
-import org.jboss.portal.core.model.portal.PortalContextImpl;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.WindowContextImpl;
-import org.jboss.portal.portlet.ActionURL;
-import org.jboss.portal.portlet.PortletURL;
-import org.jboss.portal.portlet.RenderURL;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.impl.spi.AbstractPortletInvocationContext;
-import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
-import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.spi.PortalContext;
-import org.jboss.portal.portlet.spi.PortletInvocationContext;
-import org.jboss.portal.portlet.spi.RequestContext;
-import org.jboss.portal.portlet.spi.SecurityContext;
-import org.jboss.portal.portlet.spi.UserContext;
-import org.jboss.portal.portlet.spi.WindowContext;
-import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.impl.MapAttributeResolver;
-import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.server.request.URLFormat;
-import org.jboss.portal.server.util.HTTPStreamInfo;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 5064 $
- */
-public abstract class ControllerPortletInvocationContext extends AbstractPortletInvocationContext implements PortletInvocationContext
-{
-
- /** . */
- protected ControllerContext controllerContext;
-
- /** . */
- protected ServerInvocation invocation;
-
- /** . */
- private Mode mode;
-
- /** . */
- private WindowState windowState;
-
- /** . */
- private Window window;
-
- /** . */
- protected StateString navigationalState;
-
- /** . */
- protected PortalContext portalContext;
-
- /** . */
- protected RequestContext requestContext;
-
- /** . */
- protected SecurityContext securityContext;
-
- /** . */
- protected UserContext userContext;
-
- /** . */
- protected WindowContext windowContext;
-
- public ControllerPortletInvocationContext(
- ControllerContext controllerContext,
- ServerInvocation invocation,
- Portal portal,
- StateString navigationalState,
- Mode mode,
- WindowState windowState,
- Window window)
- {
- this.controllerContext = controllerContext;
- this.invocation = invocation;
- this.window = window;
- this.mode = mode;
- this.windowState = windowState;
- this.navigationalState = navigationalState;
-
- this.requestContext = new AbstractRequestContext(invocation.getServerContext().getClientRequest(), invocation.getServerContext().getClientResponse());
- this.securityContext = new AbstractSecurityContext(invocation.getServerContext().getClientRequest());
- this.userContext = new ControllerUserContext(invocation);
- this.portalContext = new PortalContextImpl(portal);
- this.windowContext = new WindowContextImpl(window);
-
- //
- addResolver(PortletInvocation.REQUEST_SCOPE, controllerContext);
- addResolver(PortletInvocation.PRINCIPAL_SCOPE, controllerContext);
- addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, EmptyAttributeResolver.getInstance());
- addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
- }
-
- public HttpServletResponse getClientResponse()
- {
- return invocation.getServerContext().getClientResponse();
- }
-
- public HttpServletRequest getClientRequest()
- {
- return invocation.getServerContext().getClientRequest();
- }
-
- public Mode getMode()
- {
- return mode;
- }
-
- public WindowState getWindowState()
- {
- return windowState;
- }
-
- public StateString getNavigationalState()
- {
- return navigationalState;
- }
-
- public HTTPStreamInfo getStreamInfo()
- {
- return invocation.getResponse().getStreamInfo();
- }
-
- public String encodeURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
- {
- ControllerCommand cmd = null;
- if (portletURL instanceof ActionURL)
- {
- ActionURL actionURL = (ActionURL)portletURL;
- cmd = new InvokeWindowActionCommand(window.getId(), portletURL.getMode(), portletURL.getWindowState(), actionURL.getNavigationalState(), actionURL.getInteractionState(), null);
- }
- else
- {
- cmd = new InvokeWindowRenderCommand(window.getId(), portletURL.getMode(), portletURL.getWindowState(), ((RenderURL)portletURL).getNavigationalState());
- }
-
- //
- boolean secure = invocation.getServerContext().getURLContext().getSecure();
- if (wantSecure != null)
- {
- secure = wantSecure.booleanValue();
- }
-
- //
- boolean authenticated = invocation.getServerContext().getURLContext().isAuthenticated();
- if (wantAuthenticated != null)
- {
- authenticated = wantAuthenticated.booleanValue();
- }
-
- URLContext info = URLContext.newInstance(secure, authenticated);
- return controllerContext.encodeURL(cmd, info, URLFormat.newInstance(relative, true));
- }
-
- public PortletInvocation createInvocation()
- {
- PortletInvocation invocation = newInvocation();
-
- // Contextualize
- invocation.setSecurityContext(securityContext);
- invocation.setRequestContext(requestContext);
- invocation.setPortalContext(portalContext);
- invocation.setWindowContext(windowContext);
- invocation.setUserContext(userContext);
- return invocation;
- }
-
- protected abstract PortletInvocation newInvocation();
-
- public String encodeURL(ControllerCommand cmd, URLContext urlContext, boolean relative)
- {
- return controllerContext.encodeURL(cmd, urlContext, URLFormat.newInstance(relative, true));
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerRenderContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerRenderContext.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerRenderContext.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -1,59 +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.core.controller.portlet;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.core.model.portal.Portal;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.spi.RenderContext;
-import org.jboss.portal.server.ServerInvocation;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class ControllerRenderContext extends ControllerPortletInvocationContext implements RenderContext
-{
-
- public ControllerRenderContext(
- ControllerContext controllerContext,
- ServerInvocation invocation,
- Portal portal,
- StateString navigationalState,
- Mode mode,
- WindowState windowState,
- Window window)
- {
- super(controllerContext, invocation, portal, navigationalState, mode, windowState, window);
- }
-
- protected PortletInvocation newInvocation()
- {
- return new RenderInvocation(this);
- }
-}
Added: trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletCommandFactory.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletCommandFactory.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.controller.portlet;
+
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.portlet.ActionURL;
+import org.jboss.portal.portlet.RenderURL;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PortletCommandFactory
+{
+ ControllerCommand createInvokeActionCommand(ActionURL portletURL);
+ ControllerCommand createInvokeRenderCommand(RenderURL portletURL);
+}
Added: trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletContextFactory.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.controller.portlet;
+
+import org.jboss.portal.portlet.spi.PortalContext;
+import org.jboss.portal.portlet.spi.RequestContext;
+import org.jboss.portal.portlet.spi.SecurityContext;
+import org.jboss.portal.portlet.spi.UserContext;
+import org.jboss.portal.portlet.spi.WindowContext;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PortletContextFactory
+{
+ PortalContext createPortalContext();
+ RequestContext createRequestContext();
+ SecurityContext createSecurityContext();
+ UserContext createUserContext();
+ WindowContext createWindowContext();
+}
Added: trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -0,0 +1,353 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.controller.portlet;
+
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.Parameters;
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.ActionURL;
+import org.jboss.portal.portlet.RenderURL;
+import org.jboss.portal.portlet.impl.spi.AbstractActionContext;
+import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
+import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
+import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
+import org.jboss.portal.portlet.spi.ActionContext;
+import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.portlet.spi.PortalContext;
+import org.jboss.portal.portlet.spi.RequestContext;
+import org.jboss.portal.portlet.spi.SecurityContext;
+import org.jboss.portal.portlet.spi.UserContext;
+import org.jboss.portal.portlet.spi.WindowContext;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.command.InvokeWindowActionCommand;
+import org.jboss.portal.core.controller.command.InvokeWindowRenderCommand;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.PortalContextImpl;
+import org.jboss.portal.core.model.portal.WindowContextImpl;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.invocation.EmptyAttributeResolver;
+import org.jboss.portal.server.util.HTTPStreamInfo;
+import org.jboss.portal.server.impl.MapAttributeResolver;
+import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.server.request.URLFormat;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletInvocationFactory
+{
+
+ public static RenderInvocation createRender(
+ ControllerContext controllerContext,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ Window window,
+ Portal portal)
+ {
+ PortletContextFactory cf = new InternalPortletContextFactory(controllerContext, portal, window);
+ InternalPortletCommandFactory cpc = new InternalPortletCommandFactory(window, controllerContext);
+ return createRender(controllerContext, mode, windowState, navigationalState, cf, cpc);
+ }
+
+
+ public static ActionInvocation createAction(
+ ControllerContext controllerContext,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ StateString interactionState,
+ Parameters form,
+ Window window,
+ Portal portal)
+ {
+ PortletContextFactory cf = new InternalPortletContextFactory(controllerContext, portal, window);
+ InternalPortletCommandFactory cpc = new InternalPortletCommandFactory(window, controllerContext);
+ return createAction(controllerContext, mode, windowState, navigationalState, interactionState, form, cf, cpc);
+ }
+
+ public static ActionInvocation createAction(
+ ControllerContext controllerContext,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ StateString interactionState,
+ Parameters form,
+ PortletContextFactory cf,
+ PortletCommandFactory cpc)
+ {
+ HTTPStreamInfo streamInfo = controllerContext.getServerInvocation().getResponse().getStreamInfo();
+
+ //
+ ActionContext ctx = new ControllerActionContext(
+ cpc,
+ controllerContext,
+ mode, windowState,
+ navigationalState,
+ streamInfo,
+ interactionState,
+ form);
+
+ //
+ ActionInvocation action = new ActionInvocation(ctx);
+
+ //
+ action.setAttribute(PortletInvocation.REQUEST_SCOPE, "controller_context", controllerContext);
+
+ // Contextualize
+ action.setSecurityContext(cf.createSecurityContext());
+ action.setRequestContext(cf.createRequestContext());
+ action.setPortalContext(cf.createPortalContext());
+ action.setWindowContext(cf.createWindowContext());
+ action.setUserContext(cf.createUserContext());
+
+ //
+ return action;
+ }
+
+ public static RenderInvocation createRender(
+ ControllerContext controllerContext,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ PortletContextFactory cf,
+ PortletCommandFactory cpc)
+ {
+ HTTPStreamInfo streamInfo = controllerContext.getServerInvocation().getResponse().getStreamInfo();
+
+ //
+ RenderContext ctx = new ControllerRenderContext(
+ cpc,
+ controllerContext,
+ mode,
+ windowState,
+ navigationalState,
+ streamInfo);
+
+ //
+ RenderInvocation render = new RenderInvocation(ctx);
+
+ //
+ render.setAttribute(PortletInvocation.REQUEST_SCOPE, "controller_context", controllerContext);
+
+ // Contextualize
+ render.setSecurityContext(cf.createSecurityContext());
+ render.setRequestContext(cf.createRequestContext());
+ render.setPortalContext(cf.createPortalContext());
+ render.setWindowContext(cf.createWindowContext());
+ render.setUserContext(cf.createUserContext());
+
+ //
+ return render;
+ }
+
+ private static class ControllerActionContext extends AbstractActionContext
+ {
+ private PortletCommandFactory cmdFactory;
+ private ControllerContext controllerContext;
+ public ControllerActionContext(PortletCommandFactory cmdFactory, ControllerContext controllerContext, Mode mode, WindowState windowState, StateString navigationalState, HTTPStreamInfo streamInfo, StateString interactionState, Parameters form)
+ {
+ super(mode, windowState, navigationalState, streamInfo, interactionState, form);
+
+ //
+ this.cmdFactory = cmdFactory;
+ this.controllerContext = controllerContext;
+
+ //
+ addResolver(PortletInvocation.REQUEST_SCOPE, controllerContext);
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, controllerContext);
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, EmptyAttributeResolver.getInstance());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
+ }
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return controllerContext.getServerInvocation().getServerContext().getClientRequest();
+ }
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return controllerContext.getServerInvocation().getServerContext().getClientResponse();
+ }
+ public String encodeURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ return PortletInvocationFactory.encodeURL(controllerContext, cmdFactory, portletURL, wantSecure, wantAuthenticated, relative);
+ }
+ }
+
+ private static class ControllerRenderContext extends AbstractRenderContext
+ {
+ private PortletCommandFactory cmdFactory;
+ private ControllerContext controllerContext;
+ public ControllerRenderContext(PortletCommandFactory cmdFactory, ControllerContext controllerContext, Mode mode, WindowState windowState, StateString navigationalState, HTTPStreamInfo streamInfo)
+ {
+ super(mode, windowState, navigationalState, streamInfo);
+
+ //
+ this.cmdFactory = cmdFactory;
+ this.controllerContext = controllerContext;
+
+ //
+ addResolver(PortletInvocation.REQUEST_SCOPE, controllerContext);
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, controllerContext);
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, EmptyAttributeResolver.getInstance());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
+ }
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return controllerContext.getServerInvocation().getServerContext().getClientRequest();
+ }
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return controllerContext.getServerInvocation().getServerContext().getClientResponse();
+ }
+ public String encodeURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ return PortletInvocationFactory.encodeURL(controllerContext, cmdFactory, portletURL, wantSecure, wantAuthenticated, relative);
+ }
+ }
+
+ public static String encodeURL(
+ ControllerContext controllerContext,
+ PortletCommandFactory factory,
+ PortletURL portletURL,
+ Boolean wantSecure,
+ Boolean wantAuthenticated,
+ boolean relative)
+ {
+ ControllerCommand cmd;
+ if (portletURL instanceof ActionURL)
+ {
+ cmd = factory.createInvokeActionCommand((ActionURL)portletURL);
+ }
+ else
+ {
+ cmd = factory.createInvokeRenderCommand((RenderURL)portletURL);
+ }
+
+ //
+ boolean secure = controllerContext.getServerInvocation().getServerContext().getURLContext().getSecure();
+ if (wantSecure != null)
+ {
+ secure = wantSecure.booleanValue();
+ }
+
+ //
+ boolean authenticated = controllerContext.getServerInvocation().getServerContext().getURLContext().isAuthenticated();
+ if (wantAuthenticated != null)
+ {
+ authenticated = wantAuthenticated.booleanValue();
+ }
+
+ URLContext info = URLContext.newInstance(secure, authenticated);
+ return controllerContext.encodeURL(cmd, info, URLFormat.newInstance(relative, true));
+ }
+
+ private static class InternalPortletCommandFactory implements PortletCommandFactory
+ {
+
+ /** . */
+ Window window;
+
+ /** . */
+ ControllerContext controllerContext;
+
+ public InternalPortletCommandFactory(Window window, ControllerContext controllerContext)
+ {
+ this.controllerContext = controllerContext;
+ this.window = window;
+ }
+
+ public ControllerCommand createInvokeActionCommand(ActionURL actionURL)
+ {
+ return new InvokeWindowActionCommand(window.getId(), actionURL.getMode(), actionURL.getWindowState(), actionURL.getNavigationalState(), actionURL.getInteractionState(), null);
+ }
+
+ public ControllerCommand createInvokeRenderCommand(RenderURL renderURL)
+ {
+ return new InvokeWindowRenderCommand(window.getId(), renderURL.getMode(), renderURL.getWindowState(), renderURL.getNavigationalState());
+ }
+ }
+
+ private static class InternalPortletContextFactory implements PortletContextFactory
+ {
+
+ /** . */
+ private PortalContext portalContext;
+
+ /** . */
+ private RequestContext requestContext;
+
+ /** . */
+ private SecurityContext securityContext;
+
+ /** . */
+ private UserContext userContext;
+
+ /** . */
+ private WindowContext windowContext;
+
+ public InternalPortletContextFactory(ControllerContext controllerContext, Portal portal, Window window)
+ {
+
+ this.requestContext = new AbstractRequestContext(controllerContext.getServerInvocation().getServerContext().getClientRequest(), controllerContext.getServerInvocation().getServerContext().getClientResponse());
+ this.securityContext = new AbstractSecurityContext(controllerContext.getServerInvocation().getServerContext().getClientRequest());
+ this.userContext = new ControllerUserContext(controllerContext.getServerInvocation());
+ this.portalContext = new PortalContextImpl(portal);
+ this.windowContext = new WindowContextImpl(window);
+ }
+
+ public PortalContext createPortalContext()
+ {
+ return portalContext;
+ }
+
+ public RequestContext createRequestContext()
+ {
+ return requestContext;
+ }
+
+ public SecurityContext createSecurityContext()
+ {
+ return securityContext;
+ }
+
+ public UserContext createUserContext()
+ {
+ return userContext;
+ }
+
+ public WindowContext createWindowContext()
+ {
+ return windowContext;
+ }
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/cms/CMSPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/cms/CMSPortlet.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/cms/CMSPortlet.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -29,9 +29,13 @@
import org.jboss.portal.cms.model.File;
import org.jboss.portal.cms.util.FileUtil;
import org.jboss.portal.core.cms.StreamContentCommand;
-import org.jboss.portal.core.controller.portlet.ControllerPortletInvocationContext;
+import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.server.request.URLFormat;
import org.jboss.portlet.JBossRenderResponse;
+import org.jboss.portlet.JBossRenderRequest;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
@@ -217,7 +221,7 @@
while (m.find())
{
String relURI = m.group(3) != null ? m.group(3) : m.group(4);
- String absoluteURI = this.buildURL(resp, "/" + relURI);
+ String absoluteURI = this.buildURL((JBossRenderRequest)req, "/" + relURI);
m.appendReplacement(buffer, "$1$2" + FileUtil.cleanDoubleSlashes(absoluteURI) + "$2");
/* if(!relURI.startsWith("mailto") && !relURI.startsWith("http"))
{
@@ -253,12 +257,11 @@
* Rewrites urls. Typically, this is used for image src calls from the html, so they route thru the
* CMSObjectCommandMapper and invoke the StreamObjectCommand.
*/
- public String buildURL(RenderResponse resp, String path)
+ public String buildURL(JBossRenderRequest req, String path)
{
StreamContentCommand cmd = new StreamContentCommand(path);
- PortletInvocation invocation = ((JBossRenderResponse)resp).getInvocation();
- ControllerPortletInvocationContext ccrc = (ControllerPortletInvocationContext)invocation.getContext();
- return ccrc.encodeURL(cmd, null, true);
+ ControllerContext cc = req.getControllerContext();
+ return cc.encodeURL(cmd, URLContext.newInstance(false, false), URLFormat.RELATIVE_ENC);
}
public void doHelp(RenderRequest req, RenderResponse resp) throws IOException, PortletException
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -38,9 +38,9 @@
import org.jboss.portal.cms.util.FileUtil;
import org.jboss.portal.cms.util.NodeUtil;
import org.jboss.portal.core.cms.StreamContentCommand;
-import org.jboss.portal.core.controller.portlet.ControllerPortletInvocationContext;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.server.request.URLFormat;
import org.jboss.portlet.JBossActionRequest;
import org.jboss.portlet.JBossActionResponse;
import org.jboss.portlet.JBossPortlet;
@@ -49,7 +49,6 @@
import javax.portlet.PortletException;
import javax.portlet.PortletSession;
-import javax.portlet.RenderResponse;
import javax.portlet.UnavailableException;
import java.io.IOException;
import java.io.InputStream;
@@ -264,7 +263,7 @@
rRes.setContentType("text/html");
rReq.setAttribute("currpath", sPath);
- rReq.setAttribute("document_base_url", sbUrl.toString() + this.buildURL(rRes, "/"));
+ rReq.setAttribute("document_base_url", sbUrl.toString() + this.buildURL(rReq, "/"));
javax.portlet.PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(CMSAdminConstants.CMS_JSP_PATH + "/create.jsp");
prd.include(rReq, rRes);
}
@@ -300,7 +299,7 @@
rRes.setContentType("text/html");
rReq.setAttribute("currpath", sPath);
- rReq.setAttribute("document_base_url", sbUrl.toString() + this.buildURL(rRes, "/"));
+ rReq.setAttribute("document_base_url", sbUrl.toString() + this.buildURL(rReq, "/"));
Command getCommand;
@@ -872,12 +871,10 @@
* <p/>
* TODO : need to make this not a hack
*/
- public String buildURL(RenderResponse resp, String path)
+ public String buildURL(JBossRenderRequest req, String path)
{
StreamContentCommand cmd = new StreamContentCommand(path);
- PortletInvocation invocation = ((JBossRenderResponse)resp).getInvocation();
- ControllerPortletInvocationContext ccrc = (ControllerPortletInvocationContext)invocation.getContext();
- String url = ccrc.encodeURL(cmd, URLContext.newInstance(false, false), true);
- return url;
+ ControllerContext cc = req.getControllerContext();
+ return cc.encodeURL(cmd, URLContext.newInstance(false, false), URLFormat.RELATIVE_ENC);
}
}
\ No newline at end of file
Added: trunk/core/src/main/org/jboss/portal/core/ui/configurator/ConfiguratorCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ui/configurator/ConfiguratorCommandFactory.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portal/core/ui/configurator/ConfiguratorCommandFactory.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.ui.configurator;
+
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
+import org.jboss.portal.portlet.PortletRequestDecoder;
+import org.jboss.portal.server.ServerInvocation;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ConfiguratorCommandFactory extends AbstractCommandFactory
+{
+
+ public ControllerCommand doMapping(ServerInvocation invocation, String portalContextPath, String portalRequestPath)
+ {
+ PortletRequestDecoder decoder = new PortletRequestDecoder();
+ decoder.decode(invocation.getServerContext().getQueryParameterMap(), invocation.getServerContext().getBodyParameterMap());
+ switch (decoder.getType())
+ {
+ case PortletRequestDecoder.NAV_TYPE:
+ {
+ return createPortletNavCommand(decoder);
+ }
+ case PortletRequestDecoder.RENDER_TYPE:
+ {
+ return createPortletRenderCommand(decoder);
+ }
+ case PortletRequestDecoder.ACTION_TYPE:
+ {
+ return createPortletActionCommand(decoder);
+ }
+ }
+
+ //
+ return null;
+ }
+
+ /**
+ *
+ */
+ public ControllerCommand createPortletActionCommand(PortletRequestDecoder decoder)
+ {
+ return null;
+ }
+
+ /**
+ *
+ */
+ protected ControllerCommand createPortletRenderCommand(PortletRequestDecoder decoder)
+ {
+ return null;
+ }
+
+ /**
+ *
+ */
+ protected ControllerCommand createPortletNavCommand(PortletRequestDecoder decoder)
+ {
+ return null;
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/ui/configurator/RenderPortletCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ui/configurator/RenderPortletCommand.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portal/core/ui/configurator/RenderPortletCommand.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.ui.configurator;
+
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.portlet.StateString;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RenderPortletCommand extends ControllerCommand
+{
+
+ /** The instance id. */
+ private String instanceId;
+
+ /** The navigational state. */
+ private StateString navigationalState;
+
+ /** The instance displayed. */
+ private Instance instance;
+
+ public RenderPortletCommand(String instanceId, StateString navigationalState)
+ {
+ this.instanceId = instanceId;
+ this.navigationalState = navigationalState;
+ }
+
+ public RenderPortletCommand(StateString navigationalState)
+ {
+ this.navigationalState = navigationalState;
+ }
+
+ protected void create() throws ControllerException
+ {
+ InstanceContainer container = context.getController().getInstanceContainer();
+ instance = container.getInstance(instanceId);
+
+ //
+ if (instance == null)
+ {
+ // Do smth clever
+ }
+ }
+
+ public CommandInfo getInfo()
+ {
+ return null;
+ }
+
+ public Object execute() throws ControllerException
+ {
+// ControllerRenderContext ctx = new ControllerRenderContext(
+// context,
+// context.getServerInvocation().getServerContext(),
+// );
+
+
+ return null;
+ }
+}
Modified: trunk/core/src/main/org/jboss/portlet/JBossActionRequest.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossActionRequest.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portlet/JBossActionRequest.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -25,9 +25,11 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.core.aspects.controller.node.Navigation;
import org.jboss.portal.core.controller.portlet.ControllerUserContext;
+import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.impl.jsr168.ActionRequestImpl;
import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portlet.util.Parameters;
import javax.portlet.PortletPreferences;
@@ -43,21 +45,30 @@
/** The parameters. */
private Parameters blah;
+ /** . */
+ private ControllerContext controllerContext;
+
public JBossActionRequest(ActionInvocation invocation)
{
super(invocation);
+
+ //
+ this.controllerContext = (ControllerContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, "controller_context");
this.blah = null;
}
- public PortalNode getPortalNode()
+ public ControllerContext getControllerContext()
{
- return Navigation.getCurrentNode();
+ if (controllerContext == null)
+ {
+ throw new IllegalStateException("No controller context");
+ }
+ return controllerContext;
}
- /** Returns a modifiable map of user informations or null if the user is not authenticated. */
- public Map getInformations()
+ public PortalNode getPortalNode()
{
- return userContext.getInformations();
+ return Navigation.getCurrentNode();
}
/** Returns the current authenticated user or null if the user is not authenticated */
Modified: trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -28,9 +28,11 @@
import org.jboss.portal.core.aspects.controller.node.PortalNodeURLFactory;
import org.jboss.portal.core.aspects.controller.node.PortalObjectNode;
import org.jboss.portal.core.controller.portlet.SignOutResponse;
+import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.portlet.impl.jsr168.ActionResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletRequestImpl;
import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
import javax.portlet.PortletRequest;
@@ -41,9 +43,15 @@
public class JBossActionResponse extends ActionResponseImpl
{
+ /** . */
+ private ControllerContext controllerContext;
+
public JBossActionResponse(ActionInvocation invocation, PortletRequestImpl preq)
{
super(invocation, preq);
+
+ //
+ this.controllerContext = (ControllerContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, "controller_context");
}
// /**
@@ -85,11 +93,15 @@
//*/
// }
- public PortalNodeURL createActionURL(PortalNode node) throws IllegalArgumentException
+ public PortalNodeURL createActionURL(PortalNode node) throws IllegalArgumentException, IllegalStateException
{
+ if (controllerContext == null)
+ {
+ throw new IllegalStateException("Not in a controller context");
+ }
if (node instanceof PortalObjectNode)
{
- return PortalNodeURLFactory.createActionURL((PortalObjectNode)node, invocation);
+ return PortalNodeURLFactory.createActionURL((PortalObjectNode)node, controllerContext);
}
else
{
@@ -97,11 +109,15 @@
}
}
- public PortalNodeURL createRenderURL(PortalNode node) throws IllegalArgumentException
+ public PortalNodeURL createRenderURL(PortalNode node) throws IllegalArgumentException, IllegalStateException
{
+ if (controllerContext == null)
+ {
+ throw new IllegalStateException("Not in a controller context");
+ }
if (node instanceof PortalObjectNode)
{
- return PortalNodeURLFactory.createRenderURL((PortalObjectNode)node, invocation);
+ return PortalNodeURLFactory.createRenderURL((PortalObjectNode)node, controllerContext);
}
else
{
Modified: trunk/core/src/main/org/jboss/portlet/JBossRenderRequest.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossRenderRequest.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portlet/JBossRenderRequest.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -25,9 +25,11 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.core.aspects.controller.node.Navigation;
import org.jboss.portal.core.controller.portlet.ControllerUserContext;
+import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.impl.jsr168.RenderRequestImpl;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portlet.util.Parameters;
import javax.portlet.PortletPreferences;
@@ -44,11 +46,26 @@
/** The parameters. */
private Parameters blah;
+ /** . */
+ private ControllerContext controllerContext;
+
public JBossRenderRequest(RenderInvocation invocation)
{
super(invocation);
+
+ //
+ this.controllerContext = (ControllerContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, "controller_context");
}
+ public ControllerContext getControllerContext()
+ {
+ if (controllerContext == null)
+ {
+ throw new IllegalStateException("No controller context");
+ }
+ return controllerContext;
+ }
+
// protected PortletPreferences createPreferences()
// {
// CorePortletContainer container = (CorePortletContainer) portletInstance.getPortletContainer();
Modified: trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -26,6 +26,7 @@
import org.jboss.portal.api.node.PortalNodeURL;
import org.jboss.portal.core.aspects.controller.node.PortalNodeURLFactory;
import org.jboss.portal.core.aspects.controller.node.PortalObjectNode;
+import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.portlet.impl.jsr168.PortletRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.RenderResponseImpl;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -38,16 +39,26 @@
public class JBossRenderResponse extends RenderResponseImpl
{
+ /** . */
+ private ControllerContext controllerContext;
+
public JBossRenderResponse(RenderInvocation invocation, PortletRequestImpl preq)
{
super(invocation, preq);
+
+ //
+ this.controllerContext = (ControllerContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE, "controller_context");
}
- public PortalNodeURL createActionURL(PortalNode node) throws IllegalArgumentException
+ public PortalNodeURL createActionURL(PortalNode node) throws IllegalArgumentException, IllegalStateException
{
+ if (controllerContext == null)
+ {
+ throw new IllegalStateException("Not in a controller context");
+ }
if (node instanceof PortalObjectNode)
{
- return PortalNodeURLFactory.createActionURL((PortalObjectNode)node, invocation);
+ return PortalNodeURLFactory.createActionURL((PortalObjectNode)node, controllerContext);
}
else
{
@@ -55,11 +66,15 @@
}
}
- public PortalNodeURL createRenderURL(PortalNode node) throws IllegalArgumentException
+ public PortalNodeURL createRenderURL(PortalNode node) throws IllegalArgumentException, IllegalStateException
{
+ if (controllerContext == null)
+ {
+ throw new IllegalStateException("Not in a controller context");
+ }
if (node instanceof PortalObjectNode)
{
- return PortalNodeURLFactory.createRenderURL((PortalObjectNode)node, invocation);
+ return PortalNodeURLFactory.createRenderURL((PortalObjectNode)node, controllerContext);
}
else
{
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderResponseImpl.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderResponseImpl.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderResponseImpl.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -56,10 +56,10 @@
public RenderResponseImpl(RenderInvocation invocation, PortletRequestImpl preq)
{
super(invocation, preq);
- this.result = new FragmentResponse();
// 0 means no buffering - we say no buffering
this.bufferSize = 0;
+ this.result = new FragmentResponse();
}
public PortletInvocationResponse getResult()
Added: trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractActionContext.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractActionContext.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractActionContext.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -0,0 +1,97 @@
+/******************************************************************************
+ * 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.impl.spi;
+
+import org.jboss.portal.portlet.spi.ActionContext;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.Parameters;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.server.util.HTTPStreamInfo;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractActionContext extends AbstractPortletInvocationContext implements ActionContext
+{
+
+ /** . */
+ protected StateString interactionState;
+
+ /** . */
+ protected Parameters form;
+
+
+ protected AbstractActionContext(
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ HTTPStreamInfo streamInfo,
+ StateString interactionState,
+ Parameters form)
+ {
+ super(mode, windowState, navigationalState, streamInfo);
+ this.interactionState = interactionState;
+ this.form = form;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return getClientRequest().getCharacterEncoding();
+ }
+
+ public BufferedReader getReader() throws IOException
+ {
+ return getClientRequest().getReader();
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ return getClientRequest().getInputStream();
+ }
+
+ public int getContentLength()
+ {
+ return getClientRequest().getContentLength();
+ }
+
+ public String getContentType()
+ {
+ return getClientRequest().getContentType();
+ }
+
+ public StateString getInteractionState()
+ {
+ return interactionState;
+ }
+
+ public Parameters getForm()
+ {
+ return form;
+ }
+}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractPortletInvocationContext.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractPortletInvocationContext.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractPortletInvocationContext.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -25,12 +25,16 @@
import org.jboss.portal.common.invocation.AbstractInvocationContext;
import org.jboss.portal.common.util.URLTools;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.server.util.HTTPStreamInfo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
- * An abstract implementation.
+ * An abstract implementation that relies on the a request and response provided by the client (i.e the portal).
*
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
* @version $Revision: 5064 $
@@ -38,16 +42,72 @@
public abstract class AbstractPortletInvocationContext extends AbstractInvocationContext implements PortletInvocationContext
{
- /** Return the client request. */
- public abstract HttpServletRequest getClientRequest();
+ /** . */
+ protected HTTPStreamInfo streamInfo;
- /** Return the client response. */
- public abstract HttpServletResponse getClientResponse();
+ /** . */
+ protected Mode mode;
- /** Validate the url and then delegate the encoding of the url to the client response. */
+ /** . */
+ protected WindowState windowState;
+
+ /** . */
+ protected StateString navigationalState;
+
+ protected AbstractPortletInvocationContext(Mode mode, WindowState windowState, StateString navigationalState, HTTPStreamInfo streamInfo)
+ {
+ this.mode = mode;
+ this.windowState = windowState;
+ this.navigationalState = navigationalState;
+ this.streamInfo = streamInfo;
+ }
+
+ /**
+ * Return the client request.
+ *
+ * @return the client request
+ * @throws IllegalStateException if the client response is not available
+ */
+ public abstract HttpServletRequest getClientRequest() throws IllegalStateException;
+
+ /**
+ * Return the client response.
+ *
+ * @return the client response
+ * @throws IllegalStateException if the client response is not available
+ */
+ public abstract HttpServletResponse getClientResponse() throws IllegalStateException;
+
+ /**
+ * Validate the url and then delegate the encoding of the url to the client response.
+ *
+ * @return the encoded url
+ */
public String encodeURL(String url) throws IllegalArgumentException
{
URLTools.enforceAbsoluteURL(url);
+
+ //
return getClientResponse().encodeURL(url);
}
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+
+ public StateString getNavigationalState()
+ {
+ return navigationalState;
+ }
+
+ public HTTPStreamInfo getStreamInfo()
+ {
+ return streamInfo;
+ }
}
Added: trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractRenderContext.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractRenderContext.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/spi/AbstractRenderContext.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * 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.impl.spi;
+
+import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.server.util.HTTPStreamInfo;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractRenderContext extends AbstractPortletInvocationContext implements RenderContext
+{
+ protected AbstractRenderContext(
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ HTTPStreamInfo streamInfo)
+ {
+ super(mode, windowState, navigationalState, streamInfo);
+ }
+}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/invocation/PortletInvocation.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/invocation/PortletInvocation.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/invocation/PortletInvocation.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -107,13 +107,19 @@
/** The invocation context. */
protected PortletInvocationContext ctx;
- /** Create an invocation to a portlet. */
- protected PortletInvocation(PortletInvocationContext ctx)
+ /**
+ * Create an invocation to a portlet.
+ *
+ * @param ctx the portlet invocation context
+ */
+ protected PortletInvocation(PortletInvocationContext ctx) throws IllegalArgumentException
{
if (ctx == null)
{
throw new IllegalArgumentException();
}
+
+ //
this.ctx = ctx;
}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -71,7 +71,6 @@
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.impl.MapAttributeResolver;
import org.jboss.portal.server.request.URLFormat;
-import org.jboss.portal.server.util.HTTPStreamInfo;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -577,12 +576,8 @@
{
protected Portlet portlet;
- protected StateString navigationalState;
protected ServerInvocation invocation;
- protected WindowState windowState;
- protected Mode mode;
-
public PortletInvocationContextImpl(
Portlet portlet,
ServerInvocation invocation,
@@ -590,12 +585,10 @@
WindowState windowState,
Mode mode)
{
- this.portlet = portlet;
- this.navigationalState = navigationalState;
- this.windowState = windowState;
- this.mode = mode;
+ super(mode, windowState, navigationalState, invocation.getResponse().getStreamInfo());
//
+ this.portlet = portlet;
this.invocation = invocation;
//
@@ -615,26 +608,6 @@
return invocation.getServerContext().getClientRequest();
}
- public Mode getMode()
- {
- return mode;
- }
-
- public WindowState getWindowState()
- {
- return windowState;
- }
-
- public StateString getNavigationalState()
- {
- return navigationalState;
- }
-
- public HTTPStreamInfo getStreamInfo()
- {
- return invocation.getResponse().getStreamInfo();
- }
-
public String encodeURL(String url)
{
URLTools.enforceAbsoluteURL(url);
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/TestPortletInvocationContext.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/TestPortletInvocationContext.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/TestPortletInvocationContext.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -54,14 +54,18 @@
public class TestPortletInvocationContext extends AbstractPortletInvocationContext
implements PortletInvocationContext, RenderContext, ActionContext
{
- private String ns;
+
private HttpServletRequest mockRequest;
private HttpServletResponse mockResponse;
- private Mode mode;
- private WindowState state;
public TestPortletInvocationContext(Mode mode, WindowState state, String ns)
{
+ super(
+ mode != null ? mode : Mode.VIEW,
+ state != null ? state : WindowState.MAXIMIZED,
+ StateString.createFrom(ns),
+ new HTTPStreamInfo(MediaType.HTML, WSRPConstants.DEFAULT_CHARACTER_SET));
+
ClassLoader classLoader = getClass().getClassLoader();
HttpSession session = (HttpSession)Proxy.newProxyInstance(classLoader, new Class[]{HttpSession.class},
new MockHttpSession());
@@ -71,10 +75,6 @@
new MockHttpServletResponse());
addResolver(PortletInvocation.REQUEST_SCOPE, new RequestAttributeResolver(mockRequest));
-
- this.mode = (mode != null ? mode : Mode.VIEW);
- this.state = (state != null ? state : WindowState.MAXIMIZED);
- this.ns = ns;
}
public void setMockRequest(HttpServletRequest mockRequest)
@@ -87,33 +87,21 @@
this.mockResponse = mockResponse;
}
- public StateString getNavigationalState()
- {
- return StateString.createFrom(ns);
- }
-
- public Mode getMode()
- {
- return mode;
- }
-
- public WindowState getWindowState()
- {
- return state;
- }
-
- public HTTPStreamInfo getStreamInfo()
- {
- return new HTTPStreamInfo(MediaType.HTML, WSRPConstants.DEFAULT_CHARACTER_SET);
- }
-
public HttpServletRequest getClientRequest()
{
+ if (mockRequest == null)
+ {
+ throw new IllegalStateException();
+ }
return mockRequest;
}
public HttpServletResponse getClientResponse()
{
+ if (mockResponse == null)
+ {
+ throw new IllegalStateException();
+ }
return mockResponse;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/invocation/WSRPPortletInvocationContext.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/invocation/WSRPPortletInvocationContext.java 2006-11-07 20:41:02 UTC (rev 5596)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/invocation/WSRPPortletInvocationContext.java 2006-11-07 22:16:29 UTC (rev 5597)
@@ -55,21 +55,18 @@
{
protected RequestContext requestContext;
- private StateString navigationalState;
private SecurityContext securityContext;
- private HTTPStreamInfo streamInfo;
private PortalContext portalContext;
private UserContext userContext;
private InstanceContext instanceContext;
- private WindowState windowState;
- private Mode mode;
private WindowContext windowContext;
public WSRPPortletInvocationContext(StateString navigationalState, SecurityContext securityContext,
HTTPStreamInfo streamInfo, PortalContext portalContext, UserContext userContext,
InstanceContext instanceContext, WindowContext windowContext, Mode mode, WindowState windowState)
{
- this.navigationalState = navigationalState;
+ super(mode, windowState, navigationalState, streamInfo);
+
this.securityContext = securityContext;
this.streamInfo = streamInfo;
this.portalContext = portalContext;
@@ -77,8 +74,6 @@
this.instanceContext = instanceContext;
this.windowContext = windowContext;
this.requestContext = new WSRPRequestContext();
- this.mode = mode;
- this.windowState = windowState;
//
addResolver(PortletInvocation.REQUEST_SCOPE, new RequestAttributeResolver(ServletAccess.getRequest()));
@@ -96,26 +91,6 @@
return ServletAccess.getResponse();
}
- public StateString getNavigationalState()
- {
- return navigationalState;
- }
-
- public Mode getMode()
- {
- return mode;
- }
-
- public WindowState getWindowState()
- {
- return windowState;
- }
-
- public HTTPStreamInfo getStreamInfo()
- {
- return streamInfo;
- }
-
/** Override the default behavior in order to avoid to encode when it is producer written URL. */
public String encodeURL(String url)
{
More information about the jboss-svn-commits
mailing list