From 6f4ce4fad601f9a1d690502da30d6e869b988998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skaar=2C=20Bj=C3=B8rn-Andre?= Date: Wed, 17 Jan 2024 22:33:45 +0100 Subject: [PATCH] =?UTF-8?q?Re-emab=C3=B8e=20suffix=20pattern=20matching?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- klass-api/doc/requests/examples-classifications.http | 7 +++++++ .../api/controllers/ClassificationController.java | 3 ++- .../api/dto/hal/CorrespondenceTableResource.java | 3 ++- .../dto/hal/CorrespondenceTableSummaryResource.java | 2 +- klass-api/src/main/resources/application.properties | 12 +++++++++++- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/klass-api/doc/requests/examples-classifications.http b/klass-api/doc/requests/examples-classifications.http index 1d08928..c88d319 100644 --- a/klass-api/doc/requests/examples-classifications.http +++ b/klass-api/doc/requests/examples-classifications.http @@ -33,3 +33,10 @@ Accept: application/json ### Get all classifications with size and page GET {{base_url}}/classifications?size=2&page=2 Accept: application/json + +### Get a single correspondencetable +GET {{base_url}}/correspondencetables/1 +Accept: application/json + +### Get a single correspondencetable with suffix pattern matching +GET {{base_url}}/correspondencetables/1.csv diff --git a/klass-api/src/main/java/no/ssb/klass/api/controllers/ClassificationController.java b/klass-api/src/main/java/no/ssb/klass/api/controllers/ClassificationController.java index d6a8e93..5621a6f 100644 --- a/klass-api/src/main/java/no/ssb/klass/api/controllers/ClassificationController.java +++ b/klass-api/src/main/java/no/ssb/klass/api/controllers/ClassificationController.java @@ -59,6 +59,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -254,7 +255,7 @@ public ClassificationVersionResource versions(@PathVariable Long id, return new ClassificationVersionResource(version, language, corrTableVersionIsTarget, includeFuture); } - @RequestMapping(value = "/correspondencetables/{id}", method = RequestMethod.GET) + @GetMapping("/correspondencetables/{id}") public CorrespondenceTableResource correspondenceTables(@PathVariable Long id, @RequestParam(value = "language", defaultValue = "nb") Language language) { CorrespondenceTable table = classificationService.getCorrespondenceTable(id); diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableResource.java index ed1d7fa..4265b92 100644 --- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableResource.java +++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableResource.java @@ -12,7 +12,8 @@ @JacksonXmlRootElement(localName = "correspondenceTable") @JsonPropertyOrder({"name", "contactPerson", "owningSection", "source", "sourceId", "target", "targetId", "changeTable", - "lastModified", "published", "links"}) + "lastModified", "published", "sourceLevel", "targetLevel", "description", "changelogs", "correspondenceMaps", + "links"}) public class CorrespondenceTableResource extends CorrespondenceTableSummaryResource { private final String description; private final List changelogs; diff --git a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableSummaryResource.java b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableSummaryResource.java index 0af1caa..e28c700 100644 --- a/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableSummaryResource.java +++ b/klass-api/src/main/java/no/ssb/klass/api/dto/hal/CorrespondenceTableSummaryResource.java @@ -21,7 +21,7 @@ import no.ssb.klass.api.controllers.ClassificationController; @JsonPropertyOrder({"name", "contactPerson", "owningSection", "source", "sourceId", "target", "targetId", "changeTable", - "lastModified", "published", "links"}) + "lastModified", "published", "sourceLevel", "targetLevel", "links"}) public class CorrespondenceTableSummaryResource extends KlassResource { private final String name; private final ContactPersonResource contactPerson; diff --git a/klass-api/src/main/resources/application.properties b/klass-api/src/main/resources/application.properties index 656bd81..e7a2fa4 100644 --- a/klass-api/src/main/resources/application.properties +++ b/klass-api/src/main/resources/application.properties @@ -67,4 +67,14 @@ klass.env.api.path=/api/klass # Set to '/**' to skip authorization for local testing security.ignored=${klass.env.security.ignored} -spring.main.allow-bean-definition-overriding=true \ No newline at end of file +# Spring Boot 2.1 disabled bean overriding by default as a defensive approach. +# But we need to override some beans in our tests, so we need to enable it. +spring.main.allow-bean-definition-overriding=true + +# Spring MVC 5.3 disabled suffix pattern matching by default as a defensive approach. +# But we need to re-enable this since buttons from ssb.no/klass still uses it +spring.mvc.pathmatch.use-registered-suffix-pattern=true +spring.mvc.pathmatch.matching-strategy: ant-path-matcher +spring.mvc.contentnegotiation.favor-path-extension=true +# Register additional file extensions/media types: +spring.mvc.contentnegotiation.media-types.csv=text/csv \ No newline at end of file