Author: julien(a)jboss.com
Date: 2007-03-20 11:57:29 -0400 (Tue, 20 Mar 2007)
New Revision: 6777
Removed:
trunk/core/src/main/org/jboss/portal/core/WindowManipulator.java
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/HTTPResponse.java
Log:
defer page assembly to the ClassicController.sendResponse(...) by providing a custom
subclass of HTTPResponse which activate the PageRendition from the theme.
Deleted: trunk/core/src/main/org/jboss/portal/core/WindowManipulator.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/WindowManipulator.java 2007-03-20 15:23:56
UTC (rev 6776)
+++ trunk/core/src/main/org/jboss/portal/core/WindowManipulator.java 2007-03-20 15:57:29
UTC (rev 6777)
@@ -1,122 +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;
-
-import org.jboss.portal.common.invocation.AttributeResolver;
-import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
-import org.jboss.portal.core.model.portal.Window;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.SortedMap;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class WindowManipulator
-{
-
- private Map regionMap;
-
- private AttributeResolver navStateResolver;
-
- public WindowManipulator(AttributeResolver navStateResolver, Collection windows)
- {
- this.navStateResolver = navStateResolver;
-
- // Build appropriate structure
- regionMap = new HashMap();
- for (Iterator i = windows.iterator();i.hasNext();)
- {
- try
- {
- Window window = (Window)i.next();
- String region =
window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION);
- Integer order = new
Integer(window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER));
-
- //
- SortedMap windowMap = (SortedMap)regionMap.get(region);
- if (windowMap == null)
- {
- windowMap = new TreeMap();
- regionMap.put(region, windowMap);
- }
- windowMap.put(order, window);
- }
- catch (NumberFormatException ignore)
- {
- }
- }
- }
-
- public String getRegionName(Window window)
- {
- for (Iterator i = regionMap.entrySet().iterator();i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- SortedMap windows = (SortedMap)entry.getValue();
- for (Iterator j = windows.values().iterator();j.hasNext();)
- {
- Window window2 = (Window)j.next();
- if (window.getId().equals(window2.getId()))
- {
- return (String)entry.getKey();
- }
- }
- }
- return null;
- }
-
- public Set getRegionNames()
- {
- return regionMap.keySet();
- }
-
- public Collection getWindows(String regionName)
- {
- return ((Map)regionMap.get(regionName)).values();
- }
-
- public WindowNavigationalState getNavigationalState(Window window)
- {
- WindowNavigationalState wns =
(WindowNavigationalState)navStateResolver.getAttribute(window.getId() +
"_window");
- if (wns == null)
- {
- wns = new WindowNavigationalState();
- navStateResolver.setAttribute(window.getId() + "_window", wns);
- }
- return wns;
- }
-
- public void setNavigationalState(Window window, WindowNavigationalState windowNS)
- {
- navStateResolver.setAttribute(window.getId() + "_window", windowNS);
- }
-
-}
Modified:
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-03-20
15:23:56 UTC (rev 6776)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-03-20
15:57:29 UTC (rev 6777)
@@ -133,6 +133,10 @@
{
log.error("Cound not send http response", e);
}
+ catch (ServletException e)
+ {
+ log.error("Cound not send http response", e);
+ }
}
protected HandlerResponse executeCommand(ControllerContext ctx, ControllerCommand cmd)
throws ServerException
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-03-20
15:23:56 UTC (rev 6776)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2007-03-20
15:57:29 UTC (rev 6777)
@@ -24,6 +24,7 @@
import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.theme.PageRendition;
import org.jboss.portal.core.controller.command.response.SignOutResponse;
@@ -49,13 +50,17 @@
public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd,
Object response) throws IOException, ServletException, ServerException
{
- ServerInvocation invocation = ctx.getServerInvocation();
-
+ final ServerInvocation invocation = ctx.getServerInvocation();
if (response instanceof PageRendition)
{
- PageRendition rendition = (PageRendition)response;
- rendition.render(invocation);
- return null;
+ final PageRendition rendition = (PageRendition)response;
+ return new HTTPResponse()
+ {
+ public void sendResponse(ServerInvocationContext ctx) throws IOException,
ServletException
+ {
+ rendition.render(invocation);
+ }
+ };
}
else if (response instanceof SignOutResponse)
{
Modified: 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-03-20
15:23:56 UTC (rev 6776)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/HTTPResponse.java 2007-03-20
15:57:29 UTC (rev 6777)
@@ -27,6 +27,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletException;
import java.io.IOException;
import java.io.InputStream;
@@ -39,7 +40,7 @@
public abstract class HTTPResponse extends HandlerResponse
{
- public abstract void sendResponse(ServerInvocationContext ctx) throws IOException;
+ public abstract void sendResponse(ServerInvocationContext ctx) throws IOException,
ServletException;
public static class SetStatusCode extends HTTPResponse
{