Renamed KorapResponse to Response
diff --git a/Changes b/Changes
index 8e8b7a1..2738889 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.50.1 2015-02-26
+0.50.1 2015-02-27
- [feature] Deserialization of arbitrary elements with attributes (margaretha)
- [cleanup] Extracted KrillMeta from Krill,
renamed KorapQuery to KrillQuery,
@@ -14,7 +14,8 @@
renamed KorapByte to KrillByte,
renamed KorapString to KrillString,
moved KorapNode to server/Node,
- moved KorapResult to response/Result (diewald)
+ moved KorapResult to response/Result,
+ renamed KorapResponse to Response (diewald)
- [documentation] Improved documentation for API classes (diewald)
0.50 2015-02-23
diff --git a/src/main/java/de/ids_mannheim/korap/Krill.java b/src/main/java/de/ids_mannheim/korap/Krill.java
index 0daddf6..57ac31c 100644
--- a/src/main/java/de/ids_mannheim/korap/Krill.java
+++ b/src/main/java/de/ids_mannheim/korap/Krill.java
@@ -9,7 +9,7 @@
import de.ids_mannheim.korap.response.Result;
import de.ids_mannheim.korap.util.QueryException;
import de.ids_mannheim.korap.response.Notifications;
-import de.ids_mannheim.korap.response.KorapResponse;
+import de.ids_mannheim.korap.response.Response;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonNode;
@@ -42,7 +42,7 @@
/*
* Todo: Use a configuration file
*/
-public class Krill extends KorapResponse {
+public class Krill extends Response {
private KrillIndex index;
private SpanQuery spanQuery;
private JsonNode request;
diff --git a/src/main/java/de/ids_mannheim/korap/model/AbstractDocument.java b/src/main/java/de/ids_mannheim/korap/model/AbstractDocument.java
index 7dd9bf3..a71319d 100644
--- a/src/main/java/de/ids_mannheim/korap/model/AbstractDocument.java
+++ b/src/main/java/de/ids_mannheim/korap/model/AbstractDocument.java
@@ -4,7 +4,7 @@
import de.ids_mannheim.korap.util.KrillDate;
import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.response.KorapResponse;
+import de.ids_mannheim.korap.response.Response;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.annotation.*;
@@ -25,7 +25,7 @@
* @author diewald
*/
@JsonIgnoreProperties(ignoreUnknown = true)
-public abstract class AbstractDocument extends KorapResponse {
+public abstract class AbstractDocument extends Response {
private String primaryData;
@JsonIgnore
diff --git a/src/main/java/de/ids_mannheim/korap/response/MatchCollector.java b/src/main/java/de/ids_mannheim/korap/response/MatchCollector.java
index 2b24c8a..afab8b7 100644
--- a/src/main/java/de/ids_mannheim/korap/response/MatchCollector.java
+++ b/src/main/java/de/ids_mannheim/korap/response/MatchCollector.java
@@ -1,9 +1,9 @@
package de.ids_mannheim.korap.response;
import de.ids_mannheim.korap.response.Match;
-import de.ids_mannheim.korap.response.KorapResponse;
+import de.ids_mannheim.korap.response.Response;
import java.util.*;
-public class MatchCollector extends KorapResponse {
+public class MatchCollector extends Response {
public int totalResultDocs = 0;
/*
private int totalResults;
diff --git a/src/main/java/de/ids_mannheim/korap/response/KorapResponse.java b/src/main/java/de/ids_mannheim/korap/response/Response.java
similarity index 86%
rename from src/main/java/de/ids_mannheim/korap/response/KorapResponse.java
rename to src/main/java/de/ids_mannheim/korap/response/Response.java
index dcc18f7..9e2e603 100644
--- a/src/main/java/de/ids_mannheim/korap/response/KorapResponse.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Response.java
@@ -8,10 +8,9 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
+
import de.ids_mannheim.korap.KrillCollection;
import de.ids_mannheim.korap.KrillMeta;
-
-
import de.ids_mannheim.korap.KrillQuery;
import de.ids_mannheim.korap.response.Notifications;
@@ -21,7 +20,7 @@
*
* <p>
* <blockquote><pre>
- * KorapResponse km = new KorapResponse();
+ * Response km = new Response();
* System.out.println(
* km.toJsonString()
* );
@@ -33,7 +32,7 @@
// Todo: Use configuration file to get default token field "tokens"
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
-public class KorapResponse extends Notifications {
+public class Response extends Notifications {
ObjectMapper mapper = new ObjectMapper();
private KrillMeta meta;
@@ -50,9 +49,9 @@
/**
- * Construct a new KorapResponse object.
+ * Construct a new Response object.
*/
- public KorapResponse () {};
+ public Response () {};
/**
@@ -69,9 +68,9 @@
* Set the string representation of the backend's version.
*
* @param version The string representation of the backend's version
- * @return KorapResponse object for chaining
+ * @return Response object for chaining
*/
- public KorapResponse setVersion (String fullVersion) {
+ public Response setVersion (String fullVersion) {
int found = fullVersion.lastIndexOf('-');
// Is combined name and version
@@ -103,9 +102,9 @@
* All nodes in a cluster should have the same backend name.
*
* @param name The string representation of the backend's name
- * @return KorapResponse object for chaining
+ * @return Response object for chaining
*/
- public KorapResponse setName (String name) {
+ public Response setName (String name) {
this.name = name;
return this;
};
@@ -127,9 +126,9 @@
* Each node in a cluster has a unique name.
*
* @param version The string representation of the node's name
- * @return KorapResponse object for chaining
+ * @return Response object for chaining
*/
- public KorapResponse setNode (String name) {
+ public Response setNode (String name) {
this.node = name;
return this;
};
@@ -156,9 +155,9 @@
*
* @param timeout Either <tt>true</tt> or <tt>false</tt>,
* in case the response timed out
- * @return KorapResponse object for chaining
+ * @return Response object for chaining
*/
- public KorapResponse setTimeExceeded (boolean timeout) {
+ public Response setTimeExceeded (boolean timeout) {
if (timeout)
this.addWarning(682, "Response time exceeded");
this.timeExceeded = timeout;
@@ -182,10 +181,10 @@
*
* @param ts1 Starting time of the benchmark
* @param ts2 Ending time of the benchmark
- * @return KorapResponse object for chaining
+ * @return Response object for chaining
*/
@JsonIgnore
- public KorapResponse setBenchmark (long ts1, long ts2) {
+ public Response setBenchmark (long ts1, long ts2) {
this.benchmark =
(ts2 - ts1) < 100_000_000 ?
// Store as miliseconds
@@ -201,9 +200,9 @@
*
* @param bm String representation of a benchmark
* (including trailing time unit)
- * @return KorapResponse for chaining
+ * @return Response for chaining
*/
- public KorapResponse setBenchmark (String bm) {
+ public Response setBenchmark (String bm) {
this.benchmark = bm;
return this;
};
@@ -229,9 +228,9 @@
* </pre></blockquote>
*
* @param listener String representation of the listener URI
- * @return KorapResponse object for chaining
+ * @return Response object for chaining
*/
- public KorapResponse setListener (String listener) {
+ public Response setListener (String listener) {
this.listener = listener;
return this;
};
@@ -253,9 +252,9 @@
* Set the total number of results.
*
* @param results The total number of results.
- * @return {link KorapResponse} object for chaining.
+ * @return {link Response} object for chaining.
*/
- public KorapResponse setTotalResults (long results) {
+ public Response setTotalResults (long results) {
this.totalResults = results;
return this;
};
@@ -266,9 +265,9 @@
*
* @param incr The number of results the total number should
* be incremented by.
- * @return {@link KorapResponse} object for chaining.
+ * @return {@link Response} object for chaining.
*/
- public KorapResponse incrTotalResults (int incr) {
+ public Response incrTotalResults (int incr) {
if (this.totalResults < 0)
this.totalResults = incr;
else
@@ -297,9 +296,9 @@
*
* @param resources The total number of resources the total
* number of results occur in.
- * @return {@link KorapResponse} object for chaining.
+ * @return {@link Response} object for chaining.
*/
- public KorapResponse setTotalResources (long resources) {
+ public Response setTotalResources (long resources) {
this.totalResources = resources;
return this;
};
@@ -312,9 +311,9 @@
* @param incr The number of resources the total number of
* results occur in should be incremented by.
* (I don't care that this isn't English!)
- * @return {@link KorapResponse} object for chaining.
+ * @return {@link Response} object for chaining.
*/
- public KorapResponse incrTotalResources (int i) {
+ public Response incrTotalResources (int i) {
if (this.totalResources < 0)
this.totalResources = i;
else
@@ -343,14 +342,14 @@
*
* @param query The {@link KrillQuery} object,
* representing the KoralQuery query object.
- * @return The {@link KorapResponse} object for chaining
+ * @return The {@link Response} object for chaining
*/
@JsonIgnore
- public KorapResponse setQuery (KrillQuery query) {
+ public Response setQuery (KrillQuery query) {
this.query = query;
// Move messages from the query
- return (KorapResponse) this.moveNotificationsFrom(query);
+ return (Response) this.moveNotificationsFrom(query);
};
@@ -373,14 +372,14 @@
* Set a new {@link KrillCollection} object.
*
* @param collection A {@link KrillCollection} object.
- * @return The {@link KorapResponse} object for chaining
+ * @return The {@link Response} object for chaining
*/
@JsonIgnore
- public KorapResponse setCollection (KrillCollection collection) {
+ public Response setCollection (KrillCollection collection) {
this.collection = collection;
// Move messages from the collection
- return (KorapResponse) this.moveNotificationsFrom(collection);
+ return (Response) this.moveNotificationsFrom(collection);
};
@@ -403,14 +402,14 @@
* Set a new {@link KrillMeta} object.
*
* @param meta A {@link KrillMeta} object.
- * @return The {@link KorapResponse} object for chaining
+ * @return The {@link Response} object for chaining
*/
@JsonIgnore
- public KorapResponse setMeta (KrillMeta meta) {
+ public Response setMeta (KrillMeta meta) {
this.meta = meta;
// Move messages from the collection
- return (KorapResponse) this.moveNotificationsFrom(meta);
+ return (Response) this.moveNotificationsFrom(meta);
};
diff --git a/src/main/java/de/ids_mannheim/korap/response/Result.java b/src/main/java/de/ids_mannheim/korap/response/Result.java
index cb35b08..257780f 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Result.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Result.java
@@ -13,7 +13,7 @@
// Remove:
import de.ids_mannheim.korap.meta.SearchContext;
-import de.ids_mannheim.korap.response.KorapResponse;
+import de.ids_mannheim.korap.response.Response;
import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.Krill;
@@ -32,7 +32,7 @@
* TODO: Synopsis and let it base on KoralQuery
*
* @author diewald
- * @see KorapResponse
+ * @see Response
*/
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
diff --git a/src/main/java/de/ids_mannheim/korap/server/Resource.java b/src/main/java/de/ids_mannheim/korap/server/Resource.java
index ed47ff7..d48884d 100644
--- a/src/main/java/de/ids_mannheim/korap/server/Resource.java
+++ b/src/main/java/de/ids_mannheim/korap/server/Resource.java
@@ -10,7 +10,6 @@
import javax.ws.rs.Produces;
import javax.ws.rs.Consumes;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.core.MultivaluedMap;
@@ -26,7 +25,7 @@
import de.ids_mannheim.korap.KrillCollection;
import de.ids_mannheim.korap.response.Result;
import de.ids_mannheim.korap.response.Match;
-import de.ids_mannheim.korap.response.KorapResponse;
+import de.ids_mannheim.korap.response.Response;
import de.ids_mannheim.korap.index.FieldDocument;
import de.ids_mannheim.korap.util.QueryException;
import de.ids_mannheim.korap.response.MatchCollector;
@@ -90,7 +89,7 @@
@Produces(MediaType.APPLICATION_JSON)
public String info () {
KrillIndex index = Node.getIndex();
- KorapResponse kresp = new KorapResponse();
+ Response kresp = new Response();
kresp.setNode(Node.getName());
kresp.setName(index.getName());
kresp.setVersion(index.getVersion());
@@ -138,7 +137,7 @@
// Get index
KrillIndex index = Node.getIndex();
- KorapResponse kresp = new KorapResponse();
+ Response kresp = new Response();
kresp.setNode(Node.getName());
if (index == null) {
@@ -181,7 +180,7 @@
// Get index
KrillIndex index = Node.getIndex();
- KorapResponse kresp = new KorapResponse();
+ Response kresp = new Response();
kresp.setNode(Node.getName());
if (index == null) {
@@ -251,7 +250,7 @@
return kr.toJsonString();
};
- KorapResponse kresp = new KorapResponse();
+ Response kresp = new Response();
kresp.setNode(Node.getName());
kresp.setName(index.getName());
kresp.setVersion(index.getVersion());
@@ -280,7 +279,7 @@
// No index found
if (index == null) {
- KorapResponse kresp = new KorapResponse();
+ Response kresp = new Response();
kresp.setNode(Node.getName());
kresp.addError(601, "Unable to find index");
return kresp.toJsonString();
@@ -304,7 +303,7 @@
log.error(e.getLocalizedMessage());
};
- KorapResponse kresp = new KorapResponse();
+ Response kresp = new Response();
kresp.setNode(Node.getName());
kresp.setName(index.getName());
kresp.setVersion(index.getVersion());
@@ -343,7 +342,7 @@
return kr.toJsonString();
};
- KorapResponse kresp = new KorapResponse();
+ Response kresp = new Response();
kresp.setNode(Node.getName());
kresp.setName(index.getName());
kresp.setVersion(index.getVersion());
@@ -410,7 +409,7 @@
// Nothing found
catch (QueryException qe) {
- // Todo: Make Match rely on KorapResponse!
+ // Todo: Make Match rely on Response!
Match km = new Match();
km.addError(qe.getErrorCode(), qe.getMessage());
return km.toJsonString();
diff --git a/src/test/java/de/ids_mannheim/korap/response/TestResponse.java b/src/test/java/de/ids_mannheim/korap/response/TestResponse.java
index 4cb46e2..220ce19 100644
--- a/src/test/java/de/ids_mannheim/korap/response/TestResponse.java
+++ b/src/test/java/de/ids_mannheim/korap/response/TestResponse.java
@@ -4,7 +4,7 @@
import de.ids_mannheim.korap.response.Messages;
import de.ids_mannheim.korap.response.Notifications;
-import de.ids_mannheim.korap.response.KorapResponse;
+import de.ids_mannheim.korap.response.Response;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonNode;
@@ -22,7 +22,7 @@
@Test
public void testResponse () throws IOException {
- KorapResponse resp = new KorapResponse();
+ Response resp = new Response();
assertEquals("{}", resp.toJsonString());
resp.setVersion("0.24");
resp.setNode("Tanja");
@@ -51,7 +51,7 @@
@Test
public void testResponseNotifications () throws IOException {
- KorapResponse resp = new KorapResponse();
+ Response resp = new Response();
assertEquals("{}", resp.toJsonString());
resp.setVersion("0.24");
resp.setNode("Tanja");
@@ -85,45 +85,45 @@
@Test
public void testResponseDeserialzation () throws IOException {
String jsonResponse = "{\"version\":\"0.38\"}";
- KorapResponse kresp = mapper.readValue(jsonResponse, KorapResponse.class);
+ Response kresp = mapper.readValue(jsonResponse, Response.class);
assertEquals("0.38", kresp.getVersion());
assertNull(kresp.getName());
assertEquals(jsonResponse, kresp.toJsonString());
jsonResponse = "{\"version\":\"seaweed-0.49\"}";
- kresp = mapper.readValue(jsonResponse, KorapResponse.class);
+ kresp = mapper.readValue(jsonResponse, Response.class);
assertEquals("0.49", kresp.getVersion());
assertEquals("seaweed", kresp.getName());
assertTrue(kresp.toJsonString().contains("seaweed-0.49"));
jsonResponse = "{\"version\":\"seaweed-\"}";
- kresp = mapper.readValue(jsonResponse, KorapResponse.class);
+ kresp = mapper.readValue(jsonResponse, Response.class);
assertEquals("seaweed-", kresp.getVersion());
assertNull(kresp.getName());
assertTrue(kresp.toJsonString().contains("seaweed-"));
jsonResponse = "{\"timeExceeded\":true}";
- kresp = mapper.readValue(jsonResponse, KorapResponse.class);
+ kresp = mapper.readValue(jsonResponse, Response.class);
assertTrue(kresp.hasTimeExceeded());
assertTrue(kresp.hasWarnings());
jsonResponse = "{\"benchmark\":\"40.5s\", \"foo\":\"bar\"}";
- kresp = mapper.readValue(jsonResponse, KorapResponse.class);
+ kresp = mapper.readValue(jsonResponse, Response.class);
assertEquals("40.5s", kresp.getBenchmark());
jsonResponse = "{\"listener\":\"10.0.10.14:678\", \"foo\":\"bar\"}";
- kresp = mapper.readValue(jsonResponse, KorapResponse.class);
+ kresp = mapper.readValue(jsonResponse, Response.class);
assertEquals("10.0.10.14:678", kresp.getListener());
jsonResponse = "{\"node\":\"tanja\", \"foo\":\"bar\"}";
- kresp = mapper.readValue(jsonResponse, KorapResponse.class);
+ kresp = mapper.readValue(jsonResponse, Response.class);
assertEquals("tanja", kresp.getNode());
jsonResponse = "{\"node\":\"tanja\", \"version\":\"seaweed-0.49\", " +
" \"benchmark\":\"40.5s\", \"listener\":\"10.0.10.14:678\"," +
"\"timeExceeded\":true }";
- kresp = mapper.readValue(jsonResponse, KorapResponse.class);
+ kresp = mapper.readValue(jsonResponse, Response.class);
assertEquals("0.49", kresp.getVersion());
assertEquals("seaweed", kresp.getName());
assertEquals("40.5s", kresp.getBenchmark());
@@ -138,7 +138,7 @@
" \"node\":\"tanja\", \"version\":\"seaweed-0.49\", " +
" \"benchmark\":\"40.5s\", \"listener\":\"10.0.10.14:678\"," +
"\"timeExceeded\":true }";
- kresp = mapper.readValue(jsonResponse, KorapResponse.class);
+ kresp = mapper.readValue(jsonResponse, Response.class);
assertTrue(kresp.hasWarnings());
assertTrue(kresp.hasErrors());
assertFalse(kresp.hasMessages());
diff --git a/src/test/java/de/ids_mannheim/korap/server/TestResource.java b/src/test/java/de/ids_mannheim/korap/server/TestResource.java
index bbe0e8c..5780d05 100644
--- a/src/test/java/de/ids_mannheim/korap/server/TestResource.java
+++ b/src/test/java/de/ids_mannheim/korap/server/TestResource.java
@@ -21,7 +21,7 @@
import de.ids_mannheim.korap.server.Node;
import de.ids_mannheim.korap.response.Result;
-import de.ids_mannheim.korap.response.KorapResponse;
+import de.ids_mannheim.korap.response.Response;
import static de.ids_mannheim.korap.util.KrillString.*;
@@ -74,7 +74,7 @@
@Test
public void testResource() throws IOException {
- KorapResponse kresp;
+ Response kresp;
for (String i : new String[] {"00001",
"00002",
@@ -94,7 +94,7 @@
try {
kresp = target.path("/index/" + i).
request("application/json").
- put(jsonE, KorapResponse.class);
+ put(jsonE, Response.class);
assertEquals(kresp.getNode(), "milena");
assertFalse(kresp.hasErrors());
@@ -108,7 +108,7 @@
kresp = target.path("/index").
request("application/json").
- post(Entity.text(""), KorapResponse.class);
+ post(Entity.text(""), Response.class);
assertEquals(kresp.getNode(), "milena");
assertFalse(kresp.hasErrors());
assertFalse(kresp.hasWarnings());
@@ -123,12 +123,12 @@
);
try {
- KorapResponse kresp
+ Response kresp
= target.path("/").
queryParam("uid", "1").
queryParam("uid", "4").
request("application/json").
- post(Entity.json(json), KorapResponse.class);
+ post(Entity.json(json), Response.class);
assertEquals(2, kresp.getTotalResults());
assertFalse(kresp.hasErrors());