[Yanel-commits] rev 25842 - public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/updatefinder/utils

simon at wyona.com simon at wyona.com
Mon Jul 9 17:47:51 CEST 2007


Author: simon
Date: 2007-07-09 17:47:50 +0200 (Mon, 09 Jul 2007)
New Revision: 25842

Modified:
   public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/updatefinder/utils/InstallInfo.java
Log:
added new contructor to get an InstallInfo of a certain webapp

Modified: public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/updatefinder/utils/InstallInfo.java
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/updatefinder/utils/InstallInfo.java	2007-07-09 15:47:06 UTC (rev 25841)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/resources/update-webapp/src/java/org/wyona/yanel/impl/resources/updatefinder/utils/InstallInfo.java	2007-07-09 15:47:50 UTC (rev 25842)
@@ -25,6 +25,7 @@
     private String revision;
     private String installtype;
     private String contextPrefix;
+    private String webappName;
     private String updateURL;
     private String osName; //platform
     private String javaVersion;
@@ -36,6 +37,7 @@
     
     public InstallInfo(HttpServletRequest request)  throws java.io.FileNotFoundException{
         String WEBINFPath = request.getSession().getServletContext().getRealPath("WEB-INF");
+        webappName = new File(request.getSession().getServletContext().getRealPath(".")).getParentFile().getName();
         contextPrefix = request.getSession().getServletContext().getServletContextName();
         if (contextPrefix.equalsIgnoreCase("ROOT")) {
             contextPrefix = "ROOT";
@@ -54,6 +56,29 @@
         javaVersion = System.getProperty("java.version");
     }
 
+    public InstallInfo(HttpServletRequest request, String webapp)  throws java.io.FileNotFoundException, Exception{
+        String webappsDirectoryPath = request.getSession().getServletContext().getRealPath(".") + File.separator + ".." + File.separator;
+        TomcatContextHandler tomcatContextHandler = new TomcatContextHandler(request);
+        webappName = webapp;
+        contextPrefix = (String) tomcatContextHandler.getContextsOfWebapp(webapp).get(0);
+        
+        if (contextPrefix.equalsIgnoreCase("ROOT")) {
+            contextPrefix = "ROOT";
+        } else {
+            contextPrefix = contextPrefix.toLowerCase();
+        }
+        InputStream installRdfIn = new FileInputStream(new File(webappsDirectoryPath + webapp + File.separator + "WEB-INF" + File.separator + "classes" + File.separator + "install.rdf"));
+        Model model = ModelFactory.createDefaultModel();
+        //read the RDF/XML file
+        model.read(installRdfIn, "");
+        parseModel(model);
+        
+        setServerInfoDetail(request);
+        
+        osName = System.getProperty("os.name");
+        javaVersion = System.getProperty("java.version");
+    }
+
     private void parseModel(Model model) {
         Resource install = model.getResource("urn:wyona:application:install");
         
@@ -112,9 +137,14 @@
     public String getInstalltype() {
         return installtype;
     }
+    
     public String getContextPrefix() {
         return contextPrefix;
     }
+    
+    public String getWebaName() {
+        return webappName;
+    }
 
     public String getUpdateURL() {
         return updateURL;




More information about the Yanel-commits mailing list