Merge "Added support for unrestricted corpus statistics"
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java b/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
index 41efb23..4317308 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
@@ -265,12 +265,26 @@
      *            JSON-LD string with potential meta filters.
      */
     public String getStatistics (String json) {
-        jlog.trace(json);
         if (this.index == null) {
             return "{\"documents\" : -1, error\" : \"No index given\" }";
         };
-        // Create Virtual collection from json search
-        KrillCollection kc = new KrillCollection(json);
+
+		// Define a virtual corpus
+		KrillCollection kc;
+		if (json != null && !json.equals("")) {
+			jlog.trace(json);
+
+			// Create Virtual collection from json search
+			kc = new KrillCollection(json);
+		}
+
+		// There is no json string defined
+		else {
+
+			// Create Virtual collection of everything
+			kc = new KrillCollection();
+		};
+
         // Set index
         kc.setIndex(this.index);
         long docs = 0, tokens = 0, sentences = 0, paragraphs = 0;
diff --git a/lite/Changes b/lite/Changes
index d539fc5..bd0f1db 100644
--- a/lite/Changes
+++ b/lite/Changes
@@ -1,3 +1,7 @@
+version 0.60.2
+29/06/2018
+    - Added support for unrestricted corpus statistics (ndiewald)
+
 version 0.60.1
 12/06/2018
     - removed kustvakt_encryption (margaretha)
diff --git a/lite/pom.xml b/lite/pom.xml
index a1e95b9..f8d78bd 100644
--- a/lite/pom.xml
+++ b/lite/pom.xml
@@ -3,7 +3,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>de.ids_mannheim.korap</groupId>
 	<artifactId>Kustvakt-lite</artifactId>
-	<version>0.60.1</version>
+	<version>0.60.2</version>
 	<properties>
 		<java.version>1.8</java.version>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -172,4 +172,4 @@
 			<scope>test</scope>
 		</dependency>
 	</dependencies>
-</project>
\ No newline at end of file
+</project>
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 192d257..3a384d5 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
@@ -301,16 +301,23 @@
             @QueryParam("corpusQuery") String collectionQuery) {
 
         KoralCollectionQueryBuilder builder = new KoralCollectionQueryBuilder();
-        builder.with(collectionQuery);
-        String json;
-        try {
-            json = builder.toJSON();
-        }
-        catch (KustvaktException e) {
-            throw kustvaktResponseHandler.throwit(e);
-        }
 
-        String stats = searchKrill.getStatistics(json);
+		String stats;
+		if (collectionQuery != null && !collectionQuery.equals("")) {
+			builder.with(collectionQuery);
+			String json;
+			try {
+				json = builder.toJSON();
+			}
+			catch (KustvaktException e) {
+				throw kustvaktResponseHandler.throwit(e);
+			}
+			stats = searchKrill.getStatistics(json);
+		}
+		else {
+			stats = searchKrill.getStatistics(null);
+		};
+
         if (stats.contains("-1"))
             throw kustvaktResponseHandler.throwit(StatusCodes.NO_RESULT_FOUND);
         jlog.debug("Stats: " + stats);
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 bc3064c..8c815e8 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
@@ -77,6 +77,35 @@
         assertEquals(514, node.at("/paragraphs").asInt());
     }
 
+	@Test
+    public void testEmptyStatistics () throws KustvaktException{
+        ClientResponse response = resource()
+			.path("statistics")
+			.queryParam("corpusQuery", "")
+			.method("GET", ClientResponse.class);
+        assertEquals(ClientResponse.Status.OK.getStatusCode(),
+                response.getStatus());
+        String query = response.getEntity(String.class);
+        JsonNode node = JsonUtils.readTree(query);
+        assertEquals(11, node.at("/documents").asInt());
+        assertEquals(665842, node.at("/tokens").asInt());
+        assertEquals(25074, node.at("/sentences").asInt());
+        assertEquals(772, node.at("/paragraphs").asInt());
+
+		response = resource()
+                .path("statistics")
+                .method("GET", ClientResponse.class);
+        assertEquals(ClientResponse.Status.OK.getStatusCode(),
+                response.getStatus());
+		query = response.getEntity(String.class);
+		node = JsonUtils.readTree(query);
+        assertEquals(11, node.at("/documents").asInt());
+        assertEquals(665842, node.at("/tokens").asInt());
+        assertEquals(25074, node.at("/sentences").asInt());
+        assertEquals(772, node.at("/paragraphs").asInt());
+	}
+
+	
     @Test
     public void testGetJSONQuery () throws KustvaktException{
         ClientResponse response = resource()