From 0e44acbb2fec928a1606dc60f427a148fff405c9 Mon Sep 17 00:00:00 2001
From: Mohamed Ragab <moragab@gmail.com>
Date: Wed, 02 May 2012 11:15:01 -0400
Subject: [PATCH] Added a script to facilitate setting the proxy host and port and no proxy hosts, and then it concatenates all the java system properties for setting the java proxy configurations and puts the resulting string in an environment variable JAVA_PROXY_CONFIG, modified the scirpts gitblit,  gitblit-ubuntu, and gitblit-centos to source the java-proxy-config.sh script and then include the resulting java proxy configuration in the java command

---
 src/com/gitblit/JsonServlet.java |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/com/gitblit/JsonServlet.java b/src/com/gitblit/JsonServlet.java
index ad1d67b..3ad2b7d 100644
--- a/src/com/gitblit/JsonServlet.java
+++ b/src/com/gitblit/JsonServlet.java
@@ -28,9 +28,8 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.gitblit.utils.JsonUtils;
 import com.gitblit.utils.StringUtils;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
 
 /**
  * Servlet class for interpreting json requests.
@@ -42,6 +41,12 @@
 
 	private static final long serialVersionUID = 1L;
 
+	protected final int forbiddenCode = HttpServletResponse.SC_FORBIDDEN;
+	
+	protected final int notAllowedCode = HttpServletResponse.SC_METHOD_NOT_ALLOWED;
+
+	protected final int failureCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
+	
 	protected final Logger logger;
 
 	public JsonServlet() {
@@ -79,8 +84,7 @@
 			return null;
 		}
 
-		Gson gson = new Gson();
-		X object = gson.fromJson(json.toString(), clazz);
+		X object = JsonUtils.fromJsonString(json.toString(), clazz);
 		return object;
 	}
 
@@ -91,8 +95,7 @@
 			return null;
 		}
 
-		Gson gson = new Gson();
-		X object = gson.fromJson(json.toString(), type);
+		X object = JsonUtils.fromJsonString(json.toString(), type);
 		return object;
 	}
 
@@ -118,8 +121,8 @@
 	protected void serialize(HttpServletResponse response, Object o) throws IOException {
 		if (o != null) {
 			// Send JSON response
-			Gson gson = new GsonBuilder().setPrettyPrinting().create();
-			String json = gson.toJson(o);
+			String json = JsonUtils.toJsonString(o);
+			response.setCharacterEncoding(Constants.ENCODING);
 			response.getWriter().append(json);
 		}
 	}

--
Gitblit v1.9.1