Fixed KustvaktResponseHandler and missing exceptions in JsonUtils. 

Change-Id: I3a95361659cebf91dc9175d08891dd67815b1851
diff --git a/lite/pom.xml b/lite/pom.xml
index fc394fb..4215b5e 100644
--- a/lite/pom.xml
+++ b/lite/pom.xml
@@ -155,7 +155,7 @@
 		<dependency>
 			<groupId>de.ids_mannheim.korap</groupId>
 			<artifactId>Kustvakt-core</artifactId>
-			<version>0.59.8</version>
+			<version>0.59.9</version>
 		</dependency>
 		<dependency>
 			<groupId>de.ids_mannheim.korap</groupId>
diff --git a/lite/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java b/lite/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
index 05f8056..1b745b7 100644
--- a/lite/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
+++ b/lite/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
@@ -58,6 +58,8 @@
     private static Logger jlog = LoggerFactory.getLogger(LightService.class);
 
     @Autowired
+    KustvaktResponseHandler kustvaktResponseHandler;
+    @Autowired
     private SearchKrill searchKrill;
     private ClientsHandler graphDBhandler;
     @Autowired
@@ -86,7 +88,7 @@
             result = graphDBhandler.getResponse("distCollo", "q", query);
         }
         catch (KustvaktException e) {
-            throw KustvaktResponseHandler.throwit(e);
+            throw kustvaktResponseHandler.throwit(e);
         }
         return Response.ok(result).build();
     }
@@ -126,7 +128,7 @@
             query = this.processor.processQuery(ss.toJSON(), null);
         }
         catch (KustvaktException e) {
-            throw KustvaktResponseHandler.throwit(e);
+            throw kustvaktResponseHandler.throwit(e);
         }
         return Response.ok(query).build();
     }
@@ -140,7 +142,7 @@
             jsonld = processor.processQuery(jsonld, null);
         }
         catch (KustvaktException e) {
-            throw KustvaktResponseHandler.throwit(e);
+            throw kustvaktResponseHandler.throwit(e);
         }
         // todo: should be possible to add the meta part to the query serialization
         jlog.info("Serialized search: {}", jsonld);
@@ -184,7 +186,7 @@
             query = this.processor.processQuery(serializer.toJSON(), null);
         }
         catch (KustvaktException e) {
-            throw KustvaktResponseHandler.throwit(e);
+            throw kustvaktResponseHandler.throwit(e);
         }
         jlog.info("the serialized query {}", query);
 
@@ -202,7 +204,7 @@
                 result = this.graphDBhandler.getResponse(map, "distKwic");
             }
             catch (KustvaktException e) {
-                throw KustvaktResponseHandler.throwit(e);
+                throw kustvaktResponseHandler.throwit(e);
             }
         }
         else
@@ -261,13 +263,13 @@
                 query = this.processor.processQuery(s.toJSON(), null);
             }
             catch (KustvaktException e) {
-                throw KustvaktResponseHandler.throwit(e);
+                throw kustvaktResponseHandler.throwit(e);
             }
         }
         String result;
         try {
             if (eng.equals(KustvaktConfiguration.BACKENDS.NEO4J)) {
-                if (raw) throw KustvaktResponseHandler.throwit(
+                if (raw) throw kustvaktResponseHandler.throwit(
                         StatusCodes.ILLEGAL_ARGUMENT, "raw not supported!",
                         null);
                 MultivaluedMap map = new MultivaluedMapImpl();
@@ -285,7 +287,7 @@
         }
         catch (Exception e) {
             jlog.error("Exception for serialized query: " + query, e);
-            throw KustvaktResponseHandler.throwit(500, e.getMessage(), null);
+            throw kustvaktResponseHandler.throwit(500, e.getMessage(), null);
         }
 
         jlog.debug("The result set: {}", result);
@@ -300,11 +302,17 @@
 
         KoralCollectionQueryBuilder builder = new KoralCollectionQueryBuilder();
         builder.with(collectionQuery);
-        String json = builder.toJSON();
+        String json;
+        try {
+            json = builder.toJSON();
+        }
+        catch (KustvaktException e) {
+            throw kustvaktResponseHandler.throwit(e);
+        }
 
         String stats = searchKrill.getStatistics(json);
         if (stats.contains("-1"))
-            throw KustvaktResponseHandler.throwit(StatusCodes.NO_RESULT_FOUND);
+            throw kustvaktResponseHandler.throwit(StatusCodes.NO_RESULT_FOUND);
         jlog.debug("Stats: " + stats);
         return Response.ok(stats).build();
     }
diff --git a/lite/src/main/resources/test-config.xml b/lite/src/main/resources/test-config.xml
index 3ff2ef1..6b1fa49 100644
--- a/lite/src/main/resources/test-config.xml
+++ b/lite/src/main/resources/test-config.xml
@@ -34,6 +34,11 @@
     <bean id="kustvakt_auditing"
           class="de.ids_mannheim.korap.interfaces.defaults.DefaultAuditing">
     </bean>
+    
+    <bean id="kustvakt_response"
+          class="de.ids_mannheim.korap.web.utils.KustvaktResponseHandler">
+          <constructor-arg index="0" name="iface" ref="kustvakt_auditing"/>
+    </bean>
 
     <bean id="kustvakt_config"
           class="de.ids_mannheim.korap.config.KustvaktConfiguration">
diff --git a/lite/src/test/java/de/ids_mannheim/korap/web/service/LightServiceTest.java b/lite/src/test/java/de/ids_mannheim/korap/web/service/LightServiceTest.java
index e0ecf31..99312ec 100644
--- a/lite/src/test/java/de/ids_mannheim/korap/web/service/LightServiceTest.java
+++ b/lite/src/test/java/de/ids_mannheim/korap/web/service/LightServiceTest.java
@@ -30,7 +30,7 @@
     public void initMethod () throws KustvaktException {}
 
     @Test
-    public void testStatistics () {
+    public void testStatistics () throws KustvaktException{
         ClientResponse response = resource()
                 .path("statistics")
                 .queryParam("collectionQuery", "textType=Autobiographie & corpusSigle=GOE")
@@ -46,7 +46,7 @@
     }
 
     @Test
-    public void testGetJSONQuery () {
+    public void testGetJSONQuery () throws KustvaktException{
         ClientResponse response = resource()
                 .path("query").queryParam("q", "[orth=das]")
                 .queryParam("ql", "poliqarp").queryParam("context", "sentence")
@@ -66,7 +66,7 @@
 
 
     @Test
-    public void testbuildAndPostQuery () {
+    public void testbuildAndPostQuery () throws KustvaktException{
         ClientResponse response = resource()
                 .path("query").queryParam("q", "[orth=das]")
                 .queryParam("ql", "poliqarp")
@@ -91,7 +91,7 @@
 
 
     @Test
-    public void testQueryGet () {
+    public void testQueryGet () throws KustvaktException{
         ClientResponse response = resource()
                 .path("search").queryParam("q", "[orth=das]")
                 .queryParam("ql", "poliqarp").queryParam("context", "sentence")
@@ -109,7 +109,7 @@
 
 
     @Test
-    public void testFoundryRewrite () {
+    public void testFoundryRewrite () throws KustvaktException{
         ClientResponse response = resource()
                 .path("search").queryParam("q", "[orth=das]")
                 .queryParam("ql", "poliqarp").queryParam("context", "sentence")
@@ -125,7 +125,7 @@
 
 
     @Test
-    public void testQueryPost () {
+    public void testQueryPost () throws KustvaktException{
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[orth=das]", "poliqarp");
 
@@ -142,7 +142,7 @@
 
 
     @Test
-    public void testParameterField () {
+    public void testParameterField () throws KustvaktException{
         ClientResponse response = resource()
                 .path("search").queryParam("q", "[orth=das]")
                 .queryParam("ql", "poliqarp")
@@ -161,7 +161,7 @@
     }
 
 	@Test
-	public void testMatchInfoGetWithoutSpans () {
+	public void testMatchInfoGetWithoutSpans () throws KustvaktException{
         ClientResponse response = resource()
 			
 			.path("corpus/GOE/AGA/01784/p36-46/matchInfo")
@@ -178,7 +178,7 @@
 	};
 
 	@Test
-	public void testMatchInfoGet2 () {
+	public void testMatchInfoGet2 () throws KustvaktException{
         ClientResponse response = resource()
 			
 			.path("corpus/GOE/AGA/01784/p36-46/matchInfo")
@@ -194,7 +194,7 @@
 	};
 
     @Test
-    public void testCollectionQueryParameter () {
+    public void testCollectionQueryParameter () throws KustvaktException{
         ClientResponse response = resource()
                 .path("query").queryParam("q", "[orth=das]")
                 .queryParam("ql", "poliqarp")