[jboss-svn-commits] JBoss Common SVN: r3493 - declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Aug 26 20:49:03 EDT 2009


Author: ALRubinger
Date: 2009-08-26 20:49:03 -0400 (Wed, 26 Aug 2009)
New Revision: 3493

Modified:
   declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveImpl.java
Log:
[TMPARCH-16] Fix errors shown by VFS test case

Modified: declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveImpl.java
===================================================================
--- declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveImpl.java	2009-08-26 13:47:14 UTC (rev 3492)
+++ declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveImpl.java	2009-08-27 00:49:03 UTC (rev 3493)
@@ -195,6 +195,16 @@
       // Precondition check
       Validate.notNull(path, "No path was specified");
 
+      // Ensure contains
+      if (!this.contains(path))
+      {
+         if (log.isLoggable(Level.FINE))
+         {
+            log.fine("Not deleting non-existent path: " + path + " from " + this);
+         }
+         return false;
+      }
+
       // Get the URL form of the Path
       final URL url = this.urlFromPath(path);
 
@@ -320,15 +330,40 @@
          throw new RuntimeException("Could not obtain children for " + root, ioe);
       }
 
+      // Define the internal root context name, which we ignore
+      final String rootContextName = this.getRootUrl().getPath();
+      int rootContextNameLength = rootContextName.length();
+
       // For each child
       for (final VirtualFile file : files)
       {
-         // Populate the Map
-         final String pathName = file.getPathName();
-         final Path path = new BasicPath(pathName);
-         final Asset asset = this.getAsset(file);
-         content.put(path, asset);
+         // Don't add the internal context root
+         boolean isInternalConextRoot = false;
+         try
+         {
+            final VirtualFile parent = file.getParent();
+            final VirtualFile internalRoot = this.getRoot();
+            isInternalConextRoot = parent.equals(internalRoot);
+         }
+         catch (final IOException ioe)
+         {
+            throw new RuntimeException("Could not obtain parent of " + file, ioe);
+         }
 
+         // Only add stuff in this representation if this is not the 
+         // internal context root
+         if (!isInternalConextRoot)
+         {
+            // Populate the Map
+            final String pathName = file.getPathName();
+            // Strip out the internal context root name
+            final String adjustedPathName = pathName.substring(rootContextNameLength);
+            final Path path = new BasicPath(adjustedPathName);
+            final Asset asset = this.getAsset(file);
+            content.put(path, asset);
+
+         }
+
          // ...and repeat for all children
          this.populateContentMap(file, content);
       }



More information about the jboss-svn-commits mailing list