From 8e474a9e532a95a975bfcaa1af642a69e7947d13 Mon Sep 17 00:00:00 2001
From: Gabriel Landais <glandais@kereval.com>
Date: Tue, 16 Apr 2013 14:06:07 +0000
Subject: [PATCH] Explain error

git-svn-id: https://scm.gforge.inria.fr/authscm/ycadoret/svn/gazelle/Maven/gazelle-proxy/trunk@35173 356b4b1a-1d2b-0410-8bf1-ffa24008f01e
---
 .../ihe/gazelle/proxy/gui/MessageBean.java    | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/gui/MessageBean.java b/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/gui/MessageBean.java
index 59d2cafc..f930f665 100644
--- a/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/gui/MessageBean.java
+++ b/gazelle-proxy-jar/src/main/java/net/ihe/gazelle/proxy/gui/MessageBean.java
@@ -41,6 +41,7 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.log4j.Logger;
 import org.dcm4che2.tool.dcm2txt.Dcm2Txt;
 import org.jboss.resteasy.client.ClientExecutor;
@@ -155,12 +156,12 @@ public class MessageBean {
 	}
 
 	public void downloadFile(boolean inline) {
+		HttpServletResponse response = (HttpServletResponse) extCtx.getResponse();
+		InputStream messageStream = message.getMessageReceivedStream();
+		ServletOutputStream servletOutputStream = null;
 		try {
-			HttpServletResponse response = (HttpServletResponse) extCtx.getResponse();
-			InputStream messageStream = message.getMessageReceivedStream();
-			ServletOutputStream servletOutputStream = response.getOutputStream();
 			response.setContentType("text/plain");
-
+			servletOutputStream = response.getOutputStream();
 			if (!inline) {
 				response.setHeader("Content-Disposition", "attachment;filename=\"" + message.getId() + "\"");
 			}
@@ -195,7 +196,12 @@ public class MessageBean {
 			facesContext.responseComplete();
 		} catch (Exception e) {
 			log.error("Failed to download file", e);
-			FacesMessages.instance().add(StatusMessage.Severity.ERROR, "Failed to download file", e);
+			try {
+				IOUtils.write("Failed to download file " + ExceptionUtils.getFullStackTrace(e), servletOutputStream);
+			} catch (IOException e1) {
+				log.error("Failed to send error to browser", e);
+			}
+			// FacesMessages.instance().add(StatusMessage.Severity.ERROR, "Failed to download file", e);
 		}
 	}
 
@@ -438,7 +444,8 @@ public class MessageBean {
 
 		// Chemin vers evs client
 		String validatorUrl = Preferences.getProperty("evsclient.url"); // "http://192.168.20.100:8080/EVSClient/"
-		ClientRequest request = new ClientRequest(validatorUrl.concat("resteasy/GetValidationPermanentLink"), CLIENT_EXECUTOR);
+		ClientRequest request = new ClientRequest(validatorUrl.concat("resteasy/GetValidationPermanentLink"),
+				CLIENT_EXECUTOR);
 		request.queryParameter("oid", oid);
 		ClientResponse<String> response = null;
 		try {
-- 
GitLab