Added API URL versioning.
Change-Id: I0000000000000000000000000000000000000000
diff --git a/lite/Changes b/lite/Changes
index 9747ca5..942779a 100644
--- a/lite/Changes
+++ b/lite/Changes
@@ -1,3 +1,7 @@
+version 0.61.0
+28/08/2018
+ - Added API URL versioning (margaretha)
+
version 0.60.2
05/07/2018
- Added support for unrestricted corpus statistics (ndiewald)
diff --git a/lite/pom.xml b/lite/pom.xml
index 36996fe..9e8ccaf 100644
--- a/lite/pom.xml
+++ b/lite/pom.xml
@@ -147,7 +147,7 @@
<dependency>
<groupId>de.ids_mannheim.korap</groupId>
<artifactId>Kustvakt-core</artifactId>
- <version>0.61.0</version>
+ <version>0.61.1</version>
</dependency>
<!-- Spring -->
diff --git a/lite/src/main/java/de/ids_mannheim/korap/web/service/lite/LiteService.java b/lite/src/main/java/de/ids_mannheim/korap/web/service/lite/LiteService.java
index 0ed2b95..f5b648b 100644
--- a/lite/src/main/java/de/ids_mannheim/korap/web/service/lite/LiteService.java
+++ b/lite/src/main/java/de/ids_mannheim/korap/web/service/lite/LiteService.java
@@ -23,8 +23,7 @@
import org.springframework.stereotype.Controller;
import com.sun.jersey.core.util.MultivaluedMapImpl;
-
-import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.jersey.spi.container.ResourceFilters;
import de.ids_mannheim.korap.config.KustvaktConfiguration;
import de.ids_mannheim.korap.config.QueryBuilderUtil;
@@ -37,24 +36,26 @@
import de.ids_mannheim.korap.web.ClientsHandler;
import de.ids_mannheim.korap.web.CoreResponseHandler;
import de.ids_mannheim.korap.web.SearchKrill;
-import de.ids_mannheim.korap.utils.JsonUtils;
+import de.ids_mannheim.korap.web.APIVersionFilter;
/**
* @author hanl
* @date 29/01/2014
*
* @author margaretha
- * @update 10/10/2017
+ * @update 28/08/2018
*
* <pre>
* Recent changes:
* - removed version from service paths
* - altered service with path /search and method trace to path
* /query and method get
+ * - added API versioning
* </pre>
*/
@Controller
-@Path("/")
+@Path("{version}/")
+@ResourceFilters(APIVersionFilter.class)
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public class LiteService {
@@ -104,6 +105,7 @@
}
+ @SuppressWarnings("unchecked")
@GET
@Path("query")
public Response buildQuery (@QueryParam("q") String q,
@@ -162,6 +164,7 @@
}
+ @SuppressWarnings({ "unchecked", "rawtypes" })
@GET
@Path("search")
public Response searchbyNameAll (@QueryParam("q") String q,
@@ -249,6 +252,7 @@
* @param engine
* @return
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
//fixme: search in collection /collection/collection-id/search
@Deprecated
@GET
diff --git a/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteServiceTest.java b/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteServiceTest.java
index 9ea02c7..8212e84 100644
--- a/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteServiceTest.java
+++ b/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteServiceTest.java
@@ -11,7 +11,6 @@
import java.util.Iterator;
import java.util.concurrent.ThreadLocalRandom;
-import org.apache.lucene.LucenePackage;
import org.junit.Test;
import org.springframework.web.context.ContextLoaderListener;
@@ -42,7 +41,8 @@
*/
public class LiteServiceTest extends JerseyTest{
- public static final String classPackage = "de.ids_mannheim.korap.web.service.light";
+ public static final String API_VERSION = "v0.1";
+ public static final String classPackage = "de.ids_mannheim.korap.web.service.lite";
@Override
protected TestContainerFactory getTestContainerFactory ()
@@ -76,7 +76,7 @@
@Test
public void testStatistics () throws KustvaktException{
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("statistics")
.queryParam("corpusQuery", "textType=Autobiographie & corpusSigle=GOE")
.method("GET", ClientResponse.class);
@@ -92,7 +92,7 @@
@Test
public void testEmptyStatistics () throws KustvaktException{
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("statistics")
.queryParam("corpusQuery", "")
.method("GET", ClientResponse.class);
@@ -105,7 +105,7 @@
assertEquals(25074, node.at("/sentences").asInt());
assertEquals(772, node.at("/paragraphs").asInt());
- response = resource()
+ response = resource().path(API_VERSION)
.path("statistics")
.method("GET", ClientResponse.class);
assertEquals(ClientResponse.Status.OK.getStatusCode(),
@@ -121,7 +121,7 @@
@Test
public void testGetJSONQuery () throws KustvaktException{
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("query").queryParam("q", "[orth=das]")
.queryParam("ql", "poliqarp").queryParam("context", "sentence")
.queryParam("count", "13")
@@ -141,7 +141,7 @@
@Test
public void testbuildAndPostQuery () throws KustvaktException{
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("query").queryParam("q", "[orth=das]")
.queryParam("ql", "poliqarp")
.queryParam("cq", "corpusSigle=WPD | corpusSigle=GOE")
@@ -153,7 +153,7 @@
JsonNode node = JsonUtils.readTree(query);
assertNotNull(node);
- response = resource().path("search")
+ response = resource().path(API_VERSION).path("search")
.post(ClientResponse.class, query);
assertEquals(ClientResponse.Status.OK.getStatusCode(),
@@ -166,7 +166,7 @@
@Test
public void testQueryGet () throws KustvaktException{
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("search").queryParam("q", "[orth=das]")
.queryParam("ql", "poliqarp").queryParam("context", "sentence")
.queryParam("count", "13").get(ClientResponse.class);
@@ -183,7 +183,7 @@
@Test
public void testQueryFailure () throws KustvaktException{
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("search").queryParam("q", "[orth=das")
.queryParam("ql", "poliqarp")
.queryParam("cq", "corpusSigle=WPD | corpusSigle=GOE")
@@ -205,7 +205,7 @@
@Test
public void testFoundryRewrite () throws KustvaktException{
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("search").queryParam("q", "[orth=das]")
.queryParam("ql", "poliqarp").queryParam("context", "sentence")
.queryParam("count", "13").get(ClientResponse.class);
@@ -224,7 +224,7 @@
QuerySerializer s = new QuerySerializer();
s.setQuery("[orth=das]", "poliqarp");
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("search").post(ClientResponse.class, s.toJSON());
assertEquals(ClientResponse.Status.OK.getStatusCode(),
response.getStatus());
@@ -238,7 +238,7 @@
@Test
public void testParameterField () throws KustvaktException{
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("search").queryParam("q", "[orth=das]")
.queryParam("ql", "poliqarp")
.queryParam("fields", "author, docSigle")
@@ -257,7 +257,7 @@
@Test
public void testMatchInfoGetWithoutSpans () throws KustvaktException{
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("corpus/GOE/AGA/01784/p36-46(5)37-45(2)38-42/matchInfo")
.queryParam("foundry", "*")
.queryParam("spans", "false")
@@ -275,7 +275,7 @@
@Test
public void testMatchInfoGetWithoutHighlights () throws KustvaktException{
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("corpus/GOE/AGA/01784/p36-46(5)37-45(2)38-42/matchInfo")
.queryParam("foundry", "xy")
.queryParam("spans", "false")
@@ -296,7 +296,7 @@
@Test
public void testMatchInfoGetWithHighlights () throws KustvaktException{
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("corpus/GOE/AGA/01784/p36-46(5)37-45(2)38-42/matchInfo")
.queryParam("foundry", "xy")
.queryParam("spans", "false")
@@ -318,7 +318,7 @@
@Test
public void testMatchInfoGet2 () throws KustvaktException{
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("corpus/GOE/AGA/01784/p36-46/matchInfo")
.queryParam("foundry", "*")
@@ -334,7 +334,7 @@
@Test
public void testCollectionQueryParameter () throws KustvaktException{
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("query").queryParam("q", "[orth=das]")
.queryParam("ql", "poliqarp")
.queryParam("fields", "author, docSigle")
@@ -351,13 +351,13 @@
.asText());
assertEquals("WPD", node.at("/collection/operands/1/value").asText());
- response = resource().path("search")
+ response = resource().path(API_VERSION).path("search")
.queryParam("q", "[orth=das]").queryParam("ql", "poliqarp")
.queryParam("fields", "author, docSigle")
.queryParam("context", "sentence").queryParam("count", "13")
.queryParam("cq", "textClass=Politik & corpus=WPD")
.get(ClientResponse.class);
- String version = LucenePackage.get().getImplementationVersion();;
+// String version = LucenePackage.get().getImplementationVersion();;
// System.out.println("VERSION "+ version);
// System.out.println("RESPONSE "+ response);
assertEquals(ClientResponse.Status.OK.getStatusCode(),
@@ -373,7 +373,7 @@
@Test
public void testMetaFields () throws KustvaktException {
- ClientResponse response = resource()
+ ClientResponse response = resource().path(API_VERSION)
.path("/corpus/GOE/AGA/01784")
.method("GET", ClientResponse.class);
assertEquals(ClientResponse.Status.OK.getStatusCode(),
diff --git a/lite/src/test/java/de/ids_mannheim/korap/web/service/VCReferenceTest.java b/lite/src/test/java/de/ids_mannheim/korap/web/service/VCReferenceTest.java
index 6de7432..2a0bd0c 100644
--- a/lite/src/test/java/de/ids_mannheim/korap/web/service/VCReferenceTest.java
+++ b/lite/src/test/java/de/ids_mannheim/korap/web/service/VCReferenceTest.java
@@ -25,7 +25,8 @@
public class VCReferenceTest extends JerseyTest{
- public static final String classPackage = "de.ids_mannheim.korap.web.service.light";
+ public static final String API_VERSION = "v0.1";
+ public static final String classPackage = "de.ids_mannheim.korap.web.service.lite";
@Override
protected TestContainerFactory getTestContainerFactory ()
@@ -59,7 +60,7 @@
@Test
public void testSearchWithVCRef () throws KustvaktException {
- ClientResponse response = resource().path("search")
+ ClientResponse response = resource().path(API_VERSION).path("search")
.queryParam("q", "[orth=der]").queryParam("ql", "poliqarp")
.queryParam("cq", "referTo named-vc1")
.get(ClientResponse.class);
@@ -73,7 +74,7 @@
@Test
public void testStatisticsWithVCReference () throws KustvaktException {
String corpusQuery = "referTo named-vc1";
- ClientResponse response = resource().path("statistics")
+ ClientResponse response = resource().path(API_VERSION).path("statistics")
.queryParam("corpusQuery", corpusQuery)
.get(ClientResponse.class);