Author: julien(a)jboss.com
Date: 2007-04-08 13:24:01 -0400 (Sun, 08 Apr 2007)
New Revision: 6959
Added:
trunk/core/src/main/org/jboss/portal/core/controller/ControllerResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandlerException.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ThrowableResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/command/response/ThrowableResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/handler/
trunk/core/src/main/org/jboss/portal/core/controller/handler/AbstractResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/handler/AjaxResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/handler/CommandForward.java
trunk/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/handler/HandlerResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/handler/ResponseForward.java
trunk/core/src/main/org/jboss/portal/core/controller/handler/ResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/theme/
trunk/core/src/main/org/jboss/portal/core/theme/PageRendition.java
trunk/core/src/main/org/jboss/portal/core/theme/WindowRendition.java
Removed:
trunk/core/src/main/org/jboss/portal/core/controller/AjaxResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/CommandForward.java
trunk/core/src/main/org/jboss/portal/core/controller/HTTPResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/HandlerResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/AbstractResponseHandler.java
trunk/theme/src/main/org/jboss/portal/theme/page/PageRendition.java
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/default-object.xml
trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PolicyEnforcementInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
trunk/core/src/main/org/jboss/portal/core/controller/ControllerCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
trunk/core/src/main/org/jboss/portal/core/controller/ControllerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandlerSelector.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/response/SignOutResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
trunk/core/src/main/org/jboss/portal/core/model/instance/PortletInstanceResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/model/instance/command/action/InvokePortletInstanceActionCommand.java
trunk/core/src/main/org/jboss/portal/core/model/instance/command/action/InvokePortletInstanceRenderCommand.java
trunk/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java
trunk/core/src/main/org/jboss/portal/core/model/instance/command/response/UpdatePortletInstanceResponse.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/ImportPageToDashboardCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/MoveWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdatePageResponse.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowResponse.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewDashboardCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPageCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java
Log:
update command response stuff to handle throwable as any other kind of response allowing a
more flexible handling of exceptions
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -25,6 +25,7 @@
import org.jboss.portal.core.controller.ControllerInterceptor;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
import org.jboss.portal.common.invocation.InvocationException;
@@ -36,9 +37,9 @@
*/
public class NavigationalStateInterceptor extends ControllerInterceptor
{
- public Object invoke(ControllerCommand cmd) throws Exception, InvocationException
+ public ControllerResponse invoke(ControllerCommand cmd) throws Exception,
InvocationException
{
- Object ret = cmd.invokeNext();
+ ControllerResponse ret = (ControllerResponse)cmd.invokeNext();
// We commit the nav state changes only for the classic controller at the base of
the pipeline
ControllerContext controllerContext = cmd.getControllerContext();
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -29,6 +29,7 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerInterceptor;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.command.SignOutCommand;
import org.jboss.portal.core.impl.model.portal.PortalObjectImpl;
import org.jboss.portal.core.model.CustomizationManager;
@@ -44,12 +45,12 @@
import org.jboss.portal.core.model.portal.command.render.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.view.ViewDashboardCommand;
import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
+import org.jboss.portal.core.theme.PageRendition;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.security.PortalSecurityException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.theme.page.PageRendition;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
import org.jboss.portal.theme.page.Region;
@@ -101,9 +102,9 @@
this.portalAuthorizationManagerFactory = portalAuthorizationManagerFactory;
}
- public Object invoke(ControllerCommand cmd) throws Exception
+ public ControllerResponse invoke(ControllerCommand cmd) throws Exception
{
- Object resp = cmd.invokeNext();
+ ControllerResponse resp = (ControllerResponse)cmd.invokeNext();
// Insert navigation portlet in the page
if (resp instanceof PageRendition)
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PolicyEnforcementInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PolicyEnforcementInterceptor.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PolicyEnforcementInterceptor.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -28,6 +28,7 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerInterceptor;
import org.jboss.portal.core.controller.ControllerSecurityException;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.security.PortalSecurityException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
@@ -58,14 +59,14 @@
* @throws org.jboss.portal.common.invocation.InvocationException
*
*/
- public Object invoke(ControllerCommand cmd) throws Exception, InvocationException
+ public ControllerResponse invoke(ControllerCommand cmd) throws Exception,
InvocationException
{
try
{
PortalAuthorizationManagerFactory pamf =
cmd.getControllerContext().getController().getPortalAuthorizationManagerFactory();
PortalAuthorizationManager pam = pamf.getManager();
cmd.enforceSecurity(pam);
- return cmd.invokeNext();
+ return (ControllerResponse)cmd.invokeNext();
}
catch (PortalSecurityException e)
{
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -39,6 +39,7 @@
import org.jboss.portal.core.controller.CommandRedirectionException;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerInterceptor;
+import org.jboss.portal.core.controller.ControllerResponse;
import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowActionCommand;
import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
import org.jboss.portal.core.model.portal.command.WindowCommand;
@@ -73,7 +74,7 @@
this.listenerRegistry = listenerRegistry;
}
- public Object invoke(ControllerCommand cmd) throws Exception, InvocationException
+ public ControllerResponse invoke(ControllerCommand cmd) throws Exception,
InvocationException
{
PortalObjectNode node = Navigation.getCurrentNode();
@@ -184,7 +185,7 @@
}
else
{
- return cmd.invokeNext();
+ return (ControllerResponse)cmd.invokeNext();
}
}
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeInterceptor.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeInterceptor.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -25,6 +25,7 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerInterceptor;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.model.portal.command.render.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.WindowCommand;
import org.jboss.portal.core.model.portal.Page;
@@ -37,7 +38,7 @@
public class PortalNodeInterceptor extends ControllerInterceptor
{
- public Object invoke(ControllerCommand cmd) throws Exception, InvocationException
+ public ControllerResponse invoke(ControllerCommand cmd) throws Exception,
InvocationException
{
// Get the next node
PortalObjectNode next = getNode(cmd);
@@ -51,7 +52,7 @@
Navigation.setCurrentNode(next);
// Invoke
- return cmd.invokeNext();
+ return (ControllerResponse)cmd.invokeNext();
}
finally
{
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/AjaxResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/AjaxResponse.java 2007-04-08
14:22:53 UTC (rev 6958)
+++ trunk/core/src/main/org/jboss/portal/core/controller/AjaxResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -1,58 +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;
-
-import org.jboss.portal.core.controller.HandlerResponse;
-import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
-import org.jboss.portal.theme.impl.render.dynamic.JSONMarshaller;
-import org.jboss.portal.server.ServerInvocationContext;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class AjaxResponse extends HandlerResponse
-{
-
- /** . */
- private static final JSONMarshaller marshaller = new JSONMarshaller();
-
- /** The response to the client. */
- private final DynaResponse dynaResponse;
-
- public AjaxResponse(DynaResponse dynaResponse)
- {
- this.dynaResponse = dynaResponse;
- }
-
- public void sendResponse(ServerInvocationContext ctx) throws IOException,
ServletException
- {
- HttpServletResponse resp = ctx.getClientResponse();
- resp.setContentType("text/html");
- marshaller.write(dynaResponse, resp.getWriter());
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/CommandForward.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/CommandForward.java 2007-04-08
14:22:53 UTC (rev 6958)
+++ trunk/core/src/main/org/jboss/portal/core/controller/CommandForward.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -1,61 +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;
-
-import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.core.controller.ControllerCommand;
-
-/**
- * Forward to a new command.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class CommandForward extends HandlerResponse
-{
- /** . */
- private final ControllerCommand cmd;
-
- /** . */
- private final URLContext urlCtx;
-
- public CommandForward(ControllerCommand cmd, URLContext urlCtx)
- {
- if (cmd == null)
- {
- throw new IllegalArgumentException("No command provided");
- }
- this.cmd = cmd;
- this.urlCtx = urlCtx;
- }
-
- public ControllerCommand getCommand()
- {
- return cmd;
- }
-
- public URLContext getURLContext()
- {
- return urlCtx;
- }
-}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2007-04-08
14:22:53 UTC (rev 6958)
+++ trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -25,6 +25,13 @@
import org.jboss.portal.theme.PageService;
import org.jboss.portal.core.controller.command.mapper.CommandFactory;
import org.jboss.portal.core.controller.command.mapper.URLFactory;
+import org.jboss.portal.core.controller.command.response.ThrowableResponse;
+import org.jboss.portal.core.controller.handler.HandlerResponse;
+import org.jboss.portal.core.controller.handler.ResponseForward;
+import org.jboss.portal.core.controller.handler.HTTPResponse;
+import org.jboss.portal.core.controller.handler.CommandForward;
+import org.jboss.portal.core.controller.handler.ResponseHandler;
+import org.jboss.portal.core.controller.handler.AjaxResponse;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.content.ContentRendererRegistry;
import org.jboss.portal.core.model.instance.InstanceContainer;
@@ -35,12 +42,8 @@
import org.jboss.portal.server.RequestController;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerException;
-import org.jboss.portal.server.ServerURL;
-import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.web.spi.ServletContainerContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
@@ -213,85 +216,100 @@
* Handle a command which means it executes the command and reacts upon the response
created by the command.
*
* @param controllerContext the controller context
- * @param cmd the command
+ * @param command the command
* @throws org.jboss.portal.server.ServerException
*/
- protected void processCommand(ControllerContext controllerContext, ControllerCommand
cmd) throws ServerException
+ protected void processCommand(ControllerContext controllerContext, ControllerCommand
command) throws ServerException
{
- HandlerResponse handlerResp = executeCommand(controllerContext, cmd);
+ ControllerResponse response = executeCommand(controllerContext, command);
//
- if (handlerResp == null)
+ if (response == null)
{
return;
}
+ if (response instanceof ThrowableResponse)
+ {
+ ThrowableResponse throwableResponse = (ThrowableResponse)response;
+ Throwable t = throwableResponse.getThrowable();
- // Find out if we can execute in the same server invocation
- if (handlerResp instanceof CommandForward)
+ // Handle the special exception here
+ if (t instanceof CommandRedirectionException)
+ {
+ CommandRedirectionException commandRedirection =
(CommandRedirectionException)t;
+ processHandlerResponse(
+ controllerContext,
+ command,
+ new CommandForward(commandRedirection.getRedirection(), null));
+ }
+ }
+
+ //
+ processCommandResponse(controllerContext, command, response);
+ }
+
+ protected void processCommandResponse(
+ ControllerContext controllerContext,
+ ControllerCommand command,
+ ControllerResponse response) throws ServerException
+ {
+ // Handle the result
+ HandlerResponse handlerResponse;
+ try
{
- CommandForward forward = (CommandForward)handlerResp;
- processCommand(controllerContext, forward.getCommand());
+ handlerResponse = responseHandler.processCommandResponse(controllerContext,
command, response);
}
- else if (handlerResp instanceof HTTPResponse)
+ catch (ResponseHandlerException e)
{
- HTTPResponse hr = (HTTPResponse)handlerResp;
- sendResponse(controllerContext, hr);
+ throw new ServerException(e);
}
- else if (handlerResp instanceof AjaxResponse)
+
+ // Might be null if no handling done
+ if (handlerResponse == null)
{
- AjaxResponse ar = (AjaxResponse)handlerResp;
- sendResponse(controllerContext, ar);
+ return;
}
+
+ //
+ processHandlerResponse(controllerContext, command, handlerResponse);
}
- protected HandlerResponse executeCommand(ControllerContext controllerContext,
ControllerCommand command) throws ServerException
+ protected void processHandlerResponse(ControllerContext controllerContext,
ControllerCommand command, HandlerResponse handlerResponse) throws ServerException
{
- URLContext urlContext =
controllerContext.getServerInvocation().getServerContext().getURLContext();
-
- try
+ // Find out if we can execute in the same server invocation
+ if (handlerResponse instanceof CommandForward)
{
- // Execute command
- Object commandResponse = controllerContext.execute(command);
-
- // Handle the result, might be null if no handling done
- return responseHandler.processCommandResponse(controllerContext, command,
commandResponse);
+ CommandForward forward = (CommandForward)handlerResponse;
+ processCommand(controllerContext, forward.getCommand());
}
- catch (CommandRedirectionException e)
+ else if (handlerResponse instanceof ResponseForward)
{
- // Handle the redirection as forward
- return new CommandForward(e.getRedirection(), null);
+ ResponseForward forward = (ResponseForward)handlerResponse;
+ ControllerResponse response = forward.getResponse();
+ processCommandResponse(controllerContext, command, response);
}
- catch (ControllerSecurityException e)
+ else if (handlerResponse instanceof HTTPResponse)
{
- if (urlContext.isAuthenticated())
- {
- return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_UNAUTHORIZED);
- }
- else
- {
- urlContext = URLContext.newInstance(urlContext.isSecure(), true);
- ServerURL serverURL =
getURLFactory().doMapping(controllerContext.getServerInvocation(), command);
- String url =
controllerContext.getServerInvocation().getResponse().renderURL(serverURL, urlContext,
null);
- return new HTTPResponse.SendRedirect(url);
- }
+ HTTPResponse hr = (HTTPResponse)handlerResponse;
+ sendResponse(controllerContext, hr);
}
- catch (ResourceNotFoundException e)
+ else if (handlerResponse instanceof AjaxResponse)
{
- log.error("Resource not found " + e.getRef(), e);
- return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_NOT_FOUND);
+ AjaxResponse ar = (AjaxResponse)handlerResponse;
+ sendResponse(controllerContext, ar);
}
- catch (ControllerException e)
+ }
+
+ protected ControllerResponse executeCommand(ControllerContext controllerContext,
ControllerCommand command)
+ {
+ try
{
- throw new ServerException(e);
+ return controllerContext.execute(command);
}
- catch (ServletException e)
+ catch (Throwable t)
{
- throw new ServerException(e);
+ return new ThrowableResponse(t);
}
- catch (IOException e)
- {
- throw new ServerException(e);
- }
}
/**
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ControllerCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ControllerCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -133,7 +133,7 @@
}
/** Execute the command. */
- public abstract Object execute() throws ControllerException;
+ public abstract ControllerResponse execute() throws ControllerException;
public static void rethrow(Exception e) throws ControllerException,
InvocationException, RuntimeException
{
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-04-08
14:22:53 UTC (rev 6958)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -32,7 +32,6 @@
import org.jboss.portal.identity.User;
import org.jboss.portal.core.aspects.server.UserInterceptor;
import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
-import org.jboss.portal.core.CoreConstants;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@@ -97,7 +96,7 @@
addResolver(ControllerCommand.PRINCIPAL_SCOPE, serverInvocation.getContext());
}
- public Object execute(ControllerCommand command) throws ControllerException,
InvocationException
+ public ControllerResponse execute(ControllerCommand command) throws
ControllerException, InvocationException
{
if (command == null)
{
@@ -119,7 +118,7 @@
InterceptorStack commandStack =
controller.getStackFactory().getInterceptorStack();
//
- return command.invoke(commandStack);
+ return (ControllerResponse)command.invoke(commandStack);
}
catch (Exception e)
{
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ControllerInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/ControllerInterceptor.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ControllerInterceptor.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -38,5 +38,5 @@
return invoke((ControllerCommand)invocation);
}
- public abstract Object invoke(ControllerCommand cmd) throws Exception,
InvocationException;
+ public abstract ControllerResponse invoke(ControllerCommand cmd) throws Exception,
InvocationException;
}
Added: trunk/core/src/main/org/jboss/portal/core/controller/ControllerResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerResponse.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ControllerResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ControllerResponse
+{
+}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/HTTPResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/HTTPResponse.java 2007-04-08
14:22:53 UTC (rev 6958)
+++ trunk/core/src/main/org/jboss/portal/core/controller/HTTPResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -1,119 +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;
-
-import org.jboss.portal.server.ServerInvocationContext;
-import org.jboss.portal.common.util.Tools;
-
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.ServletException;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Response that sends a response to the http stream.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class HTTPResponse extends HandlerResponse
-{
-
- public abstract void sendResponse(ServerInvocationContext ctx) throws IOException,
ServletException;
-
- public static class SetStatusCode extends HTTPResponse
- {
-
- /** . */
- private final int statusCode;
-
- public SetStatusCode(int statusCode)
- {
- this.statusCode = statusCode;
- }
-
- public void sendResponse(ServerInvocationContext ctx) throws IOException
- {
- HttpServletResponse resp = ctx.getClientResponse();
- resp.sendError(statusCode);
- }
- }
-
- public static class SendRedirect extends HTTPResponse
- {
-
- /** . */
- private final String redirect;
-
- public SendRedirect(String redirect)
- {
- this.redirect = redirect;
- }
-
- public void sendResponse(ServerInvocationContext ctx) throws IOException
- {
- HttpServletResponse resp = ctx.getClientResponse();
- resp.sendRedirect(redirect);
- }
- }
-
- public static class SendBinary extends HTTPResponse
- {
-
- /** . */
- private final String contentType;
-
- /** . */
- private final InputStream in;
-
- public SendBinary(String contentType, InputStream inputStream)
- {
- this.contentType = contentType;
- this.in = inputStream;
- }
-
- public void sendResponse(ServerInvocationContext ctx) throws IOException
- {
- HttpServletResponse resp = ctx.getClientResponse();
- resp.setContentType(contentType);
- ServletOutputStream sout = null;
- try
- {
- sout = resp.getOutputStream();
- byte[] buf = new byte[2048];
- int len;
- while ((len = in.read(buf)) > 0)
- {
- sout.write(buf, 0, len);
- }
- sout.flush();
- }
- finally
- {
- Tools.safeClose(in);
- Tools.safeClose(sout);
- }
- }
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/HandlerResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/HandlerResponse.java 2007-04-08
14:22:53 UTC (rev 6958)
+++ trunk/core/src/main/org/jboss/portal/core/controller/HandlerResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -1,33 +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;
-
-/**
- * The response from a a response handler.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class HandlerResponse
-{
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandler.java 2007-04-08
14:22:53 UTC (rev 6958)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandler.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -1,39 +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;
-
-import org.jboss.portal.server.ServerException;
-import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.ControllerContext;
-
-import javax.servlet.ServletException;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface ResponseHandler
-{
- public HandlerResponse processCommandResponse(ControllerContext controllerContext,
ControllerCommand command, Object commandResponse) throws IOException, ServletException,
ServerException;
-}
Added: trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandlerException.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandlerException.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandlerException.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ResponseHandlerException extends Exception
+{
+ public ResponseHandlerException()
+ {
+ }
+
+ public ResponseHandlerException(String message)
+ {
+ super(message);
+ }
+
+ public ResponseHandlerException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public ResponseHandlerException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandlerSelector.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandlerSelector.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandlerSelector.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -22,12 +22,9 @@
******************************************************************************/
package org.jboss.portal.core.controller;
-import org.jboss.portal.server.ServerException;
+import org.jboss.portal.core.controller.handler.ResponseHandler;
+import org.jboss.portal.core.controller.handler.HandlerResponse;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -61,15 +58,15 @@
this.ajaxResponseHandler = ajaxResponseHandler;
}
- public HandlerResponse processCommandResponse(ControllerContext controllerContext,
ControllerCommand command, Object commandResponse) throws IOException, ServletException,
ServerException
+ public HandlerResponse processCommandResponse(ControllerContext controllerContext,
ControllerCommand command, ControllerResponse response) throws ResponseHandlerException
{
if (ControllerContext.AJAX_TYPE == controllerContext.getType())
{
- return ajaxResponseHandler.processCommandResponse(controllerContext, command,
commandResponse);
+ return ajaxResponseHandler.processCommandResponse(controllerContext, command,
response);
}
else
{
- return classicResponseHandler.processCommandResponse(controllerContext, command,
commandResponse);
+ return classicResponseHandler.processCommandResponse(controllerContext, command,
response);
}
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -26,9 +26,10 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerInterceptor;
import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.model.portal.command.render.RenderPageCommand;
import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
-import org.jboss.portal.theme.page.PageRendition;
+import org.jboss.portal.core.theme.PageRendition;
import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
import org.jboss.portal.server.ServerURL;
@@ -48,9 +49,9 @@
/** . */
private static final DynaRenderOptions AJAX_OPTIONS =
DynaRenderOptions.getOptions(Boolean.TRUE, Boolean.TRUE);
- public Object invoke(ControllerCommand cmd) throws Exception, InvocationException
+ public ControllerResponse invoke(ControllerCommand cmd) throws Exception,
InvocationException
{
- Object response = cmd.invokeNext();
+ ControllerResponse response = (ControllerResponse)cmd.invokeNext();
// Configure ajax if needed
if (response instanceof PageRendition)
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -22,17 +22,18 @@
******************************************************************************/
package org.jboss.portal.core.controller.ajax;
-import org.jboss.portal.core.controller.ResponseHandler;
-import org.jboss.portal.core.controller.HandlerResponse;
+import org.jboss.portal.core.controller.handler.ResponseHandler;
+import org.jboss.portal.core.controller.handler.HandlerResponse;
+import org.jboss.portal.core.controller.handler.AjaxResponse;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.CommandForward;
-import org.jboss.portal.core.controller.AjaxResponse;
+import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.ResponseHandlerException;
+import org.jboss.portal.core.controller.handler.CommandForward;
import org.jboss.portal.core.controller.portlet.PortletResponseHandler;
import org.jboss.portal.core.model.portal.command.response.PortletWindowResponse;
import org.jboss.portal.core.model.portal.command.response.UpdateWindowResponse;
import org.jboss.portal.core.model.portal.command.response.UpdatePageResponse;
-import org.jboss.portal.core.model.portal.command.PortalObjectCommand;
import org.jboss.portal.core.model.portal.command.render.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.render.RenderWindowCommand;
import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
@@ -47,7 +48,7 @@
import org.jboss.portal.core.ns.NavigationalStateChange;
import org.jboss.portal.core.ns.NavigationalStateObjectChange;
import org.jboss.portal.core.ns.NavigationalStateKey;
-import org.jboss.portal.server.ServerException;
+import org.jboss.portal.core.theme.WindowRendition;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.RenderResponse;
@@ -69,8 +70,6 @@
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.Region;
-import javax.servlet.ServletException;
-import java.io.IOException;
import java.io.StringWriter;
import java.util.Set;
import java.util.HashSet;
@@ -141,12 +140,12 @@
public HandlerResponse processCommandResponse(
ControllerContext controllerContext,
- ControllerCommand command,
- Object commandResponse) throws IOException, ServletException, ServerException
+ ControllerCommand commeand,
+ ControllerResponse response) throws ResponseHandlerException
{
- if (commandResponse instanceof PortletWindowResponse)
+ if (response instanceof PortletWindowResponse)
{
- PortletWindowResponse pwr = (PortletWindowResponse)commandResponse;
+ PortletWindowResponse pwr = (PortletWindowResponse)response;
PortletInvocationResponse pir = pwr.getResult();
if (pir instanceof RenderResponse)
{
@@ -166,27 +165,23 @@
}
else
{
- throw new Error("todo " + commandResponse);
+ throw new Error("todo " + response);
}
}
- else if (commandResponse instanceof UpdatePageResponse)
+ else if (response instanceof UpdatePageResponse)
{
- UpdatePageResponse upr = (UpdatePageResponse)commandResponse;
+ UpdatePageResponse upr = (UpdatePageResponse)response;
ViewPageCommand rpc = new ViewPageCommand(upr.getPageId());
String url = controllerContext.renderURL(rpc, null, null);
UpdatePageLocationResponse dresp = new UpdatePageLocationResponse(url);
return new AjaxResponse(dresp);
}
- else if (commandResponse instanceof UpdateWindowResponse)
+ else if (response instanceof UpdateWindowResponse)
{
- // We make an assumption here, the window result should carry somehow the window
id
- PortalObjectCommand pocmd = (PortalObjectCommand)command;
+ UpdateWindowResponse upw = (UpdateWindowResponse)response;
- //
- ServerInvocation invocation = controllerContext.getServerInvocation();
-
// Obtain page and portal
- final Window window =
(Window)portalObjectContainer.getObject(pocmd.getTargetId());
+ final Window window =
(Window)portalObjectContainer.getObject(upw.getWindowId());
Page page = (Page)window.getParent();
Portal portal = page.getPortal();
@@ -288,16 +283,20 @@
PageResult res = new PageResult(page.getName(), page.getProperties(),
portal.getProperties());
//
+ ServerInvocation invocation = controllerContext.getServerInvocation();
+
+ //
for (Iterator i = windowToRefresh.iterator();i.hasNext();)
{
final PortalObject _window = (PortalObject)i.next();
RenderWindowCommand rwc = new RenderWindowCommand(_window.getId());
try
{
- Object wresp = controllerContext.execute(rwc);
- if (wresp instanceof WindowResult)
+ ControllerResponse wresp = controllerContext.execute(rwc);
+ if (wresp instanceof WindowRendition)
{
- final WindowResult windowResult = (WindowResult)wresp;
+ WindowRendition rendition = (WindowRendition)wresp;
+ final WindowResult windowResult = rendition.getWindow();
//
WindowContext wc = new WindowContext(
Deleted:
trunk/core/src/main/org/jboss/portal/core/controller/classic/AbstractResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/classic/AbstractResponseHandler.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/AbstractResponseHandler.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -1,34 +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.classic;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.core.controller.ResponseHandler;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class AbstractResponseHandler extends AbstractJBossService implements
ResponseHandler
-{
-}
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -22,21 +22,23 @@
******************************************************************************/
package org.jboss.portal.core.controller.classic;
-import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.theme.page.PageRendition;
+import org.jboss.portal.core.theme.PageRendition;
import org.jboss.portal.core.controller.command.response.SignOutResponse;
import org.jboss.portal.core.controller.command.response.StreamContentResponse;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.core.controller.HTTPResponse;
-import org.jboss.portal.core.controller.HandlerResponse;
-import org.jboss.portal.core.controller.ResponseHandler;
-import org.jboss.portal.core.controller.CommandForward;
+import org.jboss.portal.core.controller.ResponseHandlerException;
+import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.handler.AbstractResponseHandler;
+import org.jboss.portal.core.controller.handler.HTTPResponse;
+import org.jboss.portal.core.controller.handler.HandlerResponse;
+import org.jboss.portal.core.controller.handler.ResponseHandler;
+import org.jboss.portal.core.controller.handler.CommandForward;
import org.jboss.portal.core.controller.portlet.PortletResponseHandler;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
@@ -62,15 +64,15 @@
public HandlerResponse processCommandResponse(
ControllerContext controllerContext,
ControllerCommand command,
- Object commandResponse) throws IOException, ServletException, ServerException
+ ControllerResponse commandResponse) throws ResponseHandlerException
{
- HandlerResponse response = processHandlers(controllerContext, command,
commandResponse);
+ HandlerResponse handlerResponse = processHandlers(controllerContext, command,
commandResponse);
// Handle redirection here
- if (response instanceof CommandForward)
+ if (handlerResponse instanceof CommandForward)
{
- CommandForward forward = (CommandForward)response;
+ CommandForward forward = (CommandForward)handlerResponse;
URLContext urlContext =
controllerContext.getServerInvocation().getServerContext().getURLContext();
if (requiresRedirect(command, urlContext, forward))
{
@@ -80,13 +82,13 @@
}
//
- return response;
+ return handlerResponse;
}
private HandlerResponse processHandlers(
ControllerContext controllerContext,
ControllerCommand command,
- Object commandResponse) throws IOException, ServletException, ServerException
+ ControllerResponse commandResponse) throws ResponseHandlerException
{
for (int i = 0;i < handlers.length;i++)
{
@@ -104,12 +106,12 @@
private static class OtherResponseHandler implements ResponseHandler
{
- public HandlerResponse processCommandResponse(ControllerContext controllerContext,
ControllerCommand command, Object commandResponse) throws IOException, ServletException,
ServerException
+ public HandlerResponse processCommandResponse(ControllerContext controllerContext,
ControllerCommand cdmand, ControllerResponse response) throws ResponseHandlerException
{
final ServerInvocation invocation = controllerContext.getServerInvocation();
- if (commandResponse instanceof PageRendition)
+ if (response instanceof PageRendition)
{
- final PageRendition rendition = (PageRendition)commandResponse;
+ final PageRendition rendition = (PageRendition)response;
// Defer execution of rendition to the right place which is in the classic
controller send response
return new HTTPResponse()
@@ -122,10 +124,10 @@
}
};
}
- else if (commandResponse instanceof SignOutResponse)
+ else if (response instanceof SignOutResponse)
{
// Get the optional signout location
- String location = ((SignOutResponse)commandResponse).getLocation();
+ String location = ((SignOutResponse)response).getLocation();
// Indicate that we want a sign out to be done
invocation.getResponse().setWantSignOut(true);
@@ -143,9 +145,9 @@
//
return new HTTPResponse.SendRedirect(location);
}
- else if (commandResponse instanceof StreamContentResponse)
+ else if (response instanceof StreamContentResponse)
{
- StreamContentResponse scr = (StreamContentResponse)commandResponse;
+ StreamContentResponse scr = (StreamContentResponse)response;
return new HTTPResponse.SendBinary(scr.getContentType(),
scr.getInputStream());
}
else
@@ -158,6 +160,7 @@
// Unhardcode this
private ResponseHandler[] handlers = new ResponseHandler[]
{
+ new ThrowableResponseHandler(),
new OtherResponseHandler(),
new PortletInstanceResponseHandler(),
new PortalObjectResponseHandler(),
Added:
trunk/core/src/main/org/jboss/portal/core/controller/classic/ThrowableResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/classic/ThrowableResponseHandler.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/ThrowableResponseHandler.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -0,0 +1,94 @@
+/******************************************************************************
+ * 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.classic;
+
+import org.jboss.portal.core.controller.handler.ResponseHandler;
+import org.jboss.portal.core.controller.handler.HandlerResponse;
+import org.jboss.portal.core.controller.handler.HTTPResponse;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ResponseHandlerException;
+import org.jboss.portal.core.controller.ControllerSecurityException;
+import org.jboss.portal.core.controller.ResourceNotFoundException;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.command.response.ThrowableResponse;
+import org.jboss.portal.server.ServerURL;
+import org.jboss.portal.server.request.URLContext;
+
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThrowableResponseHandler implements ResponseHandler
+{
+ public HandlerResponse processCommandResponse(ControllerContext controllerContext,
ControllerCommand command, ControllerResponse response) throws ResponseHandlerException
+ {
+ if (response instanceof ThrowableResponse)
+ {
+ ThrowableResponse tr = (ThrowableResponse)response;
+ Throwable t = tr.getThrowable();
+ URLContext urlContext =
controllerContext.getServerInvocation().getServerContext().getURLContext();
+
+ //
+ if (t instanceof ControllerSecurityException)
+ {
+ if (urlContext.isAuthenticated())
+ {
+ return new
HTTPResponse.SetStatusCode(HttpServletResponse.SC_UNAUTHORIZED);
+ }
+ else
+ {
+ urlContext = URLContext.newInstance(urlContext.isSecure(), true);
+ ServerURL serverURL =
controllerContext.getController().getURLFactory().doMapping(controllerContext.getServerInvocation(),
command);
+ String url =
controllerContext.getServerInvocation().getResponse().renderURL(serverURL, urlContext,
null);
+ return new HTTPResponse.SendRedirect(url);
+ }
+ }
+ else if (t instanceof ResourceNotFoundException)
+ {
+ ResourceNotFoundException rnfe = (ResourceNotFoundException)t;
+ // log.error("Resource not found " + e.getRef(), e);
+ return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_NOT_FOUND);
+ }
+ else if (t instanceof ControllerException)
+ {
+ ControllerException ce = (ControllerException)t;
+ throw new ResponseHandlerException(ce);
+ }
+ else if (t instanceof Exception)
+ {
+ Exception e = (Exception)t;
+ throw new ResponseHandlerException(e);
+ }
+ else
+ {
+ // todo
+ t.printStackTrace();
+ }
+ }
+ return null;
+ }
+}
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -24,6 +24,7 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerResponse;
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.SignOutResponse;
@@ -58,7 +59,7 @@
return info;
}
- public Object execute() throws ControllerException
+ public ControllerResponse execute() throws ControllerException
{
if (location != null)
{
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/command/response/SignOutResponse.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/command/response/SignOutResponse.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/controller/command/response/SignOutResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -22,11 +22,13 @@
******************************************************************************/
package org.jboss.portal.core.controller.command.response;
+import org.jboss.portal.core.controller.ControllerResponse;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class SignOutResponse
+public class SignOutResponse extends ControllerResponse
{
/** Location is a URL to navigate to after signing out or null to indicate default
behavior. */
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -22,13 +22,15 @@
******************************************************************************/
package org.jboss.portal.core.controller.command.response;
+import org.jboss.portal.core.controller.ControllerResponse;
+
import java.io.InputStream;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class StreamContentResponse
+public class StreamContentResponse extends ControllerResponse
{
/** . */
Added:
trunk/core/src/main/org/jboss/portal/core/controller/command/response/ThrowableResponse.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/command/response/ThrowableResponse.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/controller/command/response/ThrowableResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * 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.command.response;
+
+import org.jboss.portal.core.controller.ControllerResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThrowableResponse extends ControllerResponse
+{
+
+ /** . */
+ private final Throwable throwable;
+
+ public ThrowableResponse(Throwable throwable)
+ {
+ this.throwable = throwable;
+ }
+
+ public Throwable getThrowable()
+ {
+ return throwable;
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/controller/handler/AbstractResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/handler/AbstractResponseHandler.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/controller/handler/AbstractResponseHandler.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * 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.handler;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.core.controller.handler.ResponseHandler;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractResponseHandler extends AbstractJBossService implements
ResponseHandler
+{
+}
Added: trunk/core/src/main/org/jboss/portal/core/controller/handler/AjaxResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/handler/AjaxResponse.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/controller/handler/AjaxResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * 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.handler;
+
+import org.jboss.portal.core.controller.handler.HandlerResponse;
+import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
+import org.jboss.portal.theme.impl.render.dynamic.JSONMarshaller;
+import org.jboss.portal.server.ServerInvocationContext;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AjaxResponse extends HandlerResponse
+{
+
+ /** . */
+ private static final JSONMarshaller marshaller = new JSONMarshaller();
+
+ /** The response to the client. */
+ private final DynaResponse dynaResponse;
+
+ public AjaxResponse(DynaResponse dynaResponse)
+ {
+ this.dynaResponse = dynaResponse;
+ }
+
+ public void sendResponse(ServerInvocationContext ctx) throws IOException,
ServletException
+ {
+ HttpServletResponse resp = ctx.getClientResponse();
+ resp.setContentType("text/html");
+ marshaller.write(dynaResponse, resp.getWriter());
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/controller/handler/CommandForward.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/handler/CommandForward.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/controller/handler/CommandForward.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * 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.handler;
+
+import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.core.controller.ControllerCommand;
+
+/**
+ * Forward to a new command.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CommandForward extends HandlerResponse
+{
+ /** . */
+ private final ControllerCommand cmd;
+
+ /** . */
+ private final URLContext urlCtx;
+
+ public CommandForward(ControllerCommand cmd, URLContext urlCtx)
+ {
+ if (cmd == null)
+ {
+ throw new IllegalArgumentException("No command provided");
+ }
+ this.cmd = cmd;
+ this.urlCtx = urlCtx;
+ }
+
+ public ControllerCommand getCommand()
+ {
+ return cmd;
+ }
+
+ public URLContext getURLContext()
+ {
+ return urlCtx;
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * 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.handler;
+
+import org.jboss.portal.server.ServerInvocationContext;
+import org.jboss.portal.common.util.Tools;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletException;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Response that sends a response to the http stream.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class HTTPResponse extends HandlerResponse
+{
+
+ public abstract void sendResponse(ServerInvocationContext ctx) throws IOException,
ServletException;
+
+ public static class SetStatusCode extends HTTPResponse
+ {
+
+ /** . */
+ private final int statusCode;
+
+ public SetStatusCode(int statusCode)
+ {
+ this.statusCode = statusCode;
+ }
+
+ public void sendResponse(ServerInvocationContext ctx) throws IOException
+ {
+ HttpServletResponse resp = ctx.getClientResponse();
+ resp.sendError(statusCode);
+ }
+ }
+
+ public static class SendRedirect extends HTTPResponse
+ {
+
+ /** . */
+ private final String redirect;
+
+ public SendRedirect(String redirect)
+ {
+ this.redirect = redirect;
+ }
+
+ public void sendResponse(ServerInvocationContext ctx) throws IOException
+ {
+ HttpServletResponse resp = ctx.getClientResponse();
+ resp.sendRedirect(redirect);
+ }
+ }
+
+ public static class SendBinary extends HTTPResponse
+ {
+
+ /** . */
+ private final String contentType;
+
+ /** . */
+ private final InputStream in;
+
+ public SendBinary(String contentType, InputStream inputStream)
+ {
+ this.contentType = contentType;
+ this.in = inputStream;
+ }
+
+ public void sendResponse(ServerInvocationContext ctx) throws IOException
+ {
+ HttpServletResponse resp = ctx.getClientResponse();
+ resp.setContentType(contentType);
+ ServletOutputStream sout = null;
+ try
+ {
+ sout = resp.getOutputStream();
+ byte[] buf = new byte[2048];
+ int len;
+ while ((len = in.read(buf)) > 0)
+ {
+ sout.write(buf, 0, len);
+ }
+ sout.flush();
+ }
+ finally
+ {
+ Tools.safeClose(in);
+ Tools.safeClose(sout);
+ }
+ }
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/controller/handler/HandlerResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/handler/HandlerResponse.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/controller/handler/HandlerResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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.handler;
+
+/**
+ * The response from a a response handler.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class HandlerResponse
+{
+}
Added: trunk/core/src/main/org/jboss/portal/core/controller/handler/ResponseForward.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/handler/ResponseForward.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/controller/handler/ResponseForward.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * 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.handler;
+
+import org.jboss.portal.core.controller.ControllerResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ResponseForward extends HandlerResponse
+{
+
+ /** . */
+ private ControllerResponse response;
+
+ public ResponseForward(ControllerResponse response)
+ {
+ this.response = response;
+ }
+
+ public ControllerResponse getResponse()
+ {
+ return response;
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/controller/handler/ResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/handler/ResponseHandler.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/controller/handler/ResponseHandler.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * 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.handler;
+
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.ResponseHandlerException;
+import org.jboss.portal.core.controller.ControllerResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ResponseHandler
+{
+ public HandlerResponse processCommandResponse(
+ ControllerContext controllerContext,
+ ControllerCommand command,
+ ControllerResponse response) throws ResponseHandlerException;
+}
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponse.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponse.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.controller.portlet;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.core.controller.ControllerResponse;
/**
* Controller response provided by a portlet.
@@ -30,7 +31,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public abstract class PortletResponse
+public abstract class PortletResponse extends ControllerResponse
{
/** . */
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -24,10 +24,12 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.core.controller.HTTPResponse;
-import org.jboss.portal.core.controller.CommandForward;
-import org.jboss.portal.core.controller.classic.AbstractResponseHandler;
-import org.jboss.portal.core.controller.HandlerResponse;
+import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.ResponseHandlerException;
+import org.jboss.portal.core.controller.handler.HTTPResponse;
+import org.jboss.portal.core.controller.handler.CommandForward;
+import org.jboss.portal.core.controller.handler.AbstractResponseHandler;
+import org.jboss.portal.core.controller.handler.HandlerResponse;
import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowActionCommand;
import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
@@ -35,7 +37,6 @@
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.instance.command.response.PortletInstanceResponse;
import
org.jboss.portal.core.model.instance.command.action.InvokePortletInstanceRenderCommand;
-import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
@@ -48,9 +49,7 @@
import org.jboss.portal.WindowState;
import org.jboss.portal.Mode;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -85,12 +84,12 @@
}
}
- public HandlerResponse processCommandResponse(ControllerContext controllerContext,
ControllerCommand command, Object commandResponse) throws IOException, ServletException,
ServerException
+ public HandlerResponse processCommandResponse(ControllerContext controllerContext,
ControllerCommand command, ControllerResponse response) throws ResponseHandlerException
{
- if (commandResponse instanceof PortletResponse)
+ if (response instanceof PortletResponse)
{
ServerInvocation invocation = controllerContext.getServerInvocation();
- PortletResponse pr = (PortletResponse)commandResponse;
+ PortletResponse pr = (PortletResponse)response;
PortletInvocationResponse pir = pr.getResult();
//
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -38,8 +38,10 @@
import org.jboss.portal.core.controller.ResourceNotFoundException;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ResourceAccessDeniedException;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
import org.jboss.portal.core.ns.NavigationalStateKey;
+import org.jboss.portal.core.theme.WindowRendition;
import org.jboss.portal.server.config.ServerConfig;
import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.request.URLContext;
@@ -146,7 +148,7 @@
*/
protected abstract Instance getViewModePortletInstance(RenderWindowCommand command);
- public Object renderWindow(RenderWindowCommand cmd) throws Exception
+ public ControllerResponse renderWindow(RenderWindowCommand cmd) throws Exception
{
Window window = cmd.getWindow();
Portal portal = cmd.getPortal();
@@ -169,7 +171,7 @@
String contentChars;
String headerChars = null;
Map actionMap = new HashMap();
- Map windowProps = new HashMap(window.getDeclaredProperties());
+ Map windowProps = new HashMap(window.getProperties());
//
try
@@ -282,21 +284,21 @@
// Update window props after render if needed
Boolean asynchronous =
(Boolean)invocation.getAttribute(PortletInvocation.RESPONSE_PROPERTIES_SCOPE,
"asynchronous");
- if (asynchronous != null)
+ if (asynchronous != null && Boolean.FALSE.equals(asynchronous))
{
DynaRenderOptions options = DynaRenderOptions.getOptions(null,
asynchronous);
options.setOptions(windowProps);
}
//
- return new WindowResult(
+ return new WindowRendition(new WindowResult(
windowTitle,
contentChars,
actionMap,
windowProps,
headerChars,
windowNS.getWindowState(),
- windowNS.getMode());
+ windowNS.getMode()));
}
else if (response instanceof ErrorResponse)
{
@@ -313,7 +315,7 @@
{
contentChars = Exceptions.toHTML(t, true);
}
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
headerChars, windowNS.getWindowState(), windowNS.getMode());
+ return new WindowRendition(new WindowResult(windowTitle, contentChars,
actionMap, windowProps, headerChars, windowNS.getWindowState(), windowNS.getMode()));
}
}
else if (response instanceof UnavailableResponse)
@@ -325,7 +327,7 @@
actionMap = new HashMap();
actionMap.put(ActionRendererContext.MODES_KEY, Collections.EMPTY_LIST);
actionMap.put(ActionRendererContext.WINDOWSTATES_KEY,
Collections.EMPTY_LIST);
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
headerChars, windowNS.getWindowState(), windowNS.getMode());
+ return new WindowRendition(new WindowResult(windowTitle, contentChars,
actionMap, windowProps, headerChars, windowNS.getWindowState(), windowNS.getMode()));
}
}
else if (response instanceof InsufficientPrivilegesResponse)
@@ -350,7 +352,7 @@
actionMap.put(ActionRendererContext.WINDOWSTATES_KEY,
Collections.EMPTY_LIST);
windowTitle = "Access denied";
contentChars = "Access denied";
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
headerChars, windowNS.getWindowState(), windowNS.getMode());
+ return new WindowRendition(new WindowResult(windowTitle, contentChars,
actionMap, windowProps, headerChars, windowNS.getWindowState(), windowNS.getMode()));
}
}
catch (ResourceNotFoundException e)
@@ -365,7 +367,7 @@
actionMap.put(ActionRendererContext.WINDOWSTATES_KEY,
Collections.EMPTY_LIST);
windowTitle = "Cannot render";
contentChars = "Object not found " + e.getRef();
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
headerChars, windowNS.getWindowState(), windowNS.getMode());
+ return new WindowRendition(new WindowResult(windowTitle, contentChars,
actionMap, windowProps, headerChars, windowNS.getWindowState(), windowNS.getMode()));
}
}
catch (ControllerException e)
@@ -381,7 +383,7 @@
{
windowTitle = "An internal error occured while rendering window
'" + window + "'";
contentChars = Exceptions.toHTML(e, true);
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
headerChars, windowNS.getWindowState(), windowNS.getMode());
+ return new WindowRendition(new WindowResult(windowTitle, contentChars,
actionMap, windowProps, headerChars, windowNS.getWindowState(), windowNS.getMode()));
}
}
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -34,8 +34,10 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.impl.model.content.InternalContentProvider;
import org.jboss.portal.core.ns.NavigationalStateKey;
+import org.jboss.portal.core.theme.WindowRendition;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.theme.page.WindowResult;
@@ -152,7 +154,7 @@
{
}
- public Object renderWindow(RenderWindowCommand cmd) throws Exception
+ public ControllerResponse renderWindow(RenderWindowCommand cmd) throws Exception
{
ControllerContext context = cmd.getControllerContext();
Window window = cmd.getWindow();
@@ -189,12 +191,13 @@
}
//
- Object o = super.renderWindow(cmd);
+ ControllerResponse o = super.renderWindow(cmd);
//
- if (o instanceof WindowResult && getDecorateContent() == false)
+ if (o instanceof WindowRendition && getDecorateContent() == false)
{
- WindowResult result = (WindowResult)o;
+ WindowRendition rendition = (WindowRendition)o;
+ WindowResult result = rendition.getWindow();
//
Map props = result.getProperties();
Modified:
trunk/core/src/main/org/jboss/portal/core/model/instance/PortletInstanceResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/instance/PortletInstanceResponseHandler.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/instance/PortletInstanceResponseHandler.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -22,12 +22,14 @@
******************************************************************************/
package org.jboss.portal.core.model.instance;
-import org.jboss.portal.core.controller.ResponseHandler;
-import org.jboss.portal.core.controller.HandlerResponse;
+import org.jboss.portal.core.controller.handler.ResponseHandler;
+import org.jboss.portal.core.controller.handler.HandlerResponse;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.HTTPResponse;
+import org.jboss.portal.core.controller.handler.HTTPResponse;
import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.ResponseHandlerException;
import
org.jboss.portal.core.model.instance.command.response.UpdatePortletInstanceResponse;
import org.jboss.portal.core.model.instance.command.render.RenderPortletInstanceCommand;
import org.jboss.portal.server.ServerException;
@@ -35,7 +37,7 @@
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.web.ServletContextDispatcher;
import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.theme.page.PageRendition;
+import org.jboss.portal.core.theme.PageRendition;
import javax.servlet.ServletException;
import java.io.IOException;
@@ -46,13 +48,13 @@
*/
public class PortletInstanceResponseHandler implements ResponseHandler
{
- public HandlerResponse processCommandResponse(ControllerContext controllerContext,
ControllerCommand command, Object commandResponse) throws IOException, ServletException,
ServerException
+ public HandlerResponse processCommandResponse(ControllerContext controllerContext,
ControllerCommand codmmand, ControllerResponse response) throws ResponseHandlerException
{
- if (commandResponse instanceof UpdatePortletInstanceResponse)
+ if (response instanceof UpdatePortletInstanceResponse)
{
try
{
- UpdatePortletInstanceResponse upir =
(UpdatePortletInstanceResponse)commandResponse;
+ UpdatePortletInstanceResponse upir =
(UpdatePortletInstanceResponse)response;
RenderPortletInstanceCommand render= new
RenderPortletInstanceCommand(upir.getInstanceId(), upir.getNavigationalState());
final PageRendition rendition =
(PageRendition)controllerContext.execute(render);
final ServerInvocation invocation = controllerContext.getServerInvocation();
Modified:
trunk/core/src/main/org/jboss/portal/core/model/instance/command/action/InvokePortletInstanceActionCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/instance/command/action/InvokePortletInstanceActionCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/instance/command/action/InvokePortletInstanceActionCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.model.instance.command.action;
import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.portlet.PortletContextFactory;
import org.jboss.portal.core.controller.portlet.InvokePortletCommandFactory;
import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
@@ -75,7 +76,7 @@
return null;
}
- public Object execute() throws ControllerException
+ public ControllerResponse execute() throws ControllerException
{
try
{
@@ -101,7 +102,7 @@
}
catch (PortletInvokerException e)
{
- return new ControllerException(e);
+ throw new ControllerException(e);
}
}
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/instance/command/action/InvokePortletInstanceRenderCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/instance/command/action/InvokePortletInstanceRenderCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/instance/command/action/InvokePortletInstanceRenderCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.model.instance.command.action;
import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import
org.jboss.portal.core.model.instance.command.response.UpdatePortletInstanceResponse;
import org.jboss.portal.core.model.instance.command.PortletInstanceCommand;
@@ -45,7 +46,7 @@
return null;
}
- public Object execute() throws ControllerException
+ public ControllerResponse execute() throws ControllerException
{
return new UpdatePortletInstanceResponse(instanceId, navigationalState);
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -26,9 +26,11 @@
import org.jboss.portal.core.model.instance.InvokePortletInstanceCommandFactory;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.portlet.PortletContextFactory;
import org.jboss.portal.core.controller.portlet.InvokePortletCommandFactory;
import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
+import org.jboss.portal.core.theme.PageRendition;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.RenderInvocation;
@@ -44,7 +46,6 @@
import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.page.WindowContext;
-import org.jboss.portal.theme.page.PageRendition;
import org.jboss.portal.common.NotYetImplemented;
import java.util.Map;
@@ -68,7 +69,7 @@
return null;
}
- public Object execute() throws ControllerException
+ public ControllerResponse execute() throws ControllerException
{
try
Modified:
trunk/core/src/main/org/jboss/portal/core/model/instance/command/response/UpdatePortletInstanceResponse.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/instance/command/response/UpdatePortletInstanceResponse.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/instance/command/response/UpdatePortletInstanceResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -23,12 +23,13 @@
package org.jboss.portal.core.model.instance.command.response;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.core.controller.ControllerResponse;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class UpdatePortletInstanceResponse
+public class UpdatePortletInstanceResponse extends ControllerResponse
{
/** . */
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -22,21 +22,22 @@
******************************************************************************/
package org.jboss.portal.core.model.portal;
-import org.jboss.portal.core.controller.classic.AbstractResponseHandler;
-import org.jboss.portal.core.controller.CommandForward;
-import org.jboss.portal.core.controller.HandlerResponse;
+import org.jboss.portal.core.controller.handler.AbstractResponseHandler;
+import org.jboss.portal.core.controller.handler.CommandForward;
+import org.jboss.portal.core.controller.handler.HandlerResponse;
+import org.jboss.portal.core.controller.handler.HTTPResponse;
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.HTTPResponse;
+import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.ResponseHandlerException;
import org.jboss.portal.core.model.portal.command.response.UpdatePageResponse;
import org.jboss.portal.core.model.portal.command.response.UpdateWindowResponse;
import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
import org.jboss.portal.core.model.portal.command.render.RenderPageCommand;
-import org.jboss.portal.server.ServerException;
+import org.jboss.portal.core.theme.PageRendition;
import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.theme.page.PageRendition;
import org.jboss.portal.web.ServletContextDispatcher;
import org.jboss.portal.common.util.MarkupInfo;
@@ -50,11 +51,11 @@
public class PortalObjectResponseHandler extends AbstractResponseHandler
{
- public HandlerResponse processCommandResponse(ControllerContext controllerContext,
ControllerCommand command, Object commandResponse) throws IOException, ServletException,
ServerException
+ public HandlerResponse processCommandResponse(ControllerContext controllerContext,
ControllerCommand ceommand, ControllerResponse response) throws ResponseHandlerException
{
- if (commandResponse instanceof UpdatePageResponse)
+ if (response instanceof UpdatePageResponse)
{
- UpdatePageResponse uvr = (UpdatePageResponse)commandResponse;
+ UpdatePageResponse uvr = (UpdatePageResponse)response;
try
{
@@ -79,9 +80,9 @@
return null;
}
}
- else if (commandResponse instanceof UpdateWindowResponse)
+ else if (response instanceof UpdateWindowResponse)
{
- UpdateWindowResponse uwmr = (UpdateWindowResponse)commandResponse;
+ UpdateWindowResponse uwmr = (UpdateWindowResponse)response;
PortalObjectContainer portalObjectContainer =
controllerContext.getController().getPortalObjectContainer();
PortalObject window = portalObjectContainer.getObject(uwmr.getWindowId());
Page page = (Page)window.getParent();
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/ImportPageToDashboardCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/ImportPageToDashboardCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/ImportPageToDashboardCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -25,6 +25,7 @@
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
@@ -73,7 +74,7 @@
dashboardPortal = manager.getDashboard(user);
}
- public Object execute() throws ControllerException
+ public ControllerResponse execute() throws ControllerException
{
String name = target.getName();
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -28,6 +28,7 @@
import org.jboss.portal.identity.User;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ResourceNotFoundException;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
@@ -140,7 +141,7 @@
}
}
- public Object execute() throws ControllerException
+ public ControllerResponse execute() throws ControllerException
{
try
{
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -28,6 +28,7 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.model.portal.command.response.UpdateWindowResponse;
import org.jboss.portal.core.model.portal.command.action.InvokeWindowCommand;
import org.jboss.portal.core.model.portal.PortalObjectId;
@@ -80,7 +81,7 @@
return info;
}
- public Object execute() throws InvocationException
+ public ControllerResponse execute() throws InvocationException
{
InvocationContext ctx = getContext();
PortalObjectId windowId = window.getId();
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/MoveWindowCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/MoveWindowCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/MoveWindowCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.model.portal.command.action;
import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.model.portal.PortalObject;
@@ -70,7 +71,7 @@
return info;
}
- public Object execute() throws ControllerException
+ public ControllerResponse execute() throws ControllerException
{
// For now just update the navigational state of the page
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -26,6 +26,7 @@
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ControllerSecurityException;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.model.portal.Page;
@@ -40,7 +41,8 @@
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.theme.LayoutService;
-import org.jboss.portal.theme.page.PageRendition;
+import org.jboss.portal.core.theme.PageRendition;
+import org.jboss.portal.core.theme.WindowRendition;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.PortalTheme;
import org.jboss.portal.theme.ServerRegistrationID;
@@ -150,7 +152,7 @@
*
* @throws InvocationException
*/
- public Object execute() throws ControllerException, InvocationException
+ public ControllerResponse execute() throws ControllerException, InvocationException
{
ServerInvocation sinv = context.getServerInvocation();
HttpServletRequest request = sinv.getServerContext().getClientRequest();
@@ -217,7 +219,7 @@
RenderWindowCommand renderCmd = new
RenderWindowCommand(window.getId());
//
- Object res = null;
+ ControllerResponse res = null;
//
if (renderCmd != null)
@@ -230,9 +232,10 @@
{
// Skip
}
- else if (res instanceof WindowResult)
+ else if (res instanceof WindowRendition)
{
- WindowResult result = (WindowResult)res;
+ WindowRendition rendition = (WindowRendition)res;
+ WindowResult result = rendition.getWindow();
String region =
window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION);
String order =
window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER);
WindowContext wc = new WindowContext(
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -25,6 +25,7 @@
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.command.WindowCommand;
import org.jboss.portal.core.model.portal.content.ContentRendererRegistry;
@@ -73,7 +74,7 @@
return info;
}
- public Object execute() throws ControllerException
+ public ControllerResponse execute() throws ControllerException
{
ContentRendererRegistry registry =
context.getController().getContentRendererRegistry();
ContentType contentType = window.getContentType();
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdatePageResponse.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdatePageResponse.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdatePageResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -23,12 +23,13 @@
package org.jboss.portal.core.model.portal.command.response;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.controller.ControllerResponse;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class UpdatePageResponse
+public class UpdatePageResponse extends ControllerResponse
{
/** . */
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowResponse.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowResponse.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowResponse.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -23,12 +23,13 @@
package org.jboss.portal.core.model.portal.command.response;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.controller.ControllerResponse;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class UpdateWindowResponse
+public class UpdateWindowResponse extends ControllerResponse
{
/** . */
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewDashboardCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewDashboardCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewDashboardCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -24,6 +24,7 @@
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ControllerSecurityException;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.model.portal.command.response.UpdatePageResponse;
@@ -104,7 +105,7 @@
}
}
- public Object execute() throws ControllerException
+ public ControllerResponse execute() throws ControllerException
{
return new UpdatePageResponse(dashboardPage.getId());
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPageCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPageCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPageCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -28,6 +28,7 @@
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerResponse;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -49,7 +50,7 @@
return info;
}
- public Object execute() throws ControllerException
+ public ControllerResponse execute() throws ControllerException
{
return new UpdatePageResponse(page.getId());
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.model.portal.content;
import org.jboss.portal.core.model.portal.command.render.RenderWindowCommand;
+import org.jboss.portal.core.controller.ControllerResponse;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -30,5 +31,5 @@
*/
public interface ContentRenderer
{
- Object renderWindow(RenderWindowCommand cmd) throws Exception;
+ ControllerResponse renderWindow(RenderWindowCommand cmd) throws Exception;
}
Added: trunk/core/src/main/org/jboss/portal/core/theme/PageRendition.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/theme/PageRendition.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/theme/PageRendition.java 2007-04-08 17:24:01
UTC (rev 6959)
@@ -0,0 +1,93 @@
+/******************************************************************************
+ * 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.theme;
+
+import org.jboss.portal.theme.PageService;
+import org.jboss.portal.theme.render.RendererContext;
+import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.ThemeContext;
+import org.jboss.portal.theme.PortalLayout;
+import org.jboss.portal.theme.PortalTheme;
+import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.web.ServletContextDispatcher;
+import org.jboss.portal.core.controller.ControllerResponse;
+
+import javax.servlet.ServletException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PageRendition extends ControllerResponse
+{
+
+ /** . */
+ private PortalLayout layout;
+
+ /** . */
+ private PageResult pageResult;
+
+ /** . */
+ private PortalTheme theme;
+
+ /** . */
+ private PageService pageService;
+
+ public PageRendition(
+ PortalLayout layout,
+ PortalTheme theme,
+ PageResult markupResult,
+ PageService pageService)
+ {
+ this.layout = layout;
+ this.theme = theme;
+ this.pageResult = markupResult;
+ this.pageService = pageService;
+ }
+
+ /** Performs the page rendition. */
+ public void render(MarkupInfo markupInfo, ServletContextDispatcher dispatcher) throws
IOException, ServletException
+ {
+ ThemeContext themeContext = new ThemeContext(theme,
pageService.getThemeService());
+
+ //
+ RendererContext rendererContext = layout.getRenderContext(themeContext, markupInfo,
dispatcher);
+
+ //
+ try
+ {
+ rendererContext.render(pageResult);
+ }
+ catch (RenderException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public PageResult getPageResult()
+ {
+ return pageResult;
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/theme/WindowRendition.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/theme/WindowRendition.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/theme/WindowRendition.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * 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.theme;
+
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.core.controller.ControllerResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WindowRendition extends ControllerResponse
+{
+
+ /** . */
+ private final WindowResult window;
+
+ public WindowRendition(WindowResult window)
+ {
+ this.window = window;
+ }
+
+ public WindowResult getWindow()
+ {
+ return window;
+ }
+}
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -31,6 +31,7 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerResponse;
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.StreamContentResponse;
@@ -69,7 +70,7 @@
return info;
}
- public Object execute() throws InvocationException, ControllerException
+ public ControllerResponse execute() throws InvocationException, ControllerException
{
try
{
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -27,6 +27,7 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
import org.jboss.portal.core.cms.CMSObjectCommandFactory;
+import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.Mode;
/**
@@ -88,7 +89,7 @@
super.start();
}
- public Object renderWindow(RenderWindowCommand cmd) throws Exception
+ public ControllerResponse renderWindow(RenderWindowCommand cmd) throws Exception
{
try
{
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/default-object.xml
===================================================================
---
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/default-object.xml 2007-04-08
14:22:53 UTC (rev 6958)
+++
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/default-object.xml 2007-04-08
17:24:01 UTC (rev 6959)
@@ -65,6 +65,255 @@
<page-name>Test</page-name>
<properties>
<property>
+ <name>order</name>
+ <value>3</value>
+ </property>
+ </properties>
+ <window>
+ <window-name>TestPortletWindow</window-name>
+ <instance-ref>TestPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <page>
+ <page-name>event test</page-name>
+ <listener>test_listener</listener>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>PortletAWindow</window-name>
+ <instance-ref>PortletAInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>PortletBWindow</window-name>
+ <instance-ref>PortletBInstance</instance-ref>
+ <region>center</region>
+ <height>1</height>
+ </window>
+ </page>
+ <page>
+ <page-name>page event test</page-name>
+ <listener>window_event_listener</listener>
+ <window>
+ <window-name>CatalogPortletWindow1</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>CatalogPortletWindow2</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>1</height>
+ </window>
+ <window>
+ <window-name>CatalogPortletWindow3</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>2</height>
+ </window>
+ <window>
+ <window-name>CatalogPortletWindow4</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>CatalogPortletWindow5</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>center</region>
+ <height>1</height>
+ </window>
+ <window>
+ <window-name>CatalogPortletWindow6</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>center</region>
+ <height>2</height>
+ </window>
+ </page>
+ <page>
+ <page-name>secure test</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>SecuredTestPortletWindow</window-name>
+ <instance-ref>SecuredTestPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ </page>
+ <page>
+ <page-name>exception test</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>ExceptionPortletWindow</window-name>
+ <instance-ref>ExceptionPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ </page>
+ <page>
+ <page-name>cache test</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>CachedCounterPortletWindow</window-name>
+ <instance-ref>CachedCounterPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>CounterPortletWindow</window-name>
+ <instance-ref>CounterPortletInstance</instance-ref>
+ <region>center</region>
+ <height>1</height>
+ </window>
+ </page>
+ <page>
+ <page-name>session test</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>PortletSessionPortletWindow</window-name>
+ <instance-ref>PortletSessionPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ </page>
+ <page>
+ <page-name>missing portlet</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>MissingPortletWindow</window-name>
+ <instance-ref>MissingPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ </page>
+ <page>
+ <page-name>URL portlet</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>URLPortletWindow</window-name>
+ <instance-ref>URLPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>AsyncURLPortletWindow</window-name>
+ <instance-ref>AsyncURLPortletInstance</instance-ref>
+ <region>center</region>
+ <height>1</height>
+ </window>
+ </page>
+ <page>
+ <page-name>missing instance</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>MissingInstanceWindow</window-name>
+ <instance-ref>MissingInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ </page>
+ <page>
+ <page-name>charset test</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>CharsetPortletWindow</window-name>
+ <instance-ref>CharsetPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ </page>
+ <page>
+ <page-name>encoding test</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>EncodingPortletWindow</window-name>
+ <instance-ref>EncodingPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ </page>
+ <page>
+ <page-name>header test</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>HeaderContentPortletWindow</window-name>
+ <instance-ref>HeaderContentPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ </page>
+ </page>
+ </deployment>
+ <deployment>
+ <parent-ref>default</parent-ref>
+ <if-exists>keep</if-exists>
+ <page>
+ <page-name>TestWithAjax</page-name>
+ <properties>
+ <property>
<name>theme.dyna.async_window_enabled</name>
<value>true</value>
</property>
@@ -242,6 +491,12 @@
<region>center</region>
<height>0</height>
</window>
+ <window>
+ <window-name>AsyncURLPortletWindow</window-name>
+ <instance-ref>AsyncURLPortletInstance</instance-ref>
+ <region>center</region>
+ <height>1</height>
+ </window>
</page>
<page>
<page-name>missing instance</page-name>
Deleted: trunk/theme/src/main/org/jboss/portal/theme/page/PageRendition.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PageRendition.java 2007-04-08
14:22:53 UTC (rev 6958)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PageRendition.java 2007-04-08
17:24:01 UTC (rev 6959)
@@ -1,91 +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.theme.page;
-
-import org.jboss.portal.theme.PageService;
-import org.jboss.portal.theme.render.RendererContext;
-import org.jboss.portal.theme.render.RenderException;
-import org.jboss.portal.theme.render.ThemeContext;
-import org.jboss.portal.theme.PortalLayout;
-import org.jboss.portal.theme.PortalTheme;
-import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.web.ServletContextDispatcher;
-
-import javax.servlet.ServletException;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PageRendition
-{
-
- /** . */
- private PortalLayout layout;
-
- /** . */
- private PageResult pageResult;
-
- /** . */
- private PortalTheme theme;
-
- /** . */
- private PageService pageService;
-
- public PageRendition(
- PortalLayout layout,
- PortalTheme theme,
- PageResult markupResult,
- PageService pageService)
- {
- this.layout = layout;
- this.theme = theme;
- this.pageResult = markupResult;
- this.pageService = pageService;
- }
-
- /** Performs the page rendition. */
- public void render(MarkupInfo markupInfo, ServletContextDispatcher dispatcher) throws
IOException, ServletException
- {
- ThemeContext themeContext = new ThemeContext(theme,
pageService.getThemeService());
-
- //
- RendererContext rendererContext = layout.getRenderContext(themeContext, markupInfo,
dispatcher);
-
- //
- try
- {
- rendererContext.render(pageResult);
- }
- catch (RenderException e)
- {
- e.printStackTrace();
- }
- }
-
- public PageResult getPageResult()
- {
- return pageResult;
- }
-}