Author: julien(a)jboss.com
Date: 2008-02-05 09:21:20 -0500 (Tue, 05 Feb 2008)
New Revision: 9771
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/PageUpdateResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/PortletResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ResourceResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/PageRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/Renderer.java
Removed:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ErrorControllerResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/PageUpdate.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/RedirectControllerResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ResourceControllerResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ControllerResponseRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/PageUpdateRenderer.java
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/AbstractMarkupRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ControllerResponseRendererFactory.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ErrorResponseRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/RedirectResponseRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ResourceRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java
Log:
- reuse more the portlet response types in order to avoid to mirror them
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -23,12 +23,12 @@
package org.jboss.portal.portlet.test;
import org.jboss.portal.portlet.test.controller.response.ControllerResponse;
-import org.jboss.portal.portlet.test.controller.response.PageUpdate;
import org.jboss.portal.portlet.test.controller.PortletController;
import org.jboss.portal.portlet.test.controller2.PortletControllerContextImpl;
import org.jboss.portal.portlet.test.controller.PageNavigationalState;
import org.jboss.portal.portlet.test.controller2.ControllerResponseRendererFactory;
-import org.jboss.portal.portlet.test.controller2.ControllerResponseRenderer;
+import org.jboss.portal.portlet.test.controller2.Renderer;
+import org.jboss.portal.portlet.test.controller2.PageRenderer;
import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import javax.servlet.ServletException;
@@ -81,19 +81,16 @@
ControllerResponse response = controller.process(context.getRequest());
//
- ControllerResponseRenderer renderer =
ControllerResponseRendererFactory.getRenderer(response);
+ Renderer renderer = ControllerResponseRendererFactory.getRenderer(response);
//
renderer.render(context);
}
else
{
- PageUpdate pageUpdate = new PageUpdate(new ResponseProperties(), new
PageNavigationalState());
-
+ PageRenderer renderer = new PageRenderer(new ResponseProperties(), new
PageNavigationalState());
+
//
- ControllerResponseRenderer renderer =
ControllerResponseRendererFactory.getRenderer(pageUpdate);
-
- //
renderer.render(context);
}
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -16,7 +16,6 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.EventInvocation;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
@@ -27,9 +26,8 @@
import org.jboss.portal.portlet.test.controller.request.PortletRenderRequest;
import org.jboss.portal.portlet.test.controller.request.PortletRequest;
import org.jboss.portal.portlet.test.controller.response.ControllerResponse;
-import org.jboss.portal.portlet.test.controller.response.ErrorControllerResponse;
-import org.jboss.portal.portlet.test.controller.response.RedirectControllerResponse;
-import org.jboss.portal.portlet.test.controller.response.PageUpdate;
+import org.jboss.portal.portlet.test.controller.response.PageUpdateResponse;
+import org.jboss.portal.portlet.test.controller.response.PortletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@@ -75,12 +73,8 @@
ResponseProperties requestProperties = new ResponseProperties();
//
- if (response instanceof ErrorResponse)
+ if (response instanceof UpdateNavigationalStateResponse)
{
- return new ErrorControllerResponse((ErrorResponse)response);
- }
- else if (response instanceof UpdateNavigationalStateResponse)
- {
// Update portlet NS
UpdateNavigationalStateResponse updateResponse =
(UpdateNavigationalStateResponse)response;
updateNavigationalState(context, portletRequest.getWindowId(), updateResponse,
pageState);
@@ -145,18 +139,14 @@
// Do something here !!!!
}
}
+
+ //
+ return new PageUpdateResponse(updateResponse, requestProperties, pageState);
}
- else if (response instanceof HTTPRedirectionResponse)
- {
- return new RedirectControllerResponse((HTTPRedirectionResponse)response);
- }
else
{
- System.out.println("Not yet handled " + response);
+ return new PortletResponse(response);
}
-
- //
- return new PageUpdate(requestProperties, pageState);
}
PortletInvocationResponse invoke(PortletRequest portletRequest) throws
PortletInvokerException
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -32,16 +32,13 @@
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.portlet.invocation.ResourceInvocation;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.test.controller.request.ControllerRequest;
import
org.jboss.portal.portlet.test.controller.request.PageScopedFullPortletResourceRequest;
import org.jboss.portal.portlet.test.controller.request.PortletResourceRequest;
import
org.jboss.portal.portlet.test.controller.request.PortletScopedPortletResourceRequest;
import org.jboss.portal.portlet.test.controller.response.ControllerResponse;
-import org.jboss.portal.portlet.test.controller.response.ErrorControllerResponse;
-import org.jboss.portal.portlet.test.controller.response.ResourceControllerResponse;
+import org.jboss.portal.portlet.test.controller.response.ResourceResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -60,19 +57,7 @@
ControllerResponse processResponse(PortletResourceRequest request,
PortletInvocationResponse response) throws IOException, PortletInvokerException
{
- //
- if (response instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)response;
-
- return new ResourceControllerResponse(fragment);
- }
- else
- {
- // todo
- }
-
- return new ErrorControllerResponse(new ErrorResponse("Couldn't handle
resource request"));
+ return new ResourceResponse(response);
}
PortletInvocationResponse invoke(PortletResourceRequest portletResourceRequest) throws
PortletInvokerException
Deleted:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ErrorControllerResponse.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ErrorControllerResponse.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ErrorControllerResponse.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -1,44 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.jboss.portal.portlet.test.controller.response;
-
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class ErrorControllerResponse extends ControllerResponse
-{
-
- /** . */
- public ErrorResponse error;
-
-
- public ErrorControllerResponse(ErrorResponse error)
- {
- this.error = error;
- }
-
-}
Deleted:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/PageUpdate.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/PageUpdate.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/PageUpdate.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -1,57 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.test.controller.response;
-
-import org.jboss.portal.portlet.invocation.response.ResponseProperties;
-import org.jboss.portal.portlet.test.controller.response.ControllerResponse;
-import org.jboss.portal.portlet.test.controller.PageNavigationalState;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class PageUpdate extends ControllerResponse
-{
-
- /** . */
- private ResponseProperties properties;
-
- /** . */
- private PageNavigationalState pageState;
-
- public PageUpdate(ResponseProperties properties, PageNavigationalState pageState)
- {
- this.properties = properties;
- this.pageState = pageState;
- }
-
- public ResponseProperties getProperties()
- {
- return properties;
- }
-
- public PageNavigationalState getPageState()
- {
- return pageState;
- }
-}
Copied:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/PageUpdateResponse.java
(from rev 9770,
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/PageUpdate.java)
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/PageUpdateResponse.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/PageUpdateResponse.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.controller.response;
+
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
+import org.jboss.portal.portlet.test.controller.response.ControllerResponse;
+import org.jboss.portal.portlet.test.controller.PageNavigationalState;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PageUpdateResponse extends PortletResponse
+{
+
+ /** . */
+ private ResponseProperties properties;
+
+ /** . */
+ private PageNavigationalState pageState;
+
+ public PageUpdateResponse(
+ UpdateNavigationalStateResponse update,
+ ResponseProperties properties,
+ PageNavigationalState pageState)
+ {
+ super(update);
+
+ //
+ this.properties = properties;
+ this.pageState = pageState;
+ }
+
+ public ResponseProperties getProperties()
+ {
+ return properties;
+ }
+
+ public PageNavigationalState getPageState()
+ {
+ return pageState;
+ }
+}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/PortletResponse.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/PortletResponse.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/PortletResponse.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -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.portlet.test.controller.response;
+
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletResponse extends ControllerResponse
+{
+
+ /** . */
+ public final PortletInvocationResponse response;
+
+ public PortletResponse(PortletInvocationResponse response)
+ {
+ this.response = response;
+ }
+}
Deleted:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/RedirectControllerResponse.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/RedirectControllerResponse.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/RedirectControllerResponse.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -1,42 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.jboss.portal.portlet.test.controller.response;
-
-import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class RedirectControllerResponse extends ControllerResponse
-{
-
- /** . */
- public HTTPRedirectionResponse redirection;
-
- public RedirectControllerResponse(HTTPRedirectionResponse redirection)
- {
- this.redirection = redirection;
- }
-}
Deleted:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ResourceControllerResponse.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ResourceControllerResponse.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ResourceControllerResponse.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -1,42 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.jboss.portal.portlet.test.controller.response;
-
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class ResourceControllerResponse extends ControllerResponse
-{
-
- /** . */
- public FragmentResponse fragment;
-
- public ResourceControllerResponse(FragmentResponse fragment)
- {
- this.fragment = fragment;
- }
-}
\ No newline at end of file
Copied:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ResourceResponse.java
(from rev 9770,
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ResourceControllerResponse.java)
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ResourceResponse.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ResourceResponse.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.portlet.test.controller.response;
+
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ResourceResponse extends ControllerResponse
+{
+
+ /** . */
+ public PortletInvocationResponse response;
+
+ public ResourceResponse(PortletInvocationResponse response)
+ {
+ this.response = response;
+ }
+}
\ No newline at end of file
Property changes on:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/response/ResourceResponse.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/AbstractMarkupRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/AbstractMarkupRenderer.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/AbstractMarkupRenderer.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -35,7 +35,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public abstract class AbstractMarkupRenderer implements ControllerResponseRenderer
+public abstract class AbstractMarkupRenderer implements Renderer
{
/** . */
Deleted:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ControllerResponseRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ControllerResponseRenderer.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ControllerResponseRenderer.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -1,36 +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.portlet.test.controller2;
-
-import org.jboss.portal.portlet.test.controller.PortletControllerContext;
-
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public interface ControllerResponseRenderer
-{
- void render(PortletControllerContext context) throws IOException;
-}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ControllerResponseRendererFactory.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ControllerResponseRendererFactory.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ControllerResponseRendererFactory.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -23,10 +23,13 @@
package org.jboss.portal.portlet.test.controller2;
import org.jboss.portal.portlet.test.controller.response.ControllerResponse;
-import org.jboss.portal.portlet.test.controller.response.ErrorControllerResponse;
-import org.jboss.portal.portlet.test.controller.response.PageUpdate;
-import org.jboss.portal.portlet.test.controller.response.RedirectControllerResponse;
-import org.jboss.portal.portlet.test.controller.response.ResourceControllerResponse;
+import org.jboss.portal.portlet.test.controller.response.PageUpdateResponse;
+import org.jboss.portal.portlet.test.controller.response.ResourceResponse;
+import org.jboss.portal.portlet.test.controller.response.PortletResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -34,26 +37,51 @@
*/
public class ControllerResponseRendererFactory
{
- public static ControllerResponseRenderer getRenderer(ControllerResponse response)
+ public static Renderer getRenderer(ControllerResponse response)
{
- if (response instanceof PageUpdate)
+ if (response instanceof PageUpdateResponse)
{
- return new PageUpdateRenderer((PageUpdate)response);
+ PageUpdateResponse pageUpdate = (PageUpdateResponse)response;
+
+ //
+ return new PageRenderer(pageUpdate.getProperties(), pageUpdate.getPageState());
}
- else if (response instanceof RedirectControllerResponse)
+ else if (response instanceof PortletResponse)
{
- return new RedirectResponseRenderer((RedirectControllerResponse)response);
+ return getRenderer(((PortletResponse)response).response);
}
- else if (response instanceof ErrorControllerResponse)
+ else if (response instanceof ResourceResponse)
{
- return new ErrorResponseRenderer((ErrorControllerResponse)response);
+ ResourceResponse resourceResponse = (ResourceResponse)response;
+
+ //
+ if (resourceResponse.response instanceof FragmentResponse)
+ {
+ return new ResourceRenderer((FragmentResponse)resourceResponse.response);
+ }
+ else
+ {
+ return getRenderer(((PortletResponse)response).response);
+ }
}
- else if (response instanceof ResourceControllerResponse)
+
+ //
+ throw new IllegalArgumentException("Unknown response type: " +
response);
+ }
+
+ private static Renderer getRenderer(PortletInvocationResponse response)
+ {
+ if (response instanceof HTTPRedirectionResponse)
{
- return new ResourceRenderer((ResourceControllerResponse)response);
+ return new RedirectResponseRenderer((HTTPRedirectionResponse)response);
}
+ else if (response instanceof ErrorResponse)
+ {
+ return new ErrorResponseRenderer((ErrorResponse)response);
+ }
//
throw new IllegalArgumentException("Unknown response type: " +
response);
}
+
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ErrorResponseRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ErrorResponseRenderer.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ErrorResponseRenderer.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet.test.controller2;
-import org.jboss.portal.portlet.test.controller.response.ErrorControllerResponse;
import org.jboss.portal.portlet.test.controller.PortletControllerContext;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.apache.log4j.Logger;
import java.io.IOException;
@@ -32,33 +32,32 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class ErrorResponseRenderer implements ControllerResponseRenderer
+public class ErrorResponseRenderer implements Renderer
{
/** . */
- private static final Logger log = Logger.getLogger(ErrorControllerResponse.class);
+ private static final Logger log = Logger.getLogger(ErrorResponseRenderer.class);
/** . */
- private ErrorControllerResponse response;
+ private ErrorResponse response;
- public ErrorResponseRenderer(ErrorControllerResponse response)
+ public ErrorResponseRenderer(ErrorResponse response)
{
this.response = response;
}
public void render(PortletControllerContext context) throws IOException
{
- //
- if (response.error.getCause() != null)
+ if (response.getCause() != null)
{
- log.error("Portlet action threw an error: " +
response.error.getMessage(), response.error.getCause());
+ log.error("Portlet action threw an error: " + response.getMessage(),
response.getCause());
}
else
{
- log.error("Portlet action threw an error: " +
response.error.getMessage());
+ log.error("Portlet action threw an error: " + response.getMessage());
}
//
- context.getClientResponse().sendError(404, response.error.getMessage());
+ context.getClientResponse().sendError(404, response.getMessage());
}
}
Copied:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/PageRenderer.java
(from rev 9770,
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/PageUpdateRenderer.java)
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/PageRenderer.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/PageRenderer.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -0,0 +1,249 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.portlet.test.controller2;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MultiValuedPropertyMap;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.xml.XMLTools;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
+import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
+import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
+import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
+import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
+import org.jboss.portal.portlet.test.controller2.TestInstanceContext;
+import org.jboss.portal.portlet.test.controller.WindowNavigationalState;
+import org.jboss.portal.portlet.test.controller2.TestPortalContext;
+import org.jboss.portal.portlet.test.controller.PageNavigationalState;
+import org.jboss.portal.portlet.test.controller.PortletControllerContext;
+import org.jboss.portal.portlet.test.controller.response.PageUpdateResponse;
+import org.w3c.dom.Element;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 9748 $
+ */
+public class PageRenderer extends AbstractMarkupRenderer
+{
+
+ private FragmentRenderer fragmentRenderer = new SimpleFragmentRenderer();
+ private List<FragmentResponse> fragments;
+ private List<ErrorResponse> errors;
+ private PageNavigationalState pageState;
+
+ public PageRenderer(ResponseProperties properties, PageNavigationalState pageState)
+ {
+ super(properties);
+
+ //
+ this.pageState = pageState;
+ }
+
+ public void setFragmentRenderer(FragmentRenderer fragmentRenderer)
+ {
+ this.fragmentRenderer = fragmentRenderer;
+ }
+
+ protected void renderContent(HttpServletResponse resp) throws IOException
+ {
+ //
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+ writer.print("<html>");
+
+ // Render the head contributions
+ writer.print("<head>");
+ MultiValuedPropertyMap<Element> markupHeaders =
properties.getMarkupHeaders();
+ List<Element> headElement =
markupHeaders.getValues("javax.portlet.markup.head.element");
+ if (headElement != null)
+ {
+ for (Element headerValue : headElement)
+ {
+ try
+ {
+ String serializedElement = XMLTools.toString(headerValue);
+ writer.print(serializedElement);
+ }
+ catch (Exception e)
+ {
+ // todo
+ e.printStackTrace();
+ }
+ }
+ }
+ writer.print("</head>");
+
+
+ writer.print("<body>");
+ for (FragmentResponse fragment : fragments)
+ {
+ writer.print(fragmentRenderer.renderPortlet(fragment));
+
+ }
+
+ for (ErrorResponse error : errors)
+ {
+ writer.print(fragmentRenderer.renderError(error));
+ }
+
+ writer.print("</body></html>");
+ }
+
+ protected void prepareRendering(PortletControllerContext context)
+ {
+
+ // What we collect during the different renders
+ // we don't reuse the render properties argument since we want to avoid that
+ // a portlet rendition affects another rendition of a portlet on the same page
+ ResponseProperties renderProperties = new ResponseProperties();
+
+ //
+ try
+ {
+ Collection<Portlet> portlets =
((PortletControllerContextImpl)context).getPortlets();
+
+ int capacity = portlets.size();
+ fragments = new ArrayList<FragmentResponse>(capacity);
+ errors = new ArrayList<ErrorResponse>(capacity);
+
+ for (Portlet portlet : portlets)
+ {
+ WindowNavigationalState windowNS =
pageState.getWindowNavigationalState(portlet.getContext().getId());
+
+ //
+ Mode mode = Mode.VIEW;
+ WindowState windowState = WindowState.NORMAL;
+ StateString portletNS = null;
+
+ //
+ if (windowNS != null)
+ {
+ if (windowNS.getMode() != null)
+ {
+ mode = windowNS.getMode();
+ }
+ if (windowNS.getWindowState() != null)
+ {
+ windowState = windowNS.getWindowState();
+ }
+ if (windowNS.getPortletNavigationalState() != null)
+ {
+ portletNS = windowNS.getPortletNavigationalState();
+ }
+ }
+
+ //
+ ParameterMap publicNS =
pageState.getPublicNavigationalState(portlet.getInfo());
+
+ RenderInvocation render = createRenderInvocation(context, properties,
pageState, portlet, windowNS, mode, windowState, portletNS, publicNS);
+
+ //
+ try
+ {
+ PortletInvocationResponse response = context.invoke(render);
+
+ if (response instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)response;
+
+ //
+ fragments.add(fragment);
+
+ //
+ ResponseProperties fragmentProperties = fragment.getProperties();
+ if (fragmentProperties != null)
+ {
+ renderProperties.append(fragmentProperties);
+ }
+ }
+ else if (response instanceof ErrorResponse)
+ {
+ ErrorResponse error = (ErrorResponse)response;
+ errors.add(error);
+ }
+
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ // todo
+ e.printStackTrace();
+ }
+
+ // Now we combine the render properties with the page properties
+ properties.append(renderProperties);
+ }
+
+ protected RenderInvocation createRenderInvocation(
+ PortletControllerContext context, ResponseProperties pageProperties,
PageNavigationalState pageNS, Portlet portlet,
+ WindowNavigationalState windowNS, Mode mode, WindowState windowState, StateString
portletNS, ParameterMap publicNS)
+ {
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+
+ //
+ TestInstanceContext instanceContext = new TestInstanceContext(req,
portlet.getContext(), false);
+
+ PortletInvocationContext renderContext =
context.createPortletInvocationContext(portlet.getContext().getId(), pageNS);
+
+ //
+ RenderInvocation render = new RenderInvocation(renderContext);
+ render.setClientContext(new AbstractClientContext(req,
pageProperties.getCookies()));
+ render.setServerContext(new AbstractServerContext(req, resp));
+ render.setInstanceContext(instanceContext);
+ render.setUserContext(new AbstractUserContext(req));
+ render.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
+ render.setPortalContext(new TestPortalContext());
+ render.setSecurityContext(new AbstractSecurityContext(req));
+ render.setTarget(instanceContext.getTarget());
+ render.setMode(mode);
+ render.setWindowState(windowState);
+ render.setNavigationalState(portletNS);
+ render.setPublicNavigationalState(publicNS);
+ return render;
+ }
+}
Deleted:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/PageUpdateRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/PageUpdateRenderer.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/PageUpdateRenderer.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -1,249 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.jboss.portal.portlet.test.controller2;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.MultiValuedPropertyMap;
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.common.xml.XMLTools;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.spi.PortletInvocationContext;
-import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
-import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
-import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
-import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
-import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.ResponseProperties;
-import org.jboss.portal.portlet.test.controller2.TestInstanceContext;
-import org.jboss.portal.portlet.test.controller.WindowNavigationalState;
-import org.jboss.portal.portlet.test.controller2.TestPortalContext;
-import org.jboss.portal.portlet.test.controller.PageNavigationalState;
-import org.jboss.portal.portlet.test.controller.PortletControllerContext;
-import org.jboss.portal.portlet.test.controller.response.PageUpdate;
-import org.w3c.dom.Element;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision: 9748 $
- */
-public class PageUpdateRenderer extends AbstractMarkupRenderer
-{
-
- private FragmentRenderer fragmentRenderer = new SimpleFragmentRenderer();
- private List<FragmentResponse> fragments;
- private List<ErrorResponse> errors;
- private PageNavigationalState pageState;
-
- public PageUpdateRenderer(PageUpdate pageUpdate)
- {
- super(pageUpdate.getProperties());
-
- //
- this.pageState = pageUpdate.getPageState();
- }
-
- public void setFragmentRenderer(FragmentRenderer fragmentRenderer)
- {
- this.fragmentRenderer = fragmentRenderer;
- }
-
- protected void renderContent(HttpServletResponse resp) throws IOException
- {
- //
- resp.setContentType("text/html");
- PrintWriter writer = resp.getWriter();
- writer.print("<html>");
-
- // Render the head contributions
- writer.print("<head>");
- MultiValuedPropertyMap<Element> markupHeaders =
properties.getMarkupHeaders();
- List<Element> headElement =
markupHeaders.getValues("javax.portlet.markup.head.element");
- if (headElement != null)
- {
- for (Element headerValue : headElement)
- {
- try
- {
- String serializedElement = XMLTools.toString(headerValue);
- writer.print(serializedElement);
- }
- catch (Exception e)
- {
- // todo
- e.printStackTrace();
- }
- }
- }
- writer.print("</head>");
-
-
- writer.print("<body>");
- for (FragmentResponse fragment : fragments)
- {
- writer.print(fragmentRenderer.renderPortlet(fragment));
-
- }
-
- for (ErrorResponse error : errors)
- {
- writer.print(fragmentRenderer.renderError(error));
- }
-
- writer.print("</body></html>");
- }
-
- protected void prepareRendering(PortletControllerContext context)
- {
-
- // What we collect during the different renders
- // we don't reuse the render properties argument since we want to avoid that
- // a portlet rendition affects another rendition of a portlet on the same page
- ResponseProperties renderProperties = new ResponseProperties();
-
- //
- try
- {
- Collection<Portlet> portlets =
((PortletControllerContextImpl)context).getPortlets();
-
- int capacity = portlets.size();
- fragments = new ArrayList<FragmentResponse>(capacity);
- errors = new ArrayList<ErrorResponse>(capacity);
-
- for (Portlet portlet : portlets)
- {
- WindowNavigationalState windowNS =
pageState.getWindowNavigationalState(portlet.getContext().getId());
-
- //
- Mode mode = Mode.VIEW;
- WindowState windowState = WindowState.NORMAL;
- StateString portletNS = null;
-
- //
- if (windowNS != null)
- {
- if (windowNS.getMode() != null)
- {
- mode = windowNS.getMode();
- }
- if (windowNS.getWindowState() != null)
- {
- windowState = windowNS.getWindowState();
- }
- if (windowNS.getPortletNavigationalState() != null)
- {
- portletNS = windowNS.getPortletNavigationalState();
- }
- }
-
- //
- ParameterMap publicNS =
pageState.getPublicNavigationalState(portlet.getInfo());
-
- RenderInvocation render = createRenderInvocation(context, properties,
pageState, portlet, windowNS, mode, windowState, portletNS, publicNS);
-
- //
- try
- {
- PortletInvocationResponse response = context.invoke(render);
-
- if (response instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)response;
-
- //
- fragments.add(fragment);
-
- //
- ResponseProperties fragmentProperties = fragment.getProperties();
- if (fragmentProperties != null)
- {
- renderProperties.append(fragmentProperties);
- }
- }
- else if (response instanceof ErrorResponse)
- {
- ErrorResponse error = (ErrorResponse)response;
- errors.add(error);
- }
-
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
- }
- }
- catch (PortletInvokerException e)
- {
- // todo
- e.printStackTrace();
- }
-
- // Now we combine the render properties with the page properties
- properties.append(renderProperties);
- }
-
- protected RenderInvocation createRenderInvocation(
- PortletControllerContext context, ResponseProperties pageProperties,
PageNavigationalState pageNS, Portlet portlet,
- WindowNavigationalState windowNS, Mode mode, WindowState windowState, StateString
portletNS, ParameterMap publicNS)
- {
- HttpServletRequest req = context.getClientRequest();
- HttpServletResponse resp = context.getClientResponse();
-
- //
- TestInstanceContext instanceContext = new TestInstanceContext(req,
portlet.getContext(), false);
-
- PortletInvocationContext renderContext =
context.createPortletInvocationContext(portlet.getContext().getId(), pageNS);
-
- //
- RenderInvocation render = new RenderInvocation(renderContext);
- render.setClientContext(new AbstractClientContext(req,
pageProperties.getCookies()));
- render.setServerContext(new AbstractServerContext(req, resp));
- render.setInstanceContext(instanceContext);
- render.setUserContext(new AbstractUserContext(req));
- render.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- render.setPortalContext(new TestPortalContext());
- render.setSecurityContext(new AbstractSecurityContext(req));
- render.setTarget(instanceContext.getTarget());
- render.setMode(mode);
- render.setWindowState(windowState);
- render.setNavigationalState(portletNS);
- render.setPublicNavigationalState(publicNS);
- return render;
- }
-}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/RedirectResponseRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/RedirectResponseRenderer.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/RedirectResponseRenderer.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.test.controller2;
import org.jboss.portal.portlet.test.controller.PortletControllerContext;
-import org.jboss.portal.portlet.test.controller.response.RedirectControllerResponse;
+import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
import java.io.IOException;
@@ -31,19 +31,19 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class RedirectResponseRenderer implements ControllerResponseRenderer
+public class RedirectResponseRenderer implements Renderer
{
/** . */
- private RedirectControllerResponse response;
+ private HTTPRedirectionResponse response;
- public RedirectResponseRenderer(RedirectControllerResponse response)
+ public RedirectResponseRenderer(HTTPRedirectionResponse response)
{
this.response = response;
}
public void render(PortletControllerContext context) throws IOException
{
- context.getClientResponse().sendRedirect(response.redirection.getLocation());
+ context.getClientResponse().sendRedirect(response.getLocation());
}
}
Copied:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/Renderer.java
(from rev 9770,
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ControllerResponseRenderer.java)
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/Renderer.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/Renderer.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.controller2;
+
+import org.jboss.portal.portlet.test.controller.PortletControllerContext;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface Renderer
+{
+ void render(PortletControllerContext context) throws IOException;
+}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ResourceRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ResourceRenderer.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller2/ResourceRenderer.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -23,7 +23,6 @@
package org.jboss.portal.portlet.test.controller2;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-import org.jboss.portal.portlet.test.controller.response.ResourceControllerResponse;
import org.jboss.portal.common.io.IOTools;
import javax.servlet.http.HttpServletResponse;
@@ -41,12 +40,12 @@
/** . */
private FragmentResponse fragment;
- public ResourceRenderer(ResourceControllerResponse response)
+ public ResourceRenderer(FragmentResponse response)
{
- super(response.fragment.getProperties());
+ super(response.getProperties());
//
- this.fragment = response.fragment;
+ this.fragment = response;
}
protected void renderContent(HttpServletResponse resp) throws IOException
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java 2008-02-05
13:37:45 UTC (rev 9770)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java 2008-02-05
14:21:20 UTC (rev 9771)
@@ -26,10 +26,10 @@
import org.jboss.portal.portlet.test.controller.PageNavigationalState;
import org.jboss.portal.portlet.test.controller.PortletController;
import org.jboss.portal.portlet.test.controller.response.ControllerResponse;
-import org.jboss.portal.portlet.test.controller.response.PageUpdate;
-import org.jboss.portal.portlet.test.controller2.ControllerResponseRenderer;
+import org.jboss.portal.portlet.test.controller2.Renderer;
import org.jboss.portal.portlet.test.controller2.ControllerResponseRendererFactory;
import org.jboss.portal.portlet.test.controller2.PortletControllerContextImpl;
+import org.jboss.portal.portlet.test.controller2.PageRenderer;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -81,19 +81,16 @@
ControllerResponse response = controller.process(context.getRequest());
//
- ControllerResponseRenderer renderer =
ControllerResponseRendererFactory.getRenderer(response);
+ Renderer renderer = ControllerResponseRendererFactory.getRenderer(response);
//
renderer.render(context);
}
else
{
- PageUpdate pageUpdate = new PageUpdate(new ResponseProperties(), new
PageNavigationalState());
+ PageRenderer renderer = new PageRenderer(new ResponseProperties(), new
PageNavigationalState());
//
- ControllerResponseRenderer renderer =
ControllerResponseRendererFactory.getRenderer(pageUpdate);
-
- //
renderer.render(context);
}
}