JBoss Portal SVN: r5706 - in trunk/core/src: main/org/jboss/portal/core/aspects/controller main/org/jboss/portal/core/aspects/controller/node main/org/jboss/portal/core/cms main/org/jboss/portal/core/controller main/org/jboss/portal/core/controller/ajax main/org/jboss/portal/core/controller/classic main/org/jboss/portal/core/controller/command main/org/jboss/portal/core/controller/command/response main/org/jboss/portal/core/controller/portlet main/org/jboss/portal/core/model/portal main/org
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2006-11-21 16:51:07 -0500 (Tue, 21 Nov 2006)
New Revision: 5706
Added:
trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/
trunk/core/src/main/org/jboss/portal/core/controller/classic/AbstractResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/CommandForward.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.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/model/portal/PortalObjectResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/
trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowActionCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowRenderCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/MoveWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/PageCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/UpdateWindowMarkupResponse.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/ViewDashboardCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateViewResponse.java
trunk/core/src/main/org/jboss/portal/core/ui/configurator/InvokePortletCommand.java
Removed:
trunk/core/src/main/org/jboss/portal/core/controller/CoreController.java
trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowActionCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowRenderCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/MoveWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/PageCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/PortalCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/PortalObjectCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/RenderPageCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/RenderWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/ViewDashboardCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/WindowCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/response/PortletResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/command/response/UpdateViewResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/command/response/UpdateWindowMarkupResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/AuthenticateResponse.java
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageNavigationInterceptor.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/aspects/controller/node/PortalNodeURLFactory.java
trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.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/portlet/PortletInvocationFactory.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/SignOutResponse.java
trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/DefaultPortalCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java
trunk/core/src/main/org/jboss/portal/core/ui/configurator/InvokePortletActionCommand.java
trunk/core/src/main/org/jboss/portal/core/ui/configurator/InvokePortletRenderCommand.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
Log:
core controller refactorings
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 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -27,9 +27,9 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerInterceptor;
-import org.jboss.portal.core.controller.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.controller.command.SignOutCommand;
-import org.jboss.portal.core.controller.command.ViewDashboardCommand;
+import org.jboss.portal.core.model.portal.command.ViewDashboardCommand;
import org.jboss.portal.core.impl.model.portal.PortalObjectImpl;
import org.jboss.portal.core.model.portal.Context;
import org.jboss.portal.core.model.portal.Page;
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageNavigationInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageNavigationInterceptor.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageNavigationInterceptor.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -31,10 +31,10 @@
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.command.PageCommand;
-import org.jboss.portal.core.controller.command.PortalObjectCommand;
-import org.jboss.portal.core.controller.command.RenderPageCommand;
-import org.jboss.portal.core.controller.command.WindowCommand;
+import org.jboss.portal.core.model.portal.command.PageCommand;
+import org.jboss.portal.core.model.portal.command.PortalObjectCommand;
+import org.jboss.portal.core.model.portal.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.command.WindowCommand;
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObject;
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 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -36,9 +36,9 @@
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.command.InvokeWindowActionCommand;
-import org.jboss.portal.core.controller.command.InvokeWindowRenderCommand;
-import org.jboss.portal.core.controller.command.WindowCommand;
+import org.jboss.portal.core.model.portal.command.InvokeWindowActionCommand;
+import org.jboss.portal.core.model.portal.command.InvokeWindowRenderCommand;
+import org.jboss.portal.core.model.portal.command.WindowCommand;
import org.jboss.portal.core.event.PortalEventListenerRegistry;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.portlet.Parameters;
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 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeInterceptor.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -25,8 +25,8 @@
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.command.RenderPageCommand;
-import org.jboss.portal.core.controller.command.WindowCommand;
+import org.jboss.portal.core.model.portal.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.command.WindowCommand;
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.Window;
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactory.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/PortalNodeURLFactory.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -28,8 +28,8 @@
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.core.controller.command.RenderPageCommand;
-import org.jboss.portal.core.controller.command.InvokeWindowRenderCommand;
+import org.jboss.portal.core.model.portal.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.command.InvokeWindowRenderCommand;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -29,7 +29,7 @@
import org.jboss.portal.cms.model.Content;
import org.jboss.portal.cms.model.File;
import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.command.InvokeWindowRenderCommand;
+import org.jboss.portal.core.model.portal.command.InvokeWindowRenderCommand;
import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.server.ServerInvocation;
Added: trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,133 @@
+/******************************************************************************
+ * 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.theme.page.PageService;
+import org.jboss.portal.core.controller.command.mapper.CommandFactory;
+import org.jboss.portal.core.controller.command.mapper.URLFactory;
+import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.common.invocation.InterceptorStackFactory;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.server.RequestController;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class Controller extends AbstractJBossService implements RequestController
+{
+
+ /** . */
+ protected PageService pageService;
+
+ /** . */
+ protected CommandFactory commandFactory;
+
+ /** . */
+ protected URLFactory urlFactory;
+
+ /** . */
+ protected InterceptorStackFactory stackFactory;
+
+ /** . */
+ protected PortalObjectContainer portalObjectContainer;
+
+ /** . */
+ protected InstanceContainer instanceContainer;
+
+ /** . */
+ protected PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
+
+ public PortalAuthorizationManagerFactory getPortalAuthorizationManagerFactory()
+ {
+ return portalAuthorizationManagerFactory;
+ }
+
+ public void setPortalAuthorizationManagerFactory(PortalAuthorizationManagerFactory portalAuthorizationManagerFactory)
+ {
+ this.portalAuthorizationManagerFactory = portalAuthorizationManagerFactory;
+ }
+
+ public InstanceContainer getInstanceContainer()
+ {
+ return instanceContainer;
+ }
+
+ public void setInstanceContainer(InstanceContainer instanceContainer)
+ {
+ this.instanceContainer = instanceContainer;
+ }
+
+ public PortalObjectContainer getPortalObjectContainer()
+ {
+ return portalObjectContainer;
+ }
+
+ public void setPortalObjectContainer(PortalObjectContainer portalObjectContainer)
+ {
+ this.portalObjectContainer = portalObjectContainer;
+ }
+
+ public URLFactory getURLFactory()
+ {
+ return urlFactory;
+ }
+
+ public void setURLFactory(URLFactory urlFactory)
+ {
+ this.urlFactory = urlFactory;
+ }
+
+ public CommandFactory getCommandFactory()
+ {
+ return commandFactory;
+ }
+
+ public void setCommandFactory(CommandFactory commandFactory)
+ {
+ this.commandFactory = commandFactory;
+ }
+
+ public PageService getPageService()
+ {
+ return pageService;
+ }
+
+ public void setPageService(PageService pageService)
+ {
+ this.pageService = pageService;
+ }
+
+ public InterceptorStackFactory getStackFactory()
+ {
+ return stackFactory;
+ }
+
+ public void setStackFactory(InterceptorStackFactory stackFactory)
+ {
+ this.stackFactory = stackFactory;
+ }
+
+}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -41,9 +41,9 @@
private ServerInvocation serverInvocation;
/** The controller. */
- private CoreController controller;
+ private Controller controller;
- public ControllerContext(ServerInvocation serverInvocation, CoreController controller)
+ public ControllerContext(ServerInvocation serverInvocation, Controller controller)
{
if (serverInvocation == null)
{
@@ -107,7 +107,7 @@
return serverInvocation;
}
- public CoreController getController()
+ public Controller getController()
{
return controller;
}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/CoreController.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/CoreController.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/CoreController.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,479 +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.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.invocation.InterceptorStackFactory;
-import org.jboss.portal.core.controller.command.InvokeWindowActionCommand;
-import org.jboss.portal.core.controller.command.InvokeWindowRenderCommand;
-import org.jboss.portal.core.controller.command.RenderPageCommand;
-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.mapper.CommandFactory;
-import org.jboss.portal.core.controller.command.mapper.URLFactory;
-import org.jboss.portal.core.controller.command.response.PortletResponse;
-import org.jboss.portal.core.controller.command.response.StreamContentResponse;
-import org.jboss.portal.core.controller.command.response.UpdateViewResponse;
-import org.jboss.portal.core.controller.command.response.UpdateWindowMarkupResponse;
-import org.jboss.portal.core.controller.portlet.SignOutResponse;
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.Portal;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.PortalObjectContainer;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
-import org.jboss.portal.portlet.invocation.response.InsufficientPrivilegesResponse;
-import org.jboss.portal.portlet.invocation.response.InsufficientTransportGuaranteeResponse;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.RenderResponse;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
-import org.jboss.portal.server.RequestController;
-import org.jboss.portal.server.ServerException;
-import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.ServerURL;
-import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.theme.PageRendition;
-import org.jboss.portal.theme.page.PageService;
-
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class CoreController extends AbstractJBossService implements RequestController
-{
-
- /** . */
- private PageService pageService;
-
- /** . */
- private CommandFactory commandFactory;
-
- /** . */
- private URLFactory urlFactory;
-
- /** . */
- private InterceptorStackFactory stackFactory;
-
- /** . */
- private PortalObjectContainer portalObjectContainer;
-
- /** . */
- private InstanceContainer instanceContainer;
-
- /** . */
- private PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
-
- public PortalAuthorizationManagerFactory getPortalAuthorizationManagerFactory()
- {
- return portalAuthorizationManagerFactory;
- }
-
- public void setPortalAuthorizationManagerFactory(PortalAuthorizationManagerFactory portalAuthorizationManagerFactory)
- {
- this.portalAuthorizationManagerFactory = portalAuthorizationManagerFactory;
- }
-
- public InstanceContainer getInstanceContainer()
- {
- return instanceContainer;
- }
-
- public void setInstanceContainer(InstanceContainer instanceContainer)
- {
- this.instanceContainer = instanceContainer;
- }
-
- public PortalObjectContainer getPortalObjectContainer()
- {
- return portalObjectContainer;
- }
-
- public void setPortalObjectContainer(PortalObjectContainer portalObjectContainer)
- {
- this.portalObjectContainer = portalObjectContainer;
- }
-
- public URLFactory getURLFactory()
- {
- return urlFactory;
- }
-
- public void setURLFactory(URLFactory urlFactory)
- {
- this.urlFactory = urlFactory;
- }
-
- public CommandFactory getCommandFactory()
- {
- return commandFactory;
- }
-
- public void setCommandFactory(CommandFactory commandFactory)
- {
- this.commandFactory = commandFactory;
- }
-
- public PageService getPageService()
- {
- return pageService;
- }
-
- public void setPageService(PageService pageService)
- {
- this.pageService = pageService;
- }
-
- public InterceptorStackFactory getStackFactory()
- {
- return stackFactory;
- }
-
- public void setStackFactory(InterceptorStackFactory stackFactory)
- {
- this.stackFactory = stackFactory;
- }
-
- public void handle(ServerInvocation invocation) throws ServerException
- {
- URLContext urlContext = invocation.getServerContext().getURLContext();
- ControllerContext controllerContext = new ControllerContext(invocation, this);
-
- // Invoke the chain that creates the initial command
- ControllerCommand cmd = commandFactory.doMapping(invocation, invocation.getServerContext().getPortalContextPath(), invocation.getServerContext().getPortalRequestPath());
-
- //
- if (cmd == null)
- {
- // Handle that case
- throw new ServerException("No valid command");
- }
-
- try
- {
- while (true)
- {
- Forward forward;
-
- //
- try
- {
- // Execute command
- Object response = controllerContext.execute(cmd);
-
- // Handle the result
- forward = handleResult(cmd, response, invocation);
- }
- catch (CommandRedirectionException e)
- {
- // Handle the redirection as forward
- forward = new Forward(e.getRedirection(), null);
- }
-
- //
- if (forward == null)
- {
- break;
- }
-
- // Find out if we can execute in the same server invocation
- if (requiresRedirect(urlContext, cmd, invocation))
- {
- String url = controllerContext.renderURL(forward.getCommand(), forward.getURLContext(), null);
- if (url == null)
- {
- throw new ControllerException();
- }
- sendRedirect(invocation, url);
- break;
- }
- else
- {
- cmd = forward.getCommand();
- }
- }
- }
- catch (InsufficientTransportGuaranteeException e)
- {
- urlContext = URLContext.newInstance(true, urlContext.isAuthenticated());
- ServerURL serverURL = getURLFactory().doMapping(invocation, cmd);
- String url = invocation.getResponse().renderURL(serverURL, urlContext, null);
- sendRedirect(invocation, url);
- }
- catch (ControllerSecurityException e)
- {
- if (urlContext.isAuthenticated())
- {
- sendStatusCode(invocation, HttpServletResponse.SC_UNAUTHORIZED);
- }
- else
- {
- urlContext = URLContext.newInstance(urlContext.getSecure(), true);
- ServerURL serverURL = getURLFactory().doMapping(invocation, cmd);
- String url = invocation.getResponse().renderURL(serverURL, urlContext, null);
- sendRedirect(invocation, url);
- }
- }
- catch (ResourceNotFoundException e)
- {
- sendStatusCode(invocation, HttpServletResponse.SC_NOT_FOUND);
- }
- catch (ControllerException e)
- {
- throw new ServerException(e);
- }
- catch (ServletException e)
- {
- throw new ServerException(e);
- }
- catch (IOException e)
- {
- throw new ServerException(e);
- }
- }
-
- /**
- *
- */
- private Forward handleResult(ControllerCommand cmd, Object response, ServerInvocation invocation) throws IOException, ServletException, ServerException
- {
- if (response instanceof PageRendition)
- {
- PageRendition rendition = (PageRendition)response;
- rendition.render(invocation);
- return null;
- }
- else if (response instanceof org.jboss.portal.core.controller.command.response.PortletResponse)
- {
- PortletResponse pr = (PortletResponse)response;
- PortletInvocationResponse pir = pr.getResult();
- if (pir instanceof RenderResponse)
- {
- RenderResponse renderResult = (RenderResponse)pir;
- StateString portletNavState = renderResult.getNavigationalState();
- WindowState windowState = renderResult.getWindowState();
- Mode mode = renderResult.getMode();
- InvokeWindowRenderCommand iwrc = new InvokeWindowRenderCommand(
- pr.getWindowId(),
- mode,
- windowState,
- portletNavState);
- return new Forward(iwrc, null);
- }
- else if (pir instanceof HTTPRedirectionResponse)
- {
- HTTPRedirectionResponse redirectionResult = (HTTPRedirectionResponse)pir;
- String url = redirectionResult.getLocation();
- sendRedirect(invocation, url);
- return null;
- }
- else if (pir instanceof InsufficientTransportGuaranteeResponse)
- {
- boolean authenticated = invocation.getServerContext().getURLContext().isAuthenticated();
- return new Forward(cmd, URLContext.newInstance(true, authenticated));
- }
- else if (pir instanceof InsufficientPrivilegesResponse)
- {
- boolean authenticated = invocation.getServerContext().getURLContext().isAuthenticated();
- return new Forward(cmd, URLContext.newInstance(true, authenticated));
- }
- else if (pir instanceof SignOutResponse)
- {
- SignOutResponse signOut = (SignOutResponse)pir;
-
- // Indicate that we want a sign out to be done
- invocation.getResponse().setWantSignOut(true);
-
- // Get the optional signout location
- String location = signOut.getLocation();
-
- //
- if (location == null)
- {
- // Redirect to the same page
- InvokeWindowActionCommand iwac = (InvokeWindowActionCommand)cmd;
- Page page = iwac.getPage();
- RenderPageCommand renderCmd = new RenderPageCommand(page.getId());
- boolean secure = invocation.getServerContext().getURLContext().getSecure();
- URLContext urlInfo = URLContext.newInstance(secure, false);
- return new Forward(renderCmd, urlInfo);
- }
- else
- {
- sendRedirect(invocation, location);
- return null;
- }
- }
- else if (pir instanceof ErrorResponse)
- {
- ErrorResponse error = (ErrorResponse)pir;
- error.logErrorTo(log, "An portlet exception occured in portlet");
- sendStatusCode(invocation, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- return null;
- }
- else
- {
- throw new IllegalStateException();
- }
- }
- else if (response instanceof org.jboss.portal.core.controller.command.response.SignOutResponse)
- {
- // Indicate that we want a sign out to be done
- invocation.getResponse().setWantSignOut(true);
-
- //
- Portal portal = portalObjectContainer.getContext().getDefaultPortal();
- RenderPageCommand renderCmd = new RenderPageCommand(portal.getId());
- boolean secure = invocation.getServerContext().getURLContext().getSecure();
- URLContext urlInfo = URLContext.newInstance(secure, false);
- return new Forward(renderCmd, urlInfo);
- }
- else if (response instanceof StreamContentResponse)
- {
- StreamContentResponse scr = (StreamContentResponse)response;
- HttpServletResponse resp = invocation.getServerContext().getClientResponse();
- resp.setContentType(scr.getContentType());
- ServletOutputStream sout = resp.getOutputStream();
- InputStream is = scr.getInputStream();
- byte[] buf = new byte[2048];
- int len;
- while ((len = is.read(buf)) > 0)
- {
- sout.write(buf, 0, len);
- }
- sout.flush();
- sout.close();
- return null;
- }
- else if (response instanceof UpdateViewResponse)
- {
- UpdateViewResponse uvr = (UpdateViewResponse)response;
- RenderPageCommand renderCmd = new RenderPageCommand(uvr.getPageId());
- return new Forward(renderCmd, null);
- }
- else if (response instanceof UpdateWindowMarkupResponse)
- {
- UpdateWindowMarkupResponse uwmr = (UpdateWindowMarkupResponse)response;
- PortalObject window = portalObjectContainer.getObject(uwmr.getWindowId());
- Page page = (Page)window.getParent();
- RenderPageCommand rpc = new RenderPageCommand(page.getId());
- return new Forward(rpc, null);
- }
- else
- {
- throw new IllegalArgumentException();
- }
- }
-
- private void sendStatusCode(ServerInvocation invocation, int sc) throws ServerException
- {
- try
- {
- HttpServletResponse resp = invocation.getServerContext().getClientResponse();
- resp.sendError(sc);
- }
- catch (IOException e)
- {
- throw new ServerException(e);
- }
- }
-
- private void sendRedirect(ServerInvocation invocation, String redirect) throws ServerException
- {
- try
- {
- HttpServletResponse resp = invocation.getServerContext().getClientResponse();
- resp.sendRedirect(redirect);
- }
- catch (IOException e)
- {
- throw new ServerException(e);
- }
- }
-
- public static class Forward
- {
-
- /** . */
- private final ControllerCommand cmd;
-
- /** . */
- private final URLContext urlCtx;
-
- public Forward(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;
- }
- }
-
- public boolean requiresRedirect(URLContext urlCtx, ControllerCommand cmd, ServerInvocation invocation)
- {
- CommandInfo cmdInfo = cmd.getInfo();
- if (cmdInfo instanceof ActionCommandInfo && !((ActionCommandInfo)cmdInfo).isIdempotent())
- {
- return true;
- }
- else
- {
- boolean currentAuthenticated = invocation.getServerContext().getURLContext().isAuthenticated();
- if (urlCtx != null && currentAuthenticated != urlCtx.isAuthenticated())
- {
- return true;
- }
- else
- {
- boolean currentSecure = invocation.getServerContext().getURLContext().getSecure();
- if (urlCtx != null && urlCtx.getSecure() && !currentSecure)
- {
- return true;
- }
- }
- }
- return false;
- }
-}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -25,9 +25,8 @@
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.CoreController;
-import org.jboss.portal.core.controller.command.MoveWindowCommand;
-import org.jboss.portal.server.RequestController;
+import org.jboss.portal.core.controller.Controller;
+import org.jboss.portal.core.model.portal.command.MoveWindowCommand;
import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
@@ -37,9 +36,8 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class AjaxController extends CoreController implements RequestController
+public class AjaxController extends Controller
{
-
public void handle(ServerInvocation invocation) throws ServerException
{
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 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -25,7 +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.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.theme.PageRendition;
import org.jboss.portal.theme.ThemeConstants;
Added: trunk/core/src/main/org/jboss/portal/core/controller/classic/AbstractResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/AbstractResponseHandler.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/AbstractResponseHandler.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * 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.server.ServerInvocation;
+import org.jboss.portal.server.ServerException;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractResponseHandler extends AbstractJBossService implements ResponseHandler
+{
+
+ public static void sendStatusCode(ServerInvocation invocation, int sc) throws ServerException
+ {
+ try
+ {
+ HttpServletResponse resp = invocation.getServerContext().getClientResponse();
+ resp.sendError(sc);
+ }
+ catch (IOException e)
+ {
+ throw new ServerException(e);
+ }
+ }
+
+ public static void sendRedirect(ServerInvocation invocation, String redirect) throws ServerException
+ {
+ try
+ {
+ HttpServletResponse resp = invocation.getServerContext().getClientResponse();
+ resp.sendRedirect(redirect);
+ }
+ catch (IOException e)
+ {
+ throw new ServerException(e);
+ }
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/CoreController.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/CoreController.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,198 @@
+/******************************************************************************
+ * 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.command.info.ActionCommandInfo;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.Controller;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.CommandRedirectionException;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.InsufficientTransportGuaranteeException;
+import org.jboss.portal.core.controller.ControllerSecurityException;
+import org.jboss.portal.core.controller.ResourceNotFoundException;
+import org.jboss.portal.core.controller.portlet.PortletResponseHandler;
+import org.jboss.portal.core.model.portal.PortalObjectResponseHandler;
+import org.jboss.portal.server.ServerException;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.server.ServerURL;
+import org.jboss.portal.server.request.URLContext;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ClassicController extends Controller
+{
+
+ private ResponseHandler[] handlers = new ResponseHandler[]
+ {
+ new ClassicResponseHandler(),
+ new PortalObjectResponseHandler(),
+ new PortletResponseHandler()
+ };
+
+ public void handle(ServerInvocation invocation) throws ServerException
+ {
+ URLContext urlContext = invocation.getServerContext().getURLContext();
+ ControllerContext ctx = new ControllerContext(invocation, this);
+
+ // Invoke the chain that creates the initial command
+ ControllerCommand cmd = commandFactory.doMapping(invocation, invocation.getServerContext().getPortalContextPath(), invocation.getServerContext().getPortalRequestPath());
+
+ //
+ if (cmd == null)
+ {
+ // Handle that case
+ throw new ServerException("No valid command");
+ }
+
+ try
+ {
+ while (true)
+ {
+ CommandForward forward;
+
+ //
+ try
+ {
+ // Execute command
+ Object response = ctx.execute(cmd);
+
+ // Handle the result
+ forward = handleResponse(ctx, cmd, response);
+ }
+ catch (CommandRedirectionException e)
+ {
+ // Handle the redirection as forward
+ forward = new CommandForward(e.getRedirection(), null);
+ }
+
+ //
+ if (forward == null)
+ {
+ break;
+ }
+
+ // Find out if we can execute in the same server invocation
+ if (requiresRedirect(urlContext, cmd, invocation))
+ {
+ String url = ctx.renderURL(forward.getCommand(), forward.getURLContext(), null);
+ if (url == null)
+ {
+ throw new ControllerException();
+ }
+ AbstractResponseHandler.sendRedirect(invocation, url);
+ break;
+ }
+ else
+ {
+ cmd = forward.getCommand();
+ }
+ }
+ }
+ catch (InsufficientTransportGuaranteeException e)
+ {
+ urlContext = URLContext.newInstance(true, urlContext.isAuthenticated());
+ ServerURL serverURL = getURLFactory().doMapping(invocation, cmd);
+ String url = invocation.getResponse().renderURL(serverURL, urlContext, null);
+ AbstractResponseHandler.sendRedirect(invocation, url);
+ }
+ catch (ControllerSecurityException e)
+ {
+ if (urlContext.isAuthenticated())
+ {
+ AbstractResponseHandler.sendStatusCode(invocation, HttpServletResponse.SC_UNAUTHORIZED);
+ }
+ else
+ {
+ urlContext = URLContext.newInstance(urlContext.getSecure(), true);
+ ServerURL serverURL = getURLFactory().doMapping(invocation, cmd);
+ String url = invocation.getResponse().renderURL(serverURL, urlContext, null);
+ AbstractResponseHandler.sendRedirect(invocation, url);
+ }
+ }
+ catch (ResourceNotFoundException e)
+ {
+ AbstractResponseHandler.sendStatusCode(invocation, HttpServletResponse.SC_NOT_FOUND);
+ }
+ catch (ControllerException e)
+ {
+ throw new ServerException(e);
+ }
+ catch (ServletException e)
+ {
+ throw new ServerException(e);
+ }
+ catch (IOException e)
+ {
+ throw new ServerException(e);
+ }
+ }
+
+ private CommandForward handleResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
+ {
+ for (int i = 0;i < handlers.length;i++)
+ {
+ ResponseHandler handler = handlers[i];
+ CommandForward forward = handler.handleResponse(ctx, cmd, response);
+ if (forward != null)
+ {
+ return forward;
+ }
+ }
+ return null;
+ }
+
+ public boolean requiresRedirect(URLContext urlCtx, ControllerCommand cmd, ServerInvocation invocation)
+ {
+ CommandInfo cmdInfo = cmd.getInfo();
+ if (cmdInfo instanceof ActionCommandInfo && !((ActionCommandInfo)cmdInfo).isIdempotent())
+ {
+ return true;
+ }
+ else
+ {
+ boolean currentAuthenticated = invocation.getServerContext().getURLContext().isAuthenticated();
+ if (urlCtx != null && currentAuthenticated != urlCtx.isAuthenticated())
+ {
+ return true;
+ }
+ else
+ {
+ boolean currentSecure = invocation.getServerContext().getURLContext().getSecure();
+ if (urlCtx != null && urlCtx.getSecure() && !currentSecure)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,108 @@
+/******************************************************************************
+ * 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.server.ServerException;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.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.classic.AbstractResponseHandler;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.portal.command.RenderPageCommand;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassicResponseHandler extends AbstractResponseHandler
+{
+
+ public CommandForward handleResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
+ {
+ ServerInvocation invocation = ctx.getServerInvocation();
+
+ if (response instanceof PageRendition)
+ {
+ PageRendition rendition = (PageRendition)response;
+ rendition.render(invocation);
+ return null;
+ }
+ else if (response instanceof SignOutResponse)
+ {
+ // Get the optional signout location
+ String location = ((SignOutResponse)response).getLocation();
+
+ // Indicate that we want a sign out to be done
+ invocation.getResponse().setWantSignOut(true);
+
+ //
+ if (location == null)
+ {
+ PortalObjectContainer portalObjectContainer = ctx.getController().getPortalObjectContainer();
+ Portal portal = portalObjectContainer.getContext().getDefaultPortal();
+ RenderPageCommand renderCmd = new RenderPageCommand(portal.getId());
+ boolean secure = invocation.getServerContext().getURLContext().getSecure();
+ URLContext urlContext = URLContext.newInstance(secure, false);
+ location = ctx.renderURL(renderCmd, urlContext, null);
+ }
+
+ //
+ sendRedirect(invocation, location);
+
+ //
+ return null;
+ }
+ else if (response instanceof StreamContentResponse)
+ {
+ StreamContentResponse scr = (StreamContentResponse)response;
+ HttpServletResponse resp = invocation.getServerContext().getClientResponse();
+ resp.setContentType(scr.getContentType());
+ ServletOutputStream sout = resp.getOutputStream();
+ InputStream is = scr.getInputStream();
+ byte[] buf = new byte[2048];
+ int len;
+ while ((len = is.read(buf)) > 0)
+ {
+ sout.write(buf, 0, len);
+ }
+ sout.flush();
+ sout.close();
+ return null;
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/controller/classic/CommandForward.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/CommandForward.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/CommandForward.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * 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.server.request.URLContext;
+import org.jboss.portal.core.controller.ControllerCommand;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CommandForward
+{
+ /** . */
+ 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/classic/ResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * 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.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 CommandForward handleResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException;
+}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowActionCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowActionCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowActionCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,140 +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.command;
-
-import org.jboss.logging.Logger;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.controller.ResourceNotFoundException;
-import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
-import org.jboss.portal.core.controller.command.info.CommandInfo;
-import org.jboss.portal.core.controller.command.response.PortletResponse;
-import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
-import org.jboss.portal.portlet.NoSuchPortletException;
-import org.jboss.portal.portlet.Parameters;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class InvokeWindowActionCommand extends InvokeWindowCommand
-{
-
- /** . */
- private static final Logger log = Logger.getLogger(InvokeWindowActionCommand.class);
-
- /** . */
- private static final CommandInfo info = new ActionCommandInfo(false, "view", false);
-
- /** . */
- private StateString navigationalState;
-
- /** . */
- private StateString interactionState;
-
- /** . */
- private Parameters formParameters;
-
- public InvokeWindowActionCommand(
- String windowId,
- Mode mode,
- WindowState windowState,
- StateString navigationalState,
- StateString interactionState,
- Parameters formParameters)
- throws IllegalArgumentException
- {
- super(windowId, mode, windowState);
- this.navigationalState = navigationalState;
- this.interactionState = interactionState;
- this.formParameters = formParameters;
- }
-
- public StateString getNavigationalState()
- {
- return navigationalState;
- }
-
- public StateString getInteractionState()
- {
- return interactionState;
- }
-
- public void setInteractionState(StateString interactionState)
- {
- this.interactionState = interactionState;
- }
-
- public Parameters getFormParameters()
- {
- return formParameters;
- }
-
- public void setFormParameters(Parameters formParameters)
- {
- this.formParameters = formParameters;
- }
-
- public CommandInfo getInfo()
- {
- return info;
- }
-
- public Object execute() throws ControllerException
- {
- try
- {
- PortletInvocation invocation = PortletInvocationFactory.createAction(
- context,
- mode,
- windowState,
- navigationalState,
- interactionState,
- formParameters,
- window,
- portal);
-
- //
- PortletInvocationResponse resp = instance.invoke(invocation);
-
- //
- return new PortletResponse(targetId, resp);
- }
- catch (PortletInvokerException e)
- {
- if (e instanceof NoSuchPortletException)
- {
- throw new ResourceNotFoundException(((NoSuchPortletException)e).getPortletId());
- }
- else
- {
- throw new ControllerException(e);
- }
- }
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,57 +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.command;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class InvokeWindowCommand extends WindowCommand
-{
-
- /** . */
- protected final Mode mode;
-
- /** . */
- protected final WindowState windowState;
-
- public InvokeWindowCommand(String windowId, Mode mode, WindowState windowState) throws IllegalArgumentException
- {
- super(windowId);
- this.mode = mode;
- this.windowState = windowState;
- }
-
- public Mode getMode()
- {
- return mode;
- }
-
- public WindowState getWindowState()
- {
- return windowState;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowRenderCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowRenderCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowRenderCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,125 +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.command;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.invocation.InvocationContext;
-import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.core.aspects.controller.PageNavigationInterceptor;
-import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.ControllerContext;
-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.UpdateWindowMarkupResponse;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.theme.LayoutService;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
-import org.jboss.portal.theme.strategy.StrategyException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class InvokeWindowRenderCommand extends InvokeWindowCommand
-{
-
- private static final CommandInfo info = new ViewCommandInfo(false, "view");
-
- /** . */
- protected final StateString navigationalState;
-
- public InvokeWindowRenderCommand(
- String windowRef,
- Mode mode,
- WindowState windowState,
- StateString navigationalState)
- throws IllegalArgumentException
- {
- super(windowRef, mode, windowState);
- this.navigationalState = navigationalState;
- }
-
- public InvokeWindowRenderCommand(
- String windowId,
- Mode mode,
- WindowState windowState)
- throws IllegalArgumentException
- {
- super(windowId, mode, windowState);
- this.navigationalState = null;
- }
-
- public StateString getNavigationalState()
- {
- return navigationalState;
- }
-
- public CommandInfo getInfo()
- {
- return info;
- }
-
- public Object execute() throws InvocationException
- {
- InvocationContext ctx = getContext();
-
- //
- if (navigationalState != null)
- {
- ctx.setAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, window.getInstanceRef(), navigationalState);
- }
-
- // Update the window nav state
- WindowNavigationalState windowNavState = (WindowNavigationalState)ctx.getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, window.getInstanceRef() + "_window");
- if (windowNavState == null)
- {
- windowNavState = new WindowNavigationalState();
- ctx.setAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, window.getId() + "_window", windowNavState);
- }
- if (mode != null)
- {
- windowNavState.setMode(mode);
- }
- if (windowState != null)
- {
- windowNavState.setWindowState(windowState);
- }
-
- // Udpate the page nav state
- try
- {
- ServerInvocation sinv = ((ControllerContext)getContext()).getServerInvocation();
- LayoutService layoutService = ((ControllerContext)getContext()).getController().getPageService().getLayoutService();
- PageNavigationInterceptor.updatePageNavigationalState(layoutService, context, sinv, portal, page, window, getMode(), getWindowState());
- }
- catch (StrategyException e)
- {
- throw new InvocationException(e);
- }
-
- //
- return new UpdateWindowMarkupResponse(window.getId());
- }
-}
\ No newline at end of file
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/MoveWindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/MoveWindowCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/MoveWindowCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,142 +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.command;
-
-import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.ControllerException;
-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;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.theme.navigation.PageNavigationalState;
-import org.jboss.portal.theme.page.WindowContext;
-
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class MoveWindowCommand extends WindowCommand
-{
-
- /** . */
- private static final CommandInfo info = new ActionCommandInfo(false, "view", false);
-
- /** . */
- private int fromPos;
-
- /** . */
- private String fromRegion;
-
- /** . */
- private int toPos;
-
- /** . */
- private String toRegion;
-
- public MoveWindowCommand(String windowRef, int fromPos, String fromRegion, int toPos, String toRegion)
- throws IllegalArgumentException
- {
- super(windowRef);
- this.fromPos = fromPos;
- this.fromRegion = fromRegion;
- this.toPos = toPos;
- this.toRegion = toRegion;
- }
-
- public CommandInfo getInfo()
- {
- return info;
- }
-
- public Object execute() throws ControllerException
- {
-
- // For now just update the navigational state of the page
- PageNavigationalState pns = (PageNavigationalState)getContext().getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, page.getId());
-
- //
- for (Iterator i = pns.getWindowContexts().iterator(); i.hasNext();)
- {
- WindowContext windowCtx = (WindowContext)i.next();
- String windowRegion = windowCtx.getRegionName();
- if (targetId.equals(windowCtx.getId()))
- {
- windowCtx.setRegionName(toRegion);
- windowCtx.setOrder(toPos);
- }
- else if (fromRegion.equals(windowRegion) && fromPos < windowCtx.getOrder())
- {
- windowCtx.setOrder(windowCtx.getOrder() - 1);
- }
- else if (toRegion.equals(windowRegion) && toPos <= windowCtx.getOrder())
- {
- windowCtx.setOrder(windowCtx.getOrder() + 1);
- }
- }
-
- //
- if (isDashboard())
- {
- for (Iterator i = page.getChildren().iterator(); i.hasNext();)
- {
- PortalObject child = (PortalObject)i.next();
- if (child.getType() == PortalObject.TYPE_WINDOW)
- {
- Window window = (Window)child;
- String windowId = window.getId();
- String regionId = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION);
- String posAsString = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER);
- if (regionId != null && posAsString != null)
- {
- try
- {
- int pos = Integer.parseInt(posAsString);
- if (targetId.equals(windowId))
- {
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, toRegion);
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(toPos));
- }
- else if (fromRegion.equals(regionId) && fromPos < pos)
- {
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(toPos - 1));
- }
- else if (toRegion.equals(regionId) && toPos <= pos)
- {
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(toPos + 1));
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
- }
- }
-
- //
- return null;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/PageCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/PageCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/PageCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,80 +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.command;
-
-import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.controller.ResourceNotFoundException;
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.Portal;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class PageCommand extends PortalObjectCommand
-{
-
- /** . */
- protected Page page;
-
- /** . */
- protected Portal portal;
-
- public PageCommand(String pageId)
- {
- super(pageId);
- }
-
- /**
- * Get the requested page
- *
- * @return the requested page
- */
- public Page getPage()
- {
- return page;
- }
-
- /**
- * Initialize the command
- *
- * @throws org.jboss.portal.common.invocation.InvocationException
- *
- */
- public void create() throws ControllerException
- {
- super.create();
-
- //
- page = (Page)getTarget();
-
- // Get nearest portal ancestor
- portal = page.getPortal();
-
- //
- if (portal == null)
- {
- throw new ResourceNotFoundException(targetId);
- }
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/PortalCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/PortalCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/PortalCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,66 +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.command;
-
-import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.model.portal.Portal;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class PortalCommand extends PortalObjectCommand
-{
-
- /** . */
- protected Portal portal;
-
- public PortalCommand(String portalId)
- {
- super(portalId);
- }
-
- /**
- * Get the requestet portal
- *
- * @return the requested portal
- */
- public Portal getPortal()
- {
- return portal;
- }
-
- /**
- * Initialize the command
- *
- * @throws org.jboss.portal.common.invocation.InvocationException
- *
- */
- public void create() throws ControllerException
- {
- super.create();
-
- //
- portal = (Portal)getTarget();
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/PortalObjectCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/PortalObjectCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/PortalObjectCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,121 +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.command;
-
-import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.controller.ControllerSecurityException;
-import org.jboss.portal.core.controller.ResourceAccessDeniedException;
-import org.jboss.portal.core.controller.ResourceNotFoundException;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.PortalObjectPermission;
-import org.jboss.portal.security.PortalSecurityException;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class PortalObjectCommand extends ControllerCommand
-{
-
- protected final String targetId;
-
- protected PortalObject target;
-
- private Boolean dashboard;
-
- protected PortalObjectCommand(String targetId)
- {
- if (targetId == null)
- {
- throw new IllegalArgumentException();
- }
- this.targetId = targetId;
- }
-
-
- public final String getTargetId()
- {
- return targetId;
- }
-
- public void create() throws ControllerException
- {
- // Get portal object
- target = context.getController().getPortalObjectContainer().getObject(targetId);
-
- if (target == null)
- {
- throw new ResourceNotFoundException(targetId);
- }
- }
-
- /**
- * Enforce the security on this command using the provided portal authorization manager.
- *
- * @param pam the portal authorization manager
- * @throws org.jboss.portal.core.controller.ControllerSecurityException
- * if the access is not granted
- */
- public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
- {
- PortalObject target = getTarget();
- String id = target.getId();
- PortalObjectPermission perm = new PortalObjectPermission(id, PortalObjectPermission.VIEW_MASK);
- if (!pam.checkPermission(perm))
- {
- throw new ResourceAccessDeniedException("Not Authorized");
- }
- }
-
- /**
- * Return the target portal object of this command.
- *
- * @return the target portal object
- */
- public final PortalObject getTarget()
- {
- return target;
- }
-
- public boolean isDashboard()
- {
- if (dashboard == null)
- {
- try
- {
- PortalAuthorizationManagerFactory pamf = getControllerContext().getController().getPortalAuthorizationManagerFactory();
- PortalAuthorizationManager pam = pamf.getManager();
- PortalObjectPermission perm = new PortalObjectPermission(targetId, PortalObjectPermission.DASHBOARD_MASK);
- dashboard = Boolean.valueOf(pam.checkPermission(perm));
- }
- catch (PortalSecurityException e)
- {
- dashboard = Boolean.FALSE;
- }
- }
- return dashboard.booleanValue();
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/RenderPageCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/RenderPageCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/RenderPageCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,643 +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.command;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.invocation.AttributeResolver;
-import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.common.util.Exceptions;
-import org.jboss.portal.common.NotYetImplemented;
-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.ControllerSecurityException;
-import org.jboss.portal.core.controller.ResourceAccessDeniedException;
-import org.jboss.portal.core.controller.ResourceNotFoundException;
-import org.jboss.portal.core.controller.command.info.CommandInfo;
-import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
-import org.jboss.portal.core.controller.command.response.PortletResponse;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.PortalObjectPermission;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.identity.User;
-import org.jboss.portal.portlet.Properties;
-import org.jboss.portal.portlet.info.ModeInfo;
-import org.jboss.portal.portlet.info.WindowStateInfo;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-import org.jboss.portal.portlet.invocation.response.InsufficientPrivilegesResponse;
-import org.jboss.portal.portlet.invocation.response.InsufficientTransportGuaranteeResponse;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
-import org.jboss.portal.security.PortalSecurityException;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
-import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.ServerInvocationContext;
-import org.jboss.portal.server.config.ServerConfig;
-import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.server.request.URLFormat;
-import org.jboss.portal.theme.LayoutService;
-import org.jboss.portal.theme.PageRendition;
-import org.jboss.portal.theme.PortalLayout;
-import org.jboss.portal.theme.PortalTheme;
-import org.jboss.portal.theme.ServerRegistrationID;
-import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.theme.ThemeResult;
-import org.jboss.portal.theme.ThemeService;
-import org.jboss.portal.theme.navigation.PageNavigationalState;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
-import org.jboss.portal.theme.page.ModifiablePageResult;
-import org.jboss.portal.theme.page.ModifiableWindowResult;
-import org.jboss.portal.theme.page.PageService;
-import org.jboss.portal.theme.page.WindowResult;
-import org.jboss.portal.theme.render.MarkupResult;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-/**
- * Render a full page.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public final class RenderPageCommand extends PageCommand
-{
-
- /**
- * .
- */
- private static String WINDOW_ACCESS_DENIED = "core.render.window_access_denied";
-
- /**
- * .
- */
- private static String WINDOW_UNAVAILABLE = "core.render.window_unavailable";
-
- /**
- * .
- */
- private static String WINDOW_ERROR = "core.render.window_error";
-
- /**
- * .
- */
- private static String WINDOW_INTERNAL_ERROR = "core.render.window_internal_error";
-
- /**
- * .
- */
- private static String WINDOW_NOT_FOUND = "core.render.window_not_found";
-
- /**
- * .
- */
- private static String HIDE = "hide";
-
- /**
- * .
- */
- private static String SHOW = "show";
-
- /**
- * .
- */
- private static final CommandInfo info = new ViewCommandInfo(false, "view");
-
- /**
- * The windows to render.
- */
- private Collection windows;
-
- /**
- * .
- */
- private PortalLayout layout;
-
- /**
- * .
- */
- private boolean personalizable;
-
- public RenderPageCommand(String pageId)
- {
- super(pageId);
- }
-
- /**
- * Get the command info (runtime info about the command)
- *
- * @return info about the command
- */
- public CommandInfo getInfo()
- {
- return info;
- }
-
- /**
- * Get the layout that was determined for this request (based on portal and page properties)
- *
- * @return the layout to use for this request
- */
- public PortalLayout getLayout()
- {
- return layout;
- }
-
- /**
- * Returns the modifiable list of windows.
- *
- * @return the windows on the page
- */
- public Collection getWindows()
- {
- return windows;
- }
-
- /**
- * initialize the command
- *
- * @throws InvocationException
- */
- public void create() throws ControllerException
- {
- super.create();
-
- // All windows on the page
- windows = new ArrayList(getPage().getChildren());
-
- //
- LayoutService layoutService = context.getController().getPageService().getLayoutService();
- layout = getLayout(layoutService, page);
- }
-
- public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
- {
- //
- super.enforceSecurity(pam);
-
- // Check if the user can personalize the page
- String uri = page.getId();
- PortalObjectPermission perm = new PortalObjectPermission(uri, PortalObjectPermission.PERSONALIZE_MASK);
- personalizable = pam.checkPermission(perm);
- }
-
- /**
- * execute the command
- *
- * @throws InvocationException
- */
- public Object execute() throws ControllerException, InvocationException
- {
- ServerInvocation sinv = context.getServerInvocation();
- HttpServletRequest request = sinv.getServerContext().getClientRequest();
- try
- {
- // Ensure that the page nav state is in place
- AttributeResolver navCtx = sinv.getContext().getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
- PageNavigationalState pageNavState = (PageNavigationalState)navCtx.getAttribute(page.getId());
-
- if (pageNavState == null)
- {
- throw new InvocationException("PageNavigationalState not available in NavigationalStateContext");
- }
-
- //
- PageService pageService = context.getController().getPageService();
- PortalTheme theme = null;
-
- if (personalizable)
- {
- ControllerContext controllerCtx = (ControllerContext)getContext();
- User user = (User)controllerCtx.getServerInvocation().getRequest().getUser();
- if (user != null)
- {
- String themeId = user.getTheme();
- if (themeId != null)
- {
- theme = getTheme(themeId);
- }
- }
- }
-
- // If nothing get it from the object properties
- if (theme == null)
- {
- String themeId = page.getProperty(ThemeConstants.PORTAL_PROP_THEME);
- theme = getTheme(themeId);
- }
-
- // Call the portlet container to create the markup fragment(s) for each portlet that needs to render itself
- ServerConfig cfg = sinv.getRequest().getServer().getConfig();
- ModifiablePageResult renderResult = new ModifiablePageResult(getPage().getName(), new HashMap(getPage().getDeclaredProperties()), new HashMap(getPage().getPortal().getDeclaredProperties()));
-
- // Render
- for (Iterator i = windows.iterator(); i.hasNext();)
- {
- PortalObject o = (PortalObject)i.next();
- if (o instanceof Window)
- {
- Window window = (Window)o;
- if (pageNavState.isWindowVisible(window.getId()))
- {
- Object res = renderPortletWindow(cfg, window);
- if (res == null)
- {
- // Skip
- }
- else if (res instanceof MarkupResult)
- {
- MarkupResult result = (MarkupResult)res;
- renderResult.addWindowContext(pageNavState.getWindowContext(window.getId()));
- renderResult.addWindowResult(window.getId(), (WindowResult)result);
- }
- else
- {
- return res;
- }
- }
- }
- }
-
- // Make the theme available as servlet request attribute (needed for CM)
- if (theme != null)
- {
- // render the theme markup and place it into the request so that the markup assembler (theme tag) can pick it up there
- ThemeResult themeResult = theme.assembleResponse(sinv.getRequest(), sinv.getResponse());
- renderResult.setTheme(theme);
- renderResult.setThemeResult(themeResult);
-
- //
- return new PageRendition(layout, pageNavState, renderResult, pageService);
- }
- }
- catch (Exception e)
- {
- ControllerCommand.rethrow(e);
- }
- finally
- {
- request.removeAttribute(ThemeConstants.ATTR_THEMESERVER);
- request.removeAttribute(ThemeConstants.ATTR_THEME);
- request.removeAttribute(ThemeConstants.ATTR_THEMERESULT);
- }
-
- //
- return null;
- }
-
- private PortalTheme getTheme(String themeIdString)
- {
- //
- ThemeService service = context.getController().getPageService().getThemeService();
-
- // If the id is provided in the form of context.name then look up the theme via a registration id
- if (themeIdString.lastIndexOf(".") > 0)
- {
- ServerRegistrationID themeId = ServerRegistrationID.createID(ServerRegistrationID.TYPE_THEME, parseID(themeIdString));
- return service.getTheme(themeId, true);
- }
- else
- {
- // Otherwise use the ordinary theme name provided and lookup the theme via the name
- return service.getTheme(themeIdString, true);
- }
- }
-
- /**
- * Get the portal layout to use for the provided page. <p>The name of the layout to use can be defined as a property
- * in the portal, or the individual page. The page property overwrites the portal property. If no property was set, a
- * default layout with the name "nodesk" is assumed.</p>
- *
- * @param layoutService the layout service that allows access to the layout
- * @param page the page that hosts the markup container to render (the page, region, window,...)
- * @return a <code>PortalLayout</code> for the defined layout name
- */
- public static PortalLayout getLayout(LayoutService layoutService, Page page)
- {
- String layoutIDString = page.getProperty(ThemeConstants.PORTAL_PROP_LAYOUT);
-
- // Last resort: use the nodesk layout
- if (layoutIDString == null)
- {
- layoutIDString = "nodesk";
- }
-
- //
- PortalLayout layout;
- if (layoutIDString.lastIndexOf(".") > 0)
- {
- // if the id is provided in the form of context.name then look up the layout via a registration id
- ServerRegistrationID layoutID = ServerRegistrationID.createID(ServerRegistrationID.TYPE_LAYOUT, parseID(layoutIDString));
- layout = layoutService.getLayout(layoutID, true);
- }
- else
- {
- // otherwise use the ordinary layout name provided and lookup the layout via the name
- layout = layoutService.getLayout(layoutIDString, true);
- }
-
- // We don't like that situation
- if (layout == null)
- {
- throw new IllegalStateException("NO LAYOUT FOUND FOR " + layoutIDString);
- }
-
- //
- return layout;
- }
-
- /**
- * Call the component container to render the markup fragment of a window
- *
- * @param cfg the server config to get information about the error behaviour
- * @param window the window to render
- * @return a result containing markup, or other result information (redirect url, etc.)
- * @throws InvocationException
- */
- protected Object renderPortletWindow(ServerConfig cfg, Window window) throws ControllerException
- {
- // Execute render command
- String windowRef = window.getId();
-
- //
- String windowTitle;
- String contentChars = "";
- String headerChars = null;
- Map actionMap = new HashMap();
- Properties responseProps;
- Map windowProps = window.getDeclaredProperties();
- WindowNavigationalState windowNavState = (WindowNavigationalState)this.context.getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, window.getId() + "_window");
-
- try
- {
- RenderWindowCommand renderCmd = new RenderWindowCommand(windowRef);
-
- //
- PortletResponse portletResponse = (PortletResponse)context.execute(renderCmd);
- PortletInvocationResponse response = portletResponse.getResult();
-
- //
- if (response instanceof InsufficientTransportGuaranteeResponse)
- {
- return response;
- }
-
- //
- if (response instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)response;
- windowTitle = fragment.getTitle();
- if (windowTitle == null)
- {
- windowTitle = window.getName();
- }
- headerChars = fragment.getHeader();
-// responseProps = fragment.getProperties();
- responseProps = new Properties(); // remove me
-
- //
- Instance instance = renderCmd.getInstance();
-
- //
- List supportedWindowStates = new ArrayList();
- for (Iterator i = instance.getPortlet().getInfo().getCapabilities().getAllWindowStates().iterator(); i.hasNext();)
- {
- WindowStateInfo windowStateInfo = (WindowStateInfo)i.next();
- WindowState windowState = windowStateInfo.getWindowState();
- if (portal.getSupportedWindowStates().contains(windowState))
- {
- supportedWindowStates.add(windowState);
- }
- }
-
- //
- List supportedModes = new ArrayList();
- for (Iterator i = instance.getPortlet().getInfo().getCapabilities().getAllModes().iterator(); i.hasNext();)
- {
- ModeInfo modeInfo = (ModeInfo)i.next();
- Mode mode = modeInfo.getMode();
- if (portal.getSupportedModes().contains(mode))
- {
- supportedModes.add(mode);
- }
- }
-
- // Remove edit mode if the user is not logged it
- if (getControllerContext().getServerInvocation().getServerContext().getClientRequest().getUserPrincipal() == null)
- {
- supportedModes.remove(Mode.EDIT);
- }
-
- //
- addModeActions(window, actionMap, windowNavState.getMode(), supportedModes);
-
- //
- addStateActions(window, actionMap, windowNavState.getWindowState(), supportedWindowStates);
-
- //
- contentChars = fragment.getContent();
-
- //
- return new ModifiableWindowResult(windowTitle, contentChars, actionMap, windowProps, responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
- }
- else if (response instanceof ErrorResponse)
- {
- ErrorResponse errorResult = (ErrorResponse)response;
- String logMessage = "Rendering portlet window " + windowRef + " triggered the following error :";
- errorResult.logErrorTo(ControllerCommand.log, logMessage);
- String property = cfg.getProperty(WINDOW_ERROR);
- if (!HIDE.equals(property))
- {
- windowTitle = "An error occured while rendering window '" + windowRef + "'";
- responseProps = new Properties();
- contentChars = errorResult.getMessage();
- Throwable t = errorResult.getThrowable();
- if (t != null && SHOW.equals(property))
- {
- contentChars = Exceptions.toHTML(t, true);
- }
- return new ModifiableWindowResult(windowTitle, contentChars, actionMap, windowProps, responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
- }
- }
- else if (response instanceof UnavailableResponse)
- {
- if (SHOW.equals(cfg.getProperty(WINDOW_UNAVAILABLE)))
- {
- windowTitle = "Portlet unavailable";
- contentChars = "Portlet unavailable";
- actionMap = new HashMap();
- actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
- actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
- responseProps = new Properties();
- return new ModifiableWindowResult(windowTitle, contentChars, actionMap, windowProps, responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
- }
- }
- else if (response instanceof InsufficientPrivilegesResponse)
- {
- // Julien : go to the section below, I know it is very ugly
- throw new ResourceAccessDeniedException(windowRef);
- }
- else
- {
- throw new NotYetImplemented("Unexpected result from a portlet invocation " + response);
- }
- }
- catch (ResourceAccessDeniedException e)
- {
- if (ControllerCommand.log.isTraceEnabled())
- {
- ControllerCommand.log.trace("Window access denied", e);
- }
- if (SHOW.equals(cfg.getProperty(WINDOW_ACCESS_DENIED)))
- {
- actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
- actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
- windowTitle = "Access denied";
- contentChars = "Access denied";
- responseProps = new Properties();
- return new ModifiableWindowResult(windowTitle, contentChars, actionMap, windowProps, responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
- }
- }
- catch (ResourceNotFoundException e)
- {
- if (ControllerCommand.log.isTraceEnabled())
- {
- ControllerCommand.log.trace("Window not found", e);
- }
- if (SHOW.equals(cfg.getProperty(WINDOW_NOT_FOUND)))
- {
- actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
- actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
- windowTitle = "Cannot render";
- contentChars = "Object not found " + e.getRef();
- responseProps = new Properties();
- return new ModifiableWindowResult(windowTitle, contentChars, actionMap, windowProps, responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
- }
- }
- catch (ControllerException e)
- {
- // It's a CommandException that we rethrow
- throw e;
- }
- catch (Exception e)
- {
- ControllerCommand.log.error("Rendering portlet window " + windowRef + " produced an internal error", e);
- String property = cfg.getProperty(WINDOW_INTERNAL_ERROR);
- if (SHOW.equals(property))
- {
- windowTitle = "An internal error occured while rendering window '" + window + "'";
- responseProps = new Properties();
- contentChars = Exceptions.toHTML(e, true);
- return new ModifiableWindowResult(windowTitle, contentChars, actionMap, windowProps, responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
- }
- }
-
- return null;
- }
-
- /**
- * parse the provided String for '.' as a separator. For each token, add an entry to a String[] that will be returned
- * as the result
- *
- * @param layoutIDString the string to be examined
- * @return an array of Strings
- */
- private static String[] parseID(String layoutIDString)
- {
- List names = new ArrayList();
- StringTokenizer tokens = new StringTokenizer(layoutIDString, ".");
- if (tokens.countTokens() > 1)
- {
- while (tokens.hasMoreElements())
- {
- names.add(tokens.nextToken());
- }
- }
- else
- {
- names.add(layoutIDString);
- }
-
- String[] id = new String[names.size()];
- names.toArray(id);
- return id;
- }
-
- /**
- * Create the action URLs for the allowed window states of the rendered portlet window and add them to the provided
- * actionMap.
- */
- private void addStateActions(Window window, Map actionMap, WindowState currentWindowState, List supportedWindowStates)
- {
- List windowStates = new ArrayList(supportedWindowStates.size());
- for (Iterator j = supportedWindowStates.iterator(); j.hasNext();)
- {
- WindowState windowState = (WindowState)j.next();
- String url = createUpdateNavigationalStateURL(window, null, windowState);
- boolean disabled = windowState.equals(currentWindowState);
- WindowResult.Action action = new WindowResult.Action(windowState, url, !disabled);
- windowStates.add(action);
- }
- actionMap.put(WindowResult.WINDOWSTATES_KEY, windowStates);
- }
-
- /**
- * Create the action URLs for the allowed portlet modes of the rendered portlet window and add them to the provided
- * actionMap.
- */
- private void addModeActions(Window window, Map actionMap, Mode currentMode, List supportedModes)
- {
- List modes = new ArrayList(supportedModes.size());
- for (Iterator j = supportedModes.iterator(); j.hasNext();)
- {
- Mode mode = (Mode)j.next();
- String url = createUpdateNavigationalStateURL(window, mode, null);
- boolean disabled = mode.equals(currentMode);
- WindowResult.Action action = new WindowResult.Action(mode, url, !disabled);
- modes.add(action);
- }
- actionMap.put(WindowResult.MODES_KEY, modes);
- }
-
- public String createUpdateNavigationalStateURL(Window window, Mode mode, WindowState windowState)
- {
- InvokeWindowRenderCommand cmd = new InvokeWindowRenderCommand(window.getId(), mode, windowState);
- ControllerContext controllerContext = getControllerContext();
- ServerInvocationContext serverContext = controllerContext.getServerInvocation().getServerContext();
- boolean secure = serverContext.getURLContext().getSecure();
- boolean authenticated = serverContext.getURLContext().isAuthenticated();
- URLContext urlContext = URLContext.newInstance(secure, authenticated);
- return controllerContext.renderURL(cmd, urlContext, URLFormat.newInstance(true, true));
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/RenderWindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/RenderWindowCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/RenderWindowCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,110 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.controller.command;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.controller.ResourceNotFoundException;
-import org.jboss.portal.core.controller.command.info.CommandInfo;
-import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
-import org.jboss.portal.core.controller.command.response.PortletResponse;
-import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
-import org.jboss.portal.portlet.NoSuchPortletException;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
-
-/**
- * Render a single window.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class RenderWindowCommand extends WindowCommand
-{
-
- /** . */
- private static final CommandInfo info = new ViewCommandInfo(true, "view");
-
- public RenderWindowCommand(String windowRef) throws IllegalArgumentException
- {
- super(windowRef);
- }
-
- public CommandInfo getInfo()
- {
- return info;
- }
-
- public Object execute() throws ControllerException
- {
- StateString navigationalState = (StateString)getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, window.getInstanceRef());
-
- //
- WindowNavigationalState windowNavState = (WindowNavigationalState)getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, targetId + "_window");
- if (windowNavState == null)
- {
- windowNavState = new WindowNavigationalState();
- setAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, window.getId() + "_window", windowNavState);
- }
-
- // Get the mode
- Mode mode = windowNavState.getMode();
-
- // Get the window state
- WindowState windowState = windowNavState.getWindowState();
-
- //
- RenderInvocation invocation = PortletInvocationFactory.createRender(
- context,
- mode,
- windowState,
- navigationalState,
- window,
- portal);
-
- //
- try
- {
- PortletInvocationResponse resp = instance.invoke(invocation);
-
- //
- return new PortletResponse(targetId, resp);
- }
- catch (PortletInvokerException e)
- {
- if (e instanceof NoSuchPortletException)
- {
- throw new ResourceNotFoundException(((NoSuchPortletException)e).getPortletId());
- }
- else
- {
- throw new ControllerException(e);
- }
- }
- }
-}
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 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -24,9 +24,9 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.portlet.SignOutResponse;
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;
/**
* A global signout.
@@ -40,6 +40,19 @@
/** . */
private static final CommandInfo info = new ActionCommandInfo(false, "view", false);
+ /** . */
+ private String location;
+
+ public SignOutCommand()
+ {
+ this(null);
+ }
+
+ public SignOutCommand(String location)
+ {
+ this.location = location;
+ }
+
public CommandInfo getInfo()
{
return info;
@@ -47,6 +60,13 @@
public Object execute() throws ControllerException
{
- return new SignOutResponse();
+ if (location != null)
+ {
+ return new SignOutResponse(location);
+ }
+ else
+ {
+ return new SignOutResponse();
+ }
}
}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/ViewDashboardCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/ViewDashboardCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/ViewDashboardCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,125 +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.command;
-
-import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.controller.ControllerSecurityException;
-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.UpdateViewResponse;
-import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.security.PortalSecurityException;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
-
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ViewDashboardCommand extends PortalCommand
-{
-
- /** . */
- private static final CommandInfo info = new ViewCommandInfo(false, "view");
-
- /** . */
- private Page dashboardPage;
-
- /** . */
- private String userId;
-
- public ViewDashboardCommand(String portalId)
- {
- super(portalId);
- }
-
- public CommandInfo getInfo()
- {
- return info;
- }
-
- public void create() throws ControllerException
- {
- super.create();
-
- //
- userId = getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser();
- }
-
- public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
- {
- if (userId == null)
- {
- throw new ControllerSecurityException("User needs to be authenticated to view a dashboard");
- }
- }
-
- public Object execute() throws ControllerException
- {
- dashboardPage = portal.getPage(userId);
-
- // Create if not exist
- if (dashboardPage == null)
- {
- try
- {
- dashboardPage = portal.createPage(userId);
- Page templatePage = (Page)portal.getParent().getChild("default").getChild("default");
- for (Iterator i = templatePage.getChildren().iterator(); i.hasNext();)
- {
- PortalObject child = (PortalObject)i.next();
- if (child.getType() == PortalObject.TYPE_WINDOW)
- {
- Window window = (Window)child;
- Window newWindow = dashboardPage.createWindow(window.getName());
- newWindow.setInstanceRef(window.getInstanceRef());
- for (Iterator j = window.getDeclaredProperties().entrySet().iterator(); j.hasNext();)
- {
- Map.Entry entry = (Map.Entry)j.next();
- String name = (String)entry.getKey();
- String value = (String)entry.getValue();
- newWindow.setDeclaredProperty(name, value);
- }
- }
- }
- }
- catch (DuplicatePortalObjectException e)
- {
- throw new ControllerException(e);
- }
- }
-
- //
- return new UpdateViewResponse(dashboardPage.getId());
- }
-
- public Page getDashboardPage()
- {
- return dashboardPage;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/WindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/WindowCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/WindowCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,136 +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.command;
-
-import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.controller.ControllerSecurityException;
-import org.jboss.portal.core.controller.ResourceNotFoundException;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.Portal;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.security.PortalSecurityException;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
-
-/**
- * A superclass for command that target a specific window.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class WindowCommand extends PortalObjectCommand
-{
-
- /** The portal. */
- protected Portal portal;
-
- /** The portal. */
- protected Page page;
-
- /** The window. */
- protected Window window;
-
- /** The instance. */
- protected Instance instance;
-
- public WindowCommand(String windowId) throws IllegalArgumentException
- {
- super(windowId);
- }
-
- public Instance getInstance()
- {
- return instance;
- }
-
- public Portal getPortal()
- {
- return portal;
- }
-
- public Page getPage()
- {
- return page;
- }
-
- public Window getWindow()
- {
- return window;
- }
-
- public void create() throws ControllerException
- {
- super.create();
-
- // Retrieve the window
- window = (Window)getTarget();
-
- // First retrieve the target
- page = (Page)window.getParent();
- if (page == null)
- {
- throw new ResourceNotFoundException(targetId);
- }
-
- // Get hardcoded portal for now
- portal = page.getPortal();
- if (portal == null)
- {
- throw new ResourceNotFoundException(targetId);
- }
-
- // Get instance
- instance = context.getController().getInstanceContainer().getInstance(window.getInstanceRef());
- if (instance == null)
- {
- throw new ResourceNotFoundException(window.getInstanceRef());
- }
-
- // Get the user customization id
- String userId = getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser();
- if (userId != null)
- {
- instance = instance.getCustomization(userId);
-
- //
- if (isDashboard())
- {
- String dashboardId = userId + targetId;
- instance = instance.getCustomization(dashboardId);
- }
- }
- }
-
- /**
- * We only enforce security at instance and component level.
- *
- * @param pam
- * @throws org.jboss.portal.core.controller.ControllerSecurityException
- *
- * @throws org.jboss.portal.security.PortalSecurityException
- *
- */
- public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
- {
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/response/PortletResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/response/PortletResponse.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/response/PortletResponse.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,63 +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.command.response;
-
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletResponse
-{
-
- /** . */
- private String windowId;
-
- /** . */
- private PortletInvocationResponse response;
-
- public PortletResponse(String windowId, PortletInvocationResponse response)
- {
- if (windowId == null)
- {
- throw new IllegalArgumentException();
- }
- if (response == null)
- {
- throw new IllegalArgumentException();
- }
- this.windowId = windowId;
- this.response = response;
- }
-
- public String getWindowId()
- {
- return windowId;
- }
-
- public PortletInvocationResponse getResult()
- {
- return response;
- }
-}
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 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/response/SignOutResponse.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -28,4 +28,30 @@
*/
public class SignOutResponse
{
+
+ /** Location is a URL to navigate to after signing out or null to indicate default behavior. */
+ protected String location;
+
+ public SignOutResponse()
+ {
+ }
+
+ public SignOutResponse(String location)
+ {
+ if (location == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.location = location;
+ }
+
+ /**
+ * Returns a destination URL or null.
+ *
+ * @return URL to navigate to after signing out or null to indicate default behavior
+ */
+ public String getLocation()
+ {
+ return location;
+ }
}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/response/UpdateViewResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/response/UpdateViewResponse.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/response/UpdateViewResponse.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,48 +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.command.response;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class UpdateViewResponse
-{
-
- /** . */
- private String pageId;
-
- public UpdateViewResponse(String pageId)
- {
- if (pageId == null)
- {
- throw new IllegalArgumentException();
- }
- this.pageId = pageId;
- }
-
- public String getPageId()
- {
- return pageId;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/command/response/UpdateWindowMarkupResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/response/UpdateWindowMarkupResponse.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/response/UpdateWindowMarkupResponse.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -1,48 +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.command.response;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class UpdateWindowMarkupResponse
-{
-
- /** . */
- private String windowId;
-
- public UpdateWindowMarkupResponse(String windowId)
- {
- if (windowId == null)
- {
- throw new IllegalArgumentException();
- }
- this.windowId = windowId;
- }
-
- public String getWindowId()
- {
- return windowId;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/portlet/AuthenticateResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/AuthenticateResponse.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/AuthenticateResponse.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -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.portlet;
-
-import org.jboss.portal.portlet.invocation.response.RedirectionResponse;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision:5352 $
- */
-public class AuthenticateResponse extends RedirectionResponse
-{
-}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -36,8 +36,8 @@
import org.jboss.portal.portlet.spi.RenderContext;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.command.InvokeWindowActionCommand;
-import org.jboss.portal.core.controller.command.InvokeWindowRenderCommand;
+import org.jboss.portal.core.model.portal.command.InvokeWindowActionCommand;
+import org.jboss.portal.core.model.portal.command.InvokeWindowRenderCommand;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.Mode;
Copied: trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponse.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/response/PortletResponse.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/response/PortletResponse.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponse.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.controller.portlet;
+
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+
+/**
+ * Controller response provided by a portlet.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletResponse
+{
+
+ /** . */
+ private String windowId;
+
+ /** . */
+ private PortletInvocationResponse response;
+
+ public PortletResponse(String windowId, PortletInvocationResponse response)
+ {
+ if (windowId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (response == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.windowId = windowId;
+ this.response = response;
+ }
+
+ public String getWindowId()
+ {
+ return windowId;
+ }
+
+ public PortletInvocationResponse getResult()
+ {
+ return response;
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,139 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.controller.portlet;
+
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.classic.AbstractResponseHandler;
+import org.jboss.portal.core.controller.classic.CommandForward;
+import org.jboss.portal.core.model.portal.command.InvokeWindowRenderCommand;
+import org.jboss.portal.core.model.portal.command.InvokeWindowActionCommand;
+import org.jboss.portal.core.model.portal.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.Page;
+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;
+import org.jboss.portal.portlet.invocation.response.RenderResponse;
+import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
+import org.jboss.portal.portlet.invocation.response.InsufficientTransportGuaranteeResponse;
+import org.jboss.portal.portlet.invocation.response.InsufficientPrivilegesResponse;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.StateString;
+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>
+ * @version $Revision: 1.1 $
+ */
+public class PortletResponseHandler extends AbstractResponseHandler
+{
+
+ public CommandForward handleResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
+ {
+ if (response instanceof PortletResponse)
+ {
+ ServerInvocation invocation = ctx.getServerInvocation();
+ PortletResponse pr = (PortletResponse)response;
+ PortletInvocationResponse pir = pr.getResult();
+ if (pir instanceof RenderResponse)
+ {
+ RenderResponse renderResult = (RenderResponse)pir;
+ StateString portletNavState = renderResult.getNavigationalState();
+ WindowState windowState = renderResult.getWindowState();
+ Mode mode = renderResult.getMode();
+ InvokeWindowRenderCommand iwrc = new InvokeWindowRenderCommand(
+ pr.getWindowId(),
+ mode,
+ windowState,
+ portletNavState);
+ return new CommandForward(iwrc, null);
+ }
+ else if (pir instanceof HTTPRedirectionResponse)
+ {
+ HTTPRedirectionResponse redirectionResult = (HTTPRedirectionResponse)pir;
+ String url = redirectionResult.getLocation();
+ sendRedirect(invocation, url);
+ return null;
+ }
+ else if (pir instanceof InsufficientTransportGuaranteeResponse)
+ {
+ boolean authenticated = invocation.getServerContext().getURLContext().isAuthenticated();
+ return new CommandForward(cmd, URLContext.newInstance(true, authenticated));
+ }
+ else if (pir instanceof InsufficientPrivilegesResponse)
+ {
+ boolean authenticated = invocation.getServerContext().getURLContext().isAuthenticated();
+ return new CommandForward(cmd, URLContext.newInstance(true, authenticated));
+ }
+ else if (pir instanceof SignOutResponse)
+ {
+ SignOutResponse signOut = (SignOutResponse)pir;
+
+ // Indicate that we want a sign out to be done
+ invocation.getResponse().setWantSignOut(true);
+
+ // Get the optional signout location
+ String location = signOut.getLocation();
+
+ //
+ if (location == null)
+ {
+ // Redirect to the same page
+ InvokeWindowActionCommand iwac = (InvokeWindowActionCommand)cmd;
+ Page page = iwac.getPage();
+ RenderPageCommand renderCmd = new RenderPageCommand(page.getId());
+ boolean secure = invocation.getServerContext().getURLContext().getSecure();
+ URLContext urlContext = URLContext.newInstance(secure, false);
+ location = ctx.renderURL(renderCmd, urlContext, null);
+ }
+
+ //
+ sendRedirect(invocation, location);
+
+ //
+ return null;
+ }
+ else if (pir instanceof ErrorResponse)
+ {
+ ErrorResponse error = (ErrorResponse)pir;
+ error.logErrorTo(log, "An portlet exception occured in portlet");
+ sendStatusCode(invocation, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ return null;
+ }
+ else
+ {
+ throw new IllegalStateException();
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/portlet/SignOutResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/SignOutResponse.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/SignOutResponse.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -25,6 +25,8 @@
import org.jboss.portal.portlet.invocation.response.RedirectionResponse;
/**
+ * Sign out wanted by a portlet.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision:5352 $
*/
@@ -56,9 +58,4 @@
{
return location;
}
-
- public void setLocation(String location)
- {
- this.location = location;
- }
}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -23,7 +23,7 @@
package org.jboss.portal.core.model.portal;
import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.command.ViewDashboardCommand;
+import org.jboss.portal.core.model.portal.command.ViewDashboardCommand;
import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
import org.jboss.portal.server.ServerInvocation;
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/DefaultPortalCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/DefaultPortalCommandFactory.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/DefaultPortalCommandFactory.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -23,7 +23,7 @@
package org.jboss.portal.core.model.portal;
import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
import org.jboss.portal.core.controller.command.mapper.CommandFactory;
import org.jboss.portal.server.ServerInvocation;
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -25,9 +25,9 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.command.InvokeWindowActionCommand;
-import org.jboss.portal.core.controller.command.InvokeWindowRenderCommand;
-import org.jboss.portal.core.controller.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.command.InvokeWindowActionCommand;
+import org.jboss.portal.core.model.portal.command.InvokeWindowRenderCommand;
+import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
import org.jboss.portal.server.ServerInvocation;
Added: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * 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.model.portal;
+
+import org.jboss.portal.core.controller.classic.AbstractResponseHandler;
+import org.jboss.portal.core.controller.classic.CommandForward;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.model.portal.command.response.UpdateViewResponse;
+import org.jboss.portal.core.model.portal.command.UpdateWindowMarkupResponse;
+import org.jboss.portal.core.model.portal.command.RenderPageCommand;
+import org.jboss.portal.server.ServerException;
+
+import javax.servlet.ServletException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortalObjectResponseHandler extends AbstractResponseHandler
+{
+
+ public CommandForward handleResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
+ {
+ if (response instanceof UpdateViewResponse)
+ {
+ UpdateViewResponse uvr = (UpdateViewResponse)response;
+ RenderPageCommand renderCmd = new RenderPageCommand(uvr.getPageId());
+ return new CommandForward(renderCmd, null);
+ }
+ else if (response instanceof UpdateWindowMarkupResponse)
+ {
+ UpdateWindowMarkupResponse uwmr = (UpdateWindowMarkupResponse)response;
+ PortalObjectContainer portalObjectContainer = ctx.getController().getPortalObjectContainer();
+ PortalObject window = portalObjectContainer.getObject(uwmr.getWindowId());
+ Page page = (Page)window.getParent();
+ RenderPageCommand rpc = new RenderPageCommand(page.getId());
+ return new CommandForward(rpc, null);
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -26,10 +26,10 @@
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.command.InvokeWindowActionCommand;
-import org.jboss.portal.core.controller.command.InvokeWindowCommand;
-import org.jboss.portal.core.controller.command.InvokeWindowRenderCommand;
-import org.jboss.portal.core.controller.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.command.InvokeWindowActionCommand;
+import org.jboss.portal.core.model.portal.command.InvokeWindowCommand;
+import org.jboss.portal.core.model.portal.command.InvokeWindowRenderCommand;
+import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.controller.command.mapper.URLFactoryDelegate;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.impl.PortletRequestEncoder;
Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowActionCommand.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowActionCommand.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowActionCommand.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowActionCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,140 @@
+/******************************************************************************
+ * 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.model.portal.command;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ResourceNotFoundException;
+import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.portlet.PortletResponse;
+import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
+import org.jboss.portal.portlet.NoSuchPortletException;
+import org.jboss.portal.portlet.Parameters;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class InvokeWindowActionCommand extends InvokeWindowCommand
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(InvokeWindowActionCommand.class);
+
+ /** . */
+ private static final CommandInfo info = new ActionCommandInfo(false, "view", false);
+
+ /** . */
+ private StateString navigationalState;
+
+ /** . */
+ private StateString interactionState;
+
+ /** . */
+ private Parameters formParameters;
+
+ public InvokeWindowActionCommand(
+ String windowId,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ StateString interactionState,
+ Parameters formParameters)
+ throws IllegalArgumentException
+ {
+ super(windowId, mode, windowState);
+ this.navigationalState = navigationalState;
+ this.interactionState = interactionState;
+ this.formParameters = formParameters;
+ }
+
+ public StateString getNavigationalState()
+ {
+ return navigationalState;
+ }
+
+ public StateString getInteractionState()
+ {
+ return interactionState;
+ }
+
+ public void setInteractionState(StateString interactionState)
+ {
+ this.interactionState = interactionState;
+ }
+
+ public Parameters getFormParameters()
+ {
+ return formParameters;
+ }
+
+ public void setFormParameters(Parameters formParameters)
+ {
+ this.formParameters = formParameters;
+ }
+
+ public CommandInfo getInfo()
+ {
+ return info;
+ }
+
+ public Object execute() throws ControllerException
+ {
+ try
+ {
+ PortletInvocation invocation = PortletInvocationFactory.createAction(
+ context,
+ mode,
+ windowState,
+ navigationalState,
+ interactionState,
+ formParameters,
+ window,
+ portal);
+
+ //
+ PortletInvocationResponse resp = instance.invoke(invocation);
+
+ //
+ return new PortletResponse(targetId, resp);
+ }
+ catch (PortletInvokerException e)
+ {
+ if (e instanceof NoSuchPortletException)
+ {
+ throw new ResourceNotFoundException(((NoSuchPortletException)e).getPortletId());
+ }
+ else
+ {
+ throw new ControllerException(e);
+ }
+ }
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowActionCommand.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowCommand.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowCommand.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowCommand.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -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.model.portal.command;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.core.model.portal.command.WindowCommand;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class InvokeWindowCommand extends WindowCommand
+{
+
+ /** . */
+ protected final Mode mode;
+
+ /** . */
+ protected final WindowState windowState;
+
+ public InvokeWindowCommand(String windowId, Mode mode, WindowState windowState) throws IllegalArgumentException
+ {
+ super(windowId);
+ this.mode = mode;
+ this.windowState = windowState;
+ }
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowCommand.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowRenderCommand.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowRenderCommand.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/InvokeWindowRenderCommand.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowRenderCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,124 @@
+/******************************************************************************
+ * 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.model.portal.command;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.invocation.InvocationContext;
+import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.core.aspects.controller.PageNavigationInterceptor;
+import org.jboss.portal.core.controller.ControllerContext;
+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.UpdateWindowMarkupResponse;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.theme.LayoutService;
+import org.jboss.portal.theme.navigation.WindowNavigationalState;
+import org.jboss.portal.theme.strategy.StrategyException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class InvokeWindowRenderCommand extends InvokeWindowCommand
+{
+
+ private static final CommandInfo info = new ViewCommandInfo(false, "view");
+
+ /** . */
+ protected final StateString navigationalState;
+
+ public InvokeWindowRenderCommand(
+ String windowRef,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState)
+ throws IllegalArgumentException
+ {
+ super(windowRef, mode, windowState);
+ this.navigationalState = navigationalState;
+ }
+
+ public InvokeWindowRenderCommand(
+ String windowId,
+ Mode mode,
+ WindowState windowState)
+ throws IllegalArgumentException
+ {
+ super(windowId, mode, windowState);
+ this.navigationalState = null;
+ }
+
+ public StateString getNavigationalState()
+ {
+ return navigationalState;
+ }
+
+ public CommandInfo getInfo()
+ {
+ return info;
+ }
+
+ public Object execute() throws InvocationException
+ {
+ InvocationContext ctx = getContext();
+
+ //
+ if (navigationalState != null)
+ {
+ ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, window.getInstanceRef(), navigationalState);
+ }
+
+ // Update the window nav state
+ WindowNavigationalState windowNavState = (WindowNavigationalState)ctx.getAttribute(NAVIGATIONAL_STATE_SCOPE, window.getInstanceRef() + "_window");
+ if (windowNavState == null)
+ {
+ windowNavState = new WindowNavigationalState();
+ ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, window.getId() + "_window", windowNavState);
+ }
+ if (mode != null)
+ {
+ windowNavState.setMode(mode);
+ }
+ if (windowState != null)
+ {
+ windowNavState.setWindowState(windowState);
+ }
+
+ // Udpate the page nav state
+ try
+ {
+ ServerInvocation sinv = ((ControllerContext)getContext()).getServerInvocation();
+ LayoutService layoutService = ((ControllerContext)getContext()).getController().getPageService().getLayoutService();
+ PageNavigationInterceptor.updatePageNavigationalState(layoutService, context, sinv, portal, page, window, getMode(), getWindowState());
+ }
+ catch (StrategyException e)
+ {
+ throw new InvocationException(e);
+ }
+
+ //
+ return new UpdateWindowMarkupResponse(window.getId());
+ }
+}
\ No newline at end of file
Property changes on: trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowRenderCommand.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/command/MoveWindowCommand.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/MoveWindowCommand.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/MoveWindowCommand.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/MoveWindowCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,142 @@
+/******************************************************************************
+ * 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.model.portal.command;
+
+import org.jboss.portal.core.controller.ControllerException;
+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;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.command.WindowCommand;
+import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.theme.navigation.PageNavigationalState;
+import org.jboss.portal.theme.page.WindowContext;
+
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MoveWindowCommand extends WindowCommand
+{
+
+ /** . */
+ private static final CommandInfo info = new ActionCommandInfo(false, "view", false);
+
+ /** . */
+ private int fromPos;
+
+ /** . */
+ private String fromRegion;
+
+ /** . */
+ private int toPos;
+
+ /** . */
+ private String toRegion;
+
+ public MoveWindowCommand(String windowRef, int fromPos, String fromRegion, int toPos, String toRegion)
+ throws IllegalArgumentException
+ {
+ super(windowRef);
+ this.fromPos = fromPos;
+ this.fromRegion = fromRegion;
+ this.toPos = toPos;
+ this.toRegion = toRegion;
+ }
+
+ public CommandInfo getInfo()
+ {
+ return info;
+ }
+
+ public Object execute() throws ControllerException
+ {
+
+ // For now just update the navigational state of the page
+ PageNavigationalState pns = (PageNavigationalState)getContext().getAttribute(NAVIGATIONAL_STATE_SCOPE, page.getId());
+
+ //
+ for (Iterator i = pns.getWindowContexts().iterator(); i.hasNext();)
+ {
+ WindowContext windowCtx = (WindowContext)i.next();
+ String windowRegion = windowCtx.getRegionName();
+ if (targetId.equals(windowCtx.getId()))
+ {
+ windowCtx.setRegionName(toRegion);
+ windowCtx.setOrder(toPos);
+ }
+ else if (fromRegion.equals(windowRegion) && fromPos < windowCtx.getOrder())
+ {
+ windowCtx.setOrder(windowCtx.getOrder() - 1);
+ }
+ else if (toRegion.equals(windowRegion) && toPos <= windowCtx.getOrder())
+ {
+ windowCtx.setOrder(windowCtx.getOrder() + 1);
+ }
+ }
+
+ //
+ if (isDashboard())
+ {
+ for (Iterator i = page.getChildren().iterator(); i.hasNext();)
+ {
+ PortalObject child = (PortalObject)i.next();
+ if (child.getType() == PortalObject.TYPE_WINDOW)
+ {
+ Window window = (Window)child;
+ String windowId = window.getId();
+ String regionId = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION);
+ String posAsString = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER);
+ if (regionId != null && posAsString != null)
+ {
+ try
+ {
+ int pos = Integer.parseInt(posAsString);
+ if (targetId.equals(windowId))
+ {
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, toRegion);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(toPos));
+ }
+ else if (fromRegion.equals(regionId) && fromPos < pos)
+ {
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(toPos - 1));
+ }
+ else if (toRegion.equals(regionId) && toPos <= pos)
+ {
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(toPos + 1));
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ }
+ }
+ }
+ }
+
+ //
+ return null;
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/command/PageCommand.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/PageCommand.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/PageCommand.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/PageCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * 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.model.portal.command;
+
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ResourceNotFoundException;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.Portal;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class PageCommand extends PortalObjectCommand
+{
+
+ /** . */
+ protected Page page;
+
+ /** . */
+ protected Portal portal;
+
+ public PageCommand(String pageId)
+ {
+ super(pageId);
+ }
+
+ /**
+ * Get the requested page
+ *
+ * @return the requested page
+ */
+ public Page getPage()
+ {
+ return page;
+ }
+
+ /**
+ * Initialize the command
+ *
+ * @throws org.jboss.portal.common.invocation.InvocationException
+ *
+ */
+ public void create() throws ControllerException
+ {
+ super.create();
+
+ //
+ page = (Page)getTarget();
+
+ // Get nearest portal ancestor
+ portal = page.getPortal();
+
+ //
+ if (portal == null)
+ {
+ throw new ResourceNotFoundException(targetId);
+ }
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalCommand.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/PortalCommand.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/PortalCommand.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * 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.model.portal.command;
+
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.model.portal.Portal;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class PortalCommand extends PortalObjectCommand
+{
+
+ /** . */
+ protected Portal portal;
+
+ public PortalCommand(String portalId)
+ {
+ super(portalId);
+ }
+
+ /**
+ * Get the requestet portal
+ *
+ * @return the requested portal
+ */
+ public Portal getPortal()
+ {
+ return portal;
+ }
+
+ /**
+ * Initialize the command
+ *
+ * @throws org.jboss.portal.common.invocation.InvocationException
+ *
+ */
+ public void create() throws ControllerException
+ {
+ super.create();
+
+ //
+ portal = (Portal)getTarget();
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/PortalObjectCommand.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/PortalObjectCommand.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,121 @@
+/******************************************************************************
+ * 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.model.portal.command;
+
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerSecurityException;
+import org.jboss.portal.core.controller.ResourceAccessDeniedException;
+import org.jboss.portal.core.controller.ResourceNotFoundException;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalObjectPermission;
+import org.jboss.portal.security.PortalSecurityException;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class PortalObjectCommand extends ControllerCommand
+{
+
+ protected final String targetId;
+
+ protected PortalObject target;
+
+ private Boolean dashboard;
+
+ protected PortalObjectCommand(String targetId)
+ {
+ if (targetId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.targetId = targetId;
+ }
+
+
+ public final String getTargetId()
+ {
+ return targetId;
+ }
+
+ public void create() throws ControllerException
+ {
+ // Get portal object
+ target = context.getController().getPortalObjectContainer().getObject(targetId);
+
+ if (target == null)
+ {
+ throw new ResourceNotFoundException(targetId);
+ }
+ }
+
+ /**
+ * Enforce the security on this command using the provided portal authorization manager.
+ *
+ * @param pam the portal authorization manager
+ * @throws org.jboss.portal.core.controller.ControllerSecurityException
+ * if the access is not granted
+ */
+ public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
+ {
+ PortalObject target = getTarget();
+ String id = target.getId();
+ PortalObjectPermission perm = new PortalObjectPermission(id, PortalObjectPermission.VIEW_MASK);
+ if (!pam.checkPermission(perm))
+ {
+ throw new ResourceAccessDeniedException("Not Authorized");
+ }
+ }
+
+ /**
+ * Return the target portal object of this command.
+ *
+ * @return the target portal object
+ */
+ public final PortalObject getTarget()
+ {
+ return target;
+ }
+
+ public boolean isDashboard()
+ {
+ if (dashboard == null)
+ {
+ try
+ {
+ PortalAuthorizationManagerFactory pamf = getControllerContext().getController().getPortalAuthorizationManagerFactory();
+ PortalAuthorizationManager pam = pamf.getManager();
+ PortalObjectPermission perm = new PortalObjectPermission(targetId, PortalObjectPermission.DASHBOARD_MASK);
+ dashboard = Boolean.valueOf(pam.checkPermission(perm));
+ }
+ catch (PortalSecurityException e)
+ {
+ dashboard = Boolean.FALSE;
+ }
+ }
+ return dashboard.booleanValue();
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/RenderPageCommand.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/RenderPageCommand.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,643 @@
+/******************************************************************************
+ * 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.model.portal.command;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.invocation.AttributeResolver;
+import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.common.util.Exceptions;
+import org.jboss.portal.common.NotYetImplemented;
+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.ResourceAccessDeniedException;
+import org.jboss.portal.core.controller.ResourceNotFoundException;
+import org.jboss.portal.core.controller.portlet.PortletResponse;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalObjectPermission;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.command.InvokeWindowRenderCommand;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.portlet.Properties;
+import org.jboss.portal.portlet.info.ModeInfo;
+import org.jboss.portal.portlet.info.WindowStateInfo;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.InsufficientPrivilegesResponse;
+import org.jboss.portal.portlet.invocation.response.InsufficientTransportGuaranteeResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
+import org.jboss.portal.security.PortalSecurityException;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.server.ServerInvocationContext;
+import org.jboss.portal.server.config.ServerConfig;
+import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.server.request.URLFormat;
+import org.jboss.portal.theme.LayoutService;
+import org.jboss.portal.theme.PageRendition;
+import org.jboss.portal.theme.PortalLayout;
+import org.jboss.portal.theme.PortalTheme;
+import org.jboss.portal.theme.ServerRegistrationID;
+import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.theme.ThemeResult;
+import org.jboss.portal.theme.ThemeService;
+import org.jboss.portal.theme.navigation.PageNavigationalState;
+import org.jboss.portal.theme.navigation.WindowNavigationalState;
+import org.jboss.portal.theme.page.ModifiablePageResult;
+import org.jboss.portal.theme.page.ModifiableWindowResult;
+import org.jboss.portal.theme.page.PageService;
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.theme.render.MarkupResult;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+/**
+ * Render a full page.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public final class RenderPageCommand extends PageCommand
+{
+
+ /**
+ * .
+ */
+ private static String WINDOW_ACCESS_DENIED = "core.render.window_access_denied";
+
+ /**
+ * .
+ */
+ private static String WINDOW_UNAVAILABLE = "core.render.window_unavailable";
+
+ /**
+ * .
+ */
+ private static String WINDOW_ERROR = "core.render.window_error";
+
+ /**
+ * .
+ */
+ private static String WINDOW_INTERNAL_ERROR = "core.render.window_internal_error";
+
+ /**
+ * .
+ */
+ private static String WINDOW_NOT_FOUND = "core.render.window_not_found";
+
+ /**
+ * .
+ */
+ private static String HIDE = "hide";
+
+ /**
+ * .
+ */
+ private static String SHOW = "show";
+
+ /**
+ * .
+ */
+ private static final CommandInfo info = new ViewCommandInfo(false, "view");
+
+ /**
+ * The windows to render.
+ */
+ private Collection windows;
+
+ /**
+ * .
+ */
+ private PortalLayout layout;
+
+ /**
+ * .
+ */
+ private boolean personalizable;
+
+ public RenderPageCommand(String pageId)
+ {
+ super(pageId);
+ }
+
+ /**
+ * Get the command info (runtime info about the command)
+ *
+ * @return info about the command
+ */
+ public CommandInfo getInfo()
+ {
+ return info;
+ }
+
+ /**
+ * Get the layout that was determined for this request (based on portal and page properties)
+ *
+ * @return the layout to use for this request
+ */
+ public PortalLayout getLayout()
+ {
+ return layout;
+ }
+
+ /**
+ * Returns the modifiable list of windows.
+ *
+ * @return the windows on the page
+ */
+ public Collection getWindows()
+ {
+ return windows;
+ }
+
+ /**
+ * initialize the command
+ *
+ * @throws InvocationException
+ */
+ public void create() throws ControllerException
+ {
+ super.create();
+
+ // All windows on the page
+ windows = new ArrayList(getPage().getChildren());
+
+ //
+ LayoutService layoutService = context.getController().getPageService().getLayoutService();
+ layout = getLayout(layoutService, page);
+ }
+
+ public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
+ {
+ //
+ super.enforceSecurity(pam);
+
+ // Check if the user can personalize the page
+ String uri = page.getId();
+ PortalObjectPermission perm = new PortalObjectPermission(uri, PortalObjectPermission.PERSONALIZE_MASK);
+ personalizable = pam.checkPermission(perm);
+ }
+
+ /**
+ * execute the command
+ *
+ * @throws InvocationException
+ */
+ public Object execute() throws ControllerException, InvocationException
+ {
+ ServerInvocation sinv = context.getServerInvocation();
+ HttpServletRequest request = sinv.getServerContext().getClientRequest();
+ try
+ {
+ // Ensure that the page nav state is in place
+ AttributeResolver navCtx = sinv.getContext().getAttributeResolver(NAVIGATIONAL_STATE_SCOPE);
+ PageNavigationalState pageNavState = (PageNavigationalState)navCtx.getAttribute(page.getId());
+
+ if (pageNavState == null)
+ {
+ throw new InvocationException("PageNavigationalState not available in NavigationalStateContext");
+ }
+
+ //
+ PageService pageService = context.getController().getPageService();
+ PortalTheme theme = null;
+
+ if (personalizable)
+ {
+ ControllerContext controllerCtx = (ControllerContext)getContext();
+ User user = (User)controllerCtx.getServerInvocation().getRequest().getUser();
+ if (user != null)
+ {
+ String themeId = user.getTheme();
+ if (themeId != null)
+ {
+ theme = getTheme(themeId);
+ }
+ }
+ }
+
+ // If nothing get it from the object properties
+ if (theme == null)
+ {
+ String themeId = page.getProperty(ThemeConstants.PORTAL_PROP_THEME);
+ theme = getTheme(themeId);
+ }
+
+ // Call the portlet container to create the markup fragment(s) for each portlet that needs to render itself
+ ServerConfig cfg = sinv.getRequest().getServer().getConfig();
+ ModifiablePageResult renderResult = new ModifiablePageResult(getPage().getName(), new HashMap(getPage().getDeclaredProperties()), new HashMap(getPage().getPortal().getDeclaredProperties()));
+
+ // Render
+ for (Iterator i = windows.iterator(); i.hasNext();)
+ {
+ PortalObject o = (PortalObject)i.next();
+ if (o instanceof Window)
+ {
+ Window window = (Window)o;
+ if (pageNavState.isWindowVisible(window.getId()))
+ {
+ Object res = renderPortletWindow(cfg, window);
+ if (res == null)
+ {
+ // Skip
+ }
+ else if (res instanceof MarkupResult)
+ {
+ MarkupResult result = (MarkupResult)res;
+ renderResult.addWindowContext(pageNavState.getWindowContext(window.getId()));
+ renderResult.addWindowResult(window.getId(), (WindowResult)result);
+ }
+ else
+ {
+ return res;
+ }
+ }
+ }
+ }
+
+ // Make the theme available as servlet request attribute (needed for CM)
+ if (theme != null)
+ {
+ // render the theme markup and place it into the request so that the markup assembler (theme tag) can pick it up there
+ ThemeResult themeResult = theme.assembleResponse(sinv.getRequest(), sinv.getResponse());
+ renderResult.setTheme(theme);
+ renderResult.setThemeResult(themeResult);
+
+ //
+ return new PageRendition(layout, pageNavState, renderResult, pageService);
+ }
+ }
+ catch (Exception e)
+ {
+ rethrow(e);
+ }
+ finally
+ {
+ request.removeAttribute(ThemeConstants.ATTR_THEMESERVER);
+ request.removeAttribute(ThemeConstants.ATTR_THEME);
+ request.removeAttribute(ThemeConstants.ATTR_THEMERESULT);
+ }
+
+ //
+ return null;
+ }
+
+ private PortalTheme getTheme(String themeIdString)
+ {
+ //
+ ThemeService service = context.getController().getPageService().getThemeService();
+
+ // If the id is provided in the form of context.name then look up the theme via a registration id
+ if (themeIdString.lastIndexOf(".") > 0)
+ {
+ ServerRegistrationID themeId = ServerRegistrationID.createID(ServerRegistrationID.TYPE_THEME, parseID(themeIdString));
+ return service.getTheme(themeId, true);
+ }
+ else
+ {
+ // Otherwise use the ordinary theme name provided and lookup the theme via the name
+ return service.getTheme(themeIdString, true);
+ }
+ }
+
+ /**
+ * Get the portal layout to use for the provided page. <p>The name of the layout to use can be defined as a property
+ * in the portal, or the individual page. The page property overwrites the portal property. If no property was set, a
+ * default layout with the name "nodesk" is assumed.</p>
+ *
+ * @param layoutService the layout service that allows access to the layout
+ * @param page the page that hosts the markup container to render (the page, region, window,...)
+ * @return a <code>PortalLayout</code> for the defined layout name
+ */
+ public static PortalLayout getLayout(LayoutService layoutService, Page page)
+ {
+ String layoutIDString = page.getProperty(ThemeConstants.PORTAL_PROP_LAYOUT);
+
+ // Last resort: use the nodesk layout
+ if (layoutIDString == null)
+ {
+ layoutIDString = "nodesk";
+ }
+
+ //
+ PortalLayout layout;
+ if (layoutIDString.lastIndexOf(".") > 0)
+ {
+ // if the id is provided in the form of context.name then look up the layout via a registration id
+ ServerRegistrationID layoutID = ServerRegistrationID.createID(ServerRegistrationID.TYPE_LAYOUT, parseID(layoutIDString));
+ layout = layoutService.getLayout(layoutID, true);
+ }
+ else
+ {
+ // otherwise use the ordinary layout name provided and lookup the layout via the name
+ layout = layoutService.getLayout(layoutIDString, true);
+ }
+
+ // We don't like that situation
+ if (layout == null)
+ {
+ throw new IllegalStateException("NO LAYOUT FOUND FOR " + layoutIDString);
+ }
+
+ //
+ return layout;
+ }
+
+ /**
+ * Call the component container to render the markup fragment of a window
+ *
+ * @param cfg the server config to get information about the error behaviour
+ * @param window the window to render
+ * @return a result containing markup, or other result information (redirect url, etc.)
+ * @throws InvocationException
+ */
+ protected Object renderPortletWindow(ServerConfig cfg, Window window) throws ControllerException
+ {
+ // Execute render command
+ String windowRef = window.getId();
+
+ //
+ String windowTitle;
+ String contentChars = "";
+ String headerChars = null;
+ Map actionMap = new HashMap();
+ Properties responseProps;
+ Map windowProps = window.getDeclaredProperties();
+ WindowNavigationalState windowNavState = (WindowNavigationalState)this.context.getAttribute(NAVIGATIONAL_STATE_SCOPE, window.getId() + "_window");
+
+ try
+ {
+ RenderWindowCommand renderCmd = new RenderWindowCommand(windowRef);
+
+ //
+ PortletResponse portletResponse = (PortletResponse)context.execute(renderCmd);
+ PortletInvocationResponse response = portletResponse.getResult();
+
+ //
+ if (response instanceof InsufficientTransportGuaranteeResponse)
+ {
+ return response;
+ }
+
+ //
+ if (response instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)response;
+ windowTitle = fragment.getTitle();
+ if (windowTitle == null)
+ {
+ windowTitle = window.getName();
+ }
+ headerChars = fragment.getHeader();
+// responseProps = fragment.getProperties();
+ responseProps = new Properties(); // remove me
+
+ //
+ Instance instance = renderCmd.getInstance();
+
+ //
+ List supportedWindowStates = new ArrayList();
+ for (Iterator i = instance.getPortlet().getInfo().getCapabilities().getAllWindowStates().iterator(); i.hasNext();)
+ {
+ WindowStateInfo windowStateInfo = (WindowStateInfo)i.next();
+ WindowState windowState = windowStateInfo.getWindowState();
+ if (portal.getSupportedWindowStates().contains(windowState))
+ {
+ supportedWindowStates.add(windowState);
+ }
+ }
+
+ //
+ List supportedModes = new ArrayList();
+ for (Iterator i = instance.getPortlet().getInfo().getCapabilities().getAllModes().iterator(); i.hasNext();)
+ {
+ ModeInfo modeInfo = (ModeInfo)i.next();
+ Mode mode = modeInfo.getMode();
+ if (portal.getSupportedModes().contains(mode))
+ {
+ supportedModes.add(mode);
+ }
+ }
+
+ // Remove edit mode if the user is not logged it
+ if (getControllerContext().getServerInvocation().getServerContext().getClientRequest().getUserPrincipal() == null)
+ {
+ supportedModes.remove(Mode.EDIT);
+ }
+
+ //
+ addModeActions(window, actionMap, windowNavState.getMode(), supportedModes);
+
+ //
+ addStateActions(window, actionMap, windowNavState.getWindowState(), supportedWindowStates);
+
+ //
+ contentChars = fragment.getContent();
+
+ //
+ return new ModifiableWindowResult(windowTitle, contentChars, actionMap, windowProps, responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ }
+ else if (response instanceof ErrorResponse)
+ {
+ ErrorResponse errorResult = (ErrorResponse)response;
+ String logMessage = "Rendering portlet window " + windowRef + " triggered the following error :";
+ errorResult.logErrorTo(log, logMessage);
+ String property = cfg.getProperty(WINDOW_ERROR);
+ if (!HIDE.equals(property))
+ {
+ windowTitle = "An error occured while rendering window '" + windowRef + "'";
+ responseProps = new Properties();
+ contentChars = errorResult.getMessage();
+ Throwable t = errorResult.getThrowable();
+ if (t != null && SHOW.equals(property))
+ {
+ contentChars = Exceptions.toHTML(t, true);
+ }
+ return new ModifiableWindowResult(windowTitle, contentChars, actionMap, windowProps, responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ }
+ }
+ else if (response instanceof UnavailableResponse)
+ {
+ if (SHOW.equals(cfg.getProperty(WINDOW_UNAVAILABLE)))
+ {
+ windowTitle = "Portlet unavailable";
+ contentChars = "Portlet unavailable";
+ actionMap = new HashMap();
+ actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
+ actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
+ responseProps = new Properties();
+ return new ModifiableWindowResult(windowTitle, contentChars, actionMap, windowProps, responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ }
+ }
+ else if (response instanceof InsufficientPrivilegesResponse)
+ {
+ // Julien : go to the section below, I know it is very ugly
+ throw new ResourceAccessDeniedException(windowRef);
+ }
+ else
+ {
+ throw new NotYetImplemented("Unexpected result from a portlet invocation " + response);
+ }
+ }
+ catch (ResourceAccessDeniedException e)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Window access denied", e);
+ }
+ if (SHOW.equals(cfg.getProperty(WINDOW_ACCESS_DENIED)))
+ {
+ actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
+ actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
+ windowTitle = "Access denied";
+ contentChars = "Access denied";
+ responseProps = new Properties();
+ return new ModifiableWindowResult(windowTitle, contentChars, actionMap, windowProps, responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ }
+ }
+ catch (ResourceNotFoundException e)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Window not found", e);
+ }
+ if (SHOW.equals(cfg.getProperty(WINDOW_NOT_FOUND)))
+ {
+ actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
+ actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
+ windowTitle = "Cannot render";
+ contentChars = "Object not found " + e.getRef();
+ responseProps = new Properties();
+ return new ModifiableWindowResult(windowTitle, contentChars, actionMap, windowProps, responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ }
+ }
+ catch (ControllerException e)
+ {
+ // It's a CommandException that we rethrow
+ throw e;
+ }
+ catch (Exception e)
+ {
+ log.error("Rendering portlet window " + windowRef + " produced an internal error", e);
+ String property = cfg.getProperty(WINDOW_INTERNAL_ERROR);
+ if (SHOW.equals(property))
+ {
+ windowTitle = "An internal error occured while rendering window '" + window + "'";
+ responseProps = new Properties();
+ contentChars = Exceptions.toHTML(e, true);
+ return new ModifiableWindowResult(windowTitle, contentChars, actionMap, windowProps, responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * parse the provided String for '.' as a separator. For each token, add an entry to a String[] that will be returned
+ * as the result
+ *
+ * @param layoutIDString the string to be examined
+ * @return an array of Strings
+ */
+ private static String[] parseID(String layoutIDString)
+ {
+ List names = new ArrayList();
+ StringTokenizer tokens = new StringTokenizer(layoutIDString, ".");
+ if (tokens.countTokens() > 1)
+ {
+ while (tokens.hasMoreElements())
+ {
+ names.add(tokens.nextToken());
+ }
+ }
+ else
+ {
+ names.add(layoutIDString);
+ }
+
+ String[] id = new String[names.size()];
+ names.toArray(id);
+ return id;
+ }
+
+ /**
+ * Create the action URLs for the allowed window states of the rendered portlet window and add them to the provided
+ * actionMap.
+ */
+ private void addStateActions(Window window, Map actionMap, WindowState currentWindowState, List supportedWindowStates)
+ {
+ List windowStates = new ArrayList(supportedWindowStates.size());
+ for (Iterator j = supportedWindowStates.iterator(); j.hasNext();)
+ {
+ WindowState windowState = (WindowState)j.next();
+ String url = createUpdateNavigationalStateURL(window, null, windowState);
+ boolean disabled = windowState.equals(currentWindowState);
+ WindowResult.Action action = new WindowResult.Action(windowState, url, !disabled);
+ windowStates.add(action);
+ }
+ actionMap.put(WindowResult.WINDOWSTATES_KEY, windowStates);
+ }
+
+ /**
+ * Create the action URLs for the allowed portlet modes of the rendered portlet window and add them to the provided
+ * actionMap.
+ */
+ private void addModeActions(Window window, Map actionMap, Mode currentMode, List supportedModes)
+ {
+ List modes = new ArrayList(supportedModes.size());
+ for (Iterator j = supportedModes.iterator(); j.hasNext();)
+ {
+ Mode mode = (Mode)j.next();
+ String url = createUpdateNavigationalStateURL(window, mode, null);
+ boolean disabled = mode.equals(currentMode);
+ WindowResult.Action action = new WindowResult.Action(mode, url, !disabled);
+ modes.add(action);
+ }
+ actionMap.put(WindowResult.MODES_KEY, modes);
+ }
+
+ public String createUpdateNavigationalStateURL(Window window, Mode mode, WindowState windowState)
+ {
+ InvokeWindowRenderCommand cmd = new InvokeWindowRenderCommand(window.getId(), mode, windowState);
+ ControllerContext controllerContext = getControllerContext();
+ ServerInvocationContext serverContext = controllerContext.getServerInvocation().getServerContext();
+ boolean secure = serverContext.getURLContext().getSecure();
+ boolean authenticated = serverContext.getURLContext().isAuthenticated();
+ URLContext urlContext = URLContext.newInstance(secure, authenticated);
+ return controllerContext.renderURL(cmd, urlContext, URLFormat.newInstance(true, true));
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/RenderWindowCommand.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/RenderWindowCommand.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,109 @@
+/******************************************************************************
+ * 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.model.portal.command;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ResourceNotFoundException;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
+import org.jboss.portal.core.controller.portlet.PortletResponse;
+import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
+import org.jboss.portal.portlet.NoSuchPortletException;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.theme.navigation.WindowNavigationalState;
+
+/**
+ * Render a single window.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class RenderWindowCommand extends WindowCommand
+{
+
+ /** . */
+ private static final CommandInfo info = new ViewCommandInfo(true, "view");
+
+ public RenderWindowCommand(String windowRef) throws IllegalArgumentException
+ {
+ super(windowRef);
+ }
+
+ public CommandInfo getInfo()
+ {
+ return info;
+ }
+
+ public Object execute() throws ControllerException
+ {
+ StateString navigationalState = (StateString)getAttribute(NAVIGATIONAL_STATE_SCOPE, window.getInstanceRef());
+
+ //
+ WindowNavigationalState windowNavState = (WindowNavigationalState)getAttribute(NAVIGATIONAL_STATE_SCOPE, targetId + "_window");
+ if (windowNavState == null)
+ {
+ windowNavState = new WindowNavigationalState();
+ setAttribute(NAVIGATIONAL_STATE_SCOPE, window.getId() + "_window", windowNavState);
+ }
+
+ // Get the mode
+ Mode mode = windowNavState.getMode();
+
+ // Get the window state
+ WindowState windowState = windowNavState.getWindowState();
+
+ //
+ RenderInvocation invocation = PortletInvocationFactory.createRender(
+ context,
+ mode,
+ windowState,
+ navigationalState,
+ window,
+ portal);
+
+ //
+ try
+ {
+ PortletInvocationResponse resp = instance.invoke(invocation);
+
+ //
+ return new PortletResponse(targetId, resp);
+ }
+ catch (PortletInvokerException e)
+ {
+ if (e instanceof NoSuchPortletException)
+ {
+ throw new ResourceNotFoundException(((NoSuchPortletException)e).getPortletId());
+ }
+ else
+ {
+ throw new ControllerException(e);
+ }
+ }
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/command/UpdateWindowMarkupResponse.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/response/UpdateWindowMarkupResponse.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/response/UpdateWindowMarkupResponse.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/UpdateWindowMarkupResponse.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * 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.model.portal.command;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UpdateWindowMarkupResponse
+{
+
+ /** . */
+ private String windowId;
+
+ public UpdateWindowMarkupResponse(String windowId)
+ {
+ if (windowId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.windowId = windowId;
+ }
+
+ public String getWindowId()
+ {
+ return windowId;
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/command/ViewDashboardCommand.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/ViewDashboardCommand.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/ViewDashboardCommand.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/ViewDashboardCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,125 @@
+/******************************************************************************
+ * 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.model.portal.command;
+
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerSecurityException;
+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.UpdateViewResponse;
+import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.security.PortalSecurityException;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
+
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ViewDashboardCommand extends PortalCommand
+{
+
+ /** . */
+ private static final CommandInfo info = new ViewCommandInfo(false, "view");
+
+ /** . */
+ private Page dashboardPage;
+
+ /** . */
+ private String userId;
+
+ public ViewDashboardCommand(String portalId)
+ {
+ super(portalId);
+ }
+
+ public CommandInfo getInfo()
+ {
+ return info;
+ }
+
+ public void create() throws ControllerException
+ {
+ super.create();
+
+ //
+ userId = getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser();
+ }
+
+ public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
+ {
+ if (userId == null)
+ {
+ throw new ControllerSecurityException("User needs to be authenticated to view a dashboard");
+ }
+ }
+
+ public Object execute() throws ControllerException
+ {
+ dashboardPage = portal.getPage(userId);
+
+ // Create if not exist
+ if (dashboardPage == null)
+ {
+ try
+ {
+ dashboardPage = portal.createPage(userId);
+ Page templatePage = (Page)portal.getParent().getChild("default").getChild("default");
+ for (Iterator i = templatePage.getChildren().iterator(); i.hasNext();)
+ {
+ PortalObject child = (PortalObject)i.next();
+ if (child.getType() == PortalObject.TYPE_WINDOW)
+ {
+ Window window = (Window)child;
+ Window newWindow = dashboardPage.createWindow(window.getName());
+ newWindow.setInstanceRef(window.getInstanceRef());
+ for (Iterator j = window.getDeclaredProperties().entrySet().iterator(); j.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)j.next();
+ String name = (String)entry.getKey();
+ String value = (String)entry.getValue();
+ newWindow.setDeclaredProperty(name, value);
+ }
+ }
+ }
+ }
+ catch (DuplicatePortalObjectException e)
+ {
+ throw new ControllerException(e);
+ }
+ }
+
+ //
+ return new UpdateViewResponse(dashboardPage.getId());
+ }
+
+ public Page getDashboardPage()
+ {
+ return dashboardPage;
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/WindowCommand.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/WindowCommand.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,136 @@
+/******************************************************************************
+ * 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.model.portal.command;
+
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerSecurityException;
+import org.jboss.portal.core.controller.ResourceNotFoundException;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.security.PortalSecurityException;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
+
+/**
+ * A superclass for command that target a specific window.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class WindowCommand extends PortalObjectCommand
+{
+
+ /** The portal. */
+ protected Portal portal;
+
+ /** The portal. */
+ protected Page page;
+
+ /** The window. */
+ protected Window window;
+
+ /** The instance. */
+ protected Instance instance;
+
+ public WindowCommand(String windowId) throws IllegalArgumentException
+ {
+ super(windowId);
+ }
+
+ public Instance getInstance()
+ {
+ return instance;
+ }
+
+ public Portal getPortal()
+ {
+ return portal;
+ }
+
+ public Page getPage()
+ {
+ return page;
+ }
+
+ public Window getWindow()
+ {
+ return window;
+ }
+
+ public void create() throws ControllerException
+ {
+ super.create();
+
+ // Retrieve the window
+ window = (Window)getTarget();
+
+ // First retrieve the target
+ page = (Page)window.getParent();
+ if (page == null)
+ {
+ throw new ResourceNotFoundException(targetId);
+ }
+
+ // Get hardcoded portal for now
+ portal = page.getPortal();
+ if (portal == null)
+ {
+ throw new ResourceNotFoundException(targetId);
+ }
+
+ // Get instance
+ instance = context.getController().getInstanceContainer().getInstance(window.getInstanceRef());
+ if (instance == null)
+ {
+ throw new ResourceNotFoundException(window.getInstanceRef());
+ }
+
+ // Get the user customization id
+ String userId = getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser();
+ if (userId != null)
+ {
+ instance = instance.getCustomization(userId);
+
+ //
+ if (isDashboard())
+ {
+ String dashboardId = userId + targetId;
+ instance = instance.getCustomization(dashboardId);
+ }
+ }
+ }
+
+ /**
+ * We only enforce security at instance and component level.
+ *
+ * @param pam
+ * @throws org.jboss.portal.core.controller.ControllerSecurityException
+ *
+ * @throws org.jboss.portal.security.PortalSecurityException
+ *
+ */
+ public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
+ {
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateViewResponse.java (from rev 5700, trunk/core/src/main/org/jboss/portal/core/controller/command/response/UpdateViewResponse.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/response/UpdateViewResponse.java 2006-11-21 10:09:27 UTC (rev 5700)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateViewResponse.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * 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.model.portal.command.response;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UpdateViewResponse
+{
+
+ /** . */
+ private String pageId;
+
+ public UpdateViewResponse(String pageId)
+ {
+ if (pageId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.pageId = pageId;
+ }
+
+ public String getPageId()
+ {
+ return pageId;
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/ui/configurator/InvokePortletActionCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ui/configurator/InvokePortletActionCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/ui/configurator/InvokePortletActionCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -24,44 +24,58 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.portlet.PortletContextFactory;
+import org.jboss.portal.core.controller.portlet.PortletCommandFactory;
+import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.Parameters;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.theme.page.PageService;
+import org.jboss.portal.theme.page.ModifiablePageResult;
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.theme.page.ModifiableWindowResult;
+import org.jboss.portal.theme.page.WindowContext;
+import org.jboss.portal.theme.LayoutService;
+import org.jboss.portal.theme.PortalLayout;
+import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.theme.PageRendition;
+import org.jboss.portal.theme.navigation.PageNavigationalState;
+import org.jboss.portal.common.NotYetImplemented;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class InvokePortletActionCommand extends ControllerCommand
+public class InvokePortletActionCommand extends InvokePortletCommand
{
- /** The navigational state. */
- private StateString navigationalState;
-
/** The interaction state. */
private StateString interactionState;
/** The nform. */
private Parameters form;
- /** The instance displayed. */
- private Instance instance;
-
public InvokePortletActionCommand(StateString navigationalState, StateString interactionState, Parameters form)
{
- this.navigationalState = navigationalState;
+ super(navigationalState);
this.interactionState = interactionState;
this.form = form;
}
-
- public StateString getNavigationalState()
- {
- return navigationalState;
- }
-
public StateString getInteractionState()
{
return interactionState;
@@ -72,18 +86,6 @@
return form;
}
- protected void create() throws ControllerException
- {
-// InstanceContainer container = context.getController().getInstanceContainer();
-// instance = container.getInstance(instanceId);
-
- //
- if (instance == null)
- {
- // Do smth clever
- }
- }
-
public CommandInfo getInfo()
{
return null;
@@ -91,12 +93,43 @@
public Object execute() throws ControllerException
{
-// ControllerRenderContext ctx = new ControllerRenderContext(
-// context,
-// context.getServerInvocation().getServerContext(),
-// );
+ try
+ {
+ PortletContextFactory pcf1 = new PortletContextFactory(context);
+ PortletCommandFactory pcf2 = new PortletCommandFactoryImpl();
+ ActionInvocation action = PortletInvocationFactory.createAction(
+ context,
+ Mode.VIEW,
+ WindowState.MAXIMIZED,
+ navigationalState,
+ interactionState,
+ form,
+ pcf1,
+ pcf2);
+ PortletInvocationResponse response = instance.invoke(action);
+ // For now let the controller handle non fragment response
+ String content = "";
+ if (response instanceof FragmentResponse)
+ {
+ content = ((FragmentResponse)response).getContent();
+ }
+ else if (response instanceof ErrorResponse)
+ {
+ content = ((ErrorResponse)response).toHTML();
+ }
+ else
+ {
+ throw new NotYetImplemented();
+ }
- return null;
+
+ //
+ return null;
+ }
+ catch (PortletInvokerException e)
+ {
+ return new ControllerException(e);
+ }
}
}
Added: trunk/core/src/main/org/jboss/portal/core/ui/configurator/InvokePortletCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ui/configurator/InvokePortletCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/ui/configurator/InvokePortletCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.ui.configurator;
+
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.portlet.StateString;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class InvokePortletCommand extends ControllerCommand
+{
+
+ /** The navigational state. */
+ protected StateString navigationalState;
+
+ /** The instance displayed. */
+ protected Instance instance;
+
+ public InvokePortletCommand(StateString navigationalState)
+ {
+ this.navigationalState = navigationalState;
+ }
+
+ protected void create() throws ControllerException
+ {
+ InstanceContainer container = context.getController().getInstanceContainer();
+
+ String instanceId = "ConfiguratorPortletInstance";
+
+ //
+ if (instanceId == null)
+ {
+ throw new ControllerException("No portlet instance configured on the configurator");
+ }
+
+ //
+ instance = container.getInstance(instanceId);
+ if (instance == null)
+ {
+ throw new ControllerException("Configurator portlet instance " + instanceId + " not found");
+ }
+ }
+
+ public StateString getNavigationalState()
+ {
+ return navigationalState;
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/ui/configurator/InvokePortletRenderCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ui/configurator/InvokePortletRenderCommand.java 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/main/org/jboss/portal/core/ui/configurator/InvokePortletRenderCommand.java 2006-11-21 21:51:07 UTC (rev 5706)
@@ -22,15 +22,11 @@
******************************************************************************/
package org.jboss.portal.core.ui.configurator;
-import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.portlet.PortletContextFactory;
import org.jboss.portal.core.controller.portlet.PortletCommandFactory;
import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
import org.jboss.portal.core.controller.command.info.CommandInfo;
-import org.jboss.portal.core.controller.command.response.PortletResponse;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.RenderInvocation;
@@ -59,46 +55,14 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class InvokePortletRenderCommand extends ControllerCommand
+public class InvokePortletRenderCommand extends InvokePortletCommand
{
- /** The navigational state. */
- private StateString navigationalState;
-
- /** The instance displayed. */
- private Instance instance;
-
public InvokePortletRenderCommand(StateString navigationalState)
{
- this.navigationalState = navigationalState;
+ super(navigationalState);
}
- protected void create() throws ControllerException
- {
- InstanceContainer container = context.getController().getInstanceContainer();
-
- String instanceId = "ConfiguratorPortletInstance";
-
- //
- if (instanceId == null)
- {
- throw new ControllerException("No portlet instance configured on the configurator");
- }
-
- //
- instance = container.getInstance(instanceId);
- if (instance == null)
- {
- throw new ControllerException("Configurator portlet instance " + instanceId + " not found");
- }
- }
-
-
- public StateString getNavigationalState()
- {
- return navigationalState;
- }
-
public CommandInfo getInfo()
{
return null;
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2006-11-21 21:30:34 UTC (rev 5705)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2006-11-21 21:51:07 UTC (rev 5706)
@@ -748,7 +748,7 @@
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<attribute name="Path">/dashboard</attribute>
- <attribute name="ClassNames">org.jboss.portal.core.controller.command.ViewDashboardCommand</attribute>
+ <attribute name="ClassNames">org.jboss.portal.core.model.portal.command.ViewDashboardCommand</attribute>
<depends
optional-attribute-name="Factory"
proxy-type="attribute">portal:urlFactory=Delegating</depends>
@@ -852,7 +852,7 @@
<!-- The core controller -->
<mbean
- code="org.jboss.portal.core.controller.CoreController"
+ code="org.jboss.portal.core.controller.classic.ClassicController"
name="portal:controller=Core"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
17 years, 7 months
JBoss Portal SVN: r5705 - in trunk/core/src: main/org/jboss/portal/core/portlet/dashboard resources/portal-core-war/WEB-INF resources/portal-core-war/WEB-INF/jsp/dashboard
by portal-commits@lists.jboss.org
Author: roy.russo(a)jboss.com
Date: 2006-11-21 16:30:34 -0500 (Tue, 21 Nov 2006)
New Revision: 5705
Modified:
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
trunk/core/src/resources/portal-core-war/WEB-INF/jboss-portlet.xml
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
Log:
JBPORTAL-993 - added instance listing
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-11-21 18:05:04 UTC (rev 5704)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-11-21 21:30:34 UTC (rev 5705)
@@ -21,6 +21,11 @@
*/
package org.jboss.portal.core.portlet.dashboard;
+import org.jboss.logging.Logger;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portlet.JBossActionRequest;
import org.jboss.portlet.JBossPortlet;
import org.jboss.portlet.JBossRenderRequest;
@@ -30,6 +35,10 @@
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletSecurityException;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
/**
* @author <a href="mailto:roy.russo@jboss.com">Roy Russo</a>
@@ -37,10 +46,30 @@
*/
public class Configurator extends JBossPortlet
{
+ private Logger log = Logger.getLogger(Configurator.class);
+
+ private InstanceContainer instanceContainer;
+
+ public void init()
+ throws PortletException
+ {
+ super.init();
+
+ instanceContainer = (InstanceContainer)getPortletContext().getAttribute("InstanceContainer");
+
+ if (instanceContainer == null)
+ {
+ throw new PortletException("No InstanceContainer found");
+ }
+ }
+
protected void doView(JBossRenderRequest req, JBossRenderResponse resp)
throws PortletException, PortletSecurityException, IOException
{
+ List instances = (List)instanceContainer.getInstances();
+
resp.setContentType("text/html");
+ req.setAttribute("instances", instances);
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/dashboard/editpage.jsp");
rd.include(req, resp);
}
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jboss-portlet.xml
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jboss-portlet.xml 2006-11-21 18:05:04 UTC (rev 5704)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jboss-portlet.xml 2006-11-21 21:30:34 UTC (rev 5705)
@@ -92,6 +92,12 @@
<trans-attribute>Required</trans-attribute>
</transaction>
</portlet>
+ <portlet>
+ <portlet-name>ConfiguratorPortlet</portlet-name>
+ <transaction>
+ <trans-attribute>Required</trans-attribute>
+ </transaction>
+ </portlet>
<!-- Service injected in the portlet context. -->
<service>
<service-name>PortalObjectContainer</service-name>
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-11-21 18:05:04 UTC (rev 5704)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-11-21 21:30:34 UTC (rev 5705)
@@ -1,3 +1,6 @@
+<%@ page import="org.jboss.portal.core.model.instance.Instance" %>
+<%@ page import="java.util.List" %>
+<%@ page import="org.jboss.portal.portlet.Portlet" %>
<%@ page language="java" extends="org.jboss.portal.core.servlet.jsp.PortalJsp" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@ taglib uri="/WEB-INF/portal-lib.tld" prefix="n" %>
@@ -4,6 +7,11 @@
<%@ page isELIgnored="false" %>
<portlet:defineObjects/>
+
+<%
+ List instances = (List)request.getAttribute("instances");
+%>
+
<script type="text/javascript" language="JavaScript">
function assignPortlet(op, to)
{
@@ -77,11 +85,16 @@
</td>
<td class="portlet-section-body" valign="top"><b>Available Content</b><br/>
<select name="available_instances" multiple="true" size="20">
- <option value="1">Instance 1</option>
- <option value="2">Instance 2</option>
- <option value="3">Instance 3</option>
- <option value="4">Instance 4</option>
- <option value="5">Instance 5</option>
+ <%
+ for (int i = 0; i < instances.size(); i++)
+ {
+ Instance instance = (Instance)instances.get(i);
+ %>
+ <option value="<%= instance.getId() %>"><%= instance.getId()%>
+ </option>
+ <%
+ }
+ %>
</select>
</td>
<td>
17 years, 7 months
JBoss Portal SVN: r5704 - in trunk/wsrp/src/main/org/jboss/portal: test/wsrp/registration wsrp/producer/registration/api wsrp/producer/registration/impl
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-11-21 13:05:04 -0500 (Tue, 21 Nov 2006)
New Revision: 5704
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerGroupTestCase.java
Removed:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/PersistentRegistrationObject.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationPersistenceManagerTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerGroupImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationPersistenceManagerImpl.java
Log:
- Removed unused PersistentRegistrationObject.
- Added ConsumerGroupTestCase.
- Cleaned up code.
Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerGroupTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerGroupTestCase.java 2006-11-21 17:38:29 UTC (rev 5703)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerGroupTestCase.java 2006-11-21 18:05:04 UTC (rev 5704)
@@ -0,0 +1,116 @@
+/******************************************************************************
+ * 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.test.wsrp.registration;
+
+import junit.framework.TestCase;
+import org.jboss.portal.wsrp.producer.registration.api.Consumer;
+import org.jboss.portal.wsrp.producer.registration.api.ConsumerGroup;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationException;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationStatus;
+import org.jboss.portal.wsrp.producer.registration.impl.RegistrationPersistenceManagerImpl;
+import org.jboss.portal.wsrp.producer.registration.policies.DefaultRegistrationPolicy;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ConsumerGroupTestCase extends TestCase
+{
+ private RegistrationManager manager;
+ private ConsumerGroup group;
+ private static final String NAME = "name";
+
+
+ protected void setUp() throws Exception
+ {
+ manager = new RegistrationManager();
+ manager.setPolicy(new DefaultRegistrationPolicy());
+ manager.setPersistenceManager(new RegistrationPersistenceManagerImpl());
+ group = manager.createConsumerGroup(NAME);
+ }
+
+ public void testGetName()
+ {
+ assertEquals(NAME, group.getName());
+ }
+
+ public void testConsumersManagement() throws RegistrationException
+ {
+ assertTrue(group.isEmpty());
+ assertEquals(0, group.getConsumers().size());
+
+ Consumer c1 = manager.createConsumer("c1");
+ group.addConsumer(c1);
+ assertTrue(!group.isEmpty());
+ assertEquals(1, group.getConsumers().size());
+ assertTrue(group.contains(c1));
+ assertEquals(group, c1.getGroup());
+ assertEquals(c1, group.getConsumer(c1.getIdentity()));
+
+ Consumer c2 = manager.createConsumer("c2");
+ group.addConsumer(c2);
+ assertEquals(2, group.getConsumers().size());
+ assertTrue(group.contains(c2));
+ assertEquals(group, c2.getGroup());
+
+ group.removeConsumer(c1);
+ assertEquals(1, group.getConsumers().size());
+ assertTrue(!group.contains(c1));
+ assertTrue(group.contains(c2));
+ assertEquals(null, c1.getGroup());
+ }
+
+ public void testAddNullConsumer() throws RegistrationException
+ {
+ try
+ {
+ group.addConsumer(null);
+ fail("Shouldn't be possible to add null consumer");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testStatus()
+ {
+ assertEquals(RegistrationStatus.PENDING, group.getStatus());
+ group.setStatus(RegistrationStatus.VALID);
+ assertEquals(RegistrationStatus.VALID, group.getStatus());
+ }
+
+ public void testIllegalStatus()
+ {
+ try
+ {
+ group.setStatus(null);
+ fail("Shouldn't be possible to set the status to null");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerTestCase.java 2006-11-21 17:38:29 UTC (rev 5703)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerTestCase.java 2006-11-21 18:05:04 UTC (rev 5704)
@@ -31,10 +31,6 @@
import org.jboss.portal.wsrp.producer.registration.impl.RegistrationPersistenceManagerImpl;
import org.jboss.portal.wsrp.producer.registration.policies.DefaultRegistrationPolicy;
-import javax.xml.namespace.QName;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
* @version $Revision$
@@ -44,7 +40,6 @@
{
private Consumer consumer;
private RegistrationManager manager;
- private Map registrationProperties;
protected void setUp() throws Exception
{
@@ -52,9 +47,6 @@
manager.setPolicy(new DefaultRegistrationPolicy());
manager.setPersistenceManager(new RegistrationPersistenceManagerImpl());
consumer = manager.createConsumer("name");
- registrationProperties = new HashMap();
- registrationProperties.put(new QName("prop1"), "value1");
- registrationProperties.put(new QName("prop2"), "value2");
}
public void testGetName()
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationPersistenceManagerTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationPersistenceManagerTestCase.java 2006-11-21 17:38:29 UTC (rev 5703)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationPersistenceManagerTestCase.java 2006-11-21 18:05:04 UTC (rev 5704)
@@ -318,7 +318,9 @@
String regId = reg.getId();
manager.removeRegistration(regId);
- //
+ // remove registration is the only method on RegistrationPersistenceManager that needs to "cascade"
+ // this is needed because there is no remove method on Consumer, hence the manager needs to remove the
+ // registration from its consumer since it's the only class that has access to the specific consumer impl
Collection registrations = consumer.getRegistrations();
assertNotNull(registrations);
assertEquals(0, registrations.size());
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java 2006-11-21 17:38:29 UTC (rev 5703)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java 2006-11-21 18:05:04 UTC (rev 5704)
@@ -25,7 +25,6 @@
import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
import org.jboss.portal.common.util.ParameterValidation;
-import org.jboss.portal.wsrp.producer.registration.impl.ConsumerImpl;
import java.util.ArrayList;
import java.util.Collection;
@@ -226,7 +225,7 @@
{
ParameterValidation.throwIllegalArgExceptionIfNull(registration, "Registration");
String handle = registration.getRegistrationHandle();
- ConsumerImpl consumer = (ConsumerImpl)getConsumerFor(handle);
+ Consumer consumer = getConsumerFor(handle);
if (consumer == null)
{
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerGroupImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerGroupImpl.java 2006-11-21 17:38:29 UTC (rev 5703)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerGroupImpl.java 2006-11-21 18:05:04 UTC (rev 5704)
@@ -39,7 +39,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision:5672 $
*/
-public class ConsumerGroupImpl extends PersistentRegistrationObject implements ConsumerGroup
+public class ConsumerGroupImpl implements ConsumerGroup
{
private String name;
@@ -47,16 +47,21 @@
private RegistrationStatus status;
- public ConsumerGroupImpl()
+ private ConsumerGroupImpl()
{
- this.consumers = new HashMap();
+ init();
}
- public ConsumerGroupImpl(String name, RegistrationPersistenceManagerImpl manager)
+ ConsumerGroupImpl(String name)
{
- super(manager);
this.name = name;
+ init();
+ }
+
+ private void init()
+ {
this.consumers = new HashMap();
+ status = RegistrationStatus.PENDING;
}
public String getName()
@@ -93,6 +98,7 @@
public void setStatus(RegistrationStatus status)
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(status, "RegistrationStatus");
this.status = status;
}
@@ -101,10 +107,10 @@
return Collections.unmodifiableCollection(consumers.values());
}
- public Consumer getConsumer(String consumerName) throws IllegalArgumentException, RegistrationException
+ public Consumer getConsumer(String consumerIdentity) throws IllegalArgumentException, RegistrationException
{
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerName, "Consumer name", null);
- return (Consumer)consumers.get(consumerName);
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerIdentity, "Consumer name", null);
+ return (Consumer)consumers.get(consumerIdentity);
}
public boolean isEmpty()
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java 2006-11-21 17:38:29 UTC (rev 5703)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java 2006-11-21 18:05:04 UTC (rev 5704)
@@ -41,7 +41,7 @@
* @version $Revision$
* @since 2.6
*/
-public class ConsumerImpl extends PersistentRegistrationObject implements Consumer
+public class ConsumerImpl implements Consumer
{
private String name;
@@ -54,21 +54,47 @@
private ConsumerImpl()
{
- super();
+ init();
}
- ConsumerImpl(String identity, String name, RegistrationPersistenceManagerImpl manager)
+ ConsumerImpl(String identity, String name)
{
- super(manager);
-
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "name", "Consumer");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "identity", "Consumer");
this.name = name;
this.identity = identity;
+ init();
+ }
+
+ private void init()
+ {
registrations = new HashSet(7);
+ status = RegistrationStatus.PENDING;
}
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ ConsumerImpl consumer = (ConsumerImpl)o;
+
+ return identity.equals(consumer.identity);
+ }
+
+ public int hashCode()
+ {
+ return identity.hashCode();
+ }
+
public String getName()
{
return name;
Deleted: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/PersistentRegistrationObject.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/PersistentRegistrationObject.java 2006-11-21 17:38:29 UTC (rev 5703)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/PersistentRegistrationObject.java 2006-11-21 18:05:04 UTC (rev 5704)
@@ -1,55 +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.wsrp.producer.registration.impl;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class PersistentRegistrationObject
-{
- protected RegistrationPersistenceManagerImpl manager;
-
-
- public PersistentRegistrationObject()
- {
- }
-
- protected PersistentRegistrationObject(RegistrationPersistenceManagerImpl manager)
- {
- this.manager = manager;
- }
-
-
- public RegistrationPersistenceManagerImpl getManager()
- {
- return manager;
- }
-
- public void setManager(RegistrationPersistenceManagerImpl manager)
- {
- this.manager = manager;
- }
-}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationPersistenceManagerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationPersistenceManagerImpl.java 2006-11-21 17:38:29 UTC (rev 5703)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationPersistenceManagerImpl.java 2006-11-21 18:05:04 UTC (rev 5704)
@@ -55,7 +55,7 @@
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(identity, "Consumer identity", null);
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "Consumer name", null);
- ConsumerImpl consumer = new ConsumerImpl(identity, name, this);
+ ConsumerImpl consumer = new ConsumerImpl(identity, name);
consumer.setStatus(RegistrationStatus.PENDING);
consumers.put(identity, consumer);
@@ -78,7 +78,7 @@
}
else
{
- group = new ConsumerGroupImpl(name, this);
+ group = new ConsumerGroupImpl(name);
groups.put(name, group);
return group;
}
17 years, 7 months
JBoss Portal SVN: r5703 - in trunk/core/src: main/org/jboss/portal/core/portlet/dashboard resources/portal-core-war/WEB-INF/jsp/dashboard
by portal-commits@lists.jboss.org
Author: roy.russo(a)jboss.com
Date: 2006-11-21 12:38:29 -0500 (Tue, 21 Nov 2006)
New Revision: 5703
Modified:
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
Log:
added param modifier for page edits
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-11-21 10:47:24 UTC (rev 5702)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-11-21 17:38:29 UTC (rev 5703)
@@ -21,6 +21,7 @@
*/
package org.jboss.portal.core.portlet.dashboard;
+import org.jboss.portlet.JBossActionRequest;
import org.jboss.portlet.JBossPortlet;
import org.jboss.portlet.JBossRenderRequest;
import org.jboss.portlet.JBossRenderResponse;
@@ -31,7 +32,7 @@
import java.io.IOException;
/**
- * @author <a href="mailto:royrusso@yahoo.com">Roy Russo</a>
+ * @author <a href="mailto:roy.russo@jboss.com">Roy Russo</a>
* @version $Revision: 0 $
*/
public class Configurator extends JBossPortlet
@@ -43,4 +44,9 @@
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/dashboard/editpage.jsp");
rd.include(req, resp);
}
+
+ protected void processAction(JBossActionRequest actionRequest, JBossRenderRequest renderRequest)
+ {
+ System.out.println("blah");
+ }
}
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-11-21 10:47:24 UTC (rev 5702)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-11-21 17:38:29 UTC (rev 5703)
@@ -4,39 +4,68 @@
<%@ page isELIgnored="false" %>
<portlet:defineObjects/>
+<script type="text/javascript" language="JavaScript">
+ function assignPortlet(op, to)
+ {
+ this.instancesForm.op.value = op;
+ this.instancesForm.toRegion.value = to;
+ }
+ function unassignPortlet(op, from)
+ {
+ this.instancesForm.op.value = op;
+ this.instancesForm.fromRegion.value = from;
+ }
+
+ function sortPortlet(op, region)
+ {
+ this.instancesForm.op.value = op;
+ this.instancesForm.sortRegion.value = region;
+ }
+
+ function debug()
+ {
+ alert("OP: '" + this.instancesForm.op.value + "' toRegion: '" + this.instancesForm.toRegion.value + "' fromRegion: '" + this.instancesForm.fromRegion.value + "' sortRegion: '" + this.instancesForm.sortRegion.value + "'");
+ }
+</script>
<table width="100%">
- <th colspan="2" class="portlet-section-header" align="center">Edit Page</th>
- <tr>
- <td class="portlet-section-body" align="left">
- Use this to manage the content on your page. You can control the page title, select number of columns, and add,
- order, or remove portlets.
- </td>
- </tr>
- <tr>
- <td>
- <hr/>
- </td>
- </tr>
- <tr>
- <td class="portlet-section-body" align="left"><b>Select a page to edit:</b><br/>
+<th colspan="2" class="portlet-section-header" align="center">Edit Page</th>
+<tr>
+ <td class="portlet-section-body" align="left">
+ Use this to manage the content on your page. You can control the page title, select number of columns, and add,
+ order, or remove portlets.
+ </td>
+</tr>
+<tr>
+ <td>
+ <hr/>
+ </td>
+</tr>
+<tr>
+ <td class="portlet-section-body" align="left"><b>Select a page to edit:</b><br/>
- <form action="" method="POST" style="padding:0;margin:0">
- <select name="pagename">
- <option value="">Home</option>
- <option value="">Blah</option>
- </select>
- <input type="submit" name="submit" value="Go" class="portlet-form-button"/>
- </form>
- </td>
- </tr>
- <tr>
- <td>
- <hr/>
- </td>
- </tr>
- <tr>
- <td>
+ <form action="" method="POST" style="padding:0;margin:0">
+ <select name="pagename">
+ <option value="">Home</option>
+ <option value="">Blah</option>
+ </select>
+ <input type="submit" name="submit" value="Go" class="portlet-form-button"/>
+ </form>
+ </td>
+</tr>
+<tr>
+ <td>
+ <hr/>
+ </td>
+</tr>
+<tr>
+ <td>
+ <form action="<portlet:actionURL>
+ </portlet:actionURL>" name="instancesForm" method="POST" onsubmit="debug();">
+ <input type="hidden" name="op"/>
+ <input type="hidden" name="toRegion"/>
+ <input type="hidden" name="fromRegion"/>
+ <input type="hidden" name="sortRegion"/>
<table width="100%">
<tr>
<td>
@@ -48,65 +77,90 @@
</td>
<td class="portlet-section-body" valign="top"><b>Available Content</b><br/>
<select name="available_instances" multiple="true" size="20">
- <option value="">Instance 1</option>
- <option value="">Instance 2</option>
- <option value="">Instance 3</option>
- <option value="">Instance 4</option>
- <option value="">Instance 5</option>
+ <option value="1">Instance 1</option>
+ <option value="2">Instance 2</option>
+ <option value="3">Instance 3</option>
+ <option value="4">Instance 4</option>
+ <option value="5">Instance 5</option>
</select>
</td>
<td>
- <table>
- <tr>
- <td>><br/><</td>
- <td class="portlet-section-body" valign="top">
- <b>Left Column</b><br/>
- <select name="instances_left" multiple="true" size="6">
- <option value="">Instance 1</option>
- <option value="">Instance 2</option>
- <option value="">Instance 3</option>
- <option value="">Instance 4</option>
- <option value="">Instance 5</option>
- </select>
- </td>
- <td>up<br/>dwn</td>
- </tr>
- <tr>
- <td>><br/><</td>
- <td class="portlet-section-body" valign="top"><b>Middle Column</b><br/>
- <select name="instances_middle" multiple="true" size="6">
- <option value="">Instance 1</option>
- <option value="">Instance 2</option>
- <option value="">Instance 3</option>
- <option value="">Instance 4</option>
- <option value="">Instance 5</option>
- </select></td>
- <td>up<br/>dwn</td>
- </tr>
- <tr>
- <td>><br/><</td>
- <td class="portlet-section-body" valign="top"><b>Right Column</b><br/>
- <select name="instances_right" multiple="true" size="6">
- <option value="">Instance 1</option>
- <option value="">Instance 2</option>
- <option value="">Instance 3</option>
- <option value="">Instance 4</option>
- <option value="">Instance 5</option>
- </select></td>
- <td>up<br/>dwn</td>
- </tr>
- </table>
- </td>
+ <table>
+ <tr>
+ <td>
+ <input type="submit" class="portlet-form-button" name=">" value=">"
+ onclick="assignPortlet('copy','left');"/><br/><input
+ type="submit" class="portlet-form-button" name="<" value="<"
+ onclick="unassignPortlet('remove','left');"/></td>
+ <td class="portlet-section-body" valign="top">
+ <b>Left Column</b><br/>
+ <select name="instances_left" multiple="true" size="6">
+ <option value="">Instance 1</option>
+ <option value="">Instance 2</option>
+ <option value="">Instance 3</option>
+ <option value="">Instance 4</option>
+ <option value="">Instance 5</option>
+ </select>
+ </td>
+ <td>
+ <input type="submit" class="portlet-form-button" name="Up" value="Up"
+ onclick="sortPortlet('up','left');"/><br/><input
+ type="submit" class="portlet-form-button" name="Down" value="Down"
+ onclick="sortPortlet('down','left');"/>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input type="submit" class="portlet-form-button" name=">" value=">"
+ onclick="sortPortlet('copy','center');"/><br/><input
+ type="submit" class="portlet-form-button" name="<" value="<"
+ onclick="sortPortlet('remove','center');"/></td>
+ <td class="portlet-section-body" valign="top"><b>Middle Column</b><br/>
+ <select name="instances_middle" multiple="true" size="6">
+ <option value="">Instance 1</option>
+ <option value="">Instance 2</option>
+ <option value="">Instance 3</option>
+ <option value="">Instance 4</option>
+ <option value="">Instance 5</option>
+ </select></td>
+ <td>
+ <input type="submit" class="portlet-form-button" name="Up" value="Up"
+ onclick="sortPortlet('up','center');"/><br/><input
+ type="submit" class="portlet-form-button" name="Down" value="Down"
+ onclick="sortPortlet('down','center');"/></td>
+ </tr>
+ <tr>
+ <td>
+ <input type="submit" class="portlet-form-button" name=">" value=">"
+ onclick="assignPortlet('copy','right');"/><br/><input
+ type="submit" class="portlet-form-button" name="<" value="<"
+ onclick="unassignPortlet('remove','right');"/></td>
+ <td class="portlet-section-body" valign="top"><b>Right Column</b><br/>
+ <select name="instances_right" multiple="true" size="6">
+ <option value="">Instance 1</option>
+ <option value="">Instance 2</option>
+ <option value="">Instance 3</option>
+ <option value="">Instance 4</option>
+ <option value="">Instance 5</option>
+ </select></td>
+ <td>
+ <input type="submit" class="portlet-form-button" name="Up" value="Up"
+ onclick="sortPortlet('up','right');"/><br/><input
+ type="submit" class="portlet-form-button" name="Down" value="Down"
+ onclick="sortPortlet('down','right');"/></td>
+ </tr>
+ </table>
</tr>
</table>
- </td>
- </tr>
- <tr>
- <td class="portlet-section-alternate" width="100%" colspan="4" align="center">
- <input type="submit" name="save" value="Save" class="portlet-form-button"/>
- <input type="submit" name="delete" value="Delete" class="portlet-form-button"/>
- </td>
- </tr>
+ </form>
+ </td>
+</tr>
+<tr>
+ <td class="portlet-section-alternate" width="100%" colspan="4" align="center">
+ <input type="submit" name="save" value="Save" class="portlet-form-button"/>
+ <input type="submit" name="delete" value="Delete" class="portlet-form-button"/>
+ </td>
+</tr>
</table>
</td>
</tr>
17 years, 7 months