From f8428995ce1f13dbcaf27f4915b491e167cc480f Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 15 Oct 2024 16:06:43 +0200 Subject: [PATCH 01/11] fixed test case --- .project | 5 + .settings/org.eclipse.wst.common.component | 123 ++++++++++++++++-- .../org.springframework.ide.eclipse.prefs | 2 + pom.xml | 16 ++- .../services/SpringBootActuatorConfig.java | 31 +++++ src/test/java/gis/RuntimeResourceReader.java | 23 ++-- 6 files changed, 180 insertions(+), 20 deletions(-) create mode 100644 .settings/org.springframework.ide.eclipse.prefs create mode 100644 src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java diff --git a/.project b/.project index f0af028..60f0be5 100644 --- a/.project +++ b/.project @@ -30,6 +30,11 @@ + + org.springframework.ide.eclipse.boot.validation.springbootbuilder + + + org.eclipse.jem.workbench.JavaEMFNature diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index d11cd83..c920e3e 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,16 @@ - + + + + + + + + + + + + @@ -46,7 +57,18 @@ - + + + + + + + + + + + + @@ -93,7 +115,18 @@ - + + + + + + + + + + + + @@ -140,7 +173,18 @@ - + + + + + + + + + + + + @@ -187,7 +231,18 @@ - + + + + + + + + + + + + @@ -234,7 +289,24 @@ - + + uses + + + uses + + + + + + + + + + + + + @@ -281,7 +353,18 @@ - + + + + + + + + + + + + @@ -328,7 +411,18 @@ - + + + + + + + + + + + + @@ -375,7 +469,18 @@ - + + + + + + + + + + + + diff --git a/.settings/org.springframework.ide.eclipse.prefs b/.settings/org.springframework.ide.eclipse.prefs new file mode 100644 index 0000000..a12794d --- /dev/null +++ b/.settings/org.springframework.ide.eclipse.prefs @@ -0,0 +1,2 @@ +boot.validation.initialized=true +eclipse.preferences.version=1 diff --git a/pom.xml b/pom.xml index 84a204b..62cf18b 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,8 @@ 2.25.1 - + 2.8.4 1.8 1.8 @@ -81,6 +82,19 @@ common-smartgears + + org.springframework.boot + spring-boot-actuator + 1.3.5.RELEASE + + + + org.springframework + spring-web + 4.3.5.RELEASE + + + org.gcube.core common-smartgears-app diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java b/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java new file mode 100644 index 0000000..f0a3af1 --- /dev/null +++ b/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java @@ -0,0 +1,31 @@ +package org.gcube.datatransfer.resolver.services; + +import java.util.Collection; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration; +import org.springframework.boot.actuate.autoconfigure.PublicMetricsAutoConfiguration; +import org.springframework.boot.actuate.endpoint.MetricsEndpoint; +import org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping; +import org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter; +import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +@Configuration +@Import({ EndpointAutoConfiguration.class, PublicMetricsAutoConfiguration.class }) +public class SpringBootActuatorConfig { + + @Bean + @Autowired + public EndpointHandlerMapping endpointHandlerMapping(Collection endpoints) { + return new EndpointHandlerMapping(endpoints); + } + + @Bean + @Autowired + public EndpointMvcAdapter metricsEndPoint(MetricsEndpoint delegate) { + return new EndpointMvcAdapter(delegate); + } +} \ No newline at end of file diff --git a/src/test/java/gis/RuntimeResourceReader.java b/src/test/java/gis/RuntimeResourceReader.java index acdc935..24eabd6 100644 --- a/src/test/java/gis/RuntimeResourceReader.java +++ b/src/test/java/gis/RuntimeResourceReader.java @@ -63,8 +63,10 @@ public class RuntimeResourceReader { ScopeProvider.instance.set(scope); SimpleQuery query = queryFor(ServiceEndpoint.class); - query.addCondition("$resource/Profile/Platform/Name/text() eq '" + platformName + "'"); - query.addCondition("$resource/Profile/Category/text() eq '" + category + "'"); + if (platformName != null) + query.addCondition("$resource/Profile/Platform/Name/text() eq '" + platformName + "'"); + if (category != null) + query.addCondition("$resource/Profile/Category/text() eq '" + category + "'"); if (endPoint != null && !endPoint.isEmpty()) query.addCondition("$resource/Profile/AccessPoint/Interface/Endpoint/text() eq '" + endPoint + "'"); @@ -127,27 +129,28 @@ public class RuntimeResourceReader { // String scope = "/pred4s/preprod/preVRE"; // String scope = "/d4science.research-infrastructures.eu/D4OS/GNA"; - String scope = "/gcube/devsec/devVRE"; - //String scope = "/d4science.research-infrastructures.eu/gCubeApps/Esquiline"; + // String scope = "/gcube/devsec/devVRE"; + String scope = "/d4science.research-infrastructures.eu/gCubeApps/ProtectedAreaImpactMaps"; + // String scope = "/d4science.research-infrastructures.eu/gCubeApps/Esquiline"; // String scope = "/d4science.research-infrastructures.eu/D4OS/ARIADNEplus_Project"; // String platformName = "geonetwork"; // String category = "Gis"; -// String platformName = "GeoServer"; -// String category = "Gis"; + String platformName = "GeoServer"; + String category = null; // String platformName = "postgis"; // String category = "Database"; - String platformName = "postgres"; - String category = "Database"; - +// String platformName = "postgres"; +// String category = "Database"; + // String platformName = "mongodb"; // String category = "Database"; // scope = "/pred4s/preprod/preVRE"; - + // scope = "/d4science.research-infrastructures.eu/D4OS/Blue-Cloud2026Project"; // platformName = "Zenodo"; // category = "Repository"; -- 2.17.1 From 06932cdd688fcf94f067856ed62b83b2b95e43af Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 15 Oct 2024 16:08:37 +0200 Subject: [PATCH 02/11] updated at 2.10.1-SNAPSHOT --- CHANGELOG.md | 4 ++++ pom.xml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8156cb8..80e5fdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v2.10.1-SNAPSHOT] + +- Bug fixing StorageID resolver [#28276] + ## [v2.10.0] - GeoPortal-Resolver enhancement: implemented share link towards Geoportal Data-Entry facility [#27135] diff --git a/pom.xml b/pom.xml index 62cf18b..2b803db 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.gcube.data.transfer uri-resolver - 2.10.0 + 2.10.1-SNAPSHOT war The URI Resolver is an HTTP URI resolver implemented as a REST service which gives access trough HTTP to different gcube Resolvers and gCube Applications. -- 2.17.1 From 427ceed7a0968af257a0a755bb032e5991fb505e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 15 Oct 2024 16:18:31 +0200 Subject: [PATCH 03/11] add path as metrics --- .../resolver/services/SpringBootActuatorConfig.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java b/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java index f0a3af1..8249e3b 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java @@ -2,6 +2,8 @@ package org.gcube.datatransfer.resolver.services; import java.util.Collection; +import javax.ws.rs.Path; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.PublicMetricsAutoConfiguration; @@ -15,6 +17,7 @@ import org.springframework.context.annotation.Import; @Configuration @Import({ EndpointAutoConfiguration.class, PublicMetricsAutoConfiguration.class }) +@Path("metrics") public class SpringBootActuatorConfig { @Bean -- 2.17.1 From 66632e1f82734365b0cd1eeae8c37ba211867c11 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 15 Oct 2024 16:28:03 +0200 Subject: [PATCH 04/11] added `spring_metrics` path --- .../resolver/services/SpringBootActuatorConfig.java | 2 +- .../datatransfer/resolver/services/StorageIDResolver.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java b/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java index 8249e3b..af9cb7c 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java @@ -17,7 +17,7 @@ import org.springframework.context.annotation.Import; @Configuration @Import({ EndpointAutoConfiguration.class, PublicMetricsAutoConfiguration.class }) -@Path("metrics") +@Path("spring_metrics") public class SpringBootActuatorConfig { @Bean diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java index 2b57600..99d789c 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java @@ -169,6 +169,9 @@ public class StorageIDResolver { //Reading the content size size = metaFile.getSize(); LOG.debug("Read size {} from {}", size, StorageMetadataFile.class.getSimpleName()); + }else { + //Bug fixing #28276 + throw ExceptionManager.notFoundException(httpRequest, "Error on accessing the "+STORAGE_ID+ " '"+storageId+"'. Is it a valid id?", StorageIDResolver.class, help); } //CHECKING TO DEFAULT METADATA -- 2.17.1 From 1e38d3277664593a81d352fd42da83aef9cc9af8 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 15 Oct 2024 16:31:02 +0200 Subject: [PATCH 05/11] removed `spring_metrics` path --- .../java/org/gcube/datatransfer/resolver/ConstantsResolver.java | 2 +- .../resolver/services/SpringBootActuatorConfig.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/ConstantsResolver.java b/src/main/java/org/gcube/datatransfer/resolver/ConstantsResolver.java index c14b38b..2606032 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/ConstantsResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/ConstantsResolver.java @@ -30,7 +30,7 @@ public class ConstantsResolver { public static final String QUERY_PARAM_CONTENT_TYPE = "contentType"; public static final String QUERY_PARAM_FILE_NAME = "fileName"; - public static final String[] resourcesHardCoded = { "ctlg" }; + public static final String[] resourcesHardCoded = { "ctlg", "metrics" }; // The default resource candidate to manage the input requests not matching any // resolver services diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java b/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java index af9cb7c..7ef2ad5 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java @@ -17,7 +17,6 @@ import org.springframework.context.annotation.Import; @Configuration @Import({ EndpointAutoConfiguration.class, PublicMetricsAutoConfiguration.class }) -@Path("spring_metrics") public class SpringBootActuatorConfig { @Bean -- 2.17.1 From d22eba4c0aee8755bbd3267cae4469b312286cbb Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 15 Oct 2024 16:45:28 +0200 Subject: [PATCH 06/11] integrated `health` with `microprofile-health-api` --- pom.xml | 12 ++----- .../services/SpringBootActuatorConfig.java | 33 ------------------- .../services/UriResolverHealthCheck.java | 14 ++++++++ 3 files changed, 17 insertions(+), 42 deletions(-) delete mode 100644 src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java create mode 100644 src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java diff --git a/pom.xml b/pom.xml index 2b803db..099c50c 100644 --- a/pom.xml +++ b/pom.xml @@ -83,15 +83,9 @@ - org.springframework.boot - spring-boot-actuator - 1.3.5.RELEASE - - - - org.springframework - spring-web - 4.3.5.RELEASE + org.eclipse.microprofile.health + microprofile-health-api + 4.0 diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java b/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java deleted file mode 100644 index 7ef2ad5..0000000 --- a/src/main/java/org/gcube/datatransfer/resolver/services/SpringBootActuatorConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.gcube.datatransfer.resolver.services; - -import java.util.Collection; - -import javax.ws.rs.Path; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration; -import org.springframework.boot.actuate.autoconfigure.PublicMetricsAutoConfiguration; -import org.springframework.boot.actuate.endpoint.MetricsEndpoint; -import org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping; -import org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter; -import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; - -@Configuration -@Import({ EndpointAutoConfiguration.class, PublicMetricsAutoConfiguration.class }) -public class SpringBootActuatorConfig { - - @Bean - @Autowired - public EndpointHandlerMapping endpointHandlerMapping(Collection endpoints) { - return new EndpointHandlerMapping(endpoints); - } - - @Bean - @Autowired - public EndpointMvcAdapter metricsEndPoint(MetricsEndpoint delegate) { - return new EndpointMvcAdapter(delegate); - } -} \ No newline at end of file diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java new file mode 100644 index 0000000..b14861d --- /dev/null +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java @@ -0,0 +1,14 @@ +package org.gcube.datatransfer.resolver.services; + +import javax.ws.rs.Path; + +import org.eclipse.microprofile.health.HealthCheck; +import org.eclipse.microprofile.health.HealthCheckResponse; + +@Path("health") +public class UriResolverHealthCheck implements HealthCheck { + @Override + public HealthCheckResponse call() { + return HealthCheckResponse.named("uri-resolver").up().build(); + } +} \ No newline at end of file -- 2.17.1 From a1db22e5b835bbc5ad67d3d098dd073c6d6a8114 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 15 Oct 2024 16:55:16 +0200 Subject: [PATCH 07/11] updated interface `health` --- .../datatransfer/resolver/ConstantsResolver.java | 2 +- .../resolver/services/UriResolverHealthCheck.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/ConstantsResolver.java b/src/main/java/org/gcube/datatransfer/resolver/ConstantsResolver.java index 2606032..c14b38b 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/ConstantsResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/ConstantsResolver.java @@ -30,7 +30,7 @@ public class ConstantsResolver { public static final String QUERY_PARAM_CONTENT_TYPE = "contentType"; public static final String QUERY_PARAM_FILE_NAME = "fileName"; - public static final String[] resourcesHardCoded = { "ctlg", "metrics" }; + public static final String[] resourcesHardCoded = { "ctlg" }; // The default resource candidate to manage the input requests not matching any // resolver services diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java index b14861d..712dc76 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java @@ -1,5 +1,6 @@ package org.gcube.datatransfer.resolver.services; +import javax.ws.rs.GET; import javax.ws.rs.Path; import org.eclipse.microprofile.health.HealthCheck; @@ -7,7 +8,17 @@ import org.eclipse.microprofile.health.HealthCheckResponse; @Path("health") public class UriResolverHealthCheck implements HealthCheck { + @Override + /** + * Index. + * + * @param req the req + * @return the input stream + * @throws WebApplicationException the web application exception + */ + @GET + @Path("") public HealthCheckResponse call() { return HealthCheckResponse.named("uri-resolver").up().build(); } -- 2.17.1 From e2b0020484250d856ed5658d0136fa7b23529a9e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 15 Oct 2024 17:08:42 +0200 Subject: [PATCH 08/11] added implementation of HealthCheckResponse --- .../services/UriResolverHealthCheck.java | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java index 712dc76..68f61cf 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java @@ -1,25 +1,51 @@ package org.gcube.datatransfer.resolver.services; +import java.util.Map; +import java.util.Optional; + import javax.ws.rs.GET; import javax.ws.rs.Path; import org.eclipse.microprofile.health.HealthCheck; import org.eclipse.microprofile.health.HealthCheckResponse; +/** + * The Class UriResolverHealthCheck. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Oct 15, 2024 + */ @Path("health") public class UriResolverHealthCheck implements HealthCheck { - - @Override - /** - * Index. + + /** + * Call. * - * @param req the req - * @return the input stream - * @throws WebApplicationException the web application exception + * @return the health check response */ + @Override @GET @Path("") - public HealthCheckResponse call() { - return HealthCheckResponse.named("uri-resolver").up().build(); - } + public HealthCheckResponse call() { + // return HealthCheckResponse.named("uri-resolver").up().build(); + + // WORKS in native + return new HealthCheckResponse() { + @Override + public String getName() { + return "uri-resolver"; + } + + @Override + public Status getStatus() { + return Status.UP; + } + + @Override + public Optional> getData() { + return Optional.empty(); + } + }; + } } \ No newline at end of file -- 2.17.1 From deca3440228546b58c61eef84d874051eedd8b3c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 15 Oct 2024 17:19:01 +0200 Subject: [PATCH 09/11] updated UriResolverHealthCheck --- .../resolver/services/UriResolverHealthCheck.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java index 68f61cf..d80f10b 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java @@ -5,6 +5,9 @@ import java.util.Optional; import javax.ws.rs.GET; import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.eclipse.microprofile.health.HealthCheck; import org.eclipse.microprofile.health.HealthCheckResponse; @@ -19,14 +22,22 @@ import org.eclipse.microprofile.health.HealthCheckResponse; @Path("health") public class UriResolverHealthCheck implements HealthCheck { + @GET + @Path("") + @Produces({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON }) + public Response check() { + + HealthCheckResponse hcr = call(); + + return Response.ok().entity(hcr).build(); + } + /** * Call. * * @return the health check response */ @Override - @GET - @Path("") public HealthCheckResponse call() { // return HealthCheckResponse.named("uri-resolver").up().build(); -- 2.17.1 From 22bf660710cdb3e52a88f2252ed9d7fa108a5785 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 16 Oct 2024 11:04:36 +0200 Subject: [PATCH 10/11] updated HealthCheckResponse --- .../services/UriResolverHealthCheck.java | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java index d80f10b..0631693 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverHealthCheck.java @@ -11,6 +11,8 @@ import javax.ws.rs.core.Response; import org.eclipse.microprofile.health.HealthCheck; import org.eclipse.microprofile.health.HealthCheckResponse; +import org.eclipse.microprofile.health.HealthCheckResponse.Status; +import org.eclipse.microprofile.health.Liveness; /** * The Class UriResolverHealthCheck. @@ -28,7 +30,6 @@ public class UriResolverHealthCheck implements HealthCheck { public Response check() { HealthCheckResponse hcr = call(); - return Response.ok().entity(hcr).build(); } @@ -37,26 +38,10 @@ public class UriResolverHealthCheck implements HealthCheck { * * @return the health check response */ + @Liveness @Override public HealthCheckResponse call() { - // return HealthCheckResponse.named("uri-resolver").up().build(); - // WORKS in native - return new HealthCheckResponse() { - @Override - public String getName() { - return "uri-resolver"; - } - - @Override - public Status getStatus() { - return Status.UP; - } - - @Override - public Optional> getData() { - return Optional.empty(); - } - }; + return new HealthCheckResponse("uri-resolver", Status.UP, Optional.empty()); } } \ No newline at end of file -- 2.17.1 From 7bd66b46286342581952d6efa8affcf6f523d52a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 16 Oct 2024 11:11:03 +0200 Subject: [PATCH 11/11] updated the changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80e5fdf..fa5a057 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [v2.10.1-SNAPSHOT] - Bug fixing StorageID resolver [#28276] +- Added HealthCheckResponse via `microprofile-health-api` (see https://microprofile.io/specifications/microprofile-health/) ## [v2.10.0] -- 2.17.1