From da0269b4bd57bf90877446d9f991247bc1ad2f64 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 12 Oct 2011 22:14:10 -0400
Subject: [PATCH] RPC Client: Create/Edit Repository & User. Partially working.
---
src/com/gitblit/utils/JsonUtils.java | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/com/gitblit/utils/JsonUtils.java b/src/com/gitblit/utils/JsonUtils.java
index 3834c8e..fee7990 100644
--- a/src/com/gitblit/utils/JsonUtils.java
+++ b/src/com/gitblit/utils/JsonUtils.java
@@ -157,6 +157,25 @@
}
return gson().fromJson(json, type);
}
+
+ /**
+ * Reads a gson object from the specified url.
+ *
+ * @param url
+ * @param clazz
+ * @param username
+ * @param password
+ * @return the deserialized object
+ * @throws {@link IOException}
+ */
+ public static <X> X retrieveJson(String url, Class<X> clazz, String username, char[] password)
+ throws IOException {
+ String json = retrieveJsonString(url, username, password);
+ if (StringUtils.isEmpty(json)) {
+ return null;
+ }
+ return gson().fromJson(json, clazz);
+ }
/**
* Retrieves a JSON message.
--
Gitblit v1.9.1