From a413ed7c41880cec3c224501dd2ed874fdbeef17 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Sun, 22 Nov 2015 14:53:36 -0500
Subject: [PATCH] Reset build identifiers for next point release cycle
---
src/main/java/com/gitblit/utils/JsonUtils.java | 49 +++++++++++++++++++++++++++++--------------------
1 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/src/main/java/com/gitblit/utils/JsonUtils.java b/src/main/java/com/gitblit/utils/JsonUtils.java
index e924182..f389776 100644
--- a/src/main/java/com/gitblit/utils/JsonUtils.java
+++ b/src/main/java/com/gitblit/utils/JsonUtils.java
@@ -46,6 +46,7 @@
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
@@ -54,9 +55,9 @@
/**
* Utility methods for json calls to a Gitblit server.
- *
+ *
* @author James Moger
- *
+ *
*/
public class JsonUtils {
@@ -68,7 +69,7 @@
/**
* Creates JSON from the specified object.
- *
+ *
* @param o
* @return json
*/
@@ -82,9 +83,12 @@
*
* @param json
* @param clazz
- * @return an object
+ * @return the deserialized object
+ * @throws JsonParseException
+ * @throws JsonSyntaxException
*/
- public static <X> X fromJsonString(String json, Class<X> clazz) {
+ public static <X> X fromJsonString(String json, Class<X> clazz) throws JsonParseException,
+ JsonSyntaxException {
return gson().fromJson(json, clazz);
}
@@ -92,16 +96,19 @@
* Convert a json string to an object of the specified type.
*
* @param json
- * @param clazz
- * @return an object
+ * @param type
+ * @return the deserialized object
+ * @throws JsonParseException
+ * @throws JsonSyntaxException
*/
- public static <X> X fromJsonString(String json, Type type) {
+ public static <X> X fromJsonString(String json, Type type) throws JsonParseException,
+ JsonSyntaxException {
return gson().fromJson(json, type);
}
/**
* Reads a gson object from the specified url.
- *
+ *
* @param url
* @param type
* @return the deserialized object
@@ -114,7 +121,7 @@
/**
* Reads a gson object from the specified url.
- *
+ *
* @param url
* @param type
* @return the deserialized object
@@ -127,7 +134,7 @@
/**
* Reads a gson object from the specified url.
- *
+ *
* @param url
* @param type
* @param username
@@ -146,7 +153,7 @@
/**
* Reads a gson object from the specified url.
- *
+ *
* @param url
* @param clazz
* @param username
@@ -165,7 +172,7 @@
/**
* Retrieves a JSON message.
- *
+ *
* @param url
* @return the JSON message as a string
* @throws {@link IOException}
@@ -205,7 +212,7 @@
/**
* Sends a JSON message.
- *
+ *
* @param url
* the url to write to
* @param json
@@ -219,7 +226,7 @@
/**
* Sends a JSON message.
- *
+ *
* @param url
* the url to write to
* @param json
@@ -274,10 +281,10 @@
return builder.create();
}
- private static class GmtDateTypeAdapter implements JsonSerializer<Date>, JsonDeserializer<Date> {
+ public static class GmtDateTypeAdapter implements JsonSerializer<Date>, JsonDeserializer<Date> {
private final DateFormat dateFormat;
- private GmtDateTypeAdapter() {
+ public GmtDateTypeAdapter() {
dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
}
@@ -296,7 +303,7 @@
JsonDeserializationContext jsonDeserializationContext) {
try {
synchronized (dateFormat) {
- Date date = dateFormat.parse(jsonElement.getAsString());
+ Date date = dateFormat.parse(jsonElement.getAsString());
return new Date((date.getTime() / 1000) * 1000);
}
} catch (ParseException e) {
@@ -304,7 +311,7 @@
}
}
}
-
+
private static class AccessPermissionTypeAdapter implements JsonSerializer<AccessPermission>, JsonDeserializer<AccessPermission> {
private AccessPermissionTypeAdapter() {
@@ -319,7 +326,7 @@
@Override
public synchronized AccessPermission deserialize(JsonElement jsonElement, Type type,
JsonDeserializationContext jsonDeserializationContext) {
- return AccessPermission.fromCode(jsonElement.getAsString());
+ return AccessPermission.fromCode(jsonElement.getAsString());
}
}
@@ -334,10 +341,12 @@
this.fieldName = fqfn.substring(fqfn.lastIndexOf(".") + 1);
}
+ @Override
public boolean shouldSkipClass(Class<?> arg0) {
return false;
}
+ @Override
public boolean shouldSkipField(FieldAttributes f) {
return (f.getDeclaringClass() == c && f.getName().equals(fieldName));
}
--
Gitblit v1.9.1