Added support for unrestricted corpus statistics

Change-Id: I192a3209f5face265f1ebe0f8a43bc3638eb6835
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 90673e1..5463738 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()