diff src/main/java/de/intevation/lada/rest/VersionService.java @ 971:ad8c859cfdca

Get version from pom.xml instead of hard coded.
author Tom Gottfried <tom@intevation.de>
date Tue, 07 Jun 2016 12:03:36 +0200
parents 5bdd1631a451
children
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/VersionService.java	Mon Jun 06 15:15:12 2016 +0200
+++ b/src/main/java/de/intevation/lada/rest/VersionService.java	Tue Jun 07 12:03:36 2016 +0200
@@ -7,6 +7,10 @@
  */
 package de.intevation.lada.rest;
 
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+
+import javax.inject.Inject;
 import javax.enterprise.context.RequestScoped;
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.GET;
@@ -17,6 +21,8 @@
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriInfo;
 
+import org.apache.log4j.Logger;
+
 import de.intevation.lada.util.rest.Response;
 
 /**
@@ -46,7 +52,8 @@
 @RequestScoped
 public class VersionService {
 
-    private static final String VERSION = "2.2.0";
+    @Inject
+    private Logger logger;
 
     /**
      * Get server Version.
@@ -63,6 +70,14 @@
         @Context HttpServletRequest request,
         @Context UriInfo info
     ) {
-        return new Response(true, 200, VERSION);
+        String version = "unknown";
+        try {
+            version = ResourceBundle.getBundle("lada").getString("version");
+            return new Response(true, 200, version);
+        }
+        catch (MissingResourceException mre) {
+            logger.error(mre);
+        }
+        return new Response(false, 200, version);
     }
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)