diff gnv/src/main/java/de/intevation/gnv/action/mapviewer/MapViewerCallAction.java @ 1025:2996395e44c9

Improved the logging of incoming mapviewer call data. gnv/trunk@1279 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 29 Nov 2010 09:20:01 +0000
parents b45faa9315ce
children 12c3863b2d8a
line wrap: on
line diff
--- a/gnv/src/main/java/de/intevation/gnv/action/mapviewer/MapViewerCallAction.java	Fri Nov 26 10:48:30 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/mapviewer/MapViewerCallAction.java	Mon Nov 29 09:20:01 2010 +0000
@@ -31,6 +31,7 @@
 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
 import de.intevation.gnv.artifactdatabase.objects.map.MapService;
+import de.intevation.gnv.util.CaptureInputStream;
 
 /**
  * This class provides the businesslogic for handling an 
@@ -73,21 +74,19 @@
         }
 
         if (inputStream != null){
-
-            ByteArrayOutputStream out = new ByteArrayOutputStream();
-            byte[] b = new byte[4096];
-            int i = -1;
-            while ((i = inputStream.read(b)) > 0) {
-                out.write(b, 0, i);
-            }
-            out.close();
-            inputStream.reset();
-
-            log.debug("REQUEST DOCUMENT: " + out.toString());
+            CaptureInputStream capture = log.isDebugEnabled()
+                ? new CaptureInputStream(inputStream)
+                : null;
 
             try {
-                ExternalCallParser ecp = new XMLExternalCallParser(inputStream);
+                ExternalCallParser ecp = new XMLExternalCallParser(capture);
                 ecp.parse();
+
+                // print incoming data to log
+                if (capture != null) {
+                    log.debug("REQUEST DOCUMENT: " + capture.copyToString());
+                }
+
                 String geometry = ecp.getGeometry();
                 String srs = ecp.getSRS();
                 Collection<MapService> mapServices = ecp.getMapServices();

http://dive4elements.wald.intevation.org