final JsonParser parser = new JsonParser();
final JsonElement messageJson = parser.parse(body);
final Set<ObjectId> tracked = new HashSet<ObjectId>();
RepositoryFilter filter = new RepositoryFilter();
ObjectId commitId = ObjectId.NULL;
if (messageJson.isJsonObject()) {
final JsonObject message = messageJson.getAsJsonObject();
final JsonArray trackedArray;
if (message.has("tracked") && message.get("tracked").isJsonArray()) {
trackedArray = message.get("tracked").getAsJsonArray();
} else {
trackedArray = new JsonArray();
}
if (message.has("commitId") && message.get("commitId").isJsonPrimitive()) {
commitId = ObjectId.valueOf(message.get("commitId").getAsJsonPrimitive()
.getAsString());
} else {
commitId = ObjectId.NULL;
}
for (final JsonElement e : trackedArray) {
if (e.isJsonPrimitive()) {
tracked.add(ObjectId.valueOf(e.getAsJsonPrimitive().getAsString()));
}
}
if (message.has("filter") && message.get("filter").isJsonArray()) {
JsonArray filterArray = message.get("filter").getAsJsonArray();
for (final JsonElement e : filterArray) {
if (e.isJsonObject()) {
JsonObject filterObject = e.getAsJsonObject();
String featureType = null;
String filterType = null;
String filterText = null;
if (filterObject.has("featurepath")
&& filterObject.get("featurepath").isJsonPrimitive()) {
featureType = filterObject.get("featurepath")
.getAsJsonPrimitive().getAsString();
}
if (filterObject.has("type")
&& filterObject.get("type").isJsonPrimitive()) {
filterType = filterObject.get("type").getAsJsonPrimitive()
.getAsString();
}
if (filterObject.has("filter")
&& filterObject.get("filter").isJsonPrimitive()) {
filterText = filterObject.get("filter").getAsJsonPrimitive()
.getAsString();
}
if (featureType != null && filterType != null && filterText != null) {
filter.addFilter(featureType, filterType, filterText);
}
}
}
}