portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r331172 - /portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
Date Mon, 07 Nov 2005 01:09:36 GMT
Author: ate
Date: Sun Nov  6 17:09:29 2005
New Revision: 331172

URL: http://svn.apache.org/viewcvs?rev=331172&view=rev
Log:
If a Portlet doesn't handle (ActionRequest) exceptions, propagate them back to the portlet
container, as required by the Portlet API/Specs.
See for example: PLT.12.2.2. 
Setting the PortletMode after a redirect is requested leads to an IllegalStateException.
If that exceptions isn't handled, the redirect may *not* be executed.
The JetspeedContainerServlet trapped and surpressed these exceptions.
The Portlet Container as result didn't know anything about what happened and executed the
redirect.

Modified:
    portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java

Modified: portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java?rev=331172&r1=331171&r2=331172&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
(original)
+++ portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
Sun Nov  6 17:09:29 2005
@@ -230,39 +230,58 @@
         }
         catch (Throwable t)
         {
-            ServletContext context = getServletContext();
-            context.log(JCS + "Error rendering portlet \"" + portletName + "\": " + t.toString(),
t);
-            try
+            if (method != ContainerConstants.METHOD_ACTION)
             {
-                String errorTemplate = getInitParameter("portal.error.page");
-                if (errorTemplate == null)
+                ServletContext context = getServletContext();
+                context.log(JCS + "Error rendering portlet \"" + portletName + "\": " + t.toString(),
t);
+                try
                 {
-                    errorTemplate = "/WEB-INF/templates/generic/html/error.vm";
+                    String errorTemplate = getInitParameter("portal.error.page");
+                    if (errorTemplate == null)
+                    {
+                        errorTemplate = "/WEB-INF/templates/generic/html/error.vm";
+                    }
+                    if (null != context.getResource(errorTemplate))
+                    {
+                        RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(errorTemplate);
+                        request.setAttribute("e", t);
+                        StringWriter stackTrace = new StringWriter();
+                        t.printStackTrace(new PrintWriter(stackTrace));
+                        request.setAttribute("stacktrace", stackTrace.toString());
+                        dispatcher.include(request, response);
+                    }
+                    else
+                    {
+                        displayPortletNotAvailableMessage(t, response, portletName);
+                    }
                 }
-                if (null != context.getResource(errorTemplate))
+                catch (Throwable e)
                 {
-                    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(errorTemplate);
               
-                    request.setAttribute("e", t);
-                    StringWriter stackTrace = new StringWriter();
-                    t.printStackTrace(new PrintWriter(stackTrace));
-                    request.setAttribute("stacktrace", stackTrace.toString());
-                    dispatcher.include(request, response);
+                    displayPortletNotAvailableMessage(t, response, portletName);
                 }
-                else
+                finally
                 {
-                    if (method != ContainerConstants.METHOD_ACTION)
-                    {
-                        displayPortletNotAvailableMessage(t, response, portletName);
-                    }
+                    t.printStackTrace();
                 }
             }
-            catch (Throwable e)
+            else
             {
-                displayPortletNotAvailableMessage(t, response, portletName);            
   
-            }
-            finally
-            {
-                t.printStackTrace();
+                if ( t instanceof RuntimeException )
+                {
+                    throw (RuntimeException)t;
+                }
+                else if (t instanceof IOException )
+                {
+                    throw (IOException)t;
+                }
+                else if (t instanceof ServletException)
+                {
+                    throw (ServletException)t;
+                }
+                else
+                {
+                    throw new ServletException(t);
+                }
             }
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message