diff --git a/Changes b/Changes index 4477da6c..a1278064 100644 --- a/Changes +++ b/Changes @@ -1,11 +1,12 @@ # version 0.74-SNAPSHOT -- Unified ResourceFilters and SearchResourceFilters. - Remove corpusQuery param in the statistics web-service (close #758). - Moved NamedVCLoader to the init package. - Clean up Spring XML configs. - Fix some logging to write to file instead of stdout. - Change CC RE from CC-BY.* to CC.* (kupietz) +- Unified ResourceFilters and SearchResourceFilters. +- Fixed supported versions in the configs & changed delimiter to comma. # version 0.73.2 diff --git a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java index 9fa7e858..a1ccd116 100644 --- a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java +++ b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java @@ -15,6 +15,7 @@ import java.util.Properties; import java.util.Set; import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -161,7 +162,8 @@ protected void load (Properties properties) throws Exception { this.supportedVersions = new HashSet<>(); if (!supportedVersions.isEmpty()) { List versionArray = Arrays - .asList(supportedVersions.split(" ")); + .stream(supportedVersions.split(",")).map(String::trim) + .collect(Collectors.toList()); this.supportedVersions.addAll(versionArray); } this.supportedVersions.add(currentVersion); diff --git a/src/main/resources/kustvakt.conf b/src/main/resources/kustvakt.conf index a45eb415..e90c513f 100644 --- a/src/main/resources/kustvakt.conf +++ b/src/main/resources/kustvakt.conf @@ -14,8 +14,8 @@ ldap.config = src/main/resources/embedded-ldap-example.conf # Kustvakt api.welcome.message = Welcome to KorAP API! current.api.version = v1.0 -# multiple versions separated by space -# supported.api.version = v1.0 +# multiple versions comma separated +# supported.api.versions = v1.0 # server server.port=8089 diff --git a/src/test/java/de/ids_mannheim/korap/web/ApiVersionTest.java b/src/test/java/de/ids_mannheim/korap/web/APIVersionTest.java similarity index 72% rename from src/test/java/de/ids_mannheim/korap/web/ApiVersionTest.java rename to src/test/java/de/ids_mannheim/korap/web/APIVersionTest.java index 9e138fa1..0c1dce00 100644 --- a/src/test/java/de/ids_mannheim/korap/web/ApiVersionTest.java +++ b/src/test/java/de/ids_mannheim/korap/web/APIVersionTest.java @@ -3,10 +3,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import java.net.URI; +import java.util.Set; import org.eclipse.jetty.http.HttpStatus; import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import de.ids_mannheim.korap.config.KustvaktConfiguration; import de.ids_mannheim.korap.config.SpringJerseyTest; import de.ids_mannheim.korap.exceptions.KustvaktException; import jakarta.ws.rs.core.MediaType; @@ -15,8 +18,11 @@ /** * @author margaretha */ -public class ApiVersionTest extends SpringJerseyTest { +public class APIVersionTest extends SpringJerseyTest { + @Autowired + private KustvaktConfiguration config; + @Test public void testSearchWithoutVersion () throws KustvaktException { Response response = target().path("api").path("search") @@ -36,4 +42,13 @@ public void testSearchWrongVersion () throws KustvaktException { URI location = response.getLocation(); assertEquals("/api/" + API_VERSION + "/search", location.getPath()); } + + @Test + public void testSupportedVersions () { + Set versions = config.getSupportedVersions(); + assertEquals(2, versions.size()); + + String version = versions.stream().findFirst().orElse(""); + assertEquals(4, version.length()); + } } diff --git a/src/test/resources/kustvakt-dnb.conf b/src/test/resources/kustvakt-dnb.conf index c6dbdf1d..54e0edf6 100644 --- a/src/test/resources/kustvakt-dnb.conf +++ b/src/test/resources/kustvakt-dnb.conf @@ -21,9 +21,9 @@ ldap.config = src/test/resources/test-ldap.conf # Kustvakt versions # -# multiple versions separated by space +# multiple versions comma separated current.api.version = v1.0 -supported.api.version = v0.1 v1.0 +supported.api.versions = v1.0 # Server # diff --git a/src/test/resources/kustvakt-icc.conf b/src/test/resources/kustvakt-icc.conf index 965eb4cc..354022e4 100644 --- a/src/test/resources/kustvakt-icc.conf +++ b/src/test/resources/kustvakt-icc.conf @@ -13,9 +13,9 @@ krill.test = true ldap.config = src/test/resources/test-ldap.conf # Kustvakt -# multiple versions separated by space +# multiple versions comma separated current.api.version = v1.0 -supported.api.version = v0.1 v1.0 +supported.api.versions = v1.0 # server server.port=8089 diff --git a/src/test/resources/kustvakt-test.conf b/src/test/resources/kustvakt-test.conf index eb940085..f10d3e85 100644 --- a/src/test/resources/kustvakt-test.conf +++ b/src/test/resources/kustvakt-test.conf @@ -19,9 +19,9 @@ ldap.config = src/test/resources/test-ldap.conf # Kustvakt versions # -# multiple versions separated by space +# multiple versions comma separated current.api.version = v1.0 -supported.api.version = v0.1 v1.0 +supported.api.versions = v0.1, v1.0 # Server #