Updated StatisticService.

Change-Id: Ie209a55f75f1e4b4e658a5696aa89605b166d11f
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java b/full/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java
index 9599b74..5319c51 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java
@@ -42,6 +42,12 @@
     private ResourceConverter resourceConverter;
 
 
+    /** Returns descriptions of all free resources stored in 
+     * the database.
+     * 
+     * @return a json description of all free resources stored in 
+     * the database. 
+     */
     @GET
     @Path("info")
     public Response getAllResourceInfo () {
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/service/full/SearchService.java b/full/src/main/java/de/ids_mannheim/korap/web/service/full/SearchService.java
index 617385e..ab33369 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/service/full/SearchService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/service/full/SearchService.java
@@ -24,7 +24,6 @@
 import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.UriBuilder;
 
-import org.junit.Ignore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -749,34 +748,12 @@
         }
     }
 
-    // EM: changed method POST to GET
-    @GET
-    @Path("statistics")
-    public Response getStatistics (@Context SecurityContext context,
-            @Context Locale locale, @QueryParam("collectionQuery") 
-            String collectionQuery) {
-        
-        if (collectionQuery == null || collectionQuery.isEmpty()){
-         throw KustvaktResponseHandler.throwit(new KustvaktException(
-                 StatusCodes.MISSING_ARGUMENT, "Parameter collectionQuery is missing.", 
-                 "collectionQuery"));
-        }
-        
-        
-        KoralCollectionQueryBuilder builder = new KoralCollectionQueryBuilder();
-        builder.with(collectionQuery);
-        String json = builder.toJSON();
-        
-        String stats = searchKrill.getStatistics(json);
-        if (stats.contains("-1"))
-            throw KustvaktResponseHandler.throwit(StatusCodes.NO_VALUE_FOUND);
-        jlog.debug("Stats: "+stats);
-        return Response.ok(stats).build();
-    }
+    
 
     // EM: what is child?
     @GET
     @Path("{type}/{id}/{child}/statistics")
+    @Deprecated
     public Response getStatisticsbyIdChild (@Context SecurityContext context,
             @Context Locale locale, @PathParam("type") String type,
             @PathParam("id") String id, @PathParam("child") String child) {
@@ -787,6 +764,7 @@
 
     @GET
     @Path("{type}/{id}/stats")
+    @Deprecated
     public Response getStatisticsbyId (@Context SecurityContext context,
             @Context Locale locale, @PathParam("type") String type,
             @PathParam("id") String id) {
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/service/full/StatisticService.java b/full/src/main/java/de/ids_mannheim/korap/web/service/full/StatisticService.java
new file mode 100644
index 0000000..cb76ca8
--- /dev/null
+++ b/full/src/main/java/de/ids_mannheim/korap/web/service/full/StatisticService.java
@@ -0,0 +1,87 @@
+package de.ids_mannheim.korap.web.service.full;
+
+import java.util.Locale;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.SecurityContext;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+
+import com.sun.jersey.spi.container.ResourceFilters;
+
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.exceptions.StatusCodes;
+import de.ids_mannheim.korap.utils.KoralCollectionQueryBuilder;
+import de.ids_mannheim.korap.web.SearchKrill;
+import de.ids_mannheim.korap.web.filter.PiwikFilter;
+import de.ids_mannheim.korap.web.utils.KustvaktResponseHandler;
+
+/**
+ * Services related to statistics
+ * 
+ * @author hanl
+ * @author margaretha
+ *
+ * @date 27/09/2017
+ * 
+ */
+@Controller
+@Path("statistics/")
+@ResourceFilters({ PiwikFilter.class })
+@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
+public class StatisticService {
+
+
+    private static Logger jlog =
+            LoggerFactory.getLogger(StatisticService.class);
+
+    @Autowired
+    private SearchKrill searchKrill;
+
+
+    /**
+     * Returns statistics of the virtual corpus defined by the given
+     * collectionQuery parameter.
+     * 
+     * @param context
+     *            SecurityContext
+     * @param locale
+     *            Locale
+     * @param collectionQuery
+     *            a collection query specifying a virtual corpus
+     * @return statistics of the virtual corpus defined by the given
+     *         collectionQuery parameter.
+     */
+    @GET
+    public Response getStatistics (@Context SecurityContext context,
+            @Context Locale locale,
+            @QueryParam("collectionQuery") String collectionQuery) {
+
+        if (collectionQuery == null || collectionQuery.isEmpty()) {
+            throw KustvaktResponseHandler
+                    .throwit(new KustvaktException(StatusCodes.MISSING_ARGUMENT,
+                            "Parameter collectionQuery is missing.",
+                            "collectionQuery"));
+        }
+
+
+        KoralCollectionQueryBuilder builder = new KoralCollectionQueryBuilder();
+        builder.with(collectionQuery);
+        String json = builder.toJSON();
+
+        String stats = searchKrill.getStatistics(json);
+        if (stats.contains("-1"))
+            throw KustvaktResponseHandler.throwit(StatusCodes.NO_VALUE_FOUND);
+        jlog.debug("Stats: " + stats);
+        return Response.ok(stats).build();
+    }
+}