geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r663681 - /geronimo/server/branches/2.1/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java
Date Thu, 05 Jun 2008 17:58:00 GMT
Author: gawor
Date: Thu Jun  5 10:58:00 2008
New Revision: 663681

URL: http://svn.apache.org/viewvc?rev=663681&view=rev
Log:
include empty directories in archive. related to GERONIMO-4086

Modified:
    geronimo/server/branches/2.1/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java

Modified: geronimo/server/branches/2.1/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java?rev=663681&r1=663680&r2=663681&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java
(original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java
Thu Jun  5 10:58:00 2008
@@ -101,6 +101,7 @@
 */
         
         // add in all files and mark them with default file permissions
+        Map<File, Boolean> emptyDirs = new HashMap<File, Boolean>();
         Map<String, File> all = IOUtil.listAllFileNames(source);
         removeExcludes(source, all);
         for (Map.Entry<String, File> 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<File, Boolean> 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()) {



Mime
View raw message