use of org.graylog2.versioncheck.VersionCheckResponse in project graylog2-server by Graylog2.
the class VersionCheckThread method doRun.
@Override
public void doRun() {
final Request request = new Request.Builder().addHeader(HttpHeaders.USER_AGENT, USER_AGENT).get().url(versionCheckUri.toString()).build();
try (final Response response = httpClient.newCall(request).execute()) {
if (response.isSuccessful()) {
final VersionCheckResponse versionCheckResponse = objectMapper.readValue(response.body().byteStream(), VersionCheckResponse.class);
final VersionResponse version = versionCheckResponse.version;
final com.github.zafarkhaja.semver.Version reportedVersion = com.github.zafarkhaja.semver.Version.forIntegers(version.major, version.minor, version.patch);
LOG.debug("Version check reports current version: " + versionCheckResponse);
if (reportedVersion.greaterThan(ServerVersion.VERSION.getVersion())) {
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", versionCheckResponse.toString());
notificationService.publishIfFirst(notification);
} else {
LOG.debug("Reported version is not higher than ours ({}).", ServerVersion.VERSION);
notificationService.fixed(Notification.Type.OUTDATED_VERSION);
}
} else {
LOG.error("Version check unsuccessful (response code {}).", response.code());
}
} catch (IOException e) {
LOG.error("Couldn't perform version check", e);
}
}
Aggregations