Author: thomas.diesler(a)jboss.com
Date: 2010-03-06 14:32:13 -0500 (Sat, 06 Mar 2010)
New Revision: 102034
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java
Log:
Fix getEntries
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java 2010-03-06
17:11:05 UTC (rev 102033)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java 2010-03-06
19:32:13 UTC (rev 102034)
@@ -104,7 +104,6 @@
assertNoEntries(bundle, "", "", false);
assertNoEntries(bundle, "", "", true);
assertEntryPaths("", bundle,
- "/",
"root.xml",
"root-no-suffix",
"entry1.xml",
Modified:
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java
===================================================================
---
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java 2010-03-06
17:11:05 UTC (rev 102033)
+++
projects/jboss-osgi/projects/vfs/trunk/vfs21/src/main/java/org/jboss/osgi/vfs21/VFSEntryPathsEnumeration.java 2010-03-06
19:32:13 UTC (rev 102034)
@@ -54,15 +54,22 @@
throw new IllegalArgumentException("Null root");
if (file == null)
throw new IllegalArgumentException("Null file");
-
+
String rootPath = root.getPathName();
ArrayList<String> paths = new ArrayList<String>();
- paths.add(fixPath(rootPath, file));
+ String fixedPath = fixPath(rootPath, file);
+ if (fixedPath != null)
+ paths.add(fixedPath);
+
List<VirtualFile> children = file.getChildrenRecursively();
for (VirtualFile child : children)
- paths.add(fixPath(rootPath, child));
-
+ {
+ fixedPath = fixPath(rootPath, child);
+ if (fixedPath != null)
+ paths.add(fixedPath);
+ }
+
this.paths = paths.iterator();
}
@@ -76,29 +83,25 @@
return paths.next();
}
- private String fixPath(String rootPath, VirtualFile file)
+ private String fixPath(String rootPath, VirtualFile file) throws IOException
{
- try
- {
- String result = file.getPathName();
-
- int length = rootPath.length();
- if (length != 0)
- result = result.substring(length);
-
- // Returned paths indicating subdirectory paths end with a "/"
- if (file.isLeaf() == false && result.endsWith("/") == false)
- result += "/";
-
- // The returned paths are all relative to the root of this bundle and must not
begin with "/".
- if (result.startsWith("/"))
- result = result.substring(1);
-
- return result;
- }
- catch (IOException e)
- {
- throw new RuntimeException("Error fixing path for " + file, e);
- }
+ String result = file.getPathName();
+
+ int length = rootPath.length();
+ if (length != 0)
+ result = result.substring(length);
+
+ // Returned paths indicating subdirectory paths end with a "/"
+ if (file.isLeaf() == false && result.endsWith("/") == false)
+ result += "/";
+
+ // The returned paths are all relative to the root of this bundle and must not
begin with "/".
+ if (result.startsWith("/"))
+ result = result.substring(1);
+
+ if (result.isEmpty())
+ return null;
+
+ return result;
}
}
Modified:
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java
===================================================================
---
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java 2010-03-06
17:11:05 UTC (rev 102033)
+++
projects/jboss-osgi/projects/vfs/trunk/vfs30/src/main/java/org/jboss/osgi/vfs30/VFSEntryPathsEnumeration.java 2010-03-06
19:32:13 UTC (rev 102034)
@@ -57,11 +57,18 @@
String rootPath = root.getPathName();
ArrayList<String> paths = new ArrayList<String>();
- paths.add(fixPath(rootPath, file));
+
+ String fixedPath = fixPath(rootPath, file);
+ if (fixedPath != null)
+ paths.add(fixedPath);
List<VirtualFile> children = file.getChildrenRecursively();
for (VirtualFile child : children)
- paths.add(fixPath(rootPath, child));
+ {
+ fixedPath = fixPath(rootPath, child);
+ if (fixedPath != null)
+ paths.add(fixedPath);
+ }
this.paths = paths.iterator();
}
@@ -87,11 +94,14 @@
// Returned paths indicating subdirectory paths end with a "/"
if (file.isDirectory() && result.endsWith("/") == false)
result += "/";
-
+
// The returned paths are all relative to the root of this bundle and must not
begin with "/".
if (result.startsWith("/"))
result = result.substring(1);
+ if (result.isEmpty())
+ return null;
+
return result;
}
}