From 057da8662a3ba70798b75e82613a3605dff37198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germaine=20G=C3=B6tzelmann?= Date: Mon, 16 Jun 2025 20:02:24 +0200 Subject: [PATCH 1/3] allowing for enabling of actuators and swagger ui --- build.gradle | 8 +++++--- .../java/edu/kit/scc/dem/wapsrv/app/WapServerConfig.java | 4 ++-- .../kit/scc/dem/wapsrv/controller/CatchAllController.java | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index f82e39b..7138256 100644 --- a/build.gradle +++ b/build.gradle @@ -38,7 +38,7 @@ ext { set('javersVersion', "6.8.0") set('jenaVersion', "5.4.0") set('springBootVersion', "3.4.5") - set('springDocVersion', "2.5.0") + set('springDocVersion', "2.8.9") set('keycloakVersion', "19.0.0") set('junitPlatformVersion', "1.11.4") set('junitJupiterVersion', "5.11.4") @@ -82,7 +82,7 @@ dependencies { implementation "org.springframework.boot:spring-boot-starter-data-jpa" implementation "org.springframework.boot:spring-boot-starter-data-rest" implementation "org.springframework.boot:spring-boot-starter-mail" - //implementation "org.springframework.boot:spring-boot-starter-actuator" + implementation "org.springframework.boot:spring-boot-starter-actuator" //implementation "org.springframework.security:spring-security-web:5.7.5" //implementation "org.springframework.security:spring-security-config:5.7.5" @@ -97,6 +97,8 @@ dependencies { // springdoc implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:${springDocVersion}" + implementation "org.springdoc:springdoc-openapi-starter-common:${springDocVersion}" + implementation "org.springdoc:springdoc-openapi-starter-webmvc-api:${springDocVersion}" //Keycloak // implementation "org.keycloak:keycloak-spring-boot-starter:${keycloakVersion}" @@ -197,4 +199,4 @@ tasks.register('printProjectName') { doLast { println "${project.name}" } -} +} \ No newline at end of file diff --git a/src/main/java/edu/kit/scc/dem/wapsrv/app/WapServerConfig.java b/src/main/java/edu/kit/scc/dem/wapsrv/app/WapServerConfig.java index 7d49cb9..9394f50 100644 --- a/src/main/java/edu/kit/scc/dem/wapsrv/app/WapServerConfig.java +++ b/src/main/java/edu/kit/scc/dem/wapsrv/app/WapServerConfig.java @@ -14,8 +14,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.util.PathMatcher; import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; import edu.kit.scc.dem.wapsrv.controller.WapPathMatcher; import java.util.Arrays; @@ -31,7 +31,7 @@ * @version 1.1 */ @Configuration -public class WapServerConfig extends WebMvcConfigurationSupport{ +public class WapServerConfig extends DelegatingWebMvcConfiguration { /** * The endpoint to use for all requests relating to the Web Annotation diff --git a/src/main/java/edu/kit/scc/dem/wapsrv/controller/CatchAllController.java b/src/main/java/edu/kit/scc/dem/wapsrv/controller/CatchAllController.java index e0948de..51cc72f 100644 --- a/src/main/java/edu/kit/scc/dem/wapsrv/controller/CatchAllController.java +++ b/src/main/java/edu/kit/scc/dem/wapsrv/controller/CatchAllController.java @@ -47,7 +47,7 @@ public class CatchAllController extends BasicController { * @throws WapException * in case any error occurs */ - @RequestMapping(value = "**") + @RequestMapping(value = "/{[path:[^\\.]*}") public ResponseEntity catchallRequest(HttpServletRequest request, @RequestHeader HttpHeaders headers) throws WapException { // The basic idea is that all "real" controllers just intercept those messages From bfdcb0f8d676a4ff324707ceb74fdd74194920df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germaine=20G=C3=B6tzelmann?= Date: Mon, 16 Jun 2025 20:20:32 +0200 Subject: [PATCH 2/3] fix missing info page on server root --- .../edu/kit/scc/dem/wapsrv/controller/CatchAllController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/kit/scc/dem/wapsrv/controller/CatchAllController.java b/src/main/java/edu/kit/scc/dem/wapsrv/controller/CatchAllController.java index 51cc72f..da65f94 100644 --- a/src/main/java/edu/kit/scc/dem/wapsrv/controller/CatchAllController.java +++ b/src/main/java/edu/kit/scc/dem/wapsrv/controller/CatchAllController.java @@ -47,7 +47,7 @@ public class CatchAllController extends BasicController { * @throws WapException * in case any error occurs */ - @RequestMapping(value = "/{[path:[^\\.]*}") + @RequestMapping(value = { "/", "/{path:[^\\.]*}" }) public ResponseEntity catchallRequest(HttpServletRequest request, @RequestHeader HttpHeaders headers) throws WapException { // The basic idea is that all "real" controllers just intercept those messages From 0e1d8ff7ed083f924bd0aa5b6179869c14e047b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germaine=20G=C3=B6tzelmann?= Date: Tue, 17 Jun 2025 14:32:21 +0200 Subject: [PATCH 3/3] make catch all controller obsolete in favor of a static index page on the root path. --- build.gradle | 6 ++++-- .../wapsrv/controller/CatchAllController.java | 19 ++++++++++++++++--- .../wapsrv/testsrest/AnnotationRestTest.java | 4 ++-- static/index.html | 6 ++++++ 4 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 static/index.html diff --git a/build.gradle b/build.gradle index 7138256..ffa3cd0 100644 --- a/build.gradle +++ b/build.gradle @@ -70,7 +70,8 @@ sourceSets { 'doc/**/*.*', 'webcontent/**/*.*', 'schemas/**/*.*', - 'profiles/**/FRAME_*.*' + 'profiles/**/FRAME_*.*', + 'static/index.html' ] } } @@ -80,7 +81,8 @@ dependencies { // boot starter implementation "org.springframework.boot:spring-boot-starter-validation" implementation "org.springframework.boot:spring-boot-starter-data-jpa" - implementation "org.springframework.boot:spring-boot-starter-data-rest" + //implementation "org.springframework.boot:spring-boot-starter-data-rest" + implementation "org.springframework.boot:spring-boot-starter-web" implementation "org.springframework.boot:spring-boot-starter-mail" implementation "org.springframework.boot:spring-boot-starter-actuator" diff --git a/src/main/java/edu/kit/scc/dem/wapsrv/controller/CatchAllController.java b/src/main/java/edu/kit/scc/dem/wapsrv/controller/CatchAllController.java index da65f94..50c97ba 100644 --- a/src/main/java/edu/kit/scc/dem/wapsrv/controller/CatchAllController.java +++ b/src/main/java/edu/kit/scc/dem/wapsrv/controller/CatchAllController.java @@ -5,6 +5,8 @@ import jakarta.servlet.http.HttpServletRequest; import org.eclipse.jetty.http.HttpMethod; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.core.io.ClassPathResource; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -18,6 +20,11 @@ import edu.kit.scc.dem.wapsrv.exceptions.InvalidRequestException; import edu.kit.scc.dem.wapsrv.exceptions.MethodNotAllowedException; import edu.kit.scc.dem.wapsrv.exceptions.WapException; +import org.springframework.web.servlet.function.RouterFunction; +import org.springframework.web.servlet.function.ServerResponse; + +import static org.springframework.web.servlet.function.RequestPredicates.path; +import static org.springframework.web.servlet.function.RouterFunctions.route; /** * This controller adds the catch all feature to the server which answers all request that not mapped correctly @@ -30,15 +37,20 @@ * @version 1.1 */ @RestController -@RequestMapping("/") public class CatchAllController extends BasicController { @Autowired private WapServerConfig wapServerConfig; + @Bean + RouterFunction spaRouter() { + ClassPathResource index = new ClassPathResource("static/index.html"); + return route().resource(path("/"), index).build(); + } + /** * This method implements the endpoint that catches all otherwise not mapped requests to create meaningful error * messages - * + * * @param request * The request the client sent * @param headers @@ -47,9 +59,10 @@ public class CatchAllController extends BasicController { * @throws WapException * in case any error occurs */ - @RequestMapping(value = { "/", "/{path:[^\\.]*}" }) + public ResponseEntity catchallRequest(HttpServletRequest request, @RequestHeader HttpHeaders headers) throws WapException { + //TODO: should be obsolete, currently here for sake of existing tests // The basic idea is that all "real" controllers just intercept those messages // that truly fit them and check their parameters, headers and so on there. // All request that do not exactly fit one request and cannot be mapped, land here diff --git a/src/test/java/edu/kit/scc/dem/wapsrv/testsrest/AnnotationRestTest.java b/src/test/java/edu/kit/scc/dem/wapsrv/testsrest/AnnotationRestTest.java index 29b7a2d..6361e6d 100644 --- a/src/test/java/edu/kit/scc/dem/wapsrv/testsrest/AnnotationRestTest.java +++ b/src/test/java/edu/kit/scc/dem/wapsrv/testsrest/AnnotationRestTest.java @@ -795,7 +795,7 @@ public void testPutAnnotationWithParams() { // The annotation does not have to exist for this test String containerIri = createDefaultContainer(null); // in the root container try { - URL url = new URL(containerIri); + URL url = new URL(containerIri + "anno1"); String params = "test=1"; Map requestHeaders = new Hashtable(); requestHeaders.put("Content-Type", "application/ld+json;profile=\"http://www.w3.org/ns/anno.jsonld\""); @@ -805,7 +805,7 @@ public void testPutAnnotationWithParams() { = performOwnHttpRequest(url, OwnHttpURLConnection.Request.PUT, requestHeaders, params, annotation); // logger.trace(response.getTransmittedString()); // logger.trace(response.getReceivedString()); - checkException(IllegalHttpParameterException.class, response, ErrorMessageRegistry.ALL_NO_PARAMETERS_IN_PUT); + checkException(IllegalHttpParameterException.class, response, "No parameters allowed"); } catch (MalformedURLException e) { fail(e.getMessage()); } diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..7c5f064 --- /dev/null +++ b/static/index.html @@ -0,0 +1,6 @@ + +A GET request to the server's base url has been received. To interact with this server, there are a few endpoint you can send requests to :
+
  • ./wap/ for requests to the main functinality, the Web Annotation Protocol Service
  • +
  • ./webapp for requests to the Web Annotation Protocol Service Client
  • +
  • ./javadoc for requests to the the integrated javadoc
  • +
\ No newline at end of file