Added API info web-service.

Change-Id: I8ff91cd5dccca0824146d38a361964cc284cd196
diff --git a/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java b/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
index 36d04e0..913da7b 100644
--- a/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
+++ b/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
@@ -139,10 +139,15 @@
 
         apiWelcomeMessage = properties.getProperty("api.welcome.message", "Welcome to KorAP API!");
         currentVersion = properties.getProperty("current.api.version", "v1.0");
+
         String supportedVersions =
-                properties.getProperty("supported.api.version", "");
+                properties.getProperty("supported.api.versions", "");
         
-        this.supportedVersions = new HashSet<>(Arrays.asList(supportedVersions.split(" ")));
+        this.supportedVersions = new HashSet<>();
+        if (!supportedVersions.isEmpty()){
+            List<String> versionArray = Arrays.asList(supportedVersions.split(" "));
+            this.supportedVersions.addAll(versionArray);
+        }
         this.supportedVersions.add(currentVersion);
 
         maxhits = new Integer(properties.getProperty("maxhits", "50000"));
diff --git a/core/src/main/java/de/ids_mannheim/korap/utils/ServiceInfo.java b/core/src/main/java/de/ids_mannheim/korap/utils/ServiceInfo.java
index 947f69d..f2691da 100644
--- a/core/src/main/java/de/ids_mannheim/korap/utils/ServiceInfo.java
+++ b/core/src/main/java/de/ids_mannheim/korap/utils/ServiceInfo.java
@@ -31,6 +31,11 @@
     private String cache_store;
 
 
+    @Getter
+    private String krillVersion;
+    @Getter
+    private String koralVersion;
+    
     private ServiceInfo () {
         load();
     }
@@ -48,6 +53,9 @@
             this.logger = (String) props.get("kustvakt.logging");
             this.cacheable = Boolean.valueOf((String) props.get("kustvakt.cache"));
             this.cache_store = (String) props.get("kustvakt.cache_store");
+            
+            this.krillVersion=(String) props.get("krill.version");
+            this.koralVersion=(String) props.get("koral.version");
         }
         catch (IOException e) {
             this.version = UNKNOWN;
@@ -56,12 +64,15 @@
             this.config = UNKNOWN;
             this.cacheable = false;
             this.cache_store = UNKNOWN;
+            
+            this.koralVersion = UNKNOWN;
+            this.krillVersion = UNKNOWN;
         }
     }
 
 
     private static InputStream getStream () throws IOException {
-        String path = "kustvakt.info";
+        String path = "service.properties";
         InputStream stream = ConfigLoader.loadConfigStream(path);
         if (stream == null)
             throw new IOException("stream for resource " + path
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java b/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
index e3967b4..2760810 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
@@ -1,9 +1,11 @@
 package de.ids_mannheim.korap.web.controller;// package
                                              // de.ids_mannheim.korap.ext.web;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 import java.util.Set;
 
 import javax.servlet.ServletContext;
@@ -34,6 +36,8 @@
 import de.ids_mannheim.korap.oauth2.service.OAuth2ScopeService;
 import de.ids_mannheim.korap.security.context.TokenContext;
 import de.ids_mannheim.korap.service.SearchService;
+import de.ids_mannheim.korap.utils.JsonUtils;
+import de.ids_mannheim.korap.utils.ServiceInfo;
 import de.ids_mannheim.korap.web.KustvaktResponseHandler;
 import de.ids_mannheim.korap.web.filter.APIVersionFilter;
 import de.ids_mannheim.korap.web.filter.AuthenticationFilter;
@@ -77,6 +81,24 @@
             .build();
     }
     
+    @GET
+    @Path("{version}/info")
+    @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
+    public Response info (){
+        Map<String, Object> m = new HashMap<>();
+        m.put("latest_api_version", config.getCurrentVersion());
+        m.put("supported_api_versions", config.getSupportedVersions());
+        m.put("kustvakt_version", ServiceInfo.getInfo().getVersion());
+        m.put("krill_version", ServiceInfo.getInfo().getKrillVersion());
+        m.put("koral_version", ServiceInfo.getInfo().getKoralVersion());
+        try {
+            return Response.ok(JsonUtils.toJSON(m)).build();
+        }
+        catch (KustvaktException e) {
+            throw kustvaktResponseHandler.throwit(e);
+        }
+    }
+    
     @POST
     @Path("{version}/index/close")
     public Response closeIndexReader (@FormParam("token") String token){
diff --git a/core/src/main/resources/service.properties b/core/src/main/resources/service.properties
new file mode 100644
index 0000000..cf2899d
--- /dev/null
+++ b/core/src/main/resources/service.properties
@@ -0,0 +1,3 @@
+kustvakt.version=${project.version}
+krill.version=${krill.version}
+koral.version=${koral.version}
\ No newline at end of file