From 57d25b3ed304768cce91770ea2e12ef53f6415c0 Mon Sep 17 00:00:00 2001 From: lucio Date: Wed, 24 Jan 2024 16:29:51 +0100 Subject: [PATCH] updated for health api --- pom.xml | 10 ---------- .../java/org/gcube/smartgears/health/HealthTask.java | 2 +- .../gcube/smartgears/health/KeyCloakHealthCheck.java | 6 +++--- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index ef09598..f36ac98 100644 --- a/pom.xml +++ b/pom.xml @@ -233,16 +233,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - - false - - diff --git a/src/main/java/org/gcube/smartgears/health/HealthTask.java b/src/main/java/org/gcube/smartgears/health/HealthTask.java index ef755d6..8b7100f 100644 --- a/src/main/java/org/gcube/smartgears/health/HealthTask.java +++ b/src/main/java/org/gcube/smartgears/health/HealthTask.java @@ -42,7 +42,7 @@ public class HealthTask extends TimerTask{ try { return check.check(); }catch (Throwable t) { - return HealthCheckResponse.builder(check.getName()).down().withMessage(t.getMessage()).build(); + return HealthCheckResponse.builder(check.getName()).down().error(t.getMessage()).build(); } } diff --git a/src/main/java/org/gcube/smartgears/health/KeyCloakHealthCheck.java b/src/main/java/org/gcube/smartgears/health/KeyCloakHealthCheck.java index fd087bf..d685a77 100644 --- a/src/main/java/org/gcube/smartgears/health/KeyCloakHealthCheck.java +++ b/src/main/java/org/gcube/smartgears/health/KeyCloakHealthCheck.java @@ -21,10 +21,10 @@ public class KeyCloakHealthCheck implements HealthCheck{ try { Set contexts = ProviderFactory.provider().containerContext().authorizationProvider().getContexts(); if (contexts.isEmpty()) - return HealthCheckResponse.builder(CHECK_NAME).down().withMessage("no contexts are defined for the client id provided").build(); - return HealthCheckResponse.builder(CHECK_NAME).up().build(); + return HealthCheckResponse.builder(CHECK_NAME).down().error("no contexts are defined for the client id provided").build(); + return HealthCheckResponse.builder(CHECK_NAME).up().info(String.format("running contexts are %s", contexts)).build(); }catch (Exception e) { - return HealthCheckResponse.builder(CHECK_NAME).down().withMessage(e.getMessage()).build(); + return HealthCheckResponse.builder(CHECK_NAME).down().error(e.getMessage()).build(); } }