Author: chris.laprun(a)jboss.com
Date: 2008-01-29 19:08:24 -0500 (Tue, 29 Jan 2008)
New Revision: 9639
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
Log:
- Also show errors. Next step is to extract test-dependent code.
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-30
00:05:26 UTC (rev 9638)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-30
00:08:24 UTC (rev 9639)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * 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. *
@@ -22,59 +22,61 @@
******************************************************************************/
package org.jboss.portal.portlet.test;
+import org.apache.log4j.Logger;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.util.MediaType;
+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.cache.CacheLevel;
-import org.jboss.portal.portlet.spi.ResourceInvocationContext;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.info.EventInfo;
-import org.jboss.portal.portlet.info.ParameterInfo;
-import org.jboss.portal.portlet.info.NavigationInfo;
+import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
+import org.jboss.portal.portlet.impl.spi.AbstractPortalContext;
+import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
+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.impl.spi.AbstractPortalContext;
-import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
-import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
-import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
-import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
+import org.jboss.portal.portlet.info.EventInfo;
+import org.jboss.portal.portlet.info.NavigationInfo;
+import org.jboss.portal.portlet.info.ParameterInfo;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.StateResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+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.ActionInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.EventInvocation;
-import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.invocation.response.StateResponse;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
import org.jboss.portal.web.IllegalRequestException;
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.common.util.MediaType;
-import org.jboss.portal.common.util.MultiValuedPropertyMap;
-import org.jboss.portal.common.io.IOTools;
-import org.jboss.portal.common.xml.XMLTools;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.apache.log4j.Logger;
import org.w3c.dom.Element;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.Cookie;
-import javax.servlet.ServletOutputStream;
import javax.xml.namespace.QName;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
-import java.io.PrintWriter;
-import java.io.IOException;
import java.io.Writer;
-import java.util.List;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
-import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -394,7 +396,6 @@
{
StateResponse stateResponse = (StateResponse)response;
-
// Update portlet NS
if (response instanceof UpdateNavigationalStateResponse)
{
@@ -595,7 +596,6 @@
}
/**
- *
* @param context
* @param pageProperties properties that needs to be rendered on this page
* @param pageNS
@@ -609,7 +609,8 @@
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
- List<FragmentResponse> fragments = new ArrayList<FragmentResponse>();
+ List<FragmentResponse> fragments = Collections.emptyList();
+ List<ErrorResponse> errors = Collections.emptyList();
// What we collect during the different renders
// we don't reuse the render properties argument since we want to avoid that
@@ -619,7 +620,13 @@
//
try
{
- for (Portlet portlet : context.getPortlets())
+ Collection<Portlet> portlets = context.getPortlets();
+
+ int capacity = portlets.size();
+ fragments = new ArrayList<FragmentResponse>(capacity);
+ errors = new ArrayList<ErrorResponse>(capacity);
+
+ for (Portlet portlet : portlets)
{
WindowNavigationalState windowNS =
pageNS.getWindowNavigationalState(portlet.getContext().getId());
@@ -687,6 +694,11 @@
renderProperties.append(fragmentProperties);
}
}
+ else if (response instanceof ErrorResponse)
+ {
+ ErrorResponse error = (ErrorResponse)response;
+ errors.add(error);
+ }
}
catch (PortletInvokerException e)
@@ -741,7 +753,7 @@
{
if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
{
- writer.print("<div id=\"portlet\">");
+ writer.print("<div class=\"portlet\">");
writer.print(fragment.getBuffer().getContent());
writer.print("</div>");
}
@@ -750,6 +762,14 @@
writer.print("<div/>");
}
}
+
+ for (ErrorResponse error : errors)
+ {
+ writer.print("<div class='error'>");
+ writer.print(error.toHTML());
+ writer.print("</div>");
+ }
+
writer.print("</body></html>");
}
Show replies by date