Skip to content

Commit e00e947

Browse files
Milan KuchtiakMilan Kuchtiak
Milan Kuchtiak
authored and
Milan Kuchtiak
committed
replace Integer.parseInt with JsonNode.asInt()
1 parent fc126c4 commit e00e947

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

dspace-api/src/main/java/org/dspace/matomo/MatomoHelper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ static String transformJSONResults(Set<String> keys, String report) throws Excep
106106
}
107107
ObjectNode response = OBJECT_MAPPER.createObjectNode();
108108
ObjectNode result = OBJECT_MAPPER.createObjectNode();
109+
result.set("views", (views == null ? OBJECT_MAPPER.createObjectNode() : transformJSON(views)));
110+
result.set("downloads", (downloads == null ? OBJECT_MAPPER.createObjectNode() : transformJSON(downloads)));
109111
response.set("response", result);
110-
result.set("views", transformJSON(views));
111-
result.set("downloads", transformJSON(downloads));
112112

113113
return response.toString();
114114
}
@@ -184,8 +184,8 @@ private static ObjectNode transformJSON(ObjectNode views) {
184184
total_nb_hits += v1.get("nb_hits").asInt();
185185
}
186186
v = OBJECT_MAPPER.createObjectNode();
187-
total_nb_visits += Integer.parseInt(row.get("nb_visits").toString());
188-
total_nb_hits += Integer.parseInt(row.get("nb_hits").toString());
187+
total_nb_visits += row.get("nb_visits").asInt();
188+
total_nb_hits += row.get("nb_hits").asInt();
189189
v.put("nb_hits", total_nb_hits);
190190
v.put("nb_visits", total_nb_visits);
191191
total.set(y, v);

0 commit comments

Comments
 (0)