Disable pipe rewriting by default.

To activate pipe rewriting, pipe.host property must be configured in
kustvakt.conf.

Change-Id: I2e99f334629cd75b86dd061120b6b21dd91d3984
diff --git a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
index d442741..6545719 100644
--- a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
@@ -244,8 +244,7 @@
         loginTimeout = Integer.parseInt(properties.getProperty(
                 "timeout.login", "90000"));
         
-		pipeHost = properties.getProperty("pipe.host",
-				"https://korap.ids-mannheim.de");
+		pipeHost = properties.getProperty("pipe.host","");
     }
 
     @Deprecated
diff --git a/src/main/java/de/ids_mannheim/korap/core/service/SearchService.java b/src/main/java/de/ids_mannheim/korap/core/service/SearchService.java
index f5bce26..4f96816 100644
--- a/src/main/java/de/ids_mannheim/korap/core/service/SearchService.java
+++ b/src/main/java/de/ids_mannheim/korap/core/service/SearchService.java
@@ -170,11 +170,8 @@
         String query = serializer.toJSON();
 
         if (accessRewriteDisabled && showTokens) {
-            Notifications n = new Notifications();
-            n.addWarning(StatusCodes.NOT_ALLOWED,
+            query = addWarning(query, StatusCodes.NOT_ALLOWED,
                     "Tokens cannot be shown without access.");
-            JsonNode warning = n.toJsonNode();
-            query = addWarning(query, warning);
         }
 
         // Query pipe rewrite
@@ -303,6 +300,12 @@
      */
     private String runPipes (String query, String pipes)
             throws KustvaktException {
+		if (config.getPipeHost().isEmpty()) {
+			addWarning(query, StatusCodes.NOT_SUPPORTED,
+					"Pipe is not supported.");
+			return query;
+		}
+    	
     	if (pipes != null && !pipes.isEmpty()) {
 			String[] pipeArray = pipes.split(",");
 			
@@ -359,19 +362,17 @@
 
     private String handlePipeError (String query, String url, String message)
             throws KustvaktException {
-        jlog.warn(
-                "Failed running the pipe at " + url + ". Message: " + message);
 
-        Notifications n = new Notifications();
-        n.addWarning(StatusCodes.PIPE_FAILED, "Pipe failed", url, message);
-        JsonNode warning = n.toJsonNode();
-
-        query = addWarning(query, warning);
+        query = addWarning(query, StatusCodes.PIPE_FAILED, "Pipe failed", url, message);
         return query;
     }
 
-    private String addWarning (String query, JsonNode warning)
-            throws KustvaktException {
+	private String addWarning (String query, int statusCode,
+			String warningMessage, String ... terms) throws KustvaktException {
+		Notifications n = new Notifications();
+		n.addWarning(statusCode, warningMessage, terms);
+		JsonNode warning = n.toJsonNode();
+        
     	ObjectNode node = null;
 		try {
 			node = (ObjectNode) JsonUtils.readTree(query);
diff --git a/src/main/resources/kustvakt.conf b/src/main/resources/kustvakt.conf
index 0d261dc..a0acde9 100644
--- a/src/main/resources/kustvakt.conf
+++ b/src/main/resources/kustvakt.conf
@@ -22,7 +22,7 @@
 server.host=localhost
 
 # Pipe (optional) 
-# pipe.host=https://korap.ids-mannheim.de (default)
+# pipe.host=https://korap.ids-mannheim.de
 
 # default foundries for specific layers
 default.foundry.partOfSpeech = tt
diff --git a/src/test/resources/kustvakt-lite-test.conf b/src/test/resources/kustvakt-lite-test.conf
index 0143cec..6d7a47c 100644
--- a/src/test/resources/kustvakt-lite-test.conf
+++ b/src/test/resources/kustvakt-lite-test.conf
@@ -26,7 +26,7 @@
 server.host=localhost
 
 # Pipe (optional) 
-# pipe.host=https://korap.ids-mannheim.de (default)
+# pipe.host=https://korap.ids-mannheim.de
 # LOCALHOST ONLY FOR TESTING
 pipe.host=http://localhost
 
diff --git a/src/test/resources/kustvakt-test.conf b/src/test/resources/kustvakt-test.conf
index 045dda9..13fd337 100644
--- a/src/test/resources/kustvakt-test.conf
+++ b/src/test/resources/kustvakt-test.conf
@@ -29,7 +29,7 @@
 server.host=localhost
 
 # Pipe (optional) 
-# pipe.host=https://korap.ids-mannheim.de (default)
+# pipe.host=https://korap.ids-mannheim.de
 # LOCALHOST ONLY FOR TESTING
 pipe.host=http://localhost