From: Andrew Kim Date: Tue, 7 Jan 2014 15:48:18 +0000 (+0000) Subject: Merge "API for accessing the controller version" X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-1~134 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=01eb944c644efd9304d40aacd5f09ab2f564acf0;hp=92b863639542beb0dcb04879426bc8ca58179fbd;p=controller.git Merge "API for accessing the controller version" --- diff --git a/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWeb.java b/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWeb.java index 1d4211a926..ca37f4b7c1 100644 --- a/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWeb.java +++ b/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWeb.java @@ -8,8 +8,10 @@ package org.opendaylight.controller.web; +import java.io.FileInputStream; import java.util.HashMap; import java.util.Map; +import java.util.Properties; import java.util.Set; import javax.servlet.http.HttpServletRequest; @@ -28,6 +30,7 @@ import org.opendaylight.controller.sal.utils.StatusCode; import org.opendaylight.controller.usermanager.IUserManager; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @@ -52,6 +55,23 @@ public class DaylightWeb { return "main"; } + /** + * Read the version.properties file for the property + * + * @param request + * @return String value configured in the version.properties file + */ + @RequestMapping(value="/versionProperty/{property}", method = RequestMethod.GET) + @ResponseBody + public String getVersion(HttpServletRequest request, @PathVariable("property") String property) { + Properties prop = new Properties(); + try { + prop.load(new FileInputStream("version.properties")); + return prop.getProperty(property+".version"); + } catch (Exception e) { + return null; + } + } @RequestMapping(value = "web.json") @ResponseBody public Map> bundles(HttpServletRequest request) { diff --git a/opendaylight/web/root/src/main/resources/WEB-INF/web.xml b/opendaylight/web/root/src/main/resources/WEB-INF/web.xml index 89812af53d..072f08f581 100644 --- a/opendaylight/web/root/src/main/resources/WEB-INF/web.xml +++ b/opendaylight/web/root/src/main/resources/WEB-INF/web.xml @@ -46,6 +46,7 @@ /images/* /css/* /favicon.ico + /versionProperty/*