Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 15538 invoked from network); 5 Jun 2008 17:57:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Jun 2008 17:57:44 -0000 Received: (qmail 56529 invoked by uid 500); 5 Jun 2008 17:57:47 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 56479 invoked by uid 500); 5 Jun 2008 17:57:46 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 56470 invoked by uid 99); 5 Jun 2008 17:57:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jun 2008 10:57:46 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jun 2008 17:57:06 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 40F072388A1E; Thu, 5 Jun 2008 10:57:23 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r663679 - /geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java Date: Thu, 05 Jun 2008 17:57:23 -0000 To: scm@geronimo.apache.org From: gawor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080605175723.40F072388A1E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gawor Date: Thu Jun 5 10:57:22 2008 New Revision: 663679 URL: http://svn.apache.org/viewvc?rev=663679&view=rev Log: include empty directories in archive. related to GERONIMO-4086 Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java Modified: geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java?rev=663679&r1=663678&r2=663679&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java Thu Jun 5 10:57:22 2008 @@ -101,6 +101,7 @@ */ // add in all files and mark them with default file permissions + Map emptyDirs = new HashMap(); Map all = IOUtil.listAllFileNames(source); removeExcludes(source, all); for (Map.Entry entry : all.entrySet()) { @@ -108,9 +109,44 @@ File sourceFile = entry.getValue(); if (sourceFile.isFile()) { archiver.addFile(sourceFile, destFileName, UnixStat.DEFAULT_FILE_PERM); + // mark parent directories non-empty + for (File parentDir = sourceFile.getParentFile(); + parentDir != null && !parentDir.equals(source); + parentDir = parentDir.getParentFile()) { + emptyDirs.put(parentDir, Boolean.FALSE); + } + + } else if (sourceFile.isDirectory()) { + Boolean isEmpty = emptyDirs.get(sourceFile); + if (isEmpty == null) { + emptyDirs.put(sourceFile, Boolean.TRUE); + // mark parent directories non-empty + for (File parentDir = sourceFile.getParentFile(); + parentDir != null && !parentDir.equals(source); + parentDir = parentDir.getParentFile()) { + emptyDirs.put(parentDir, Boolean.FALSE); + } + } } } - + + if (!all.isEmpty()) { + emptyDirs.put(source, Boolean.FALSE); + } + + String sourceDirPath = source.getAbsolutePath(); + for (Map.Entry entry : emptyDirs.entrySet()) { + if (entry.getValue().booleanValue()) { + String emptyDirPath = entry.getKey().getAbsolutePath(); + String relativeDir = emptyDirPath.substring(sourceDirPath.length()); + relativeDir = relativeDir.replace('\\', '/'); + archiver.addDirectory(entry.getKey(), serverName + relativeDir); + } + } + emptyDirs.clear(); + + all.clear(); + // add execute permissions to all non-batch files in the bin/ directory File bin = new File(source, "bin"); if (bin.exists()) {