markt       2005/01/14 14:47:39

  Modified:    catalina/src/share/org/apache/catalina/servlets
                        LocalStrings.properties LocalStrings_ja.properties
                        ManagerServlet.java
  Log:
  Fix bug 28830. ManagerServlet broken for deploy (&undeploy)
   - Based on a patch provided by Stephane Bailliez
  
  Revision  Changes    Path
  1.22      +2 -0      
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/LocalStrings.properties,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- LocalStrings.properties   11 Jan 2003 21:10:28 -0000      1.21
  +++ LocalStrings.properties   14 Jan 2005 22:47:38 -0000      1.22
  @@ -52,6 +52,8 @@
   managerServlet.deployed=OK - Deployed application at context path {0}
   managerServlet.exception=FAIL - Encountered exception {0}
   managerServlet.installed=OK - Installed application at context path {0}
  +managerServlet.installUploadFail=FAIL - Install Upload Failed, Exception: {0}
  +managerServlet.installUploadWarExists=FAIL - War file \"{0}\" already exists 
on server
   managerServlet.invalidPath=FAIL - Invalid context path {0} was specified
   managerServlet.invalidWar=FAIL - Invalid application URL {0} was specified
   managerServlet.listed=OK - Listed applications for virtual host {0}
  
  
  
  1.7       +2 -0      
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/LocalStrings_ja.properties
  
  Index: LocalStrings_ja.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/LocalStrings_ja.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LocalStrings_ja.properties        4 Mar 2003 17:22:15 -0000       1.6
  +++ LocalStrings_ja.properties        14 Jan 2005 22:47:38 -0000      1.7
  @@ -52,6 +52,8 @@
   managerServlet.deployed=OK - 
\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9 {0} 
\u3067\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u914d\u5099\u3057\u307e\u3057\u305f
   managerServlet.exception=\u5931\u6557 - \u4f8b\u5916 {0} 
\u304c\u767a\u751f\u3057\u307e\u3057\u305f
   managerServlet.installed=OK - 
\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9 {0} 
\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u305f
  +managerServlet.installUploadFail=\u5931\u6557 - 
\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u304c\u5931\u6557\u3057\u307e\u3057\u305f\u3001\u4f8b\u5916:
 {0}
  +managerServlet.installUploadWarExists=\u5931\u6557 - 
WAR\u30d5\u30a1\u30a4\u30eb \"{0}\" 
\u306f\u3059\u3067\u306b\u30b5\u30fc\u30d0\u4e0a\u306b\u5b58\u5728\u3057\u307e\u3059
   managerServlet.invalidPath=\u5931\u6557 - 
\u7121\u52b9\u306a\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9 {0} 
\u304c\u6307\u5b9a\u3055\u308c\u307e\u3057\u305f
   managerServlet.invalidWar=\u5931\u6557 - 
\u7121\u52b9\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306eURL {0} 
\u304c\u6307\u5b9a\u3055\u308c\u307e\u3057\u305f
   managerServlet.listed=OK - \u30d0\u30fc\u30c1\u30e3\u30eb\u30db\u30b9\u30c8 
{0} 
\u306e\u30ea\u30b9\u30c8\u3055\u308c\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3
  
  
  
  1.36      +48 -8     
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/ManagerServlet.java
  
  Index: ManagerServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/ManagerServlet.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- ManagerServlet.java       5 Jan 2005 11:54:37 -0000       1.35
  +++ ManagerServlet.java       14 Jan 2005 22:47:38 -0000      1.36
  @@ -475,17 +475,42 @@
               return;
           }
   
  +        // Identify the appBase of the owning Host of this Context
  +        // (if any)
  +        String appBase = ((Host) context.getParent()).getAppBase();
  +        File appBaseDir = new File(appBase);
  +        if (!appBaseDir.isAbsolute()) {
  +            appBaseDir = new File(System.getProperty("catalina.base"),
  +                                  appBase);
  +        }
  +        File localWar = new File(appBaseDir, basename + ".war");
  +        if (localWar.exists()) {
  +            writer.println(sm.getString
  +                        ("managerServlet.installUploadWarExists",localWar));
  +            return;
  +        }
  +
           // Upload the web application archive to a local WAR file
  -        File localWar = new File(deployed, basename + ".war");
  +        File tempWar = new File(deployed, localWar.getName());
           if (debug >= 2) {
  -            log("Uploading WAR file to " + localWar);
  +            log("Uploading WAR file to " + tempWar);
           }
           try {
  -            uploadWar(request, localWar);
  +            uploadWar(request, tempWar);
           } catch (IOException e) {
               log("managerServlet.upload[" + displayPath + "]", e);
               writer.println(sm.getString("managerServlet.exception",
                                           e.toString()));
  +            tempWar.delete();
  +            return;
  +        }
  +
  +        // renameTo doc says it is supposed not to move the file in every 
platform
  +        boolean moved = tempWar.renameTo(localWar);
  +        if (!moved){
  +            writer.println(sm.getString
  +                        ("managerServlet.installUploadFail",localWar));
  +            tempWar.delete();
               return;
           }
   
  @@ -503,6 +528,10 @@
               return;
           }
   
  +        // FIXME  There is a race condition here. If liveDeploy is true it 
means
  +        // the deployer "could" start deploy the app before we start doing 
it.
  +        // This would need host synchronization here and in HostConfig
  +
           // Deploy this web application
           try {
               URL warURL =
  @@ -1167,14 +1196,13 @@
               }
   
               // Validate the docBase path of this application
  -            String deployedPath = deployed.getCanonicalPath();
               String docBase = context.getDocBase();
               File docBaseDir = new File(docBase);
               if (!docBaseDir.isAbsolute()) {
                   docBaseDir = new File(appBaseDir, docBase);
               }
               String docBasePath = docBaseDir.getCanonicalPath();
  -            if (!docBasePath.startsWith(deployedPath)) {
  +            if (!docBasePath.startsWith(appBaseDir.getCanonicalPath())) {
                   writer.println(sm.getString("managerServlet.noDocBase",
                                               displayPath));
                   return;
  @@ -1190,15 +1218,27 @@
                   return;
               }
               deployer.remove(path);
  +            
  +            String docBaseWarPath = null;
  +            
  +            // Delete the directory if there is one
               if (docBaseDir.isDirectory()) {
                   undeployDir(docBaseDir);
  +                docBaseWarPath = docBaseDir.getCanonicalPath() + ".war";
               } else {
  -                docBaseDir.delete();  // Delete the WAR file
  +                docBaseWarPath = docBaseDir.getCanonicalPath();
               }
  +            
  +            // Delete the WAR file if there is one
  +            File docBaseWar = new File(docBaseWarPath);
  +            docBaseWar.delete();
  +            
  +            // Delete the context xml file if there is one
               String docBaseXmlPath =
  -                docBasePath.substring(0, docBasePath.length() - 4) + ".xml";
  +                docBaseWarPath.substring(0, docBaseWarPath.length() - 4) + 
".xml";
               File docBaseXml = new File(docBaseXmlPath);
               docBaseXml.delete();
  +
               writer.println(sm.getString("managerServlet.undeployed",
                                           displayPath));
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to