use of org.sonarsource.sonarlint.core.container.model.DefaultSonarQubeNotification in project sonarlint-core by SonarSource.
the class NotificationChecker method parseResponse.
private static List<SonarQubeNotification> parseResponse(String contents) {
List<SonarQubeNotification> notifications = new ArrayList<>();
try {
JsonParser parser = new JsonParser();
JsonObject root = parser.parse(contents).getAsJsonObject();
JsonArray events = root.get("events").getAsJsonArray();
for (JsonElement el : events) {
JsonObject event = el.getAsJsonObject();
String category = getOrFail(event, "category");
String message = getOrFail(event, "message");
String link = getOrFail(event, "link");
String projectKey = getOrFail(event, "project");
String dateTime = getOrFail(event, "date");
ZonedDateTime time = ZonedDateTime.parse(dateTime, TIME_FORMATTER);
notifications.add(new DefaultSonarQubeNotification(category, message, link, projectKey, time));
}
} catch (Exception e) {
LOG.error("Failed to parse SonarQube notifications response", e);
return Collections.emptyList();
}
return notifications;
}
Aggregations