JBoss Portal SVN: r6923 - in trunk: core/src/main/org/jboss/portal/core/aspects/controller and 13 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-05 09:35:24 -0400 (Thu, 05 Apr 2007)
New Revision: 6923
Added:
trunk/core/src/main/org/jboss/portal/core/controller/AjaxResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/CommandForward.java
trunk/core/src/main/org/jboss/portal/core/controller/HTTPResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/HandlerResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandlerSelector.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
Removed:
trunk/core/src/main/org/jboss/portal/core/controller/ControllerFactory.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/CommandForward.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/HTTPResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/HandlerResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java
Modified:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/TestPortlet.java
trunk/core/src/main/org/jboss/portal/core/CoreConstants.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/AbstractResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.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/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-server-war/WEB-INF/web.xml
trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
Log:
- improved javascript
- finally use only one controller and implement the ajax/classic in the response handler as it seems to be the appropriate place
Modified: trunk/core/src/main/org/jboss/portal/core/CoreConstants.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/CoreConstants.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/CoreConstants.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -26,13 +26,42 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public interface CoreConstants
+public final class CoreConstants
{
- String SES_GUEST_INFO = "org.jboss.portal.guest_info";
- String SES_USER_FINALIZER = "org.jboss.portal.user_finalizer";
- String REQ_ATT_CONTEXT_PATH = "org.jboss.portal.context_path";
- String REQ_ATT_SERVLET_PATH = "org.jboss.portal.servlet_path";
+ /**
+ * Servlet constants.
+ */
+ public static final class Servlet
+ {
- String REQ_PROP_PREFERRED_MARKUP = "org.jboss.portal.preferred_markup";
+ /**
+ * Servlet session constants.
+ */
+ public static final class Session
+ {
+
+ /** . */
+ public static final String GUEST_INFO = "jboss.portal.guest_info";
+
+ /** . */
+ public static final String USER_FINALIZER = "jboss.portal.user_finalizer";
+ }
+
+ /**
+ * Servlet request constants.
+ */
+ public static final class Request
+ {
+
+ /** . */
+ public static final String PORTAL_CONTEXT_PATH = "jboss.portal.context_path";
+
+ /** . */
+ public static final String PORTAL_SERVLET_PATH = "jboss.portal.servlet_path";
+ }
+ }
+
+ /** . */
+ public static final String REQUEST_TYPE = "jboss.portal.request_type";
}
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -25,8 +25,6 @@
import org.jboss.portal.core.controller.ControllerInterceptor;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.core.controller.Controller;
-import org.jboss.portal.core.controller.classic.ClassicController;
import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
import org.jboss.portal.common.invocation.InvocationException;
@@ -44,8 +42,7 @@
// We commit the nav state changes only for the classic controller at the base of the pipeline
ControllerContext controllerContext = cmd.getControllerContext();
- Controller controller = controllerContext.getController();
- if (controllerContext.getDepth() == 1 && controller instanceof ClassicController)
+ if (controllerContext.getDepth() == 1 && controllerContext.getType() == ControllerContext.CLASSIC_TYPE)
{
PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
ctx.applyChanges();
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -195,20 +195,20 @@
if (user == null)
{
// Erase any previous user finalizer, the side effect of unbinding the session attribute will finalize the previous user
- UserFinalizer finalizer = (UserFinalizer)httpSession.getAttribute(CoreConstants.SES_USER_FINALIZER);
+ UserFinalizer finalizer = (UserFinalizer)httpSession.getAttribute(CoreConstants.Servlet.Session.USER_FINALIZER);
if (finalizer != null)
{
if (trace)
{
log.trace("Removing finalizer for user=" + finalizer.userId);
}
- httpSession.setAttribute(CoreConstants.SES_USER_FINALIZER, null);
+ httpSession.setAttribute(CoreConstants.Servlet.Session.USER_FINALIZER, null);
}
}
else
{
// Get the current finalizer if any
- UserFinalizer finalizer = (UserFinalizer)httpSession.getAttribute(CoreConstants.SES_USER_FINALIZER);
+ UserFinalizer finalizer = (UserFinalizer)httpSession.getAttribute(CoreConstants.Servlet.Session.USER_FINALIZER);
// Get the user id from the request user
if (finalizer == null)
@@ -222,7 +222,7 @@
finalizer = new UserFinalizer(user.getId());
// Bind the new one, the side effect finalizes the previous user
- httpSession.setAttribute(CoreConstants.SES_USER_FINALIZER, finalizer);
+ httpSession.setAttribute(CoreConstants.Servlet.Session.USER_FINALIZER, finalizer);
}
else if (!finalizer.userId.equals(user.getId()))
{
@@ -235,7 +235,7 @@
finalizer = new UserFinalizer(user.getId());
// Bind the new one, the side effect finalizes the previous user
- httpSession.setAttribute(CoreConstants.SES_USER_FINALIZER, finalizer);
+ httpSession.setAttribute(CoreConstants.Servlet.Session.USER_FINALIZER, finalizer);
}
}
Copied: trunk/core/src/main/org/jboss/portal/core/controller/AjaxResponse.java (from rev 6921, trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponse.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/AjaxResponse.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/controller/AjaxResponse.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.controller;
+
+import org.jboss.portal.core.controller.HandlerResponse;
+import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
+import org.jboss.portal.theme.impl.render.dynamic.JSONMarshaller;
+import org.jboss.portal.server.ServerInvocationContext;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AjaxResponse extends HandlerResponse
+{
+
+ /** . */
+ private static final JSONMarshaller marshaller = new JSONMarshaller();
+
+ /** The response to the client. */
+ private final DynaResponse dynaResponse;
+
+ public AjaxResponse(DynaResponse dynaResponse)
+ {
+ this.dynaResponse = dynaResponse;
+ }
+
+ public void sendResponse(ServerInvocationContext ctx) throws IOException, ServletException
+ {
+ HttpServletResponse resp = ctx.getClientResponse();
+ resp.setContentType("text/html");
+ marshaller.write(dynaResponse, resp.getWriter());
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/controller/CommandForward.java (from rev 6921, trunk/core/src/main/org/jboss/portal/core/controller/classic/CommandForward.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/CommandForward.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/controller/CommandForward.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.controller;
+
+import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.core.controller.ControllerCommand;
+
+/**
+ * Forward to a new command.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CommandForward extends HandlerResponse
+{
+ /** . */
+ private final ControllerCommand cmd;
+
+ /** . */
+ private final URLContext urlCtx;
+
+ public CommandForward(ControllerCommand cmd, URLContext urlCtx)
+ {
+ if (cmd == null)
+ {
+ throw new IllegalArgumentException("No command provided");
+ }
+ this.cmd = cmd;
+ this.urlCtx = urlCtx;
+ }
+
+ public ControllerCommand getCommand()
+ {
+ return cmd;
+ }
+
+ public URLContext getURLContext()
+ {
+ return urlCtx;
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -33,12 +33,22 @@
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.server.RequestController;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.server.ServerException;
+import org.jboss.portal.server.ServerURL;
+import org.jboss.portal.server.request.URLContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+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: 1.1 $
*/
-public abstract class Controller extends AbstractJBossService implements RequestController
+public class Controller extends AbstractJBossService implements RequestController
{
/** . */
@@ -68,6 +78,9 @@
/** . */
protected ContentRendererRegistry contentRendererRegistry;
+ /** . */
+ protected ResponseHandler responseHandler;
+
public ContentRendererRegistry getContentRendererRegistry()
{
return contentRendererRegistry;
@@ -158,5 +171,155 @@
this.stackFactory = stackFactory;
}
+ public ResponseHandler getResponseHandler()
+ {
+ return responseHandler;
+ }
+ public void setResponseHandler(ResponseHandler responseHandler)
+ {
+ this.responseHandler = responseHandler;
+ }
+
+ public final void handle(ServerInvocation invocation) throws ServerException
+ {
+ // Invoke the chain that creates the initial command
+ ControllerCommand cmd = commandFactory.doMapping(invocation, invocation.getServerContext().getPortalHost(), invocation.getServerContext().getPortalContextPath(), invocation.getServerContext().getPortalRequestPath());
+
+ //
+ if (cmd == null)
+ {
+ // Handle that case
+ throw new ServerException("No command was produced by the command factory");
+ }
+
+ // Create controller context
+ ControllerContext controllerContext = new ControllerContext(invocation, this);
+
+ // Handle the command created
+ processCommand(controllerContext, cmd);
+ }
+
+ /**
+ * Handle a command which means it executes the command and reacts upon the response created by the command.
+ *
+ * @param controllerContext the controller context
+ * @param cmd the command
+ * @throws org.jboss.portal.server.ServerException
+ */
+ protected void processCommand(ControllerContext controllerContext, ControllerCommand cmd) throws ServerException
+ {
+ HandlerResponse handlerResp = executeCommand(controllerContext, cmd);
+
+ //
+ if (handlerResp == null)
+ {
+ return;
+ }
+
+ // Find out if we can execute in the same server invocation
+ if (handlerResp instanceof CommandForward)
+ {
+ CommandForward forward = (CommandForward)handlerResp;
+ processCommand(controllerContext, forward.getCommand());
+ }
+ else if (handlerResp instanceof HTTPResponse)
+ {
+ HTTPResponse hr = (HTTPResponse)handlerResp;
+ sendResponse(controllerContext, hr);
+ }
+ else if (handlerResp instanceof AjaxResponse)
+ {
+ AjaxResponse ar = (AjaxResponse)handlerResp;
+ sendResponse(controllerContext, ar);
+ }
+ }
+
+ protected HandlerResponse executeCommand(ControllerContext controllerContext, ControllerCommand command) throws ServerException
+ {
+ URLContext urlContext = controllerContext.getServerInvocation().getServerContext().getURLContext();
+
+ try
+ {
+ // Execute command
+ Object commandResponse = controllerContext.execute(command);
+
+ // Handle the result, might be null if no handling done
+ return responseHandler.processCommandResponse(controllerContext, command, commandResponse);
+ }
+ catch (CommandRedirectionException e)
+ {
+ // Handle the redirection as forward
+ return new CommandForward(e.getRedirection(), null);
+ }
+ catch (ControllerSecurityException e)
+ {
+ if (urlContext.isAuthenticated())
+ {
+ return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_UNAUTHORIZED);
+ }
+ else
+ {
+ urlContext = URLContext.newInstance(urlContext.isSecure(), true);
+ ServerURL serverURL = getURLFactory().doMapping(controllerContext.getServerInvocation(), command);
+ String url = controllerContext.getServerInvocation().getResponse().renderURL(serverURL, urlContext, null);
+ return new HTTPResponse.SendRedirect(url);
+ }
+ }
+ catch (ResourceNotFoundException e)
+ {
+ log.error("Resource not found " + e.getRef(), e);
+ return new HTTPResponse.SetStatusCode(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);
+ }
+ }
+
+ /**
+ * All http responses in the stack should be handled here.
+ */
+ protected void sendResponse(ControllerContext ctx, HTTPResponse resp)
+ {
+ try
+ {
+ resp.sendResponse(ctx.getServerInvocation().getServerContext());
+ }
+ catch (IOException e)
+ {
+ log.error("Cound not send http response", e);
+ }
+ catch (ServletException e)
+ {
+ log.error("Cound not send http response", e);
+ }
+ }
+
+ /**
+ * All http responses in the stack should be handled here.
+ */
+ protected void sendResponse(ControllerContext ctx, AjaxResponse resp)
+ {
+ try
+ {
+ resp.sendResponse(ctx.getServerInvocation().getServerContext());
+ }
+ catch (IOException e)
+ {
+ log.error("Cound not send http response", e);
+ }
+ catch (ServletException e)
+ {
+ log.error("Cound not send http response", e);
+ }
+ }
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -32,7 +32,9 @@
import org.jboss.portal.identity.User;
import org.jboss.portal.core.aspects.server.UserInterceptor;
import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
+import org.jboss.portal.core.CoreConstants;
+import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
@@ -42,12 +44,21 @@
public class ControllerContext extends AbstractInvocationContext
{
+ /** . */
+ public static final int CLASSIC_TYPE = 0;
+
+ /** . */
+ public static final int AJAX_TYPE = 1;
+
/** The server invocation. */
- private ServerInvocation serverInvocation;
+ private final ServerInvocation serverInvocation;
/** The controller. */
- private Controller controller;
+ private final Controller controller;
+ /** . */
+ private final int type;
+
/** The depth of the call stack. */
private int depth;
@@ -68,6 +79,18 @@
this.depth = 0;
//
+ HttpServletRequest req = serverInvocation.getServerContext().getClientRequest();
+ String value = req.getHeader("ajax");
+ if ("true".equalsIgnoreCase(value))
+ {
+ type = AJAX_TYPE;
+ }
+ else
+ {
+ type = CLASSIC_TYPE;
+ }
+
+ //
addResolver(ControllerCommand.REQUEST_SCOPE, serverInvocation.getContext());
addResolver(ControllerCommand.SESSION_SCOPE, serverInvocation.getContext());
addResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, new PortalObjectNavigationalStateContext(serverInvocation.getContext().getAttributeResolver(ControllerCommand.PRINCIPAL_SCOPE)));
@@ -113,6 +136,11 @@
}
}
+ public int getType()
+ {
+ return type;
+ }
+
public int getDepth()
{
return depth;
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/ControllerFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerFactory.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ControllerFactory.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -1,94 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.controller;
-
-import org.jboss.portal.server.RequestControllerFactory;
-import org.jboss.portal.server.RequestController;
-import org.jboss.portal.server.ServerInvocation;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ControllerFactory implements RequestControllerFactory
-{
-
- /** . */
- private RequestController classicController;
-
- /** . */
- private RequestController ajaxController;
-
- public RequestController getClassicController()
- {
- return classicController;
- }
-
- public void setClassicController(RequestController classicController)
- {
- this.classicController = classicController;
- }
-
-
- public RequestController getAjaxController()
- {
- return ajaxController;
- }
-
- public void setAjaxController(RequestController ajaxController)
- {
- this.ajaxController = ajaxController;
- }
-
- public RequestController createRequestController(ServerInvocation invocation)
- {
-
- HttpServletRequest req = invocation.getServerContext().getClientRequest();
- String value = req.getHeader("ajax");
- if ("true".equalsIgnoreCase(value))
- {
- return ajaxController;
- }
- else
- {
- return classicController;
- }
-
-
-// 02:03:58,636 INFO [STDOUT] host = localhost:8080
-// 02:03:58,636 INFO [STDOUT] user-agent = Mozilla/5.0 (Macintosh; U; Intel Mac OS X; fr; rv:1.8.1) Gecko/20061010 Firefox/2.0
-// 02:03:58,636 INFO [STDOUT] accept = text/javascript, text/html, application/xml, text/xml, */*
-// 02:03:58,636 INFO [STDOUT] accept-language = fr,en-us;q=0.5
-// 02:03:58,637 INFO [STDOUT] accept-encoding = gzip,deflate
-// 02:03:58,637 INFO [STDOUT] accept-charset = ISO-8859-1,utf-8;q=0.7,*;q=0.7
-// 02:03:58,637 INFO [STDOUT] keep-alive = 300
-// 02:03:58,637 INFO [STDOUT] connection = keep-alive
-// 02:03:58,637 INFO [STDOUT] x-requested-with = XMLHttpRequest
-// 02:03:58,638 INFO [STDOUT] x-prototype-version = 1.5.0_rc1
-// 02:03:58,638 INFO [STDOUT] ajax = true
-// 02:03:58,639 INFO [STDOUT] referer = http://localhost:8080/portal/auth/portal/dashboard/admin/default/
-// 02:03:58,639 INFO [STDOUT] cookie = JSESSIONID=A0B8EA1EEEAE6D977C0A8074D338B0EB
- }
-}
Copied: trunk/core/src/main/org/jboss/portal/core/controller/HTTPResponse.java (from rev 6921, trunk/core/src/main/org/jboss/portal/core/controller/classic/HTTPResponse.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/HTTPResponse.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/controller/HTTPResponse.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.controller;
+
+import org.jboss.portal.server.ServerInvocationContext;
+import org.jboss.portal.common.util.Tools;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletException;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Response that sends a response to the http stream.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class HTTPResponse extends HandlerResponse
+{
+
+ public abstract void sendResponse(ServerInvocationContext ctx) throws IOException, ServletException;
+
+ public static class SetStatusCode extends HTTPResponse
+ {
+
+ /** . */
+ private final int statusCode;
+
+ public SetStatusCode(int statusCode)
+ {
+ this.statusCode = statusCode;
+ }
+
+ public void sendResponse(ServerInvocationContext ctx) throws IOException
+ {
+ HttpServletResponse resp = ctx.getClientResponse();
+ resp.sendError(statusCode);
+ }
+ }
+
+ public static class SendRedirect extends HTTPResponse
+ {
+
+ /** . */
+ private final String redirect;
+
+ public SendRedirect(String redirect)
+ {
+ this.redirect = redirect;
+ }
+
+ public void sendResponse(ServerInvocationContext ctx) throws IOException
+ {
+ HttpServletResponse resp = ctx.getClientResponse();
+ resp.sendRedirect(redirect);
+ }
+ }
+
+ public static class SendBinary extends HTTPResponse
+ {
+
+ /** . */
+ private final String contentType;
+
+ /** . */
+ private final InputStream in;
+
+ public SendBinary(String contentType, InputStream inputStream)
+ {
+ this.contentType = contentType;
+ this.in = inputStream;
+ }
+
+ public void sendResponse(ServerInvocationContext ctx) throws IOException
+ {
+ HttpServletResponse resp = ctx.getClientResponse();
+ resp.setContentType(contentType);
+ ServletOutputStream sout = null;
+ try
+ {
+ sout = resp.getOutputStream();
+ byte[] buf = new byte[2048];
+ int len;
+ while ((len = in.read(buf)) > 0)
+ {
+ sout.write(buf, 0, len);
+ }
+ sout.flush();
+ }
+ finally
+ {
+ Tools.safeClose(in);
+ Tools.safeClose(sout);
+ }
+ }
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/controller/HandlerResponse.java (from rev 6921, trunk/core/src/main/org/jboss/portal/core/controller/classic/HandlerResponse.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/HandlerResponse.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/controller/HandlerResponse.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.controller;
+
+/**
+ * The response from a a response handler.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class HandlerResponse
+{
+}
Copied: trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandler.java (from rev 6921, trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandler.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandler.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -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;
+
+import org.jboss.portal.server.ServerException;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerContext;
+
+import javax.servlet.ServletException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ResponseHandler
+{
+ public HandlerResponse processCommandResponse(ControllerContext controllerContext, ControllerCommand command, Object commandResponse) throws IOException, ServletException, ServerException;
+}
Added: trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandlerSelector.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandlerSelector.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ResponseHandlerSelector.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.controller;
+
+import org.jboss.portal.server.ServerException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ResponseHandlerSelector implements ResponseHandler
+{
+
+ /** . */
+ private ResponseHandler classicResponseHandler;
+
+ /** . */
+ private ResponseHandler ajaxResponseHandler;
+
+ public ResponseHandler getClassicResponseHandler()
+ {
+ return classicResponseHandler;
+ }
+
+ public void setClassicResponseHandler(ResponseHandler classicResponseHandler)
+ {
+ this.classicResponseHandler = classicResponseHandler;
+ }
+
+ public ResponseHandler getAjaxResponseHandler()
+ {
+ return ajaxResponseHandler;
+ }
+
+ public void setAjaxResponseHandler(ResponseHandler ajaxResponseHandler)
+ {
+ this.ajaxResponseHandler = ajaxResponseHandler;
+ }
+
+ public HandlerResponse processCommandResponse(ControllerContext controllerContext, ControllerCommand command, Object commandResponse) throws IOException, ServletException, ServerException
+ {
+ if (ControllerContext.AJAX_TYPE == controllerContext.getType())
+ {
+ return ajaxResponseHandler.processCommandResponse(controllerContext, command, commandResponse);
+ }
+ else
+ {
+ return classicResponseHandler.processCommandResponse(controllerContext, command, commandResponse);
+ }
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxCommandFactory.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxCommandFactory.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * 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.ajax;
+
+import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.command.MoveWindowCommand;
+import org.jboss.portal.server.ServerInvocation;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AjaxCommandFactory extends AbstractCommandFactory
+{
+ public ControllerCommand doMapping(ServerInvocation invocation, String host, String contextPath, String requestPath)
+ {
+ HttpServletRequest req = invocation.getServerContext().getClientRequest();
+ String action = req.getParameter("action");
+ if ("windowmove".equals(action))
+ {
+ String windowId = req.getParameter("windowId");
+ String fromPos = req.getParameter("fromPos");
+ String fromRegion = req.getParameter("fromRegion");
+ String toPos = req.getParameter("toPos");
+ String toRegion = req.getParameter("toRegion");
+ int fromPosInt = Integer.parseInt(fromPos);
+ int toPosInt = Integer.parseInt(toPos);
+
+ //
+ PortalObjectId tmp = PortalObjectId.parse(windowId, PortalObjectId.LEGACY_BASE64_FORMAT);
+
+ //
+ return new MoveWindowCommand(tmp, fromPosInt, fromRegion, toPosInt, toRegion);
+ }
+
+ //
+ return null;
+ }
+}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -1,424 +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.ajax;
-
-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.Controller;
-import org.jboss.portal.core.controller.portlet.PortletResponseHandler;
-import org.jboss.portal.core.controller.classic.HandlerResponse;
-import org.jboss.portal.core.controller.classic.CommandForward;
-import org.jboss.portal.core.model.portal.command.MoveWindowCommand;
-import org.jboss.portal.core.model.portal.command.RenderWindowCommand;
-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.response.UpdateWindowMarkupResponse;
-import org.jboss.portal.core.model.portal.command.response.PortletWindowResponse;
-import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.Window;
-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.ns.PortalObjectNavigationalStateContext;
-import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
-import org.jboss.portal.core.ns.NavigationalStateChange;
-import org.jboss.portal.core.ns.NavigationalStateKey;
-import org.jboss.portal.core.ns.NavigationalStateObjectChange;
-import org.jboss.portal.server.ServerException;
-import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.theme.page.WindowResult;
-import org.jboss.portal.theme.page.PageResult;
-import org.jboss.portal.theme.page.WindowContext;
-import org.jboss.portal.theme.render.RenderContext;
-import org.jboss.portal.theme.PortalLayout;
-import org.jboss.portal.theme.LayoutService;
-import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageLocationResponse;
-import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageStateResponse;
-import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
-import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.Mode;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.RenderResponse;
-import org.jboss.portal.portlet.StateString;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.ServletException;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.util.Set;
-import java.util.HashSet;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class AjaxController extends Controller
-{
- public void handle(ServerInvocation invocation) throws ServerException
- {
- HttpServletRequest req = invocation.getServerContext().getClientRequest();
-
- //
- ControllerContext controllerContext = new ControllerContext(invocation, this);
-
- // Detect any change that would require a total refresh
- String clientViewId = req.getHeader("view_id");
- if (clientViewId != null)
- {
- PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
- String serverViewId = ctx.getViewId();
- if (!clientViewId.equals(serverViewId))
- {
- // todo : that will not work for FORMS submissions, we need a response for the client
- // to tell to do the request the normal way
- try
- {
- UpdatePageLocationResponse dresp = new UpdatePageLocationResponse(req.getRequestURL().toString());
- AjaxResponse aresp = new AjaxResponse(dresp);
- aresp.sendResponse(invocation.getServerContext());
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- catch (ServletException e)
- {
- e.printStackTrace();
- }
- return;
- }
- }
-
- //
- String action = req.getParameter("action");
- if ("windowmove".equals(action))
- {
- String windowId = req.getParameter("windowId");
- String fromPos = req.getParameter("fromPos");
- String fromRegion = req.getParameter("fromRegion");
- String toPos = req.getParameter("toPos");
- String toRegion = req.getParameter("toRegion");
- int fromPosInt = Integer.parseInt(fromPos);
- int toPosInt = Integer.parseInt(toPos);
-
- //
- PortalObjectId tmp = PortalObjectId.parse(windowId, PortalObjectId.LEGACY_BASE64_FORMAT);
-
- //
- try
- {
- controllerContext.execute(new MoveWindowCommand(tmp, fromPosInt, fromRegion, toPosInt, toRegion));
- }
- catch (ControllerException e)
- {
- e.printStackTrace();
- }
- }
- else
- {
- // Invoke the chain that creates the initial command
- ControllerCommand command = commandFactory.doMapping(invocation, invocation.getServerContext().getPortalHost(), invocation.getServerContext().getPortalContextPath(), invocation.getServerContext().getPortalRequestPath());
-
- //
- if (command == null)
- {
- // Handle that case
- throw new ServerException("No command was produced by the command factory");
- }
-
- // Handle the command created
- try
- {
- processCommand(controllerContext, command);
- }
- catch (ControllerException e)
- {
- e.printStackTrace();
- }
- catch (ServletException e)
- {
- e.printStackTrace();
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Handle a command which means it executes the command and reacts upon the response created by the command.
- *
- * @param controllerContext the controller context
- * @param command the command
- * @throws org.jboss.portal.server.ServerException
- */
- protected void processCommand(final ControllerContext controllerContext, final ControllerCommand command) throws ServerException, ControllerException, ServletException, IOException
- {
- Object commandResponse = controllerContext.execute(command);
-
- HandlerResponse handlerResp = processCommandResponse(controllerContext, command, commandResponse);
-
- //
- if (handlerResp == null)
- {
- return;
- }
-
- // Find out if we can execute in the same server invocation
-// if (handlerResp instanceof CommandForward)
-// {
-// CommandForward forward = (CommandForward)handlerResp;
-// URLContext urlContext = controllerContext.getServerInvocation().getServerContext().getURLContext();
-// if (requiresRedirect(command, urlContext, forward))
-// {
-// String url = controllerContext.renderURL(forward.getCommand(), forward.getURLContext(), null);
-// sendResponse(controllerContext, new HTTPResponse.SendRedirect(url));
-// }
-// else
-// {
-// processCommand(controllerContext, forward.getCommand());
-// }
-// }
-// else
-// {
-// }
-
- if (handlerResp instanceof CommandForward)
- {
- CommandForward forward = (CommandForward)handlerResp;
-// URLContext urlContext = ctx.getServerInvocation().getServerContext().getURLContext();
-// if (requiresRedirect(cmd, urlContext, forward))
-// {
-// String url = ctx.renderURL(forward.getCommand(), forward.getURLContext(), null);
-// sendResponse(ctx, new HTTPResponse.SendRedirect(url));
-// }
-// else
-// {
-// processCommand(ctx, forward.getCommand());
-// }
- processCommand(controllerContext, forward.getCommand());
- }
- else
- {
- AjaxResponse ar = (AjaxResponse)handlerResp;
- ar.sendResponse(controllerContext.getServerInvocation().getServerContext());
- }
- }
-
- public HandlerResponse processCommandResponse(ControllerContext controllerContext, ControllerCommand command, Object response) throws IOException, ServletException, ServerException
- {
- if (response instanceof PortletWindowResponse)
- {
- PortletWindowResponse pwr = (PortletWindowResponse)response;
- PortletInvocationResponse pir = pwr.getResult();
- if (pir instanceof RenderResponse)
- {
- RenderResponse rr = (RenderResponse)pir;
- StateString navState = rr.getNavigationalState();
- WindowState windowState = rr.getWindowState();
- Mode mode = rr.getMode();
- ControllerCommand renderCmd = PortletResponseHandler.createRenderCommand(mode, windowState, navState, pwr);
- if (renderCmd != null)
- {
- return new CommandForward(renderCmd, null);
- }
- else
- {
- return null;
- }
- }
- else
- {
- throw new Error("todo");
- }
- }
- else if (response instanceof UpdateWindowMarkupResponse)
- {
- // We make an assumption here, the window result should carry somehow the window id
- PortalObjectCommand pocmd = (PortalObjectCommand)command;
-
- //
- ServerInvocation invocation = controllerContext.getServerInvocation();
-
- // Obtain page and portal
- final Window window = (Window)portalObjectContainer.getObject(pocmd.getTargetId());
- Page page = (Page)window.getParent();
- Portal portal = page.getPortal();
-
- //
- PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
-
- // The windows marked dirty during the request
- Set dirtyWindowIds = new HashSet();
-
- // Whether we need a full refresh or not
- boolean refresh = false;
-
- //
- for (Iterator i = ctx.getChanges();i.hasNext();)
- {
- NavigationalStateChange change = (NavigationalStateChange)i.next();
-
- // A change that modifies potentially the page structure
- if (!(change instanceof NavigationalStateObjectChange))
- {
- refresh = true;
- break;
- }
- NavigationalStateObjectChange update = (NavigationalStateObjectChange)change;
-
- // A change that modifies potentially the page structure
- if (update.getType() != NavigationalStateObjectChange.UPDATE)
- {
- refresh = true;
- break;
- }
-
- // Get the state key
- NavigationalStateKey key = update.getKey();
-
- // We consider only portal object types
- if (key.getType() == WindowNavigationalState.class)
- {
- // Get old window state
- WindowNavigationalState oldNS = (WindowNavigationalState)update.getOldValue();
- WindowState oldWindowState = oldNS != null ? oldNS.getWindowState() : null;
-
- // Get new window state
- WindowNavigationalState newNS = (WindowNavigationalState)update.getNewValue();
- WindowState newWindowState = newNS != null ? newNS.getWindowState() : null;
-
- // Check if window state requires a refresh
- if (WindowState.MAXIMIZED.equals(oldWindowState))
- {
- if (!WindowState.MAXIMIZED.equals(newWindowState))
- {
- refresh = true;
- break;
- }
- }
- else if (WindowState.MAXIMIZED.equals(newWindowState))
- {
- refresh = true;
- break;
- }
-
- // Collect the dirty window id
- dirtyWindowIds.add(key.getId());
- }
- }
-
- // Commit changes
- ctx.applyChanges();
-
- //
- if (refresh)
- {
- RenderPageCommand rpc = new RenderPageCommand(page.getId());
- String url = controllerContext.renderURL(rpc, null, null);
- UpdatePageLocationResponse dresp = new UpdatePageLocationResponse(url);
- return new AjaxResponse(dresp);
- }
- else
- {
- ArrayList windowToRefresh = new ArrayList();
- for (Iterator i = page.getChildren(PortalObject.WINDOW_MASK).iterator();i.hasNext();)
- {
- PortalObject child = (PortalObject)i.next();
- PortalObjectId childId = child.getId();
- if (dirtyWindowIds.contains(childId))
- {
- windowToRefresh.add(child);
- }
- }
-
- // Obtain layout
- LayoutService layoutService = getPageService().getLayoutService();
- PortalLayout layout = RenderPageCommand.getLayout(layoutService, page);
-
- //
- UpdatePageStateResponse updatePage = new UpdatePageStateResponse(ctx.getViewId());
-
- // Call to the theme framework
- PageResult res = new PageResult(page.getName(), page.getProperties(), portal.getProperties());
-
- //
- for (Iterator i = windowToRefresh.iterator();i.hasNext();)
- {
- final PortalObject _window = (PortalObject)i.next();
- RenderWindowCommand rwc = new RenderWindowCommand(_window.getId());
- try
- {
- Object wresp = controllerContext.execute(rwc);
- if (wresp instanceof WindowResult)
- {
- final WindowResult windowResult = (WindowResult)wresp;
-
- //
- WindowContext wc = new WindowContext(
- _window.getName(),
- _window.getId().toString(PortalObjectId.LEGACY_BASE64_FORMAT),
- "ABC",
- 0,
- windowResult);
-
- //
- MarkupInfo markupInfo = (MarkupInfo)invocation.getResponse().getContentInfo();
-
- //
- RenderContext renderContext = layout.getRenderContext(markupInfo, invocation);
-
- // Should push region context as well
- renderContext.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED, Boolean.TRUE);
- renderContext.pushObjectRenderContext(res);
-
- //
- renderContext.render(wc);
-
- //
- updatePage.addFragment(wc.getId(), renderContext.getMarkupFragment().toString());
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- //
- return new AjaxResponse(updatePage);
- }
- }
- else
- {
- System.out.println("Not yet handled " + response);
-
- //
- return null;
- }
- }
-}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -30,8 +30,11 @@
import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
import org.jboss.portal.theme.page.PageRendition;
import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
+import org.jboss.portal.server.ServerURL;
+import org.jboss.portal.server.AbstractServerURL;
+import org.jboss.portal.server.ServerInvocationContext;
+import org.jboss.portal.server.request.URLFormat;
-import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
@@ -51,22 +54,18 @@
RenderPageCommand rpc = (RenderPageCommand)cmd;
//
+ ServerInvocationContext serverContext = cmd.getControllerContext().getServerInvocation().getServerContext();
+
+ //
ControllerContext controllerContext = rpc.getControllerContext();
// If user is logged in and is on dashboard we enable ajax
- if (controllerContext.getServerInvocation().getServerContext().getClientRequest().getRemoteUser() != null &&
+ if (serverContext.getClientRequest().getRemoteUser() != null &&
rpc.isDashboard())
{
- // Compute the url for the ajax servlet
- HttpServletRequest req = cmd.getControllerContext().getServerInvocation().getServerContext().getClientRequest();
- StringBuffer url = new StringBuffer();
- url.append(req.getScheme()).append("://");
- url.append(req.getServerName());
- if (("http".equals(req.getScheme()) && req.getServerPort() != 80) || ("https".equals(req.getScheme()) && req.getServerPort() != 443))
- {
- url.append(':').append(req.getServerPort());
- }
- url.append(req.getContextPath()).append("/ajax");
+ ServerURL surl = new AbstractServerURL();
+ surl.setPortalRequestPath("/ajax");
+ String url = serverContext.renderURL(surl, serverContext.getURLContext(), URLFormat.newInstance(true, true));
//
PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
@@ -78,7 +77,7 @@
pageProps.put(DynaConstants.JAVASCRIPT_BASE, "/portal-ajax");
pageProps.put(DynaConstants.OBJECT_ENABLED, "true");
- pageProps.put(DynaConstants.ASYNC_SERVER_URL, url.toString());
+ pageProps.put(DynaConstants.ASYNC_SERVER_URL, url);
pageProps.put(DynaConstants.VIEW_STATE, viewId);
}
}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponse.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponse.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -1,58 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.controller.ajax;
-
-import org.jboss.portal.core.controller.classic.HandlerResponse;
-import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
-import org.jboss.portal.theme.impl.render.dynamic.JSONMarshaller;
-import org.jboss.portal.server.ServerInvocationContext;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class AjaxResponse extends HandlerResponse
-{
-
- /** . */
- private static final JSONMarshaller marshaller = new JSONMarshaller();
-
- /** The response to the client. */
- private final DynaResponse dynaResponse;
-
- public AjaxResponse(DynaResponse dynaResponse)
- {
- this.dynaResponse = dynaResponse;
- }
-
- public void sendResponse(ServerInvocationContext ctx) throws IOException, ServletException
- {
- HttpServletResponse resp = ctx.getClientResponse();
- resp.setContentType("text/html");
- marshaller.write(dynaResponse, resp.getWriter());
- }
-}
Added: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -0,0 +1,328 @@
+/******************************************************************************
+ * 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.ajax;
+
+import org.jboss.portal.core.controller.ResponseHandler;
+import org.jboss.portal.core.controller.HandlerResponse;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.CommandForward;
+import org.jboss.portal.core.controller.AjaxResponse;
+import org.jboss.portal.core.controller.portlet.PortletResponseHandler;
+import org.jboss.portal.core.model.portal.command.response.PortletWindowResponse;
+import org.jboss.portal.core.model.portal.command.response.UpdateWindowMarkupResponse;
+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.RenderWindowCommand;
+import org.jboss.portal.core.model.portal.Window;
+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.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
+import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
+import org.jboss.portal.core.ns.NavigationalStateChange;
+import org.jboss.portal.core.ns.NavigationalStateObjectChange;
+import org.jboss.portal.core.ns.NavigationalStateKey;
+import org.jboss.portal.server.ServerException;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.RenderResponse;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageLocationResponse;
+import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageStateResponse;
+import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
+import org.jboss.portal.theme.LayoutService;
+import org.jboss.portal.theme.PortalLayout;
+import org.jboss.portal.theme.PageService;
+import org.jboss.portal.theme.render.RenderContext;
+import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.theme.page.WindowContext;
+
+import javax.servlet.ServletException;
+import java.io.IOException;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AjaxResponseHandler implements ResponseHandler
+{
+
+ // Detect any change that would require a total refresh
+// HttpServletRequest req = invocation.getServerContext().getClientRequest();
+// String clientViewId = req.getHeader("view_id");
+// if (clientViewId != null)
+// {
+// PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+// String serverViewId = ctx.getViewId();
+// if (!clientViewId.equals(serverViewId))
+// {
+// // todo : that will not work for FORMS submissions, we need a response for the client
+// // to tell to do the request the normal way
+// try
+// {
+// UpdatePageLocationResponse dresp = new UpdatePageLocationResponse(req.getRequestURL().toString());
+// AjaxResponse aresp = new AjaxResponse(dresp);
+// aresp.sendResponse(invocation.getServerContext());
+// }
+// catch (IOException e)
+// {
+// e.printStackTrace();
+// }
+// catch (ServletException e)
+// {
+// e.printStackTrace();
+// }
+// return;
+// }
+// }
+
+ /** . */
+ private PortalObjectContainer portalObjectContainer;
+
+ /** . */
+ private PageService pageService;
+
+ public PortalObjectContainer getPortalObjectContainer()
+ {
+ return portalObjectContainer;
+ }
+
+ public void setPortalObjectContainer(PortalObjectContainer portalObjectContainer)
+ {
+ this.portalObjectContainer = portalObjectContainer;
+ }
+
+ public PageService getPageService()
+ {
+ return pageService;
+ }
+
+ public void setPageService(PageService pageService)
+ {
+ this.pageService = pageService;
+ }
+
+ public HandlerResponse processCommandResponse(
+ ControllerContext controllerContext,
+ ControllerCommand command,
+ Object commandResponse) throws IOException, ServletException, ServerException
+ {
+ if (commandResponse instanceof PortletWindowResponse)
+ {
+ PortletWindowResponse pwr = (PortletWindowResponse)commandResponse;
+ PortletInvocationResponse pir = pwr.getResult();
+ if (pir instanceof RenderResponse)
+ {
+ RenderResponse rr = (RenderResponse)pir;
+ StateString navState = rr.getNavigationalState();
+ WindowState windowState = rr.getWindowState();
+ Mode mode = rr.getMode();
+ ControllerCommand renderCmd = PortletResponseHandler.createRenderCommand(mode, windowState, navState, pwr);
+ if (renderCmd != null)
+ {
+ return new CommandForward(renderCmd, null);
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ throw new Error("todo");
+ }
+ }
+ else if (commandResponse instanceof UpdateWindowMarkupResponse)
+ {
+ // We make an assumption here, the window result should carry somehow the window id
+ PortalObjectCommand pocmd = (PortalObjectCommand)command;
+
+ //
+ ServerInvocation invocation = controllerContext.getServerInvocation();
+
+ // Obtain page and portal
+ final Window window = (Window)portalObjectContainer.getObject(pocmd.getTargetId());
+ Page page = (Page)window.getParent();
+ Portal portal = page.getPortal();
+
+ //
+ PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+
+ // The windows marked dirty during the request
+ Set dirtyWindowIds = new HashSet();
+
+ // Whether we need a full refresh or not
+ boolean refresh = false;
+
+ //
+ for (Iterator i = ctx.getChanges();i.hasNext();)
+ {
+ NavigationalStateChange change = (NavigationalStateChange)i.next();
+
+ // A change that modifies potentially the page structure
+ if (!(change instanceof NavigationalStateObjectChange))
+ {
+ refresh = true;
+ break;
+ }
+ NavigationalStateObjectChange update = (NavigationalStateObjectChange)change;
+
+ // A change that modifies potentially the page structure
+ if (update.getType() != NavigationalStateObjectChange.UPDATE)
+ {
+ refresh = true;
+ break;
+ }
+
+ // Get the state key
+ NavigationalStateKey key = update.getKey();
+
+ // We consider only portal object types
+ if (key.getType() == WindowNavigationalState.class)
+ {
+ // Get old window state
+ WindowNavigationalState oldNS = (WindowNavigationalState)update.getOldValue();
+ WindowState oldWindowState = oldNS != null ? oldNS.getWindowState() : null;
+
+ // Get new window state
+ WindowNavigationalState newNS = (WindowNavigationalState)update.getNewValue();
+ WindowState newWindowState = newNS != null ? newNS.getWindowState() : null;
+
+ // Check if window state requires a refresh
+ if (WindowState.MAXIMIZED.equals(oldWindowState))
+ {
+ if (!WindowState.MAXIMIZED.equals(newWindowState))
+ {
+ refresh = true;
+ break;
+ }
+ }
+ else if (WindowState.MAXIMIZED.equals(newWindowState))
+ {
+ refresh = true;
+ break;
+ }
+
+ // Collect the dirty window id
+ dirtyWindowIds.add(key.getId());
+ }
+ }
+
+ // Commit changes
+ ctx.applyChanges();
+
+ //
+ if (refresh)
+ {
+ RenderPageCommand rpc = new RenderPageCommand(page.getId());
+ String url = controllerContext.renderURL(rpc, null, null);
+ UpdatePageLocationResponse dresp = new UpdatePageLocationResponse(url);
+ return new AjaxResponse(dresp);
+ }
+ else
+ {
+ ArrayList windowToRefresh = new ArrayList();
+ for (Iterator i = page.getChildren(PortalObject.WINDOW_MASK).iterator();i.hasNext();)
+ {
+ PortalObject child = (PortalObject)i.next();
+ PortalObjectId childId = child.getId();
+ if (dirtyWindowIds.contains(childId))
+ {
+ windowToRefresh.add(child);
+ }
+ }
+
+ // Obtain layout
+ LayoutService layoutService = getPageService().getLayoutService();
+ PortalLayout layout = RenderPageCommand.getLayout(layoutService, page);
+
+ //
+ UpdatePageStateResponse updatePage = new UpdatePageStateResponse(ctx.getViewId());
+
+ // Call to the theme framework
+ PageResult res = new PageResult(page.getName(), page.getProperties(), portal.getProperties());
+
+ //
+ for (Iterator i = windowToRefresh.iterator();i.hasNext();)
+ {
+ final PortalObject _window = (PortalObject)i.next();
+ RenderWindowCommand rwc = new RenderWindowCommand(_window.getId());
+ try
+ {
+ Object wresp = controllerContext.execute(rwc);
+ if (wresp instanceof WindowResult)
+ {
+ final WindowResult windowResult = (WindowResult)wresp;
+
+ //
+ WindowContext wc = new WindowContext(
+ _window.getName(),
+ _window.getId().toString(PortalObjectId.LEGACY_BASE64_FORMAT),
+ "ABC",
+ 0,
+ windowResult);
+
+ //
+ MarkupInfo markupInfo = (MarkupInfo)invocation.getResponse().getContentInfo();
+
+ //
+ RenderContext renderContext = layout.getRenderContext(markupInfo, invocation);
+
+ // Should push region context as well
+ renderContext.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED, Boolean.TRUE);
+ renderContext.pushObjectRenderContext(res);
+
+ //
+ renderContext.render(wc);
+
+ //
+ updatePage.addFragment(wc.getId(), renderContext.getMarkupFragment().toString());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ //
+ return new AjaxResponse(updatePage);
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/classic/AbstractResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/AbstractResponseHandler.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/AbstractResponseHandler.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.controller.classic;
import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.core.controller.ResponseHandler;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -1,241 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.controller.classic;
-
-import org.jboss.portal.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.ControllerSecurityException;
-import org.jboss.portal.core.controller.ResourceNotFoundException;
-import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.controller.portlet.PortletResponseHandler;
-import org.jboss.portal.core.controller.command.info.CommandInfo;
-import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
-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
-{
-
- // Unhardcode this
- private ResponseHandler[] handlers = new ResponseHandler[]
- {
- new ClassicResponseHandler(),
- new PortalObjectResponseHandler(),
- new PortletResponseHandler()
- };
-
- public void handle(ServerInvocation invocation) throws ServerException
- {
- // Invoke the chain that creates the initial command
- ControllerCommand cmd = commandFactory.doMapping(invocation, invocation.getServerContext().getPortalHost(), invocation.getServerContext().getPortalContextPath(), invocation.getServerContext().getPortalRequestPath());
-
- //
- if (cmd == null)
- {
- // Handle that case
- throw new ServerException("No command was produced by the command factory");
- }
-
- // Create controller context
- ControllerContext controllerContext = new ControllerContext(invocation, this);
-
- // Handle the command created
- processCommand(controllerContext, cmd);
- }
-
- public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
- {
- for (int i = 0;i < handlers.length;i++)
- {
- ResponseHandler handler = handlers[i];
- HandlerResponse handlerResponse = handler.processCommandResponse(ctx, cmd, response);
- if (handlerResponse != null)
- {
- return handlerResponse;
- }
- }
-
- //
- return null;
- }
-
- protected HandlerResponse executeCommand(ControllerContext ctx, ControllerCommand cmd) throws ServerException
- {
- URLContext urlContext = ctx.getServerInvocation().getServerContext().getURLContext();
-
- try
- {
- // Execute command
- Object commandResponse = ctx.execute(cmd);
-
- // Handle the result, might be null if no handling done
- return processCommandResponse(ctx, cmd, commandResponse);
- }
- catch (CommandRedirectionException e)
- {
- // Handle the redirection as forward
- return new CommandForward(e.getRedirection(), null);
- }
- catch (ControllerSecurityException e)
- {
- if (urlContext.isAuthenticated())
- {
- return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_UNAUTHORIZED);
- }
- else
- {
- urlContext = URLContext.newInstance(urlContext.isSecure(), true);
- ServerURL serverURL = getURLFactory().doMapping(ctx.getServerInvocation(), cmd);
- String url = ctx.getServerInvocation().getResponse().renderURL(serverURL, urlContext, null);
- return new HTTPResponse.SendRedirect(url);
- }
- }
- catch (ResourceNotFoundException e)
- {
- log.error("Resource not found " + e.getRef(), e);
- return new HTTPResponse.SetStatusCode(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);
- }
- }
-
- /**
- * Return true if the execution of the next command requires a redirect.
- *
- * @param currentCmd the current command which has been executed
- * @param currentURLCtx the request URL context
- * @param forward the forward
- * @return
- */
- public boolean requiresRedirect(
- ControllerCommand currentCmd,
- URLContext currentURLCtx,
- CommandForward forward)
- {
- CommandInfo currentCmdInfo = currentCmd.getInfo();
- if (currentCmdInfo instanceof ActionCommandInfo && !((ActionCommandInfo)currentCmdInfo).isIdempotent())
- {
- return true;
- }
- else
- {
- URLContext nextURLCtx = forward.getURLContext();
- boolean currentAuthenticated = currentURLCtx.isAuthenticated();
- if (nextURLCtx != null && currentAuthenticated != nextURLCtx.isAuthenticated())
- {
- return true;
- }
- else
- {
- boolean currentSecure = currentURLCtx.isSecure();
- if (nextURLCtx != null && nextURLCtx.isSecure() && !currentSecure)
- {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Handle a command which means it executes the command and reacts upon the response created by the command.
- *
- * @param ctx the controller context
- * @param cmd the command
- * @throws org.jboss.portal.server.ServerException
- */
- protected void processCommand(final ControllerContext ctx, final ControllerCommand cmd) throws ServerException
- {
- HandlerResponse handlerResp = executeCommand(ctx, cmd);
-
- //
- if (handlerResp == null)
- {
- return;
- }
-
- // Find out if we can execute in the same server invocation
- if (handlerResp instanceof CommandForward)
- {
- CommandForward forward = (CommandForward)handlerResp;
- URLContext urlContext = ctx.getServerInvocation().getServerContext().getURLContext();
- if (requiresRedirect(cmd, urlContext, forward))
- {
- String url = ctx.renderURL(forward.getCommand(), forward.getURLContext(), null);
- sendResponse(ctx, new HTTPResponse.SendRedirect(url));
- }
- else
- {
- processCommand(ctx, forward.getCommand());
- }
- }
- else
- {
- HTTPResponse hr = (HTTPResponse)handlerResp;
- sendResponse(ctx, hr);
- }
- }
-
- /**
- * All http responses in the stack should be handled here.
- */
- protected void sendResponse(ControllerContext ctx, HTTPResponse resp)
- {
- try
- {
- resp.sendResponse(ctx.getServerInvocation().getServerContext());
- }
- catch (IOException e)
- {
- log.error("Cound not send http response", e);
- }
- catch (ServletException e)
- {
- log.error("Cound not send http response", e);
- }
- }
-}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -29,11 +29,19 @@
import org.jboss.portal.theme.page.PageRendition;
import org.jboss.portal.core.controller.command.response.SignOutResponse;
import org.jboss.portal.core.controller.command.response.StreamContentResponse;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.HTTPResponse;
+import org.jboss.portal.core.controller.HandlerResponse;
+import org.jboss.portal.core.controller.ResponseHandler;
+import org.jboss.portal.core.controller.CommandForward;
+import org.jboss.portal.core.controller.portlet.PortletResponseHandler;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectResponseHandler;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import javax.servlet.ServletException;
@@ -46,53 +54,146 @@
public class ClassicResponseHandler extends AbstractResponseHandler
{
- private PortalObjectId defaultPortalPath = PortalObjectId.parse("/default", PortalObjectId.CANONICAL_FORMAT);
+ private static final PortalObjectId defaultPortalPath = PortalObjectId.parse("/default", PortalObjectId.CANONICAL_FORMAT);
- public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
+ public HandlerResponse processCommandResponse(
+ ControllerContext controllerContext,
+ ControllerCommand command,
+ Object commandResponse) throws IOException, ServletException, ServerException
{
- final ServerInvocation invocation = ctx.getServerInvocation();
- if (response instanceof PageRendition)
+
+ HandlerResponse response = processHandlers(controllerContext, command, commandResponse);
+
+ // Handle redirection here
+ if (response instanceof CommandForward)
{
- final PageRendition rendition = (PageRendition)response;
+ CommandForward forward = (CommandForward)response;
+ URLContext urlContext = controllerContext.getServerInvocation().getServerContext().getURLContext();
+ if (requiresRedirect(command, urlContext, forward))
+ {
+ String url = controllerContext.renderURL(forward.getCommand(), forward.getURLContext(), null);
+ return new HTTPResponse.SendRedirect(url);
+ }
+ }
- // Defer execution of rendition to the right place which is in the classic controller send response
- return new HTTPResponse()
+ //
+ return response;
+ }
+
+ private HandlerResponse processHandlers(
+ ControllerContext controllerContext,
+ ControllerCommand command,
+ Object commandResponse) throws IOException, ServletException, ServerException
+ {
+ for (int i = 0;i < handlers.length;i++)
+ {
+ ResponseHandler handler = handlers[i];
+ HandlerResponse handlerResponse = handler.processCommandResponse(controllerContext, command, commandResponse);
+ if (handlerResponse != null)
{
- public void sendResponse(ServerInvocationContext ctx) throws IOException, ServletException
- {
- rendition.render(invocation);
- }
- };
+ return handlerResponse;
+ }
}
- else if (response instanceof SignOutResponse)
+
+ //
+ return null;
+ }
+
+ private static class OtherResponseHandler implements ResponseHandler
+ {
+ public HandlerResponse processCommandResponse(ControllerContext controllerContext, ControllerCommand command, Object commandResponse) throws IOException, ServletException, ServerException
{
- // Get the optional signout location
- String location = ((SignOutResponse)response).getLocation();
+ final ServerInvocation invocation = controllerContext.getServerInvocation();
+ if (commandResponse instanceof PageRendition)
+ {
+ final PageRendition rendition = (PageRendition)commandResponse;
- // Indicate that we want a sign out to be done
- invocation.getResponse().setWantSignOut(true);
+ // Defer execution of rendition to the right place which is in the classic controller send response
+ return new HTTPResponse()
+ {
+ public void sendResponse(ServerInvocationContext ctx) throws IOException, ServletException
+ {
+ rendition.render(invocation);
+ }
+ };
+ }
+ else if (commandResponse instanceof SignOutResponse)
+ {
+ // Get the optional signout location
+ String location = ((SignOutResponse)commandResponse).getLocation();
- //
- if (location == null)
+ // Indicate that we want a sign out to be done
+ invocation.getResponse().setWantSignOut(true);
+
+ //
+ if (location == null)
+ {
+ PortalObjectContainer portalObjectContainer = controllerContext.getController().getPortalObjectContainer();
+ Portal portal = (Portal)portalObjectContainer.getObject(defaultPortalPath);
+ RenderPageCommand renderCmd = new RenderPageCommand(portal.getId());
+ URLContext urlContext = invocation.getServerContext().getURLContext();
+ location = controllerContext.renderURL(renderCmd, urlContext.asNonAuthenticated(), null);
+ }
+
+ //
+ return new HTTPResponse.SendRedirect(location);
+ }
+ else if (commandResponse instanceof StreamContentResponse)
{
- PortalObjectContainer portalObjectContainer = ctx.getController().getPortalObjectContainer();
- Portal portal = (Portal)portalObjectContainer.getObject(defaultPortalPath);
- RenderPageCommand renderCmd = new RenderPageCommand(portal.getId());
- URLContext urlContext = invocation.getServerContext().getURLContext();
- location = ctx.renderURL(renderCmd, urlContext.asNonAuthenticated(), null);
+ StreamContentResponse scr = (StreamContentResponse)commandResponse;
+ return new HTTPResponse.SendBinary(scr.getContentType(), scr.getInputStream());
}
+ else
+ {
+ return null;
+ }
+ }
+ }
- //
- return new HTTPResponse.SendRedirect(location);
- }
- else if (response instanceof StreamContentResponse)
+ // Unhardcode this
+ private ResponseHandler[] handlers = new ResponseHandler[]
+ {
+ new OtherResponseHandler(),
+ new PortalObjectResponseHandler(),
+ new PortletResponseHandler()
+ };
+
+ /**
+ * Return true if the execution of the next command requires a redirect.
+ *
+ * @param currentCmd the current command which has been executed
+ * @param currentURLCtx the request URL context
+ * @param forward the forward
+ * @return
+ */
+ public boolean requiresRedirect(
+ ControllerCommand currentCmd,
+ URLContext currentURLCtx,
+ CommandForward forward)
+ {
+ CommandInfo currentCmdInfo = currentCmd.getInfo();
+ if (currentCmdInfo instanceof ActionCommandInfo && !((ActionCommandInfo)currentCmdInfo).isIdempotent())
{
- StreamContentResponse scr = (StreamContentResponse)response;
- return new HTTPResponse.SendBinary(scr.getContentType(), scr.getInputStream());
+ return true;
}
else
{
- return null;
+ URLContext nextURLCtx = forward.getURLContext();
+ boolean currentAuthenticated = currentURLCtx.isAuthenticated();
+ if (nextURLCtx != null && currentAuthenticated != nextURLCtx.isAuthenticated())
+ {
+ return true;
+ }
+ else
+ {
+ boolean currentSecure = currentURLCtx.isSecure();
+ if (nextURLCtx != null && nextURLCtx.isSecure() && !currentSecure)
+ {
+ return true;
+ }
+ }
}
+ return false;
}
+
}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/classic/CommandForward.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/CommandForward.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/CommandForward.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -1,61 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.controller.classic;
-
-import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.core.controller.ControllerCommand;
-
-/**
- * Forward to a new command.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class CommandForward extends HandlerResponse
-{
- /** . */
- private final ControllerCommand cmd;
-
- /** . */
- private final URLContext urlCtx;
-
- public CommandForward(ControllerCommand cmd, URLContext urlCtx)
- {
- if (cmd == null)
- {
- throw new IllegalArgumentException("No command provided");
- }
- this.cmd = cmd;
- this.urlCtx = urlCtx;
- }
-
- public ControllerCommand getCommand()
- {
- return cmd;
- }
-
- public URLContext getURLContext()
- {
- return urlCtx;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/classic/HTTPResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/HTTPResponse.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/HTTPResponse.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -1,119 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.controller.classic;
-
-import org.jboss.portal.server.ServerInvocationContext;
-import org.jboss.portal.common.util.Tools;
-
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.ServletException;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Response that sends a response to the http stream.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class HTTPResponse extends HandlerResponse
-{
-
- public abstract void sendResponse(ServerInvocationContext ctx) throws IOException, ServletException;
-
- public static class SetStatusCode extends HTTPResponse
- {
-
- /** . */
- private final int statusCode;
-
- public SetStatusCode(int statusCode)
- {
- this.statusCode = statusCode;
- }
-
- public void sendResponse(ServerInvocationContext ctx) throws IOException
- {
- HttpServletResponse resp = ctx.getClientResponse();
- resp.sendError(statusCode);
- }
- }
-
- public static class SendRedirect extends HTTPResponse
- {
-
- /** . */
- private final String redirect;
-
- public SendRedirect(String redirect)
- {
- this.redirect = redirect;
- }
-
- public void sendResponse(ServerInvocationContext ctx) throws IOException
- {
- HttpServletResponse resp = ctx.getClientResponse();
- resp.sendRedirect(redirect);
- }
- }
-
- public static class SendBinary extends HTTPResponse
- {
-
- /** . */
- private final String contentType;
-
- /** . */
- private final InputStream in;
-
- public SendBinary(String contentType, InputStream inputStream)
- {
- this.contentType = contentType;
- this.in = inputStream;
- }
-
- public void sendResponse(ServerInvocationContext ctx) throws IOException
- {
- HttpServletResponse resp = ctx.getClientResponse();
- resp.setContentType(contentType);
- ServletOutputStream sout = null;
- try
- {
- sout = resp.getOutputStream();
- byte[] buf = new byte[2048];
- int len;
- while ((len = in.read(buf)) > 0)
- {
- sout.write(buf, 0, len);
- }
- sout.flush();
- }
- finally
- {
- Tools.safeClose(in);
- Tools.safeClose(sout);
- }
- }
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/classic/HandlerResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/HandlerResponse.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/HandlerResponse.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -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.classic;
-
-/**
- * The response from a a response handler.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class HandlerResponse
-{
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -1,39 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.controller.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 HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException;
-}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -24,10 +24,10 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.HTTPResponse;
+import org.jboss.portal.core.controller.CommandForward;
import org.jboss.portal.core.controller.classic.AbstractResponseHandler;
-import org.jboss.portal.core.controller.classic.CommandForward;
-import org.jboss.portal.core.controller.classic.HandlerResponse;
-import org.jboss.portal.core.controller.classic.HTTPResponse;
+import org.jboss.portal.core.controller.HandlerResponse;
import org.jboss.portal.core.model.portal.command.InvokePortletWindowActionCommand;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
@@ -85,12 +85,12 @@
}
}
- public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
+ public HandlerResponse processCommandResponse(ControllerContext controllerContext, ControllerCommand command, Object commandResponse) throws IOException, ServletException, ServerException
{
- if (response instanceof PortletResponse)
+ if (commandResponse instanceof PortletResponse)
{
- ServerInvocation invocation = ctx.getServerInvocation();
- PortletResponse pr = (PortletResponse)response;
+ ServerInvocation invocation = controllerContext.getServerInvocation();
+ PortletResponse pr = (PortletResponse)commandResponse;
PortletInvocationResponse pir = pr.getResult();
//
@@ -119,12 +119,12 @@
else if (pir instanceof InsufficientTransportGuaranteeResponse)
{
boolean authenticated = invocation.getServerContext().getURLContext().isAuthenticated();
- return new CommandForward(cmd, URLContext.newInstance(true, authenticated));
+ return new CommandForward(command, URLContext.newInstance(true, authenticated));
}
else if (pir instanceof InsufficientPrivilegesResponse)
{
boolean authenticated = invocation.getServerContext().getURLContext().isAuthenticated();
- return new CommandForward(cmd, URLContext.newInstance(true, authenticated));
+ return new CommandForward(command, URLContext.newInstance(true, authenticated));
}
else if (pir instanceof SignOutResponse)
{
@@ -140,12 +140,12 @@
if (location == null)
{
// Redirect to the same page
- InvokePortletWindowActionCommand iwac = (InvokePortletWindowActionCommand)cmd;
+ InvokePortletWindowActionCommand iwac = (InvokePortletWindowActionCommand)command;
Page page = iwac.getPage();
RenderPageCommand renderCmd = new RenderPageCommand(page.getId());
boolean secure = invocation.getServerContext().getURLContext().isSecure();
URLContext urlContext = URLContext.newInstance(secure, false);
- location = ctx.renderURL(renderCmd, urlContext, null);
+ location = controllerContext.renderURL(renderCmd, urlContext, null);
}
//
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -23,8 +23,8 @@
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.classic.HandlerResponse;
+import org.jboss.portal.core.controller.CommandForward;
+import org.jboss.portal.core.controller.HandlerResponse;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.model.portal.command.response.UpdateViewResponse;
@@ -42,18 +42,18 @@
public class PortalObjectResponseHandler extends AbstractResponseHandler
{
- public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
+ public HandlerResponse processCommandResponse(ControllerContext controllerContext, ControllerCommand command, Object commandResponse) throws IOException, ServletException, ServerException
{
- if (response instanceof UpdateViewResponse)
+ if (commandResponse instanceof UpdateViewResponse)
{
- UpdateViewResponse uvr = (UpdateViewResponse)response;
+ UpdateViewResponse uvr = (UpdateViewResponse)commandResponse;
RenderPageCommand renderCmd = new RenderPageCommand(uvr.getPageId());
return new CommandForward(renderCmd, null);
}
- else if (response instanceof UpdateWindowMarkupResponse)
+ else if (commandResponse instanceof UpdateWindowMarkupResponse)
{
- UpdateWindowMarkupResponse uwmr = (UpdateWindowMarkupResponse)response;
- PortalObjectContainer portalObjectContainer = ctx.getController().getPortalObjectContainer();
+ UpdateWindowMarkupResponse uwmr = (UpdateWindowMarkupResponse)commandResponse;
+ PortalObjectContainer portalObjectContainer = controllerContext.getController().getPortalObjectContainer();
PortalObject window = portalObjectContainer.getObject(uwmr.getWindowId());
Page page = (Page)window.getParent();
RenderPageCommand rpc = new RenderPageCommand(page.getId());
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 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-05 13:35:24 UTC (rev 6923)
@@ -769,6 +769,27 @@
optional-attribute-name="DelegateFactory"
proxy-type="attribute">portal:commandFactory=Dashboard</depends>
</mbean>
+ <mbean
+ code="org.jboss.portal.core.controller.ajax.AjaxCommandFactory"
+ name="portal:commandFactory=Ajax"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+ <mbean
+ code="org.jboss.portal.core.controller.command.mapper.CommandFactoryDelegate"
+ name="portal:commandFactory=Delegate,path=ajax"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <attribute name="Path">/ajax</attribute>
+ <depends
+ optional-attribute-name="DelegatingFactory"
+ proxy-type="attribute">portal:commandFactory=Delegating</depends>
+ <depends
+ optional-attribute-name="DelegateFactory"
+ proxy-type="attribute">portal:commandFactory=Ajax</depends>
+ </mbean>
<!-- URL factories -->
<mbean
@@ -899,46 +920,49 @@
proxy-type="attribute">portal:service=PortletInvoker,type=Federating</depends>
</mbean>
- <!-- The core controller -->
+ <!-- The classic response handler -->
<mbean
- code="org.jboss.portal.core.controller.classic.ClassicController"
- name="portal:controller=Classic"
+ code="org.jboss.portal.core.controller.classic.ClassicResponseHandler"
+ name="portal:service=ResponseHandler,type=Classic"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
+ </mbean>
+
+ <!-- The ajax response handler -->
+ <mbean
+ code="org.jboss.portal.core.controller.ajax.AjaxResponseHandler"
+ name="portal:service=ResponseHandler,type=Ajax"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
<depends
optional-attribute-name="PageService"
proxy-type="attribute">portal:service=PageService</depends>
<depends
- optional-attribute-name="CommandFactory"
- proxy-type="attribute">portal:commandFactory=DefaultPortal</depends>
- <depends
- optional-attribute-name="URLFactory"
- proxy-type="attribute">portal:urlFactory=Delegating</depends>
- <depends
- optional-attribute-name="StackFactory"
- proxy-type="attribute">portal:service=InterceptorStackFactory,type=Command</depends>
- <depends
optional-attribute-name="PortalObjectContainer"
proxy-type="attribute">portal:container=PortalObject</depends>
+ </mbean>
+
+ <!-- The response handler selector -->
+ <mbean
+ code="org.jboss.portal.core.controller.ResponseHandlerSelector"
+ name="portal:service=ResponseHandler,type=Selector"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
<depends
- optional-attribute-name="InstanceContainer"
- proxy-type="attribute">portal:container=Instance</depends>
+ optional-attribute-name="ClassicResponseHandler"
+ proxy-type="attribute">portal:service=ResponseHandler,type=Classic</depends>
<depends
- optional-attribute-name="PortalAuthorizationManagerFactory"
- proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
- <depends
- optional-attribute-name="CustomizationManager"
- proxy-type="attribute">portal:service=CustomizationManager</depends>
- <depends
- optional-attribute-name="ContentRendererRegistry"
- proxy-type="attribute">portal:service=ContentProviderRegistry</depends>
+ optional-attribute-name="AjaxResponseHandler"
+ proxy-type="attribute">portal:service=ResponseHandler,type=Ajax</depends>
</mbean>
- <!-- The ajax controller -->
+ <!-- The controller -->
<mbean
- code="org.jboss.portal.core.controller.ajax.AjaxController"
- name="portal:controller=Ajax"
+ code="org.jboss.portal.core.controller.Controller"
+ name="portal:service=Controller"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
@@ -969,21 +993,21 @@
<depends
optional-attribute-name="ContentRendererRegistry"
proxy-type="attribute">portal:service=ContentProviderRegistry</depends>
+ <depends
+ optional-attribute-name="ResponseHandler"
+ proxy-type="attribute">portal:service=ResponseHandler,type=Selector</depends>
</mbean>
<!-- The controller factory -->
<mbean
- code="org.jboss.portal.core.controller.ControllerFactory"
+ code="org.jboss.portal.server.impl.RequestControllerFactoryImpl"
name="portal:service=ControllerFactory"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<depends
- optional-attribute-name="ClassicController"
- proxy-type="attribute">portal:controller=Classic</depends>
- <depends
- optional-attribute-name="AjaxController"
- proxy-type="attribute">portal:controller=Ajax</depends>
+ optional-attribute-name="Controller"
+ proxy-type="attribute">portal:service=Controller</depends>
</mbean>
<!-- -->
Modified: trunk/core/src/resources/portal-server-war/WEB-INF/web.xml
===================================================================
--- trunk/core/src/resources/portal-server-war/WEB-INF/web.xml 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core/src/resources/portal-server-war/WEB-INF/web.xml 2007-04-05 13:35:24 UTC (rev 6923)
@@ -223,32 +223,4 @@
<role-name>Authenticated</role-name>
</security-role>
- <!-- AJAX -->
-
- <!-- The portal servlet for ajax requests -->
- <servlet>
- <servlet-name>PortalServletForAjax</servlet-name>
- <servlet-class>org.jboss.portal.server.servlet.PortalServlet</servlet-class>
- <init-param>
- <param-name>asDefaultServlet</param-name>
- <param-value>false</param-value>
- <description>The servlet needs to know wether it is set as a default servlet or not</description>
- </init-param>
- <init-param>
- <param-name>controllerFactoryName</param-name>
- <param-value>portal:service=ControllerFactory</param-value>
- <description>The request controller factory for the portal servlet</description>
- </init-param>
- <load-on-startup>0</load-on-startup>
- <security-role-ref>
- <role-name>Authenticated</role-name>
- <role-link>Authenticated</role-link>
- </security-role-ref>
- </servlet>
-
- <!-- Provide secure access to authenticated users -->
- <servlet-mapping>
- <servlet-name>PortalServletForAjax</servlet-name>
- <url-pattern>/ajax/*</url-pattern>
- </servlet-mapping>
</web-app>
Modified: trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/TestPortlet.java
===================================================================
--- trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/TestPortlet.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/TestPortlet.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -130,7 +130,6 @@
writer.write("<div class=\"portlet-section-header\">Capabilities</div>");
writer.write("<div class=\"portlet-section-body\">");
writer.write("<div>Content type " + req.getResponseContentType() + "</div>");
- writer.write("<div>Preferred markup " + req.getProperty(CoreConstants.REQ_PROP_PREFERRED_MARKUP) + "</div>");
writer.write("</div>");
writer.write("</p>");
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-04-05 13:35:24 UTC (rev 6923)
@@ -119,15 +119,15 @@
// Iterate all changes
for (var id in resp.fragments)
{
- var matchingElts = document.getElementsByClassName(id);
+ var matchingElt = document.getElementById(id);
// Different than 1 is not good
- if (matchingElts.length == 1)
+ if (matchingElt != null)
{
var markup = resp.fragments[id];
markup = markup.substring(25, markup.length - 7);
- var markupContainer = Element.up(matchingElts[0]);
+ var markupContainer = Element.up(matchingElt);
markupContainer.innerHTML = markup;
}
}
@@ -175,12 +175,19 @@
onEnd: function()
{
var elt = Draggables.activeDraggable.element;
+
+ //
+ var windowId = Element.down(elt).id;
var fromRegionId = elt["regionId"];
var fromPos = elt["pos"];
+
+ // Doing the snapshot after move will give us the new region and pos of the window
snapshot();
var toRegionId = elt["regionId"];
var toPos = elt["pos"];
- sendData("windowmove", elt.id, fromPos, fromRegionId, toPos, toRegionId);
+
+ // Perform request
+ sendData("windowmove", windowId, fromPos, fromRegionId, toPos, toRegionId);
}
};
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -42,7 +42,6 @@
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Iterator;
-import java.util.Collection;
/**
* Layout implementation that uses JSPs (and tags) to render the response back to the client.
@@ -77,41 +76,47 @@
WindowResult res = wc.getResult();
if (WindowState.MAXIMIZED.equals(res.getWindowState()))
{
- // TODO: Deep clone instead ?
- PageResult newRes = new PageResult(
- pageResult.getPageName(),
- pageResult.getPageProperties(),
- pageResult.getPortalProperties());
- newRes.setThemeResult(pageResult.getThemeResult());
- Collection set = pageResult.getWindowContextMap().values();
- Iterator setIterator = set.iterator();
- while (setIterator.hasNext())
- {
- WindowContext windowContext = (WindowContext)setIterator.next();
- newRes.addWindowContext(windowContext);
- }
+// // TODO: Deep clone instead ?
+// PageResult newRes = new PageResult(
+// pageResult.getPageName(),
+// pageResult.getPageProperties(),
+// pageResult.getPortalProperties());
+//
+// //
+// newRes.setLayoutState("maximized");
+// newRes.setLayoutURI(getLayoutInfo().getURI("maximized"));
+// newRes.setThemeResult(pageResult.getThemeResult());
+//
+// //
+// for (Iterator j = pageResult.getWindowContextMap().values().iterator();j.hasNext();)
+// {
+// WindowContext windowContext = (WindowContext)j.next();
+//
+// //
+// if (windowContext == wc)
+// {
+// newRes.addWindowContext(new WindowContext(wc.getName(), wc.getId(), "maximized", 0, res));
+// }
+// else
+// {
+// newRes.addWindowContext(windowContext);
+// }
+// }
+//
+// //
+// pageResult = newRes;
- //
- WindowContext ctx = pageResult.getWindowContext(windowId);
-
- //
- newRes.setLayoutState("maximized");
- newRes.setLayoutURI(getLayoutInfo().getURI("maximized"));
-
- //
- ctx.setRegionName("maximized");
- ctx.setOrder(0);
-
- //
- newRes.addWindowContext(ctx);
-
- //
- pageResult = newRes;
-
+ pageResult.setLayoutState("maximized");
+ pageResult.setLayoutURI(getLayoutInfo().getURI("maximized"));
+ wc.setRegionName("maximized");
+ wc.setOrder(0);
break;
}
}
+ // Yes it is ugly
+ pageResult.rebuild();
+
try
{
ServerInvocation invocation = renderContext.getServerInvocation();
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -97,7 +97,7 @@
markup.append("<script type='text/javascript'>\n");
// Async server URL needed for callbacks
- markup.append("async_server_url=\"").append(asyncServerURL).append(";\"\n");
+ markup.append("async_server_url=\"").append(asyncServerURL).append("\";\n");
// View state if not null
if (viewState != null)
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -61,7 +61,7 @@
//
StringBuffer out = renderContext.getMarkupFragment();
- out.append("<div id=\"").append(wrc.getId()).append("\" class=\"dyna-window\"><div class=\"").append(wrc.getId()).append("\"/>\n");
+ out.append("<div class=\"dyna-window\"><div id=\"").append(wrc.getId()).append("\"/>\n");
delegate.render(renderContext, wrc);
out.append("</div></div>\n");
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -33,6 +33,7 @@
import java.util.Map;
import java.util.Set;
import java.util.Collection;
+import java.util.Iterator;
/**
* Interface to represent the read only information of a rendered portal page. <p>The page result allows access to all
@@ -222,14 +223,18 @@
{
windowContexts.put(windowContext.getId(), windowContext);
+ //
Region region = (Region)regions.get(windowContext.getRegionName());
+
+ //
if (region == null)
{
region = new Region(this, windowContext.getRegionName());
+ regions.put(region.getId(), region);
}
+
+ //
region.addWindowContext(windowContext);
-
- regions.put(region.getId(), region);
}
// PageRenderContext implementation *********************************************************************************
@@ -248,7 +253,6 @@
return s;
}
-
public Collection getRegions()
{
return regions.values();
@@ -258,4 +262,34 @@
{
return (RegionRenderContext)regions.get(regionName);
}
+
+ public void rebuild()
+ {
+ // Clear all windows
+ for (Iterator i = regions.values().iterator();i.hasNext();)
+ {
+ Region region = (Region)i.next();
+ region.windows.clear();
+ }
+
+ // Readd all windows
+ for (Iterator i = windowContexts.values().iterator();i.hasNext();)
+ {
+ WindowContext wc = (WindowContext)i.next();
+
+ //
+ Region region = (Region)regions.get(wc.getRegionName());
+
+ //
+ if (region == null)
+ {
+ region = new Region(this, wc.getRegionName());
+ regions.put(region.getId(), region);
+ }
+
+ //
+ region.addWindowContext(wc);
+ }
+ }
}
+
\ No newline at end of file
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-04-04 21:50:16 UTC (rev 6922)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-04-05 13:35:24 UTC (rev 6923)
@@ -52,7 +52,7 @@
private boolean sorted;
/** . */
- private final ArrayList windows;
+ final ArrayList windows;
/** . */
private Map properties;
17 years, 3 months
JBoss Portal SVN: r6922 - trunk/server/src/main/org/jboss/portal/server.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-04 17:50:16 -0400 (Wed, 04 Apr 2007)
New Revision: 6922
Modified:
trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java
Log:
minor javadoc update
Modified: trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java 2007-04-04 21:12:14 UTC (rev 6921)
+++ trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java 2007-04-04 21:50:16 UTC (rev 6922)
@@ -58,8 +58,10 @@
ParameterMap getQueryParameterMap();
/**
- * Return the parameter map for the body if the request was a POST with the content type x-www-formurlencoded
- * otherwise return null.
+ * Return the parameter map for the body if the request was a POST with the content
+ * type x-www-formurlencoded otherwise return null.
+ *
+ * @return the body parameter map
*/
ParameterMap getBodyParameterMap();
@@ -71,11 +73,6 @@
String getMediaType();
/**
- * Return the charset of the request or null if none has been provided by the client.
- */
- // Charset getCharset();
-
- /**
* Return the url context of this request.
*
* @return the url context
@@ -104,9 +101,11 @@
String getPortalHost();
/**
- * @param url
- * @param context
- * @param format
+ * Renders an URL.
+ *
+ * @param url the url structure
+ * @param context the url context
+ * @param format the url format
* @return the encoded url
*/
String renderURL(ServerURL url, URLContext context, URLFormat format);
17 years, 3 months
JBoss Portal SVN: r6921 - in trunk: core/src/main/org/jboss/portal/core/controller/ajax and 9 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-04 17:12:14 -0400 (Wed, 04 Apr 2007)
New Revision: 6921
Added:
trunk/theme/src/main/org/jboss/portal/theme/PageService.java
trunk/theme/src/main/org/jboss/portal/theme/impl/PageServiceImpl.java
Removed:
trunk/theme/src/main/org/jboss/portal/theme/impl/page/
trunk/theme/src/main/org/jboss/portal/theme/page/PageService.java
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
trunk/theme/src/main/org/jboss/portal/theme/page/PageRendition.java
trunk/theme/src/resources/test/theme-test-sar/META-INF/jboss-service.xml
Log:
moved the PageService to an upper package
Modified: trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2007-04-04 20:09:09 UTC (rev 6920)
+++ trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2007-04-04 21:12:14 UTC (rev 6921)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.core.controller;
-import org.jboss.portal.theme.page.PageService;
+import org.jboss.portal.theme.PageService;
import org.jboss.portal.core.controller.command.mapper.CommandFactory;
import org.jboss.portal.core.controller.command.mapper.URLFactory;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
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 2007-04-04 20:09:09 UTC (rev 6920)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-04 21:12:14 UTC (rev 6921)
@@ -400,7 +400,7 @@
renderContext.render(wc);
//
- updatePage.addFragment(_window.getName(), renderContext.getMarkupFragment().toString());
+ updatePage.addFragment(wc.getId(), renderContext.getMarkupFragment().toString());
}
}
catch (Exception e)
Modified: trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java 2007-04-04 20:09:09 UTC (rev 6920)
+++ trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java 2007-04-04 21:12:14 UTC (rev 6921)
@@ -38,7 +38,7 @@
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.theme.page.PageService;
+import org.jboss.portal.theme.PageService;
import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.page.WindowContext;
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-04-04 20:09:09 UTC (rev 6920)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-04-04 21:12:14 UTC (rev 6921)
@@ -46,8 +46,8 @@
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.ThemeResult;
import org.jboss.portal.theme.ThemeService;
+import org.jboss.portal.theme.PageService;
import org.jboss.portal.theme.page.PageResult;
-import org.jboss.portal.theme.page.PageService;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.page.WindowContext;
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 2007-04-04 20:09:09 UTC (rev 6920)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-04 21:12:14 UTC (rev 6921)
@@ -382,7 +382,7 @@
<attribute name="DefaultLayoutName">generic</attribute>
</mbean>
<mbean
- code="org.jboss.portal.theme.impl.page.PageServiceImpl"
+ code="org.jboss.portal.theme.impl.PageServiceImpl"
name="portal:service=PageService"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java 2007-04-04 20:09:09 UTC (rev 6920)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java 2007-04-04 21:12:14 UTC (rev 6921)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.test.theme;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
import org.jboss.portal.common.invocation.AttributeResolver;
import org.jboss.portal.portlet.Properties;
import org.jboss.portal.server.ServerRequest;
@@ -34,11 +32,11 @@
import org.jboss.portal.theme.deployment.jboss.RenderSetMetaDataFactory;
import org.jboss.portal.theme.impl.LayoutServiceImpl;
import org.jboss.portal.theme.impl.ThemeServiceImpl;
-import org.jboss.portal.theme.impl.page.PageServiceImpl;
+import org.jboss.portal.theme.impl.PageServiceImpl;
import org.jboss.portal.theme.metadata.PortalLayoutMetaData;
import org.jboss.portal.theme.metadata.RenderSetMetaData;
import org.jboss.portal.theme.page.PageResult;
-import org.jboss.portal.theme.page.PageService;
+import org.jboss.portal.theme.PageService;
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.system.ServiceMBeanSupport;
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-04-04 20:09:09 UTC (rev 6920)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-04-04 21:12:14 UTC (rev 6921)
@@ -28,20 +28,17 @@
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.server.ServerRequest;
-import org.jboss.portal.theme.LayoutConstants;
-import org.jboss.portal.theme.LayoutDispatcher;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.PortalTheme;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.ThemeService;
+import org.jboss.portal.theme.PageService;
import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
-import org.jboss.portal.theme.page.PageService;
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.render.PortalRenderSet;
-import org.jboss.portal.theme.render.RenderContext;
import javax.management.MBeanServer;
import javax.management.ObjectName;
Copied: trunk/theme/src/main/org/jboss/portal/theme/PageService.java (from rev 6917, trunk/theme/src/main/org/jboss/portal/theme/page/PageService.java)
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/PageService.java (rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/PageService.java 2007-04-04 21:12:14 UTC (rev 6921)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.theme;
+
+import org.jboss.portal.theme.LayoutService;
+import org.jboss.portal.theme.ThemeService;
+
+/**
+ * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
+ * @version $Revision$
+ */
+public interface PageService
+{
+ void setLayoutService(LayoutService layoutService);
+
+ LayoutService getLayoutService();
+
+ void setThemeService(ThemeService themeService);
+
+ ThemeService getThemeService();
+}
Property changes on: trunk/theme/src/main/org/jboss/portal/theme/PageService.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/theme/src/main/org/jboss/portal/theme/impl/PageServiceImpl.java (from rev 6917, trunk/theme/src/main/org/jboss/portal/theme/impl/page/PageServiceImpl.java)
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/PageServiceImpl.java (rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/PageServiceImpl.java 2007-04-04 21:12:14 UTC (rev 6921)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.theme.impl;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.theme.LayoutService;
+import org.jboss.portal.theme.ThemeService;
+import org.jboss.portal.theme.PageService;
+
+/**
+ * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
+ * @version $Revision$
+ */
+public final class PageServiceImpl extends AbstractJBossService implements PageService
+{
+ private LayoutService layoutService;
+ private ThemeService themeService;
+// private InterceptorStack pageStack;
+
+ /** Inject the layout service (must be defined as a dependent service in service descriptor). */
+ public void setLayoutService(LayoutService layoutService)
+ {
+ this.layoutService = layoutService;
+ }
+
+ public LayoutService getLayoutService()
+ {
+ return layoutService;
+ }
+
+ /** Inject the theme service (must be defined as a dependent service in service descriptor). */
+ public void setThemeService(ThemeService themeService)
+ {
+ this.themeService = themeService;
+ }
+
+ public ThemeService getThemeService()
+ {
+ return themeService;
+ }
+}
Property changes on: trunk/theme/src/main/org/jboss/portal/theme/impl/PageServiceImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/PageRendition.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PageRendition.java 2007-04-04 20:09:09 UTC (rev 6920)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PageRendition.java 2007-04-04 21:12:14 UTC (rev 6921)
@@ -23,23 +23,17 @@
package org.jboss.portal.theme.page;
import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.theme.page.PageService;
+import org.jboss.portal.theme.PageService;
import org.jboss.portal.theme.page.PageResult;
-import org.jboss.portal.theme.page.WindowResult;
-import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.render.RenderContext;
-import org.jboss.portal.theme.render.PageRenderer;
import org.jboss.portal.theme.render.RenderException;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.MarkupInfo;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Deleted: trunk/theme/src/main/org/jboss/portal/theme/page/PageService.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PageService.java 2007-04-04 20:09:09 UTC (rev 6920)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PageService.java 2007-04-04 21:12:14 UTC (rev 6921)
@@ -1,41 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.theme.page;
-
-import org.jboss.portal.theme.LayoutService;
-import org.jboss.portal.theme.ThemeService;
-
-/**
- * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
- * @version $Revision$
- */
-public interface PageService
-{
- void setLayoutService(LayoutService layoutService);
-
- LayoutService getLayoutService();
-
- void setThemeService(ThemeService themeService);
-
- ThemeService getThemeService();
-}
Modified: trunk/theme/src/resources/test/theme-test-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/theme/src/resources/test/theme-test-sar/META-INF/jboss-service.xml 2007-04-04 20:09:09 UTC (rev 6920)
+++ trunk/theme/src/resources/test/theme-test-sar/META-INF/jboss-service.xml 2007-04-04 21:12:14 UTC (rev 6921)
@@ -39,7 +39,7 @@
<xmbean/>
</mbean>
<mbean
- code="org.jboss.portal.theme.impl.page.PageServiceImpl"
+ code="org.jboss.portal.theme.impl.PageServiceImpl"
name="portal:service=PageService"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
17 years, 3 months
JBoss Portal SVN: r6920 - in trunk/wsrp/src/main/org/jboss/portal/wsrp: servlet and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-04-04 16:09:09 -0400 (Wed, 04 Apr 2007)
New Revision: 6920
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/RequestDumperFilter.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/TransactionFilter.java
Log:
- Make logger static where appropriate.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-04-04 20:08:24 UTC (rev 6919)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-04-04 20:09:09 UTC (rev 6920)
@@ -72,7 +72,7 @@
static final String PBI = "PerformBlockingInteraction";
static final String GET_MARKUP = "GetMarkup";
- private Logger log = Logger.getLogger(MarkupHandler.class);
+ private static Logger log = Logger.getLogger(MarkupHandler.class);
MarkupHandler(WSRPProducerImpl producer)
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/RequestDumperFilter.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/RequestDumperFilter.java 2007-04-04 20:08:24 UTC (rev 6919)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/RequestDumperFilter.java 2007-04-04 20:09:09 UTC (rev 6920)
@@ -47,7 +47,7 @@
{
/** . */
- private Logger log = Logger.getLogger(RequestDumperFilter.class);
+ private static Logger log = Logger.getLogger(RequestDumperFilter.class);
public void init(FilterConfig cfg) throws ServletException
{
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/TransactionFilter.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/TransactionFilter.java 2007-04-04 20:08:24 UTC (rev 6919)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/servlet/TransactionFilter.java 2007-04-04 20:09:09 UTC (rev 6920)
@@ -47,7 +47,7 @@
{
/** . */
- private Logger log = Logger.getLogger(TransactionFilter.class);
+ private static Logger log = Logger.getLogger(TransactionFilter.class);
/** . */
private TransactionManager tm;
17 years, 3 months
JBoss Portal SVN: r6919 - in trunk/wsrp/src/main/org/jboss/portal: wsrp/consumer and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-04-04 16:08:24 -0400 (Wed, 04 Apr 2007)
New Revision: 6919
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java
Log:
- Improvements to session releasing code.
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java 2007-04-04 16:17:58 UTC (rev 6918)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java 2007-04-04 20:08:24 UTC (rev 6919)
@@ -127,7 +127,7 @@
assertEquals(sid2, info.getSessionIdForPortlet(handle2));
assertEquals(1, info.getNumberOfSessions());
- info.releaseSessionIdForPortlet(handle2);
+ info.releaseSessionForPortlet(handle2);
assertEquals(0, info.getNumberOfSessions());
}
@@ -163,6 +163,30 @@
info.releaseSessions();
assertEquals(0, info.getNumberOfSessions());
+
+ addSession("handle", "id", 1);
+ addSession("handle2", "id2", 2);
+
+ info.releaseSession("id2");
+
+ assertEquals(1, info.getNumberOfSessions());
+ assertNull(info.getSessionIdForPortlet("handle2"));
+ assertEquals("id", info.getSessionIdForPortlet("handle"));
+
+ info.releaseSessionForPortlet("handle");
+
+ assertEquals(0, info.getNumberOfSessions());
+ assertNull(info.getSessionIdForPortlet("handle"));
+
+ try
+ {
+ info.releaseSessionForPortlet("handle");
+ fail("Session for portlet 'handle' should have already been released!");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // expected
+ }
}
private Cookie createCookie(String name, String value, int secondsBeforeExpiration)
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java 2007-04-04 16:17:58 UTC (rev 6918)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java 2007-04-04 20:08:24 UTC (rev 6919)
@@ -27,7 +27,6 @@
import org.jboss.logging.Logger;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPConsumer;
import org.jboss.portal.wsrp.core.SessionContext;
@@ -47,7 +46,7 @@
*/
public class ProducerSessionInformation
{
- private Logger log = Logger.getLogger(ProducerSessionInformation.class);
+ private static Logger log = Logger.getLogger(ProducerSessionInformation.class);
private boolean initCookieDone = false;
private boolean perGroupCookies = false;
@@ -69,6 +68,11 @@
{
ParameterValidation.throwIllegalArgExceptionIfNull(associatedConsumer, "Consumer");
this.associatedConsumer = associatedConsumer;
+ /*if (associatedConsumer instanceof WSRPConsumerImpl)
+ {
+ WSRPConsumerImpl consumer = (WSRPConsumerImpl)associatedConsumer;
+ consumer.add
+ }*/
}
public String getUserCookie()
@@ -202,8 +206,58 @@
return idResult.id;
}
- public void releaseSessionIdForPortlet(String portletHandle)
+ public int getNumberOfSessions()
{
+ if (portletSessions != null)
+ {
+ return portletSessions.size();
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ public void releaseSession(String sessionId)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(sessionId, "session id");
+
+ String portletHandle = (String)sessionId2PortletHandle.get(sessionId);
+ if (portletHandle == null)
+ {
+ throw new IllegalArgumentException("No such session id: '" + sessionId + "'");
+ }
+
+ releaseSessionForPortlet(portletHandle);
+ }
+
+ public void releaseSessions()
+ {
+ List idsToRelease = new ArrayList(getNumberOfSessions());
+
+ // copy to avoid ConcurrentModificationException
+ List handlesCopy = new ArrayList(portletSessions.keySet());
+
+ for (Iterator handles = handlesCopy.iterator(); handles.hasNext();)
+ {
+ String handle = (String)handles.next();
+ SessionIdResult result = removeSessionIdForPortlet(handle);
+
+ // only release sessions that are still valid
+ if (!result.expired)
+ {
+ idsToRelease.add(result.id);
+ }
+ }
+
+ if (!idsToRelease.isEmpty())
+ {
+ releaseSessions((String[])idsToRelease.toArray(new String[0]));
+ }
+ }
+
+ public void releaseSessionForPortlet(String portletHandle)
+ {
SessionIdResult result = removeSessionIdForPortlet(portletHandle);
// if the session is still valid, release it and remove the associated mappings
@@ -232,7 +286,7 @@
{
associatedConsumer.releaseSessions(sessionIds);
}
- catch (PortletInvokerException e)
+ catch (Exception e)
{
log.debug(e);
}
@@ -247,6 +301,11 @@
ProducerSessionInformation.SessionIdResult result = internalGetSessionIdForPortlet(portletHandle);
final String id = result.id;
+ if (id == null)
+ {
+ throw new IllegalArgumentException("There is no Session associated with portlet '" + portletHandle + "'");
+ }
+
// if the session is still valid, release it and remove the associated mappings
if (!result.expired)
{
@@ -257,56 +316,6 @@
return result;
}
- public int getNumberOfSessions()
- {
- if (portletSessions != null)
- {
- return portletSessions.size();
- }
- else
- {
- return 0;
- }
- }
-
- public void releaseSession(String id)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(id, "session id");
-
- String portletHandle = (String)sessionId2PortletHandle.get(id);
- if (portletHandle == null)
- {
- throw new IllegalArgumentException("No such session id: '" + id + "'");
- }
-
- releaseSessionIdForPortlet(portletHandle);
- }
-
- public void releaseSessions()
- {
- List idsToRelease = new ArrayList(getNumberOfSessions());
-
- // copy to avoid ConcurrentModificationException
- List handlesCopy = new ArrayList(portletSessions.keySet());
-
- for (Iterator handles = handlesCopy.iterator(); handles.hasNext();)
- {
- String handle = (String)handles.next();
- SessionIdResult result = removeSessionIdForPortlet(handle);
-
- // only release sessions that are still valid
- if (!result.expired)
- {
- idsToRelease.add(result.id);
- }
- }
-
- if (!idsToRelease.isEmpty())
- {
- releaseSessions((String[])idsToRelease.toArray(new String[0]));
- }
- }
-
public void replaceUserCookiesWith(ProducerSessionInformation currentSessionInfo)
{
if (currentSessionInfo != null && currentSessionInfo.userCookie != null && currentSessionInfo.userCookie.length > 0)
17 years, 3 months
JBoss Portal SVN: r6917 - in trunk: core/src/main/org/jboss/portal/core/controller/ajax and 9 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-04 12:14:41 -0400 (Wed, 04 Apr 2007)
New Revision: 6917
Added:
trunk/theme/src/main/org/jboss/portal/theme/impl/RendererFactoryImpl.java
trunk/theme/src/main/org/jboss/portal/theme/page/PageRendition.java
trunk/theme/src/main/org/jboss/portal/theme/render/RendererFactory.java
Removed:
trunk/theme/src/main/org/jboss/portal/theme/PageRendition.java
trunk/theme/src/main/org/jboss/portal/theme/navigation/WindowNavigationalState.java
trunk/theme/src/main/org/jboss/portal/theme/page/WindowRenderContextImpl.java
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.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/classic/ClassicResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
trunk/theme/src/main/org/jboss/portal/theme/LayoutDispatcher.java
trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java
trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java
trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java
trunk/theme/src/main/org/jboss/portal/theme/page/DecorationRenderContextImpl.java
trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
trunk/theme/src/main/org/jboss/portal/theme/page/PortletRenderContextImpl.java
trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java
trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java
trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java
Log:
improve the theme stuff: better dispatch of responsibilities with better encapsulation
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -48,7 +48,7 @@
import org.jboss.portal.security.PortalSecurityException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.theme.PageRendition;
+import org.jboss.portal.theme.page.PageRendition;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
import org.jboss.portal.theme.page.Region;
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 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -49,10 +49,8 @@
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.render.RenderContext;
-import org.jboss.portal.theme.render.WindowRenderContext;
-import org.jboss.portal.theme.render.DecorationRenderContext;
-import org.jboss.portal.theme.render.PortletRenderContext;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageLocationResponse;
@@ -68,7 +66,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletException;
import java.io.IOException;
-import java.util.Collection;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.Set;
@@ -363,13 +360,13 @@
LayoutService layoutService = getPageService().getLayoutService();
PortalLayout layout = RenderPageCommand.getLayout(layoutService, page);
+ //
+ UpdatePageStateResponse updatePage = new UpdatePageStateResponse(ctx.getViewId());
+
// Call to the theme framework
PageResult res = new PageResult(page.getName(), page.getProperties(), portal.getProperties());
//
- UpdatePageStateResponse updatePage = new UpdatePageStateResponse(ctx.getViewId());
-
- //
for (Iterator i = windowToRefresh.iterator();i.hasNext();)
{
final PortalObject _window = (PortalObject)i.next();
@@ -382,82 +379,28 @@
final WindowResult windowResult = (WindowResult)wresp;
//
- WindowRenderContext wrc = new WindowRenderContext()
- {
- public String getId()
- {
- return _window.getName();
- }
+ WindowContext wc = new WindowContext(
+ _window.getName(),
+ _window.getId().toString(PortalObjectId.LEGACY_BASE64_FORMAT),
+ "ABC",
+ 0,
+ windowResult);
- public int getOrder()
- {
- return 0;
- }
+ //
+ MarkupInfo markupInfo = (MarkupInfo)invocation.getResponse().getContentInfo();
- public WindowState getWindowState()
- {
- return windowResult.getWindowState();
- }
+ //
+ RenderContext renderContext = layout.getRenderContext(markupInfo, invocation);
- public Mode getMode()
- {
- return windowResult.getMode();
- }
+ // Should push region context as well
+ renderContext.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED, Boolean.TRUE);
+ renderContext.pushObjectRenderContext(res);
- public DecorationRenderContext getDecoration()
- {
- return new DecorationRenderContext()
- {
- public String getId()
- {
- return _window.getName();
- }
+ //
+ renderContext.render(wc);
- public String getTitle()
- {
- return windowResult.getTitle();
-
- }
-
- public Collection getTriggerableActions(String familyName)
- {
- return windowResult.getTriggerableActions(familyName);
- }
-
- public String getProperty(String name)
- {
- return (String)windowResult.getWindowProperties().get(name);
- }
- };
- }
-
- public PortletRenderContext getPortlet()
- {
- return new PortletRenderContext()
- {
- public String getMarkup()
- {
- return windowResult.getContent();
- }
-
- public String getProperty(String name)
- {
- return (String)windowResult.getWindowProperties().get(name);
- }
- };
- }
-
- public String getProperty(String name)
- {
- return (String)windowResult.getWindowProperties().get(name);
- }
- };
-
//
- RenderContext renderCtx = new RenderContext(layout, (MarkupInfo)invocation.getResponse().getContentInfo(), res);
- renderCtx.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED, Boolean.TRUE);
- renderCtx.render(wrc);
- updatePage.addFragment(_window.getName(), renderCtx.getMarkupFragment().toString());
+ updatePage.addFragment(_window.getName(), renderContext.getMarkupFragment().toString());
}
}
catch (Exception e)
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -28,7 +28,7 @@
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
-import org.jboss.portal.theme.PageRendition;
+import org.jboss.portal.theme.page.PageRendition;
import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
import javax.servlet.http.HttpServletRequest;
Modified: trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -26,7 +26,7 @@
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.theme.PageRendition;
+import org.jboss.portal.theme.page.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.ControllerCommand;
Modified: trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -34,7 +34,7 @@
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.theme.PageRendition;
+import org.jboss.portal.theme.page.PageRendition;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.ThemeConstants;
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -39,7 +39,7 @@
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.theme.LayoutService;
-import org.jboss.portal.theme.PageRendition;
+import org.jboss.portal.theme.page.PageRendition;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.PortalTheme;
import org.jboss.portal.theme.ServerRegistrationID;
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -127,16 +127,16 @@
}
// set the renderctx and req/res attr
- RenderContext renderCtx = new RenderContext(layout, markupInfo, pageResult);
- response.setContentType(renderCtx.getContentType().toString());
- response.setCharacterEncoding(renderCtx.getCharset());
- request.setAttribute(LayoutConstants.ATTR_RENDERCONTEXT, renderCtx);
- request.setAttribute(LayoutConstants.ATTR_PAGE, pageResult);
- request.setAttribute(ThemeConstants.ATTR_THEME, theme);
+// RenderContext renderCtx = new RenderContext(layout, markupInfo, pageResult);
+// response.setContentType(renderCtx.getContentType().toString());
+// response.setCharacterEncoding(renderCtx.getCharset());
+// request.setAttribute(LayoutConstants.ATTR_RENDERCONTEXT, renderCtx);
+// request.setAttribute(LayoutConstants.ATTR_PAGE, pageResult);
+// request.setAttribute(ThemeConstants.ATTR_THEME, theme);
//
- LayoutDispatcher dispatcher1 = new LayoutDispatcher(renderCtx, request, response, pageResult);
- dispatcher1.include();
+// LayoutDispatcher dispatcher1 = new LayoutDispatcher(renderCtx, request, response, pageResult);
+// dispatcher1.include();
}
/**
Modified: trunk/theme/src/main/org/jboss/portal/theme/LayoutDispatcher.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/LayoutDispatcher.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/LayoutDispatcher.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -23,20 +23,16 @@
package org.jboss.portal.theme;
import org.jboss.logging.Logger;
-import org.jboss.portal.common.util.Tools;
import org.jboss.portal.server.servlet.FilterCommand;
-import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.render.RenderContext;
-import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.PageRenderContext;
-import javax.servlet.FilterChain;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.io.Writer;
/**
* Dispatches the request to the target layout. The major side effect is to change the context path returned by the
@@ -51,19 +47,27 @@
private static final Logger log = Logger.getLogger(LayoutDispatcher.class);
- /** The layout */
private final HttpServletRequest request;
private final HttpServletResponse response;
- private final PageResult markupResult;
+ private final PageRenderContext markupResult;
private final RenderContext renderContext;
+ private final String layoutURI;
+ private final LayoutInfo layoutInfo;
/**
* @param renderContext
* @throws IllegalArgumentException if the layout is null
*/
- public LayoutDispatcher(RenderContext renderContext, HttpServletRequest request, HttpServletResponse response, PageResult result)
+ public LayoutDispatcher(
+ RenderContext renderContext,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ PageRenderContext result,
+ String layoutURI,
+ LayoutInfo layoutInfo)
throws IllegalArgumentException
{
+
if (request == null)
{
throw new IllegalArgumentException("No null request allowed here");
@@ -81,7 +85,7 @@
{
throw new IllegalArgumentException("No render context provided");
}
- if (result.getLayoutURI() == null)
+ if (layoutURI == null)
{
throw new IllegalArgumentException("No null layout allowed here");
}
@@ -90,10 +94,10 @@
this.response = response;
this.markupResult = result;
this.renderContext = renderContext;
+ this.layoutURI = layoutURI;
+ this.layoutInfo = layoutInfo;
}
- /** Perform the dispatch to the target layout */
-// public void include(PortalRequest req, PortalResponse resp) throws IOException, ServletException
public void include() throws IOException, ServletException
{
try
@@ -101,64 +105,47 @@
// Set charset and content type on the response
response.setContentType(renderContext.getContentType().toString());
response.setCharacterEncoding(renderContext.getCharset());
- request.setAttribute(LayoutConstants.ATTR_RENDERCONTEXT, renderContext);
- if (markupResult instanceof PageResult)
+ RequestDispatcher dispatcher = layoutInfo.getServletContext().getRequestDispatcher(layoutURI);
+
+ log.debug("got request dispatcher for layout resource: " + (dispatcher != null));
+ if (dispatcher == null)
{
- RequestDispatcher dispatcher = renderContext.getLayoutInfo().getServletContext().getRequestDispatcher(markupResult.getLayoutURI());
+ throw new IOException("No dispatcher found for : " + layoutInfo.getName() + " [" + layoutURI + "]");
+ }
- log.debug("got request dispatcher for layout resource: " + (dispatcher != null));
- if (dispatcher == null)
+ //
+ request.setAttribute(LayoutConstants.ATTR_RENDERCONTEXT, renderContext);
+ request.setAttribute(FilterCommand.REQ_ATT_KEY, this);
+ request.setAttribute(LayoutConstants.ATTR_PAGE, markupResult);
+
+ // This request returns a context path which is the one of the war file in which the target is
+ HttpServletRequest wrapper = new HttpServletRequestWrapper(request)
+ {
+ public String getContextPath()
{
- throw new IOException("No dispatcher found for : " + renderContext.getLayoutInfo().getName() + " [" + markupResult.getLayoutURI() + "]");
+ return layoutInfo.getContextPath();
}
+ };
- request.setAttribute(FilterCommand.REQ_ATT_KEY, this);
- // add the results to the request
- request.setAttribute(LayoutConstants.ATTR_PAGE, markupResult);
- // This request returns a context path which is the one of the war file in which the target is
- HttpServletRequest wrapper = new HttpServletRequestWrapper(request)
- {
- public String getContextPath()
- {
- return renderContext.getLayoutInfo().getContextPath();
- }
- };
+ dispatcher.include(wrapper, response);
-
- dispatcher.include(wrapper, response);
-
- log.debug("done with the layout");
- }
- else
- {
- // for page fragments , render via the render context (which uses the render set in turn)...
- try
- {
- renderContext.render();
- writeResponse(renderContext, response);
- }
- catch (RenderException e)
- {
- throw new ServletException(e);
- }
- }
+ log.debug("done with the layout");
}
finally
{
- request.removeAttribute(FilterCommand.REQ_ATT_KEY);
request.removeAttribute(LayoutConstants.ATTR_PAGE);
request.removeAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
}
}
- private static void writeResponse(RenderContext renderCtx, HttpServletResponse response)
- throws IOException
- {
- Writer out = response.getWriter();
- out.write(renderCtx.getMarkupFragment().toString());
- out.flush();
- Tools.safeClose(out);
- }
+// private static void writeResponse(RenderContext renderCtx, HttpServletResponse response)
+// throws IOException
+// {
+// Writer out = response.getWriter();
+// out.write(renderCtx.getMarkupFragment().toString());
+// out.flush();
+// Tools.safeClose(out);
+// }
}
Deleted: trunk/theme/src/main/org/jboss/portal/theme/PageRendition.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/PageRendition.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/PageRendition.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -1,133 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.theme;
-
-import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.theme.page.PageService;
-import org.jboss.portal.theme.page.PageResult;
-import org.jboss.portal.theme.page.WindowResult;
-import org.jboss.portal.theme.page.WindowContext;
-import org.jboss.portal.WindowState;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PageRendition
-{
-
- /** . */
- private PortalLayout layout;
-
- /** . */
- private PageResult pageResult;
-
- /** . */
- private PageService pageService;
-
- public PageRendition(PortalLayout layout, PageResult markupResult, PageService pageService)
- {
- this.layout = layout;
- this.pageResult = markupResult;
- this.pageService = pageService;
- }
-
- /** Performs the page rendition. */
- public void render(ServerInvocation invocation) throws IOException, ServletException
- {
- //
- HttpServletRequest clientRequest = invocation.getServerContext().getClientRequest();
-
- // Take care of maximized window
- // if one window is maximized then we do chose the maximized layout for the rendition
- // and put that window on the maximized region of this layout
- for (Iterator i = pageResult.getWindowIds().iterator();i.hasNext();)
- {
- Object windowId = i.next();
- WindowContext wc = pageResult.getWindowContext(windowId);
- WindowResult res = wc.getResult();
- if (WindowState.MAXIMIZED.equals(res.getWindowState()))
- {
- // TODO: Deep clone instead ?
- PageResult newRes = new PageResult(
- pageResult.getPageName(),
- pageResult.getPageProperties(),
- pageResult.getPortalProperties());
- newRes.setThemeResult(pageResult.getThemeResult());
- Collection set = pageResult.getWindowContextMap().values();
- Iterator setIterator = set.iterator();
- while (setIterator.hasNext())
- {
- WindowContext windowContext = (WindowContext)setIterator.next();
- newRes.addWindowContext(windowContext);
- }
-
- //
- WindowContext ctx = pageResult.getWindowContext(windowId);
-
- //
- newRes.setLayoutState("maximized");
- newRes.setLayoutURI(layout.getLayoutInfo().getURI("maximized"));
-
- //
- ctx.setRegionName("maximized");
- ctx.setOrder(0);
-
- //
- newRes.addWindowContext(ctx);
-
- //
- pageResult = newRes;
-
- break;
- }
- }
-
- try
- {
-
- // Place a reference to the theme service into the request so that the theme tag can get to a theme via a theme
- // name (specified as tag attribute); this is useful if no theme was defined for the portal or the page
- clientRequest.setAttribute(ThemeConstants.ATTR_THEMESERVER, pageService.getThemeService());
- clientRequest.setAttribute(ThemeConstants.ATTR_THEME, pageResult.getTheme());
- clientRequest.setAttribute(ThemeConstants.ATTR_THEMERESULT, pageResult.getThemeResult());
- // now delegate to the layout to do the rest (assemble the markup fragments into a response)
- layout.assembleResponse(invocation, pageResult);
- }
- finally
- {
- clientRequest.removeAttribute(ThemeConstants.ATTR_THEMESERVER);
- }
- }
-
- public PageResult getPageResult()
- {
- return pageResult;
- }
-}
Modified: trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -23,15 +23,10 @@
package org.jboss.portal.theme;
import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.ServerRequest;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.theme.render.RenderContext;
-import org.jboss.portal.theme.render.PageRenderContext;
-import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.theme.render.PageRenderer;
-import javax.servlet.ServletException;
-import java.io.IOException;
-
/**
* Implementation of a <code>PortalLayout</code>. <p>An instance of this class represents the meta data of a portal
* layout.</p>
@@ -41,68 +36,34 @@
*/
public abstract class PortalLayout
{
- private LayoutInfo info;
- private LayoutServiceInfo serviceInfo;
- /** Layouts need an empty constructor (they are loaded via reflection) */
- public PortalLayout()
- {
- }
+ /** . */
+ protected LayoutInfo info;
- /**
- * Assemble the fragments created by the portlet render process into a response and send it back to the client (write
- * it to the response)
- *
- * @param invocation
- * @param markupResult the result containing the information about what was rendered and what the resulting markup
- * fragments are
- * @throws ServletException
- * @throws IOException
- */
- public abstract void assembleResponse(ServerInvocation invocation, PageResult markupResult)
- throws ServletException, IOException;
+ /** . */
+ protected LayoutServiceInfo serviceInfo;
- /**
- * Initialize the layout with a handle to the layout service and the layout's meta data
- *
- * @param serviceInfo a reference to the layout service
- * @param info the layout's meta data (the parsed content of the layout descriptor)
- */
public void init(LayoutServiceInfo serviceInfo, LayoutInfo info)
{
this.info = info;
this.serviceInfo = serviceInfo;
}
- /** destroy this layout (cleanup time) */
public void destroy()
{
info = null;
serviceInfo = null;
}
- /** @return the parsed meta data of this layout */
public LayoutInfo getLayoutInfo()
{
return info;
}
- /** @return a reference to the layout service */
public LayoutServiceInfo getServiceInfo()
{
return serviceInfo;
}
- /**
- * Create a new render context for this request and layout
- *
- * @param markupInfo the information about the content type and encoding this layout should produce
- * @param request the current server request
- * @param markupResult the result of the portlet render process
- * @return a new render context
- */
- public RenderContext getRenderContext(MarkupInfo markupInfo, ServerRequest request, PageRenderContext markupResult)
- {
- return new RenderContext(this, markupInfo, markupResult);
- }
+ public abstract RenderContext getRenderContext(MarkupInfo markupInfo, ServerInvocation invocation);
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -27,13 +27,22 @@
import org.jboss.portal.theme.LayoutDispatcher;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.theme.page.WindowContext;
+import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.render.RenderContext;
+import org.jboss.portal.theme.render.PageRenderContext;
+import org.jboss.portal.theme.render.PageRenderer;
+import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.RendererFactory;
+import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.MarkupInfo;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
+import java.util.Iterator;
+import java.util.Collection;
/**
* Layout implementation that uses JSPs (and tags) to render the response back to the client.
@@ -42,16 +51,88 @@
* @version $Revision$
* @see LayoutDispatcher
*/
-public final class JSPLayout extends PortalLayout
+public final class JSPLayout extends PortalLayout implements PageRenderer
{
- public void assembleResponse(ServerInvocation invocation, PageResult markupResult)
- throws ServletException, IOException
+ public RenderContext getRenderContext(MarkupInfo markupInfo, ServerInvocation invocation)
{
- HttpServletRequest httpRequest = invocation.getServerContext().getClientRequest();
- HttpServletResponse httpResponse = invocation.getServerContext().getClientResponse();
- RenderContext renderCtx = getRenderContext((MarkupInfo)invocation.getResponse().getContentInfo(), invocation.getRequest(), markupResult);
- LayoutDispatcher dispatcher = new LayoutDispatcher(renderCtx, httpRequest, httpResponse, markupResult);
- dispatcher.include();
+ //
+ RendererFactory factory = new RendererFactoryImpl(this, serviceInfo, info);
+
+ //
+ return new RenderContext(factory, invocation, markupInfo);
}
+
+ public void render(RenderContext renderContext, PageRenderContext prc) throws RenderException
+ {
+ PageResult pageResult = (PageResult)prc;
+
+ // Take care of maximized window
+ // if one window is maximized then we do chose the maximized layout for the rendition
+ // and put that window on the maximized region of this layout
+ for (Iterator i = pageResult.getWindowIds().iterator();i.hasNext();)
+ {
+ String windowId = (String)i.next();
+ WindowContext wc = pageResult.getWindowContext(windowId);
+ WindowResult res = wc.getResult();
+ if (WindowState.MAXIMIZED.equals(res.getWindowState()))
+ {
+ // TODO: Deep clone instead ?
+ PageResult newRes = new PageResult(
+ pageResult.getPageName(),
+ pageResult.getPageProperties(),
+ pageResult.getPortalProperties());
+ newRes.setThemeResult(pageResult.getThemeResult());
+ Collection set = pageResult.getWindowContextMap().values();
+ Iterator setIterator = set.iterator();
+ while (setIterator.hasNext())
+ {
+ WindowContext windowContext = (WindowContext)setIterator.next();
+ newRes.addWindowContext(windowContext);
+ }
+
+ //
+ WindowContext ctx = pageResult.getWindowContext(windowId);
+
+ //
+ newRes.setLayoutState("maximized");
+ newRes.setLayoutURI(getLayoutInfo().getURI("maximized"));
+
+ //
+ ctx.setRegionName("maximized");
+ ctx.setOrder(0);
+
+ //
+ newRes.addWindowContext(ctx);
+
+ //
+ pageResult = newRes;
+
+ break;
+ }
+ }
+
+ try
+ {
+ ServerInvocation invocation = renderContext.getServerInvocation();
+ HttpServletRequest httpRequest = invocation.getServerContext().getClientRequest();
+ HttpServletResponse httpResponse = invocation.getServerContext().getClientResponse();
+ LayoutDispatcher dispatcher = new LayoutDispatcher(
+ renderContext,
+ httpRequest,
+ httpResponse,
+ prc,
+ pageResult.getLayoutURI(),
+ getLayoutInfo());
+ dispatcher.include();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ catch (ServletException e)
+ {
+ e.printStackTrace();
+ }
+ }
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -62,16 +62,22 @@
public class LayoutServiceImpl extends AbstractJBossService implements LayoutService, Service
{
private static Logger log = Logger.getLogger(LayoutServiceImpl.class);
+
// map of layout id to layout
private Map layouts;
+
// map of layout name to layout id
private Map layoutNames;
+
// map of appID + "." + layout name to layout id
private Map exactLayoutNames;
+
// map of renderSet registration id to list of rendersets
private Map renderSets;
+
// map of render set name to render set
private Map renderSetNames;
+
// map of appID + "." + render set name to render set
private Map exactRenderSetNames;
Added: trunk/theme/src/main/org/jboss/portal/theme/impl/RendererFactoryImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/RendererFactoryImpl.java (rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/RendererFactoryImpl.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -0,0 +1,235 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.theme.impl;
+
+import org.jboss.portal.theme.render.RendererFactory;
+import org.jboss.portal.theme.render.ObjectRenderer;
+import org.jboss.portal.theme.render.RenderContext;
+import org.jboss.portal.theme.render.ObjectRenderContext;
+import org.jboss.portal.theme.render.RegionRenderContext;
+import org.jboss.portal.theme.render.WindowRenderContext;
+import org.jboss.portal.theme.render.PortletRenderContext;
+import org.jboss.portal.theme.render.DecorationRenderContext;
+import org.jboss.portal.theme.render.PortalRenderSet;
+import org.jboss.portal.theme.render.PageRenderContext;
+import org.jboss.portal.theme.render.PageRenderer;
+import org.jboss.portal.theme.LayoutServiceInfo;
+import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.theme.LayoutInfo;
+import org.jboss.portal.common.util.ContentInfo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RendererFactoryImpl implements RendererFactory
+{
+
+ /** . */
+ private PageRenderer pageRenderer;
+
+ /** . */
+ private LayoutServiceInfo layoutServiceInfo;
+
+ /** . */
+ private LayoutInfo layoutInfo;
+
+ public RendererFactoryImpl(
+ PageRenderer pageRenderer,
+ LayoutServiceInfo layoutServiceInfo,
+ LayoutInfo layoutInfo)
+ {
+ this.pageRenderer = pageRenderer;
+ this.layoutServiceInfo = layoutServiceInfo;
+ this.layoutInfo = layoutInfo;
+ }
+
+ public ObjectRenderer getRenderer(RenderContext renderContext, ObjectRenderContext objectRenderContext)
+ {
+ if (objectRenderContext instanceof PageRenderContext)
+ {
+ return pageRenderer;
+ }
+ if (objectRenderContext instanceof RegionRenderContext)
+ {
+ return getRegionRenderer(renderContext, (RegionRenderContext)objectRenderContext);
+ }
+ else if (objectRenderContext instanceof WindowRenderContext)
+ {
+ return getWindowRenderer(renderContext, (WindowRenderContext)objectRenderContext);
+ }
+ else if (objectRenderContext instanceof PortletRenderContext)
+ {
+ return getPortletRenderer(renderContext, (PortletRenderContext)objectRenderContext);
+ }
+ else if (objectRenderContext instanceof DecorationRenderContext)
+ {
+ return getDecorationRenderer(renderContext, (DecorationRenderContext)objectRenderContext);
+ }
+ return null;
+ }
+
+ private ObjectRenderer getRegionRenderer(RenderContext renderContext, RegionRenderContext objectRenderContext)
+ {
+ return getRenderSet(renderContext).getRegionRenderer();
+ }
+
+ /**
+ * Get the window renderer for the provided window. <p>The window result can optionally contain a window property
+ * that points to a render set to use when getting the window renderer. If no window property was provided, then the
+ * default render set of this context will be used.</p>
+ *
+ * @param result the window result possibly containing the window property that specifies an alternative render set
+ * name for the window renderer to use
+ * @return a window renderer
+ */
+ public ObjectRenderer getWindowRenderer(RenderContext renderContext, WindowRenderContext result)
+ {
+ String renderSetName = null;
+ if (result != null)
+ {
+ renderSetName = result.getProperty(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER);
+ }
+
+ //
+ if (result != null && renderSetName == null)
+ {
+ renderSetName = renderContext.getProperty(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER);
+ }
+
+ //
+ if (renderSetName != null)
+ {
+ PortalRenderSet renderSet = layoutServiceInfo.getRenderSet(renderSetName, renderContext.getContentType());
+
+ //
+ if (renderSet != null)
+ {
+ return renderSet.getWindowRenderer();
+ }
+ }
+
+ //
+ return getRenderSet(renderContext).getWindowRenderer();
+ }
+
+ /**
+ * Get the decoration renderer for the window that the provided window result is associated with. <p>If the window
+ * result contains a window property that points to a render set, that render set will be used to determine the
+ * decoration renderer. Otherwise, the render set that was determined for this context will be used.</p>
+ *
+ * @param result the window result possibly containing the window property that specifies an alternative render set
+ * name for the decoration renderer to use
+ * @return a decoration renderer
+ */
+ public ObjectRenderer getDecorationRenderer(RenderContext renderContext, DecorationRenderContext result)
+ {
+ String renderSetName = null;
+
+ if (result != null)
+ {
+ renderSetName = result.getProperty(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER);
+ }
+
+ //
+ if (result != null && renderSetName == null)
+ {
+ renderSetName = renderContext.getProperty(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER);
+ }
+
+ //
+ if (renderSetName != null)
+ {
+ PortalRenderSet renderSet = layoutServiceInfo.getRenderSet(renderSetName, renderContext.getContentType());
+
+ //
+ if (renderSet != null)
+ {
+ return renderSet.getDecorationRenderer();
+ }
+ }
+
+ //
+ return getRenderSet(renderContext).getDecorationRenderer();
+ }
+
+ /**
+ * Get the portlet renderer for the render set defined in the window properties that were provided. <p>If the
+ * provided window result doesn't contain any window property that defines a render set name, the default render set
+ * that was determined for this context will be used to get the portlet renderer.</p>
+ *
+ * @param result the window result containing the window properties to introspect for a render set name to get the
+ * portlet renderer from
+ * @return a portlet renderer
+ */
+ public ObjectRenderer getPortletRenderer(RenderContext renderContext, PortletRenderContext result)
+ {
+ String renderSetName = null;
+
+ //
+ if (result != null)
+ {
+ renderSetName = result.getProperty(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER);
+ }
+
+ //
+ if (result != null && renderSetName == null)
+ {
+ renderSetName = renderContext.getProperty(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER);
+ }
+
+ //
+ if (renderSetName != null)
+ {
+ PortalRenderSet renderSet = layoutServiceInfo.getRenderSet(renderSetName, renderContext.getContentType());
+
+ //
+ if (renderSet != null)
+ {
+ return renderSet.getPortletRenderer();
+ }
+ }
+
+ //
+ return getRenderSet(renderContext).getPortletRenderer();
+ }
+
+ private PortalRenderSet getRenderSet(RenderContext renderContext)
+ {
+ // Find the render set name
+ String renderSetName = renderContext.getProperty(ThemeConstants.PORTAL_PROP_RENDERSET);
+
+// if (renderSetName == null)
+// {
+// throw new IllegalArgumentException("No RenderSet determined");
+// }
+
+ ContentInfo contentInfo = renderContext.getMarkupInfo();
+
+ return layoutServiceInfo.getRenderSet(layoutInfo, contentInfo, renderSetName);
+// if (renderSet == null)
+// {
+// throw new IllegalArgumentException("No RenderSet determined for " + renderSetName);
+// }
+ }
+}
Deleted: trunk/theme/src/main/org/jboss/portal/theme/navigation/WindowNavigationalState.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/navigation/WindowNavigationalState.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/navigation/WindowNavigationalState.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -1,73 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.theme.navigation;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class WindowNavigationalState implements Serializable
-{
-
- /** . */
- private WindowState windowState;
-
- /** . */
- private Mode mode;
-
- public WindowNavigationalState()
- {
- this(WindowState.NORMAL, Mode.VIEW);
- }
-
- public WindowNavigationalState(WindowState windowState, Mode mode)
- {
- this.windowState = windowState;
- this.mode = mode;
- }
-
- public WindowState getWindowState()
- {
- return windowState;
- }
-
- public void setWindowState(WindowState windowState)
- {
- this.windowState = windowState;
- }
-
- public Mode getMode()
- {
- return mode;
- }
-
- public void setMode(Mode mode)
- {
- this.mode = mode;
- }
-}
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/DecorationRenderContextImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/DecorationRenderContextImpl.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/DecorationRenderContextImpl.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -33,9 +33,9 @@
public class DecorationRenderContextImpl implements DecorationRenderContext
{
- final WindowRenderContextImpl wrc;
+ final WindowContext wrc;
- public DecorationRenderContextImpl(WindowRenderContextImpl wrc)
+ public DecorationRenderContextImpl(WindowContext wrc)
{
this.wrc = wrc;
}
@@ -47,12 +47,12 @@
public String getTitle()
{
- return wrc.context.result.getTitle();
+ return wrc.result.getTitle();
}
public Collection getTriggerableActions(String familyName)
{
- return wrc.context.result.getTriggerableActions(familyName);
+ return wrc.result.getTriggerableActions(familyName);
}
public String getProperty(String name)
Copied: trunk/theme/src/main/org/jboss/portal/theme/page/PageRendition.java (from rev 6916, trunk/theme/src/main/org/jboss/portal/theme/PageRendition.java)
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PageRendition.java (rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PageRendition.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -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.theme.page;
+
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.theme.page.PageService;
+import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.theme.page.WindowContext;
+import org.jboss.portal.theme.render.RenderContext;
+import org.jboss.portal.theme.render.PageRenderer;
+import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.PortalLayout;
+import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MarkupInfo;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PageRendition
+{
+
+ /** . */
+ private PortalLayout layout;
+
+ /** . */
+ private PageResult pageResult;
+
+ /** . */
+ private PageService pageService;
+
+ public PageRendition(PortalLayout layout, PageResult markupResult, PageService pageService)
+ {
+ this.layout = layout;
+ this.pageResult = markupResult;
+ this.pageService = pageService;
+ }
+
+ /** Performs the page rendition. */
+ public void render(ServerInvocation invocation) throws IOException, ServletException
+ {
+ //
+ HttpServletRequest clientRequest = invocation.getServerContext().getClientRequest();
+
+
+ //
+
+
+ try
+ {
+
+ // Place a reference to the theme service into the request so that the theme tag can get to a theme via a theme
+ // name (specified as tag attribute); this is useful if no theme was defined for the portal or the page
+ clientRequest.setAttribute(ThemeConstants.ATTR_THEMESERVER, pageService.getThemeService());
+ clientRequest.setAttribute(ThemeConstants.ATTR_THEME, pageResult.getTheme());
+ clientRequest.setAttribute(ThemeConstants.ATTR_THEMERESULT, pageResult.getThemeResult());
+
+ MarkupInfo markupInfo = (MarkupInfo)invocation.getResponse().getContentInfo();
+
+ RenderContext renderContext = layout.getRenderContext(markupInfo, invocation);
+
+
+ renderContext.render(pageResult);
+
+ }
+ catch (RenderException e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ clientRequest.removeAttribute(ThemeConstants.ATTR_THEMESERVER);
+ }
+ }
+
+ public PageResult getPageResult()
+ {
+ return pageResult;
+ }
+}
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -25,6 +25,7 @@
import org.jboss.portal.theme.render.PortalRenderSet;
import org.jboss.portal.theme.render.PageRenderContext;
import org.jboss.portal.theme.render.RegionRenderContext;
+import org.jboss.portal.theme.render.WindowRenderContext;
import org.jboss.portal.theme.ThemeResult;
import org.jboss.portal.theme.PortalTheme;
@@ -181,34 +182,18 @@
return windowContexts.keySet();
}
-// /**
-// * Get the <code>WindowResult</code> for a specific portlet window.
-// *
-// * @param windowId the window id identifying the portlet window to get the window result for
-// * @return the window result for the provided window id
-// */
-// public WindowResult getWindowResult(Object windowId)
-// {
-// return (WindowResult)results.get(windowId);
-// }
+ public WindowRenderContext getWindow(String windowId)
+ {
+ return getWindowContext(windowId);
+ }
-// /**
-// * Get a map of <code>WindowResult</code>s keyed by window id
-// *
-// * @return a map of window results
-// */
-// public Map getWindowResultMap()
-// {
-// return results;
-// }
-
/**
* Get the <code>WindowContext</code> for the provided window id.
*
* @param windowId the window id identifying the portlet to get the context for
* @return the window context for the provided window id
*/
- public WindowContext getWindowContext(Object windowId)
+ public WindowContext getWindowContext(String windowId)
{
return (WindowContext)windowContexts.get(windowId);
}
@@ -233,15 +218,6 @@
this.layoutState = layoutState;
}
-// public void addWindowResult(Object windowId, WindowResult result)
-// {
-// if (!windowContexts.keySet().contains(windowId))
-// {
-// throw new IllegalArgumentException("there was no window added for this window:" + windowId);
-// }
-// results.put(windowId, result);
-// }
-
public void addWindowContext(WindowContext windowContext)
{
windowContexts.put(windowContext.getId(), windowContext);
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/PortletRenderContextImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PortletRenderContextImpl.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PortletRenderContextImpl.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -32,16 +32,16 @@
public class PortletRenderContextImpl implements PortletRenderContext
{
- final WindowRenderContextImpl wrc;
+ final WindowContext wrc;
- public PortletRenderContextImpl(WindowRenderContextImpl wrc)
+ public PortletRenderContextImpl(WindowContext wrc)
{
this.wrc = wrc;
}
public String getMarkup()
{
- return wrc.context.result.getContent();
+ return wrc.result.getContent();
}
public String getProperty(String name)
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -23,7 +23,6 @@
package org.jboss.portal.theme.page;
import org.jboss.portal.theme.render.RegionRenderContext;
-import org.jboss.portal.theme.render.WindowRenderContext;
import org.jboss.portal.theme.Orientation;
import java.util.ArrayList;
@@ -32,7 +31,6 @@
import java.util.List;
import java.util.Map;
import java.util.Collection;
-import java.util.Iterator;
/**
* A region on a page. <p>A region wraps one or more portlets to allow them to act as one unit inside the layout of a
@@ -146,14 +144,7 @@
public Collection getWindows()
{
- ArrayList wrcs = new ArrayList(windows.size());
- for (Iterator i = windows.iterator(); i.hasNext();)
- {
- WindowContext wc = (WindowContext)i.next();
- WindowRenderContext wrc = new WindowRenderContextImpl(this, wc);
- wrcs.add(wrc);
- }
- return wrcs;
+ return windows;
}
public Orientation getOrientation()
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -22,6 +22,12 @@
******************************************************************************/
package org.jboss.portal.theme.page;
+import org.jboss.portal.theme.render.WindowRenderContext;
+import org.jboss.portal.theme.render.DecorationRenderContext;
+import org.jboss.portal.theme.render.PortletRenderContext;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+
import java.io.Serializable;
/**
@@ -33,7 +39,7 @@
* @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
* @version $Revision$
*/
-public final class WindowContext implements Comparable, Serializable
+public final class WindowContext implements Comparable, Serializable, WindowRenderContext
{
/** The serialVersionUID */
@@ -45,6 +51,12 @@
/** . */
private final String name;
+ /** . */
+ private final DecorationRenderContextImpl decoration = new DecorationRenderContextImpl(this);
+
+ /** . */
+ private final PortletRenderContextImpl portlet = new PortletRenderContextImpl(this);
+
// Mutable properties
/** . */
@@ -70,26 +82,51 @@
return name;
}
- public Object getId()
+ public String getId()
{
return id;
}
+ public int getOrder()
+ {
+ return order;
+ }
+
public String getRegionName()
{
return regionName;
}
- public void setRegionName(String regionName)
+ public WindowState getWindowState()
{
- this.regionName = regionName;
+ return result.getWindowState();
}
- public int getOrder()
+ public Mode getMode()
{
- return order;
+ return result.getMode();
}
+ public DecorationRenderContext getDecoration()
+ {
+ return decoration;
+ }
+
+ public PortletRenderContext getPortlet()
+ {
+ return portlet;
+ }
+
+ public String getProperty(String name)
+ {
+ return (String)result.getWindowProperties().get(name);
+ }
+
+ public void setRegionName(String regionName)
+ {
+ this.regionName = regionName;
+ }
+
public void setOrder(int order)
{
this.order = order;
Deleted: trunk/theme/src/main/org/jboss/portal/theme/page/WindowRenderContextImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/WindowRenderContextImpl.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/WindowRenderContextImpl.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -1,83 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.theme.page;
-
-import org.jboss.portal.theme.render.WindowRenderContext;
-import org.jboss.portal.theme.render.DecorationRenderContext;
-import org.jboss.portal.theme.render.PortletRenderContext;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.Mode;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class WindowRenderContextImpl implements WindowRenderContext
-{
-
- final Region region;
- final WindowContext context;
- private final DecorationRenderContextImpl drc = new DecorationRenderContextImpl(this);
- private final PortletRenderContextImpl prc = new PortletRenderContextImpl(this);
-
- public WindowRenderContextImpl(Region region, WindowContext context)
- {
- this.region = region;
- this.context = context;
- }
-
- public String getId()
- {
- return context.getId().toString();
- }
-
- public int getOrder()
- {
- return context.getOrder();
- }
-
- public WindowState getWindowState()
- {
- return context.result.getWindowState();
- }
-
- public Mode getMode()
- {
- return context.result.getMode();
- }
-
- public DecorationRenderContext getDecoration()
- {
- return drc;
- }
-
- public PortletRenderContext getPortlet()
- {
- return prc;
- }
-
- public String getProperty(String name)
- {
- return (String)context.result.getWindowProperties().get(name);
- }
-}
Modified: trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -33,4 +33,6 @@
Collection getRegions();
RegionRenderContext getRegion(String regionName);
+
+ WindowRenderContext getWindow(String windowId);
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java 2007-04-04 12:25:59 UTC (rev 6916)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -24,9 +24,7 @@
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.theme.LayoutInfo;
-import org.jboss.portal.theme.PortalLayout;
-import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.server.ServerInvocation;
import java.util.ArrayList;
import java.util.Map;
@@ -44,15 +42,13 @@
{
/** . */
- private PortalRenderSet renderSet;
+// private PortalRenderSet renderSet;
+ private RendererFactory rendererFactory;
/** . */
- private PageRenderContext pageRenderContext;
+ private ServerInvocation serverInvocation;
/** . */
- private PortalLayout layout;
-
- /** . */
private StringBuffer markup;
/** . */
@@ -67,49 +63,36 @@
/**
* Create a new render context for the provided result. <p>The result contains information about the markup container
* (page, region , window context) to render.</p>
- *
- * @param layout the layout that is used for this render context
- * @param markupInfo information about the content type and encoding to use when writing the response
- * @param pageRenderContext the rendered result(s) from the portlet container (PageResult, RegionResult, WindowResult)
*/
- public RenderContext(PortalLayout layout, MarkupInfo markupInfo, PageRenderContext pageRenderContext)
+ public RenderContext(
+ RendererFactory rendererFactory,
+ ServerInvocation serverInvocation,
+ MarkupInfo markupInfo)
{
- if (layout == null)
+ if (rendererFactory == null)
{
- throw new IllegalArgumentException("no layout provided");
+ throw new IllegalArgumentException("no renderer factory provided");
}
+ if (serverInvocation == null)
+ {
+ throw new IllegalArgumentException("no server invocation provided");
+ }
if (markupInfo == null)
{
throw new IllegalArgumentException("no stream info provided");
}
- if (pageRenderContext == null)
- {
- throw new IllegalArgumentException("no result provided");
- }
- // Find a valid render set
- String renderSetName = pageRenderContext.getProperty(ThemeConstants.PORTAL_PROP_RENDERSET);
- if (renderSetName == null)
- {
- throw new IllegalArgumentException("No RenderSet determined");
- }
- PortalRenderSet renderSet = layout.getServiceInfo().getRenderSet(layout.getLayoutInfo(), markupInfo, renderSetName);
- if (renderSet == null)
- {
- throw new IllegalArgumentException("No RenderSet determined for " + renderSetName);
- }
-
- //
- this.renderSet = renderSet;
- this.layout = layout;
- this.pageRenderContext = pageRenderContext;
+ this.rendererFactory = rendererFactory;
+ this.serverInvocation = serverInvocation;
this.markupInfo = markupInfo;
this.stack = new ArrayList(6);
this.markup = new StringBuffer();
this.attributes = new HashMap();
+ }
- //
- this.stack.add(this.pageRenderContext);
+ public ServerInvocation getServerInvocation()
+ {
+ return serverInvocation;
}
public StringBuffer getMarkupFragment()
@@ -117,6 +100,11 @@
return markup;
}
+ public MarkupInfo getMarkupInfo()
+ {
+ return markupInfo;
+ }
+
public MediaType getContentType()
{
return markupInfo.getContentType();
@@ -127,11 +115,6 @@
return markupInfo.getCharset();
}
- public LayoutInfo getLayoutInfo()
- {
- return layout.getLayoutInfo();
- }
-
public Object getAttribute(String attrName)
{
if (attrName == null)
@@ -171,154 +154,39 @@
return null;
}
- public RegionRenderer getRegionRenderer(RegionRenderContext result)
+ public void pushObjectRenderContext(ObjectRenderContext ctx)
{
- return renderSet.getRegionRenderer();
+ stack.add(ctx);
}
- /**
- * Get the window renderer for the provided window. <p>The window result can optionally contain a window property
- * that points to a render set to use when getting the window renderer. If no window property was provided, then the
- * default render set of this context will be used.</p>
- *
- * @param result the window result possibly containing the window property that specifies an alternative render set
- * name for the window renderer to use
- * @return a window renderer
- */
- public WindowRenderer getWindowRenderer(WindowRenderContext result)
+ public ObjectRenderContext popObjectRenderContext()
{
- String renderSetName = null;
- if (result != null)
- {
- renderSetName = result.getProperty(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER);
- }
-
- //
- if (result != null && renderSetName == null)
- {
- renderSetName = getProperty(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER);
- }
-
- //
- if (renderSetName != null)
- {
- PortalRenderSet renderSet = layout.getServiceInfo().getRenderSet(renderSetName, markupInfo.getContentType());
-
- //
- if (renderSet != null)
- {
- return renderSet.getWindowRenderer();
- }
- }
-
- //
- return renderSet.getWindowRenderer();
+ return (ObjectRenderContext)stack.remove(stack.size() - 1);
}
- /**
- * Get the decoration renderer for the window that the provided window result is associated with. <p>If the window
- * result contains a window property that points to a render set, that render set will be used to determine the
- * decoration renderer. Otherwise, the render set that was determined for this context will be used.</p>
- *
- * @param result the window result possibly containing the window property that specifies an alternative render set
- * name for the decoration renderer to use
- * @return a decoration renderer
- */
- public DecorationRenderer getDecorationRenderer(DecorationRenderContext result)
- {
- String renderSetName = null;
-
- if (result != null)
- {
- renderSetName = result.getProperty(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER);
- }
-
- //
- if (result != null && renderSetName == null)
- {
- renderSetName = getProperty(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER);
- }
-
- //
- if (renderSetName != null)
- {
- PortalRenderSet renderSet = layout.getServiceInfo().getRenderSet(renderSetName, markupInfo.getContentType());
-
- //
- if (renderSet != null)
- {
- return renderSet.getDecorationRenderer();
- }
- }
-
- //
- return renderSet.getDecorationRenderer();
- }
-
- /**
- * Get the portlet renderer for the render set defined in the window properties that were provided. <p>If the
- * provided window result doesn't contain any window property that defines a render set name, the default render set
- * that was determined for this context will be used to get the portlet renderer.</p>
- *
- * @param result the window result containing the window properties to introspect for a render set name to get the
- * portlet renderer from
- * @return a portlet renderer
- */
- public PortletRenderer getPortletRenderer(PortletRenderContext result)
- {
- String renderSetName = null;
-
- //
- if (result != null)
- {
- renderSetName = result.getProperty(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER);
- }
-
- //
- if (result != null && renderSetName == null)
- {
- renderSetName = getProperty(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER);
- }
-
- //
- if (renderSetName != null)
- {
- PortalRenderSet renderSet = layout.getServiceInfo().getRenderSet(renderSetName, markupInfo.getContentType());
-
- //
- if (renderSet != null)
- {
- return renderSet.getPortletRenderer();
- }
- }
-
- //
- return renderSet.getPortletRenderer();
- }
-
- public void render() throws RenderException
- {
- render(pageRenderContext);
- }
-
-
public void render(ObjectRenderContext ctx) throws RenderException
{
- stack.add(ctx);
+ pushObjectRenderContext(ctx);
//
try
{
+ if (ctx instanceof PageRenderContext)
+ {
+ PageRenderContext prc = (PageRenderContext)ctx;
+ PageRenderer renderer = (PageRenderer)rendererFactory.getRenderer(this, prc);
+ renderer.render(this, prc);
+ }
if (ctx instanceof WindowRenderContext)
{
WindowRenderContext wrc = (WindowRenderContext)ctx;
- WindowRenderer renderer = getWindowRenderer(wrc);
+ WindowRenderer renderer = (WindowRenderer)rendererFactory.getRenderer(this, wrc);
renderer.render(this, wrc);
}
else if (ctx instanceof RegionRenderContext)
{
RegionRenderContext rrc = (RegionRenderContext)ctx;
- RegionRenderer renderer = getRegionRenderer(rrc);
+ RegionRenderer renderer = (RegionRenderer)rendererFactory.getRenderer(this, rrc);
//
renderer.renderHeader(this, rrc);
@@ -328,13 +196,13 @@
else if (ctx instanceof PortletRenderContext)
{
PortletRenderContext prc = (PortletRenderContext)ctx;
- PortletRenderer renderer = getPortletRenderer(prc);
+ PortletRenderer renderer = (PortletRenderer)rendererFactory.getRenderer(this, prc);
renderer.render(this, prc);
}
else if (ctx instanceof DecorationRenderContext)
{
DecorationRenderContext drc = (DecorationRenderContext)ctx;
- DecorationRenderer renderer = getDecorationRenderer(drc);
+ DecorationRenderer renderer = (DecorationRenderer)rendererFactory.getRenderer(this, drc);
//
renderer.render(this, drc);
@@ -342,7 +210,7 @@
}
finally
{
- stack.remove(stack.size() - 1);
+ popObjectRenderContext();
}
}
}
\ No newline at end of file
Added: trunk/theme/src/main/org/jboss/portal/theme/render/RendererFactory.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/RendererFactory.java (rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/RendererFactory.java 2007-04-04 16:14:41 UTC (rev 6917)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.theme.render;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface RendererFactory
+{
+
+ ObjectRenderer getRenderer(RenderContext renderContext, ObjectRenderContext objectRenderContext);
+
+}
17 years, 3 months
JBoss Portal SVN: r6916 - in trunk: core/src/main/org/jboss/portal/core/controller/ajax and 10 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-04 08:25:59 -0400 (Wed, 04 Apr 2007)
New Revision: 6916
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
trunk/theme/src/main/org/jboss/portal/theme/PageRendition.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/page/DecorationRenderContextImpl.java
trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
trunk/theme/src/main/org/jboss/portal/theme/page/PortletRenderContextImpl.java
trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java
trunk/theme/src/main/org/jboss/portal/theme/page/WindowRenderContextImpl.java
trunk/theme/src/main/org/jboss/portal/theme/tag/HeaderContentTagHandler.java
Log:
- make a real 1-1 relationship between windowresult and windowcontext for the sake of simplicity
- fix the window DnD partially
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -119,9 +119,8 @@
windowProps.put(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER, "emptyRenderer");
windowProps.put(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER, "emptyRenderer");
WindowResult res = new WindowResult("", tabbedNav.toString(), Collections.EMPTY_MAP, windowProps, null, null, WindowState.NORMAL, Mode.VIEW);
- WindowContext blah = new WindowContext("BLAH", "BLAH", "navigation", 0);
+ WindowContext blah = new WindowContext("BLAH", "BLAH", "navigation", 0, res);
rendition.getPageResult().addWindowContext(blah);
- rendition.getPageResult().addWindowResult("BLAH", res);
//
Region region = rendition.getPageResult().getRegion2("navigation");
@@ -138,9 +137,8 @@
windowProps.put(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER, "emptyRenderer");
windowProps.put(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER, "emptyRenderer");
WindowResult res = new WindowResult("", dashboardNav.toString(), Collections.EMPTY_MAP, windowProps, null, null, WindowState.NORMAL, Mode.VIEW);
- WindowContext bluh = new WindowContext("BLUH", "BLUH", "dashboardnav", 0);
+ WindowContext bluh = new WindowContext("BLUH", "BLUH", "dashboardnav", 0, res);
rendition.getPageResult().addWindowContext(bluh);
- rendition.getPageResult().addWindowResult("BLUH", res);
//
Region region = rendition.getPageResult().getRegion2("dashboardnav");
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 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -128,7 +128,7 @@
int toPosInt = Integer.parseInt(toPos);
//
- PortalObjectId tmp = PortalObjectId.parse(windowId, PortalObjectId.CANONICAL_FORMAT);
+ PortalObjectId tmp = PortalObjectId.parse(windowId, PortalObjectId.LEGACY_BASE64_FORMAT);
//
try
Modified: trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -109,9 +109,8 @@
//
WindowResult res = new WindowResult("", content, Collections.EMPTY_MAP, windowProps, null, null, WindowState.NORMAL, Mode.VIEW);
- WindowContext blah = new WindowContext("BILTO", "BILTO", "maximized", 0);
+ WindowContext blah = new WindowContext("BILTO", "BILTO", "maximized", 0, res);
result.addWindowContext(blah);
- result.addWindowResult("BILTO", res);
//
result.setLayoutState("maximized");
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -234,9 +234,13 @@
WindowResult result = (WindowResult)res;
String region = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION);
String order = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER);
- WindowContext wc = new WindowContext(window.getName(), window.getName(), region, Integer.parseInt(order));
+ WindowContext wc = new WindowContext(
+ window.getName(),
+ window.getId().toString(PortalObjectId.LEGACY_BASE64_FORMAT),
+ region,
+ Integer.parseInt(order),
+ result);
pageResult.addWindowContext(wc);
- pageResult.addWindowResult(window.getName(), result);
}
else
{
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 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-04 12:25:59 UTC (rev 6916)
@@ -902,7 +902,7 @@
<!-- The core controller -->
<mbean
code="org.jboss.portal.core.controller.classic.ClassicController"
- name="portal:controller=Core"
+ name="portal:controller=Classic"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
@@ -980,7 +980,7 @@
<xmbean/>
<depends
optional-attribute-name="ClassicController"
- proxy-type="attribute">portal:controller=Core</depends>
+ proxy-type="attribute">portal:controller=Classic</depends>
<depends
optional-attribute-name="AjaxController"
proxy-type="attribute">portal:controller=Ajax</depends>
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-04-04 12:25:59 UTC (rev 6916)
@@ -1,5 +1,6 @@
function sendData(action, windowId, fromPos, fromRegionId, toPos, toRegionId) {
var options = {
+ requestHeaders: ["ajax","true"],
method: "post",
postBody: "action=" + action + "&windowId=" + windowId + "&fromPos=" + fromPos + "&fromRegion=" + fromRegionId + "&toPos=" + toPos + "&toRegion=" + toRegionId,
onSuccess: function(t)
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -150,11 +150,10 @@
String title = "WindowA_" + i + " Title";
String content = "<p>WindowA_" + i + " Content</p>";
- WindowContext wCtx = new WindowContext("WindowA_" + i + "_Name", "WindowA_" + i, "left", i);
+ WindowContext wCtx = new WindowContext("WindowA_" + i + "_Name", "WindowA_" + i, "left", i, createWindowMarkup(title, content));
pageResult.addWindowContext(wCtx);
- pageResult.addWindowResult(wCtx.getId(), createWindowMarkup(title, content, wCtx, portalProps, pageProps));
- markupResult = createWindowMarkup(title, content, wCtx, portalProps, pageProps);
+ markupResult = createWindowMarkup(title, content);
assertEquals(markupResult.getContent(), content);
assertEquals(markupResult.getTitle(), title);
@@ -164,11 +163,10 @@
String title = "WindowB_" + i + " Title";
String content = "<p>WindowB_" + i + " Content</p>";
- WindowContext wCtx = new WindowContext("WindowB_" + i + "_Name", "WindowB_" + i, "center", i);
+ WindowContext wCtx = new WindowContext("WindowB_" + i + "_Name", "WindowB_" + i, "center", i, createWindowMarkup(title, content));
pageResult.addWindowContext(wCtx);
- pageResult.addWindowResult(wCtx.getId(), createWindowMarkup(title, content, wCtx, portalProps, pageProps));
- markupResult = createWindowMarkup(title, content, wCtx, portalProps, pageProps);
+ markupResult = createWindowMarkup(title, content);
assertEquals(markupResult.getContent(), content);
assertEquals(markupResult.getTitle(), title);
@@ -203,10 +201,9 @@
*
* @param sTitle
* @param sContent
- * @param wCtx
* @return window markup result
*/
- private WindowResult createWindowMarkup(String sTitle, String sContent, WindowContext wCtx, Map portalProps, Map pageProps)
+ private WindowResult createWindowMarkup(String sTitle, String sContent)
{
return new WindowResult(sTitle, sContent, Collections.EMPTY_MAP, new HashMap(), null, null, null, null);
}
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -117,15 +117,13 @@
// create window ctx/results and add to page result
for (int i = 0; i < LEFT_WINDOWS; i++)
{
- WindowContext wCtx = new WindowContext("WindowA_" + i, "WindowA_" + i, "left", i);
+ WindowContext wCtx = new WindowContext("WindowA_" + i, "WindowA_" + i, "left", i, createWindowMarkup("WindowA_" + i + " Title", "<p>WindowA_" + i + " Content</p>"));
pageResult.addWindowContext(wCtx);
- pageResult.addWindowResult(wCtx.getId(), createWindowMarkup("WindowA_" + i + " Title", "<p>WindowA_" + i + " Content</p>", wCtx, portalProps, pageProps));
}
for (int i = 0; i < CENTER_WINDOWS; i++)
{
- WindowContext wCtx = new WindowContext("WindowB_" + i, "WindowB_" + i, "center", i);
+ WindowContext wCtx = new WindowContext("WindowB_" + i, "WindowB_" + i, "center", i, createWindowMarkup("WindowB_" + i + " Title", "<p>WindowB_" + i + " Content</p>"));
pageResult.addWindowContext(wCtx);
- pageResult.addWindowResult(wCtx.getId(), createWindowMarkup("WindowB_" + i + " Title", "<p>WindowB_" + i + " Content</p>", wCtx, portalProps, pageProps));
}
// set the renderctx and req/res attr
@@ -146,10 +144,9 @@
*
* @param sTitle
* @param sContent
- * @param wCtx
* @return window markup result
*/
- private WindowResult createWindowMarkup(String sTitle, String sContent, WindowContext wCtx, Map portalProps, Map pageProps)
+ private WindowResult createWindowMarkup(String sTitle, String sContent)
{
return new WindowResult(sTitle, sContent, Collections.EMPTY_MAP, new HashMap(), null, null, null, null);
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/PageRendition.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/PageRendition.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/theme/src/main/org/jboss/portal/theme/PageRendition.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -34,8 +34,6 @@
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -72,7 +70,8 @@
for (Iterator i = pageResult.getWindowIds().iterator();i.hasNext();)
{
Object windowId = i.next();
- WindowResult res = pageResult.getWindowResult(windowId);
+ WindowContext wc = pageResult.getWindowContext(windowId);
+ WindowResult res = wc.getResult();
if (WindowState.MAXIMIZED.equals(res.getWindowState()))
{
// TODO: Deep clone instead ?
@@ -88,14 +87,7 @@
WindowContext windowContext = (WindowContext)setIterator.next();
newRes.addWindowContext(windowContext);
}
- Map map = pageResult.getWindowResultMap();
- Iterator keyIterator = map.keySet().iterator();
- while (keyIterator.hasNext())
- {
- Object key = keyIterator.next();
- newRes.addWindowResult(key, (WindowResult)map.get(key));
- }
-
+
//
WindowContext ctx = pageResult.getWindowContext(windowId);
@@ -109,7 +101,6 @@
//
newRes.addWindowContext(ctx);
- newRes.addWindowResult(windowId, res);
//
pageResult = newRes;
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -61,7 +61,7 @@
//
StringBuffer out = renderContext.getMarkupFragment();
- out.append("<div class=\"dyna-window").append("\"><div class=\"").append(wrc.getId()).append("\"/>\n");
+ out.append("<div id=\"").append(wrc.getId()).append("\" class=\"dyna-window\"><div class=\"").append(wrc.getId()).append("\"/>\n");
delegate.render(renderContext, wrc);
out.append("</div></div>\n");
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/DecorationRenderContextImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/DecorationRenderContextImpl.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/DecorationRenderContextImpl.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -47,12 +47,12 @@
public String getTitle()
{
- return wrc.result.getTitle();
+ return wrc.context.result.getTitle();
}
public Collection getTriggerableActions(String familyName)
{
- return wrc.result.getTriggerableActions(familyName);
+ return wrc.context.result.getTriggerableActions(familyName);
}
public String getProperty(String name)
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -181,26 +181,26 @@
return windowContexts.keySet();
}
- /**
- * Get the <code>WindowResult</code> for a specific portlet window.
- *
- * @param windowId the window id identifying the portlet window to get the window result for
- * @return the window result for the provided window id
- */
- public WindowResult getWindowResult(Object windowId)
- {
- return (WindowResult)results.get(windowId);
- }
+// /**
+// * Get the <code>WindowResult</code> for a specific portlet window.
+// *
+// * @param windowId the window id identifying the portlet window to get the window result for
+// * @return the window result for the provided window id
+// */
+// public WindowResult getWindowResult(Object windowId)
+// {
+// return (WindowResult)results.get(windowId);
+// }
- /**
- * Get a map of <code>WindowResult</code>s keyed by window id
- *
- * @return a map of window results
- */
- public Map getWindowResultMap()
- {
- return results;
- }
+// /**
+// * Get a map of <code>WindowResult</code>s keyed by window id
+// *
+// * @return a map of window results
+// */
+// public Map getWindowResultMap()
+// {
+// return results;
+// }
/**
* Get the <code>WindowContext</code> for the provided window id.
@@ -233,14 +233,14 @@
this.layoutState = layoutState;
}
- public void addWindowResult(Object windowId, WindowResult result)
- {
- if (!windowContexts.keySet().contains(windowId))
- {
- throw new IllegalArgumentException("there was no window added for this window:" + windowId);
- }
- results.put(windowId, result);
- }
+// public void addWindowResult(Object windowId, WindowResult result)
+// {
+// if (!windowContexts.keySet().contains(windowId))
+// {
+// throw new IllegalArgumentException("there was no window added for this window:" + windowId);
+// }
+// results.put(windowId, result);
+// }
public void addWindowContext(WindowContext windowContext)
{
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/PortletRenderContextImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PortletRenderContextImpl.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PortletRenderContextImpl.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -41,7 +41,7 @@
public String getMarkup()
{
- return wrc.result.getContent();
+ return wrc.context.result.getContent();
}
public String getProperty(String name)
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -150,8 +150,7 @@
for (Iterator i = windows.iterator(); i.hasNext();)
{
WindowContext wc = (WindowContext)i.next();
- WindowResult wr = page.getWindowResult(wc.getId());
- WindowRenderContext wrc = new WindowRenderContextImpl(this, wc, wr);
+ WindowRenderContext wrc = new WindowRenderContextImpl(this, wc);
wrcs.add(wrc);
}
return wrcs;
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -40,10 +40,10 @@
private static final long serialVersionUID = -225656969004976637L;
/** . */
- private final Object windowId;
+ private final String id;
/** . */
- private final String windowName;
+ private final String name;
// Mutable properties
@@ -53,22 +53,26 @@
/** . */
private int order;
- public WindowContext(String windowName, String windowId, String regionName, int order)
+ /** . */
+ final WindowResult result;
+
+ public WindowContext(String name, String id, String regionName, int order, WindowResult result)
{
- this.windowName = windowName;
- this.windowId = windowId;
+ this.name = name;
+ this.id = id;
this.regionName = regionName;
this.order = order;
+ this.result = result;
}
- public String getWindowName()
+ public String getName()
{
- return windowName;
+ return name;
}
public Object getId()
{
- return windowId;
+ return id;
}
public String getRegionName()
@@ -91,6 +95,11 @@
this.order = order;
}
+ public WindowResult getResult()
+ {
+ return result;
+ }
+
public int compareTo(Object o)
{
return order - ((WindowContext)o).order;
@@ -109,16 +118,16 @@
final WindowContext that = (WindowContext)o;
- return windowId.equals(that.windowId);
+ return id.equals(that.id);
}
public int hashCode()
{
- return windowId.hashCode();
+ return id.hashCode();
}
public String toString()
{
- return windowName + " " + windowId + " " + regionName + " " + order;
+ return name + " " + id + " " + regionName + " " + order;
}
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/WindowRenderContextImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/WindowRenderContextImpl.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/WindowRenderContextImpl.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -37,15 +37,13 @@
final Region region;
final WindowContext context;
- final WindowResult result;
private final DecorationRenderContextImpl drc = new DecorationRenderContextImpl(this);
private final PortletRenderContextImpl prc = new PortletRenderContextImpl(this);
- public WindowRenderContextImpl(Region region, WindowContext context, WindowResult result)
+ public WindowRenderContextImpl(Region region, WindowContext context)
{
this.region = region;
this.context = context;
- this.result = result;
}
public String getId()
@@ -60,12 +58,12 @@
public WindowState getWindowState()
{
- return result.getWindowState();
+ return context.result.getWindowState();
}
public Mode getMode()
{
- return result.getMode();
+ return context.result.getMode();
}
public DecorationRenderContext getDecoration()
@@ -80,6 +78,6 @@
public String getProperty(String name)
{
- return (String)result.getWindowProperties().get(name);
+ return (String)context.result.getWindowProperties().get(name);
}
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/HeaderContentTagHandler.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/HeaderContentTagHandler.java 2007-04-04 11:38:41 UTC (rev 6915)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/HeaderContentTagHandler.java 2007-04-04 12:25:59 UTC (rev 6916)
@@ -26,6 +26,7 @@
import org.jboss.portal.theme.LayoutConstants;
import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.theme.page.WindowContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
@@ -64,11 +65,11 @@
return;
}
- Map results = page.getWindowResultMap();
- for (Iterator i = results.keySet().iterator(); i.hasNext();)
+ Map results = page.getWindowContextMap();
+ for (Iterator i = results.values().iterator(); i.hasNext();)
{
- Object windowId = i.next();
- WindowResult result = page.getWindowResult(windowId);
+ WindowContext wc = (WindowContext)i.next();
+ WindowResult result = wc.getResult();
Properties responseProperties = result.getResponseProperties();
if (responseProperties != null)
17 years, 3 months