Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java @ 5720:aa1a43f5c03a
Send errors as plaintext and not as pdf documents
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 15 Apr 2013 18:32:37 +0200 |
parents | c4162d8378a1 |
children | b6f8fd50269b |
comparison
equal
deleted
inserted
replaced
5719:e8b4c69967e2 | 5720:aa1a43f5c03a |
---|---|
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 resp.setHeader("Content-Disposition", | 430 boolean checkedErrors = false; |
431 "attachment;filename=flys-karte.pdf"); | |
432 resp.setContentType("application/pdf"); | |
433 while ((r = in.read(buf)) >= 0) { | 431 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 } | |
434 out.write(buf, 0, r); | 446 out.write(buf, 0, r); |
435 } | 447 } |
436 out.flush(); | 448 out.flush(); |
437 } | 449 } |
438 finally { | 450 finally { |