chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1221637 - /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/filter/LoggingFilter.java
Date Wed, 21 Dec 2011 07:53:39 GMT
Author: jens
Date: Wed Dec 21 07:53:39 2011
New Revision: 1221637

URL: http://svn.apache.org/viewvc?rev=1221637&view=rev
Log:
Fix bugs:
Request body is not logged properly.
In the URL the query string part is missing.
[CMIS-489]

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/filter/LoggingFilter.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/filter/LoggingFilter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/filter/LoggingFilter.java?rev=1221637&r1=1221636&r2=1221637&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/filter/LoggingFilter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/filter/LoggingFilter.java
Wed Dec 21 07:53:39 2011
@@ -70,9 +70,9 @@ public class LoggingFilter implements Fi
         
         String val; 
         logDir = cfg.getInitParameter("LogDir");
-        if (null == logDir)
+        if (null == logDir || logDir.length() == 0)
             logDir = System.getProperty("java.io.tmpdir");
-        if (null == logDir)
+        if (null == logDir|| logDir.length() == 0)
             logDir = "." + File.separator;
 
         if (!logDir.endsWith(File.separator))
@@ -104,6 +104,8 @@ public class LoggingFilter implements Fi
             LoggingRequestWrapper logReq = new LoggingRequestWrapper((HttpServletRequest)req);
             LoggingResponseWrapper logResponse = new LoggingResponseWrapper((HttpServletResponse)resp);
             
+            chain.doFilter(logReq, logResponse);
+
             int reqNo = getNextRequestNumber();
             String requestFileName = getRequestFileName(reqNo);
             String cType = logReq.getContentType();
@@ -123,7 +125,6 @@ public class LoggingFilter implements Fi
             log.debug("Found request: " + requestFileName + ": " + xmlRequest);
             writeTextToFile(requestFileName, xmlRequest);
             
-            chain.doFilter(logReq, logResponse);
 
             sb = new StringBuffer();
             cType = logResponse.getContentType();
@@ -202,6 +203,11 @@ public class LoggingFilter implements Fi
         sb.append(req.getMethod());
         sb.append(" ");
         sb.append(req.getRequestURI());
+        String queryString = req.getQueryString();
+        if (null != queryString && queryString.length() > 0) {
+            sb.append("?");
+            sb.append(queryString);
+        }
         sb.append(" ");
         sb.append(req.getProtocol());
         sb.append("\n");
@@ -286,25 +292,25 @@ public class LoggingFilter implements Fi
         public int read(byte[] b) throws IOException {
            int ch = is.read(b);
            if (ch != -1) {
-              baous.write(b);
+              baous.write(b, 0, ch);
            }
            return ch;
         }
    
         @Override
         public int read(byte[] b, int o, int l) throws IOException {
-           int ch = is.read(b,o,l);
+           int ch = is.read(b, o, l);
            if (ch != -1) {
-              baous.write(b);
+              baous.write(b, o, ch);
            }
            return ch;
         }
         
         @Override
         public int readLine(byte[] b, int o, int l) throws IOException {
-           int ch = is.readLine(b,o,l);
+           int ch = is.readLine(b, o, l);
            if (ch != -1) {
-               baous.write(b, o, l);
+               baous.write(b, o, ch);
            }
            return ch;
         }



Mime
View raw message