Added API info web-service.
Change-Id: I8ff91cd5dccca0824146d38a361964cc284cd196
diff --git a/full/Changes b/full/Changes
index beb2de3..04fa3cc 100644
--- a/full/Changes
+++ b/full/Changes
@@ -26,6 +26,8 @@
- Added query and query language in virtual corpus table (margaretha)
18/02/2021
- Set corpus access public for stored query (margaretha)
+19/02/2021
+ - Enabled API info web-service (margaretha)
# version 0.62.4
diff --git a/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java b/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java
index 8d17105..3204656 100644
--- a/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java
@@ -348,7 +348,7 @@
String koralQuery, String definition, String description,
String status, boolean isCached, String username, String query,
String queryLanguage) throws KustvaktException {
- ParameterChecker.checkNameValue(queryName, "name");
+ ParameterChecker.checkNameValue(queryName, "queryName");
ParameterChecker.checkObjectValue(type, "type");
if (!queryNamePattern.matcher(queryName).matches()) {
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/KustvaktController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/KustvaktController.java
deleted file mode 100644
index 230afe1..0000000
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/KustvaktController.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package de.ids_mannheim.korap.web.controller;
-
-import java.util.HashMap;
-import java.util.Map;
-
-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.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-
-import de.ids_mannheim.korap.config.KustvaktConfiguration;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.utils.ServiceInfo;
-import de.ids_mannheim.korap.web.CoreResponseHandler;
-
-/**
- * Created by hanl on 29.04.16.
- */
-@Controller
-@Path("kustvakt")
-@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
-public class KustvaktController {
-
- @Autowired
- private CoreResponseHandler kustvaktResponseHandler;
-
- @Autowired
- private KustvaktConfiguration config;
-
- @GET
- @Path("info")
- public Response getInfo () {
-
- Map m = new HashMap();
- m.put("version", ServiceInfo.getInfo().getVersion());
- m.put("supported_api_version(s)", config.getSupportedVersions());
- m.put("service_name", ServiceInfo.getInfo().getName());
- try {
- return Response.ok(JsonUtils.toJSON(m)).build();
- }
- catch (KustvaktException e) {
- throw kustvaktResponseHandler.throwit(e);
- }
- }
-
-}
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/InfoControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/InfoControllerTest.java
new file mode 100644
index 0000000..783e417
--- /dev/null
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/InfoControllerTest.java
@@ -0,0 +1,44 @@
+package de.ids_mannheim.korap.web.controller;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.ClientResponse.Status;
+
+import de.ids_mannheim.korap.config.KustvaktConfiguration;
+import de.ids_mannheim.korap.config.SpringJerseyTest;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.utils.JsonUtils;
+import de.ids_mannheim.korap.utils.ServiceInfo;
+
+public class InfoControllerTest extends SpringJerseyTest {
+
+ @Autowired
+ private KustvaktConfiguration config;
+
+ @Test
+ public void testInfo () throws KustvaktException {
+ ClientResponse response = resource().path(API_VERSION).path("info")
+ .get(ClientResponse.class);
+
+ assertEquals(Status.OK.getStatusCode(), response.getStatus());
+
+ String entity = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(entity);
+ assertEquals(config.getCurrentVersion(),
+ node.at("/latest_api_version").asText());
+ assertEquals(config.getSupportedVersions().size(),
+ node.at("/supported_api_versions").size());
+
+ assertEquals(ServiceInfo.getInfo().getVersion(),
+ node.at("/kustvakt_version").asText());
+ assertEquals(ServiceInfo.getInfo().getKrillVersion(),
+ node.at("/krill_version").asText());
+ assertEquals(ServiceInfo.getInfo().getKoralVersion(),
+ node.at("/koral_version").asText());
+ }
+}