From c1594186b0bf7621ab7387ca4a9933d0db554ecb Mon Sep 17 00:00:00 2001
From: Guillaume Thomazon <gtn@kereval.com>
Date: Thu, 27 Jun 2013 13:54:45 +0000
Subject: [PATCH] Encode base 64 before send message to EVS

git-svn-id: https://scm.gforge.inria.fr/authscm/ycadoret/svn/gazelle/Maven/gazelle-proxy/trunk@36210 356b4b1a-1d2b-0410-8bf1-ffa24008f01e
---
 .../java/net/ihe/gazelle/proxy/gui/MessageBean.java   | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 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 1171e8f6..2784440c 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
@@ -36,6 +36,7 @@ import org.apache.commons.exec.PumpStreamHandler;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
 import org.apache.commons.httpclient.methods.multipart.FilePart;
 import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
 import org.apache.commons.httpclient.methods.multipart.Part;
@@ -328,7 +329,13 @@ public class MessageBean {
 		// use the type as file name
 		String messageType = message.getChannelType().name();
 
-		PartSource partSource = message.getPartSource(messageType);
+		// encode byte before send it to EVS
+		byte[] bytes = message.getMessageReceived();
+		bytes = Base64.encodeBase64(bytes);
+
+		PartSource partSource = new ByteArrayPartSource(messageType, bytes);
+
+//		PartSource partSource = message.getPartSource(messageType);
 		Part[] parts = { new FilePart("message", partSource) };
 		filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams()));
 		int status = -1;
@@ -338,7 +345,7 @@ public class MessageBean {
 			status = -1;
 			e.printStackTrace();
 		}
-		log.info("proxyId : "+proxyId);
+		log.info("proxyId : " + proxyId);
 		// redirect the user to the good page
 		if (status == HttpStatus.SC_OK) {
 			try {
-- 
GitLab