API for accessing the controller version 40/4040/1
authorSapan Shah <sapshah@cisco.com>
Mon, 6 Jan 2014 23:50:40 +0000 (15:50 -0800)
committerSapan Shah <sapshah@cisco.com>
Mon, 6 Jan 2014 23:50:40 +0000 (15:50 -0800)
Change-Id: I93fbe875651dd51a7eb4319fd210ab142e3b198f
Signed-off-by: Sapan Shah <sapshah@cisco.com>
opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWeb.java
opendaylight/web/root/src/main/resources/WEB-INF/web.xml

index 1d4211a9267e25a1399f48d99c145cdb6bf5b6fa..ca37f4b7c19658ca14facf9af29d6d83d2cd07cb 100644 (file)
@@ -8,8 +8,10 @@
 
 package org.opendaylight.controller.web;
 
 
 package org.opendaylight.controller.web;
 
+import java.io.FileInputStream;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 
 import javax.servlet.http.HttpServletRequest;
 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.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;
 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";
     }
 
         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<String, Map<String, Object>> bundles(HttpServletRequest request) {
     @RequestMapping(value = "web.json")
     @ResponseBody
     public Map<String, Map<String, Object>> bundles(HttpServletRequest request) {
index 89812af53df5447ef4426dd49ce312aff6f87a43..072f08f581eadb4b6b9290c92e93776f7b560c87 100644 (file)
@@ -46,6 +46,7 @@
              <url-pattern>/images/*</url-pattern>
              <url-pattern>/css/*</url-pattern>
              <url-pattern>/favicon.ico</url-pattern>
              <url-pattern>/images/*</url-pattern>
              <url-pattern>/css/*</url-pattern>
              <url-pattern>/favicon.ico</url-pattern>
+             <url-pattern>/versionProperty/*</url-pattern>
           </web-resource-collection>
         </security-constraint>
 
           </web-resource-collection>
         </security-constraint>