← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3883: Fixed exception caused by exception interceptor

 

------------------------------------------------------------
revno: 3883
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2011-06-12 14:09:35 +0200
message:
  Fixed exception caused by exception interceptor
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/ExceptionInterceptor.java
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/ExceptionInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/ExceptionInterceptor.java	2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/ExceptionInterceptor.java	2011-06-12 12:09:35 +0000
@@ -40,6 +40,8 @@
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.interceptor.Interceptor;
 
+import static org.apache.commons.lang.StringUtils.defaultIfEmpty;
+
 /**
  * This interceptor will intercept exceptions and redirect to appropriate
  * exception results / pages defined in the global-results section in the XWork 
@@ -105,7 +107,7 @@
         catch ( Exception e )
         {
             // -----------------------------------------------------------------
-            // Save exception etc. to value stack
+            // Save exception to value stack
             // -----------------------------------------------------------------
 
             Map<String, Object> parameterMap = new HashMap<String, Object>( 3 );
@@ -119,7 +121,7 @@
 
             Map<?, ?> params = actionInvocation.getProxy().getConfig().getParams();
             String exceptionResultName = (String) params.get( EXCEPTION_RESULT_KEY );
-
+                      
             if ( e instanceof AccessDeniedException || e instanceof InsufficientAuthenticationException )
             {
                 if ( EXCEPTION_RESULT_PLAIN_TEXT.equals( exceptionResultName ) )
@@ -129,20 +131,17 @@
                 
                 return EXCEPTION_RESULT_ACCESS_DENIED; // Access denied as nice page
             }
+ 
+            boolean ignore = ignoredExceptions.contains( e.getClass().getName() );
 
-            if ( e != null && !ignoredExceptions.contains( e.getClass().getName() ) )
+            if ( !ignore )
             {
                 LOG.error( "Error while executing action", e );
             }
 
-            if ( exceptionResultName != null )
-            {
-                return exceptionResultName;
-            }
-            else
-            {
-                return EXCEPTION_RESULT_DEFAULT;
-            }
+            exceptionResultName = defaultIfEmpty( exceptionResultName, EXCEPTION_RESULT_DEFAULT );
+            
+            return ignore ? EXCEPTION_RESULT_PLAIN_TEXT : exceptionResultName;
         }
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2011-06-11 20:02:07 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2011-06-12 12:09:35 +0000
@@ -125,8 +125,7 @@
 		<global-results>
 			<result name="exceptionDefault" type="velocity">/exception.vm</result>
 			<result name="accessDenied" type="velocity">/accessDenied.vm</result>
-			<result name="jsonAccessDenied" type="velocity">/dhis-web-commons/ajax/jsonAccessDenied.vm
-			</result>
+			<result name="jsonAccessDenied" type="velocity">/dhis-web-commons/ajax/jsonAccessDenied.vm</result>
 			<result name="plainTextError" type="plainTextErrorResult">
 				<param name="parse">true</param>
 				<param name="message">${exception.class.name}: ${exception.message}</param>