comparison flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java @ 5752:b6f8fd50269b

Check for errors based on the return code instead of hackish parsing
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 18 Apr 2013 10:42:40 +0200
parents aa1a43f5c03a
children
comparison
equal deleted inserted replaced
5751:37c0b35e0fb5 5752:b6f8fd50269b
425 try { 425 try {
426 OutputStream out = resp.getOutputStream(); 426 OutputStream out = resp.getOutputStream();
427 try { 427 try {
428 byte [] buf = new byte[4096]; 428 byte [] buf = new byte[4096];
429 int r; 429 int r;
430 boolean checkedErrors = false; 430 if (result < 200 || result >= 300) {
431 resp.setContentType("text/plain");
432 } else {
433 // Only send content disposition and filename content
434 // type when we have a pdf
435 resp.setHeader("Content-Disposition",
436 "attachment;filename=flys-karte.pdf");
437 resp.setContentType("application/pdf");
438 }
431 while ((r = in.read(buf)) >= 0) { 439 while ((r = in.read(buf)) >= 0) {
432 if (!checkedErrors) {
433 checkedErrors = true;
434 String header = new String(buf, "UTF-8");
435 if (header.contains("Error while generating PDF:")) {
436 resp.setContentType("text/plain");
437 } else {
438 // Only send content disposition and filename content
439 // type when we have a pdf
440 resp.setHeader("Content-Disposition",
441 "attachment;filename=flys-karte.pdf");
442 resp.setContentType("application/pdf");
443 }
444
445 }
446 out.write(buf, 0, r); 440 out.write(buf, 0, r);
447 } 441 }
448 out.flush(); 442 out.flush();
449 } 443 }
450 finally { 444 finally {

http://dive4elements.wald.intevation.org