Author: dkulp
Date: Fri Oct 10 11:22:59 2008
New Revision: 703548

URL: http://svn.apache.org/viewvc?rev=703548&view=rev
Log:
[CXF-1849] Just log policy issues on outbound.  Patch from Fred Dushin applied.


Modified:
    
cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java

Modified: 
cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java?rev=703548&r1=703547&r2=703548&view=diff
==============================================================================
--- 
cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java
 (original)
+++ 
cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java
 Fri Oct 10 11:22:59 2008
@@ -63,10 +63,32 @@
         if (policy == null) {
             return;
         }
-        
-        aim.checkEffectivePolicy(policy.getPolicy());
-        
+
+        // CXF-1849 Log a message at FINE level if policy verification fails
+        // on the outbound-server side of a response
+        try {
+            aim.checkEffectivePolicy(policy.getPolicy());
+        } catch (final PolicyException e) {
+            if (isOutboundServer(message)) {
+                LOG.fine("An exception was thrown when verifying that the 
effective policy for "
+                         + "this request was satisfied.  However, this 
exception will not result in "
+                         + "a fault.  The exception raised is: "
+                         + e.toString());
+                return;
+            } else {
+                throw e;
+            }
+        }
         LOG.fine("Verified policies for outbound message.");
     }
-
+    
+    private boolean isOutboundServer(final Message message) {
+        final Object role = message.get(Message.REQUESTOR_ROLE);
+        final boolean isClient =
+            role != null ? Boolean.TRUE.equals(role) : false;
+        final boolean isOutbound =
+            message == message.getExchange().getOutMessage()
+            || message == message.getExchange().getOutFaultMessage();
+        return !isClient && isOutbound;
+    }
 }


Reply via email to