StringWriter writer = new StringWriter();
IOUtils.copy(entity.getContent(), writer, Charset.forName("UTF-8"));
String body = writer.toString();
VersionCheckResponse parsedResponse = parse(body);
Version reportedVersion = new Version(parsedResponse.version.major, parsedResponse.version.minor, parsedResponse.version.patch);
LOG.debug("Version check reports current version: " + parsedResponse);
if (reportedVersion.greaterMinor(ServerVersion.VERSION)) {
LOG.debug("Reported version is higher than ours ({}). Writing notification.", ServerVersion.VERSION);
Notification notification = notificationService.buildNow()
.addSeverity(Notification.Severity.NORMAL)
.addType(Notification.Type.OUTDATED_VERSION)
.addDetail("current_version", parsedResponse.toString());
notificationService.publishIfFirst(notification);
} else {
LOG.debug("Reported version is not higher than ours ({}).", ServerVersion.VERSION);
notificationService.fixed(Notification.Type.OUTDATED_VERSION);
}