remm 2004/07/27 10:53:15 Modified: catalina/src/share/org/apache/catalina/startup ExpandWar.java HostConfig.java webapps/manager/WEB-INF/classes/org/apache/catalina/manager ManagerServlet.java Log: - Fixes to manager deploy. - Other small fixes. Revision Changes Path 1.9 +3 -3 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ExpandWar.java Index: ExpandWar.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ExpandWar.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ExpandWar.java 26 Jul 2004 10:56:54 -0000 1.8 +++ ExpandWar.java 27 Jul 2004 17:53:14 -0000 1.9 @@ -209,7 +209,7 @@ result = dest.mkdir(); } else { files = new String[1]; - files[0] = src.getName(); + files[0] = ""; } if (files == null) { files = new String[0]; @@ -255,7 +255,7 @@ } - + /** * Delete the specified directory, including all of its contents and * subdirectories recursively. 1.41 +13 -6 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java Index: HostConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- HostConfig.java 27 Jul 2004 11:22:53 -0000 1.40 +++ HostConfig.java 27 Jul 2004 17:53:15 -0000 1.41 @@ -921,8 +921,6 @@ File resource = new File(resources[i]); if (log.isDebugEnabled()) log.debug("Checking context[" + app.name + "] redeploy resource " + resource); - // FIXME: Limit, as before, resource removal to resources which are inside the - // Host appBase if (resource.exists()) { long lastModified = ((Long) app.redeployResources.get(resources[i])).longValue(); if ((!resource.isDirectory()) && resource.lastModified() > lastModified) { @@ -942,8 +940,11 @@ File current = new File(resources[j]); current = current.getCanonicalFile(); if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath())) - || (current.getAbsolutePath().startsWith(configBase().getAbsolutePath()))) + || (current.getAbsolutePath().startsWith(configBase().getAbsolutePath()))) { + if (log.isDebugEnabled()) + log.debug("Delete " + current); ExpandWar.delete(current); + } } catch (IOException e) { log.warn(sm.getString ("hostConfig.canonicalizing", app.name), e); @@ -969,8 +970,11 @@ File current = new File(resources[j]); current = current.getCanonicalFile(); if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath())) - || (current.getAbsolutePath().startsWith(configBase().getAbsolutePath()))) + || (current.getAbsolutePath().startsWith(configBase().getAbsolutePath()))) { + if (log.isDebugEnabled()) + log.debug("Delete " + current); ExpandWar.delete(current); + } } catch (IOException e) { log.warn(sm.getString ("hostConfig.canonicalizing", app.name), e); @@ -983,8 +987,11 @@ File current = new File(resources2[j]); current = current.getCanonicalFile(); if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath())) - || (current.getAbsolutePath().startsWith(configBase().getAbsolutePath()))) + || (current.getAbsolutePath().startsWith(configBase().getAbsolutePath()))) { + if (log.isDebugEnabled()) + log.debug("Delete " + current); ExpandWar.delete(current); + } } catch (IOException e) { log.warn(sm.getString ("hostConfig.canonicalizing", app.name), e); 1.20 +82 -35 jakarta-tomcat-catalina/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/ManagerServlet.java Index: ManagerServlet.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/ManagerServlet.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- ManagerServlet.java 27 Jul 2004 07:18:37 -0000 1.19 +++ ManagerServlet.java 27 Jul 2004 17:53:15 -0000 1.20 @@ -784,6 +784,13 @@ return; } + if (config != null && (config.startsWith("file:"))) { + config = config.substring("file:".length()); + } + if (war != null && (war.startsWith("file:"))) { + war = war.substring("file:".length()); + } + try { if (!isServiced(path)) { addServiced(path); @@ -792,8 +799,13 @@ new File(configBase, getConfigFile(path) + ".xml")); } if (war != null) { - copy(new File(war), + if (war.endsWith(".war")) { + copy(new File(war), new File(getAppBase(), getDocBase(path) + ".war")); + } else { + copy(new File(war), + new File(getAppBase(), getDocBase(path))); + } } check(path); removeServiced(path); @@ -1509,42 +1521,77 @@ /** - * Copy a file. + * Copy the specified file or directory to the destination. + * + * @param src File object representing the source + * @param dest File object representing the destination */ - private boolean copy(File src, File dest) { - FileInputStream is = null; - FileOutputStream os = null; - try { - is = new FileInputStream(src); - os = new FileOutputStream(dest); - byte[] buf = new byte[4096]; - while (true) { - int len = is.read(buf); - if (len < 0) - break; - os.write(buf, 0, len); - } - is.close(); - os.close(); - } catch (IOException e) { - return false; - } finally { - try { - if (is != null) { - is.close(); - } - } catch (Exception e) { - // Ignore - } - try { - if (os != null) { - os.close(); + public static boolean copy(File src, File dest) { + return copyInternal(src, dest, new byte[4096]); + } + + + /** + * Copy the specified file or directory to the destination. + * + * @param src File object representing the source + * @param dest File object representing the destination + */ + public static boolean copyInternal(File src, File dest, byte[] buf) { + + boolean result = true; + + String files[] = null; + if (src.isDirectory()) { + files = src.list(); + result = dest.mkdir(); + } else { + files = new String[1]; + files[0] = ""; + } + if (files == null) { + files = new String[0]; + } + for (int i = 0; (i < files.length) && result; i++) { + File fileSrc = new File(src, files[i]); + File fileDest = new File(dest, files[i]); + if (fileSrc.isDirectory()) { + result = copyInternal(fileSrc, fileDest, buf); + } else { + FileInputStream is = null; + FileOutputStream os = null; + try { + is = new FileInputStream(fileSrc); + os = new FileOutputStream(fileDest); + int len = 0; + while (true) { + len = is.read(buf); + if (len == -1) + break; + os.write(buf, 0, len); + } + } catch (IOException e) { + e.printStackTrace(); + result = false; + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + } + } + if (os != null) { + try { + os.close(); + } catch (IOException e) { + } + } } - } catch (Exception e) { - // Ignore } } - return true; + return result; + } - + + }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]