From e11f48115c93229700b7504450b324bdcf644fb2 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Mon, 17 Oct 2011 17:46:27 -0400 Subject: [PATCH] Handle the earliest tags from the Linux kernel repository (issue 25) --- 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