[jboss-cvs] JBossAS SVN: r108132 - projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/helpers.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 13 23:23:24 EDT 2010


Author: flavia.rainone at jboss.com
Date: 2010-09-13 23:23:24 -0400 (Mon, 13 Sep 2010)
New Revision: 108132

Modified:
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java
Log:
[JBDEPLOY-265] AbstractStructureDeployer.getRelativePath now handles unrelated paths (i.e., where child is not a child path of the parent path)

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java	2010-09-14 03:06:52 UTC (rev 108131)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java	2010-09-14 03:23:24 UTC (rev 108132)
@@ -113,6 +113,18 @@
             if (childPath.startsWith(parentPath))
                 return childPath.substring(parentPath.length());
          }
+         // Assuming that child and parent don't have a parent -> child relationship
+         // but instead, have a common path with different suffixes
+         VirtualFile tempFile = parent;
+         StringBuilder relativePath = new StringBuilder();
+         // find the prefix that child shares with parent (in tempFile)
+         while(!childPath.startsWith(tempFile.getPathName()))
+         {
+            relativePath.append("/.."); // for every level we need to go up in the file system 
+            tempFile = tempFile.getParent();
+         }
+         relativePath.append(childPath.substring(tempFile.getPathName().length()));
+         childPath = relativePath.toString().substring(1);
       }
       
       if (childPath.endsWith("/"))



More information about the jboss-cvs-commits mailing list