cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6417] Basic option to disable logging the complete multipart payload
Date Thu, 21 May 2015 11:31:18 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 8cd70c755 -> 186cab6a9


[CXF-6417] Basic option to disable logging the complete multipart payload


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/186cab6a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/186cab6a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/186cab6a

Branch: refs/heads/3.0.x-fixes
Commit: 186cab6a97027e54e8785deccf4433d41ad0139e
Parents: 8cd70c7
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Thu May 21 12:30:10 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Thu May 21 12:31:00 2015 +0100

----------------------------------------------------------------------
 .../cxf/interceptor/AbstractLoggingInterceptor.java  | 15 ++++++++++++++-
 .../apache/cxf/interceptor/LoggingInInterceptor.java |  5 +++++
 .../cxf/interceptor/LoggingOutInterceptor.java       |  5 +++++
 3 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/186cab6a/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
b/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
index 996ce60..f52e8e3 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
@@ -53,6 +53,8 @@ import org.apache.cxf.staxutils.StaxUtils;
 public abstract class AbstractLoggingInterceptor extends AbstractPhaseInterceptor<Message>
{
     public static final int DEFAULT_LIMIT = 48 * 1024;
     protected static final String BINARY_CONTENT_MESSAGE = "--- Binary Content ---";
+    protected static final String MULTIPART_CONTENT_MESSAGE = "--- Multipart Content ---";
+    private static final String MULTIPART_CONTENT_MEDIA_TYPE = "multipart";
     private static final List<String> BINARY_CONTENT_MEDIA_TYPES;
     static {
         BINARY_CONTENT_MEDIA_TYPES = new ArrayList<String>();
@@ -67,6 +69,7 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
     protected PrintWriter writer;
     protected boolean prettyLogging;
     private boolean showBinaryContent;
+    private boolean showMultipartContent;
     
     public AbstractLoggingInterceptor(String phase) {
         super(phase);
@@ -256,7 +259,17 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
     public boolean isShowBinaryContent() {
         return showBinaryContent;
     }
-    public boolean isBinaryContent(String contentType) {
+    protected boolean isBinaryContent(String contentType) {
         return contentType != null && BINARY_CONTENT_MEDIA_TYPES.contains(contentType);
     }
+    public boolean isShowMultipartContent() {
+        return showMultipartContent;
+    }
+    public void setShowMultipartContent(boolean showMultipartContent) {
+        this.showMultipartContent = showMultipartContent;
+    }
+    protected boolean isMultipartContent(String contentType) {
+        return contentType != null && contentType.startsWith(MULTIPART_CONTENT_MEDIA_TYPE);
+    }
+    
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/186cab6a/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
index c2510c5..fedea47 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
@@ -148,6 +148,11 @@ public class LoggingInInterceptor extends AbstractLoggingInterceptor
{
             log(logger, buffer.toString());
             return;
         }
+        if (!isShowMultipartContent() && isMultipartContent(ct)) {
+            buffer.getMessage().append(MULTIPART_CONTENT_MESSAGE).append('\n');
+            log(logger, buffer.toString());
+            return;
+        }
         
         InputStream is = message.getContent(InputStream.class);
         if (is != null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/186cab6a/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
index a037c4e..74c2788 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
@@ -226,6 +226,11 @@ public class LoggingOutInterceptor extends AbstractLoggingInterceptor
{
                 log(logger, formatLoggingMessage(buffer));
                 return;
             }
+            if (!isShowMultipartContent() && isMultipartContent(ct)) {
+                buffer.getMessage().append(MULTIPART_CONTENT_MESSAGE).append('\n');
+                log(logger, buffer.toString());
+                return;
+            }
             
             if (cos.getTempFile() == null) {
                 //buffer.append("Outbound Message:\n");


Mime
View raw message