[Dive4elements-commits] [PATCH 2 of 7] Check for errors based on the return code instead of hackish parsing

Wald Commits scm-commit at wald.intevation.org
Thu Apr 18 11:42:26 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1366274560 -7200
# Node ID b6f8fd50269b3b77314e163055235195764b116b
# Parent  37c0b35e0fb5b840a28b330712fc04a3f1a4d22f
Check for errors based on the return code instead of hackish parsing

diff -r 37c0b35e0fb5 -r b6f8fd50269b flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java
--- a/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java	Thu Apr 18 10:42:07 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java	Thu Apr 18 10:42:40 2013 +0200
@@ -427,22 +427,16 @@
                 try {
                     byte [] buf = new byte[4096];
                     int r;
-                    boolean checkedErrors = false;
+                    if (result < 200 || result >= 300) {
+                        resp.setContentType("text/plain");
+                    } else {
+                        // Only send content disposition and filename content
+                        // type when we have a pdf
+                        resp.setHeader("Content-Disposition",
+                                "attachment;filename=flys-karte.pdf");
+                        resp.setContentType("application/pdf");
+                    }
                     while ((r = in.read(buf)) >= 0) {
-                        if (!checkedErrors) {
-                            checkedErrors = true;
-                            String header = new String(buf, "UTF-8");
-                            if (header.contains("Error while generating PDF:")) {
-                                resp.setContentType("text/plain");
-                            } else {
-                                // Only send content disposition and filename content
-                                // type when we have a pdf
-                                resp.setHeader("Content-Disposition",
-                                        "attachment;filename=flys-karte.pdf");
-                                resp.setContentType("application/pdf");
-                            }
-
-                        }
                         out.write(buf, 0, r);
                     }
                     out.flush();


More information about the Dive4elements-commits mailing list