portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r772480 - in /portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed: pipeline/valve/impl/ActionValveImpl.java request/ resource/ResourceValveImpl.java
Date Thu, 07 May 2009 00:48:32 GMT
Author: ate
Date: Thu May  7 00:48:31 2009
New Revision: 772480

URL: http://svn.apache.org/viewvc?rev=772480&view=rev
Log:
JS2-947: Properly handling container invocation errors like processAction throwing an unexcepted
exception and displaying a meaningful message to the end user
See also: https://issues.apache.org/jira/browse/JS2-947
Solving this issue by leveraging the new RequestDiagnostics feature, see JS2-992

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/ActionValveImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/request/
  (props changed)
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/resource/ResourceValveImpl.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/ActionValveImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/ActionValveImpl.java?rev=772480&r1=772479&r2=772480&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/ActionValveImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/ActionValveImpl.java
Thu May  7 00:48:31 2009
@@ -16,10 +16,8 @@
  */
 package org.apache.jetspeed.pipeline.valve.impl;
 
-import java.io.IOException;
 import java.util.Collection;
 
-import javax.portlet.PortletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -39,8 +37,9 @@
 import org.apache.jetspeed.pipeline.valve.ActionValve;
 import org.apache.jetspeed.pipeline.valve.ValveContext;
 import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.request.RequestDiagnostics;
+import org.apache.jetspeed.request.RequestDiagnosticsFactory;
 import org.apache.pluto.container.PortletContainer;
-import org.apache.pluto.container.PortletContainerException;
 
 /**
  * <p>
@@ -83,6 +82,7 @@
     public void invoke(RequestContext request, ValveContext context) throws PipelineException
     {     
         boolean responseCommitted = false;
+        boolean failure = false;
         try
         {            
             PortletWindow actionWindow = request.getActionWindow();
@@ -110,30 +110,20 @@
                 request.setAttribute(PortalReservedParameters.PIPELINE, null); // clear the
pipeline
             }
         }
-        catch (PortletContainerException e)
-        {
-            log.error("Unable to retrieve portlet container!", e);
-            throw new PipelineException("Unable to retrieve portlet container!", e);
-        }
-        catch (PortletException e)
-        {
-            log.warn("Unexpected PortletException in ActionValveImpl", e);
-            //  throw new PipelineException("Unexpected PortletException in ActionValveImpl",
e);
-
-        }
-        catch (IOException e)
-        {
-            log.error("Unexpected IOException in ActionValveImpl", e);
-            // throw new PipelineException("Unexpected IOException in ActionValveImpl", e);
-        }
         catch (IllegalStateException e)
         {
             log.error("Illegal State Exception. Response was written to in Action Phase",
e);
+            failure = true;
             responseCommitted = true;
         }
         catch (Throwable t)
         {
-            log.error("Unknown exception processing Action", t);
+            failure = true;
+            RequestDiagnostics rd = RequestDiagnosticsFactory.newRequestDiagnostics();
+            RequestDiagnosticsFactory.fillInPortletWindow(rd, request.getActionWindow(),
t);
+            PipelineException pe = new PipelineException(t);
+            pe.setRequestDiagnostics(rd);
+            throw pe;
         }
         finally
         {
@@ -143,13 +133,12 @@
             {
                 log.info("Action processed and response committed (pipeline processing stopped)");
             }
-            else
+            else if (!failure)
             {
                 // Pass control to the next Valve in the Pipeline
                 context.invokeNext(request);
             }
         }
-
     }
 
     protected void clearPortletCacheForPage(RequestContext request, PortletWindow actionWindow)

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/request/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu May  7 00:48:31 2009
@@ -1,2 +1,2 @@
-target
+target
 surefire*.properties

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/resource/ResourceValveImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/resource/ResourceValveImpl.java?rev=772480&r1=772479&r2=772480&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/resource/ResourceValveImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/resource/ResourceValveImpl.java
Thu May  7 00:48:31 2009
@@ -16,22 +16,17 @@
  */
 package org.apache.jetspeed.resource;
 
-import java.io.IOException;
-
-import javax.portlet.PortletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.jetspeed.PortalReservedParameters;
-import org.apache.jetspeed.om.page.Fragment;
 import org.apache.jetspeed.pipeline.PipelineException;
 import org.apache.jetspeed.pipeline.valve.AbstractValve;
 import org.apache.jetspeed.pipeline.valve.ValveContext;
 import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.request.RequestDiagnostics;
+import org.apache.jetspeed.request.RequestDiagnosticsFactory;
 import org.apache.pluto.container.PortletContainer;
-import org.apache.pluto.container.PortletContainerException;
 import org.apache.jetspeed.container.PortletWindow;
 
 /**
@@ -44,8 +39,6 @@
  */
 public class ResourceValveImpl extends AbstractValve
 {
-
-    private static final Logger log = LoggerFactory.getLogger(ResourceValveImpl.class);
     private PortletContainer container;
 
     public ResourceValveImpl(PortletContainer container)
@@ -64,7 +57,6 @@
         {
             try
             {            
-                Fragment fragment = resourceWindow.getFragment();
                 HttpServletRequest servletRequest = request.getRequest();
                 HttpServletResponse servletResponse = request.getResponse();
                 resourceWindow.setAttribute(PortalReservedParameters.PORTLET_CONTAINER_INVOKER_USE_FORWARD,
Boolean.TRUE);
@@ -77,27 +69,13 @@
                     container.doServeResource(resourceWindow, servletRequest, servletResponse);
                 }
             }
-            catch (PortletContainerException e)
-            {
-                log.error("Unable to retrieve portlet container!", e);
-                throw new PipelineException("Unable to retrieve portlet container!", e);
-            }
-            catch (PortletException e)
-            {
-                log.warn("Unexpected PortletException", e);
-
-            }
-            catch (IOException e)
-            {
-                log.error("Unexpected IOException", e);
-            }
-            catch (IllegalStateException e)
-            {
-                log.error("Unexpected IllegalStateException.", e);
-            }
-            catch (Exception t)
+            catch (Exception e)
             {
-                log.error("Unexpected Exception", t);
+                RequestDiagnostics rd = RequestDiagnosticsFactory.newRequestDiagnostics();
+                RequestDiagnosticsFactory.fillInPortletWindow(rd, resourceWindow, e);
+                PipelineException pe = new PipelineException(e);
+                pe.setRequestDiagnostics(rd);
+                throw pe;
             }
         }
         else



---------------------------------------------------------------------
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