Relaxed path requirements. foo://figwump/thneedle///wart/ is now seen

as equivalent to foo:/figwump/thneedle/wart.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3392 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-07-24 16:14:14 +00:00
parent e5214a5d42
commit c50a4aa669
2 changed files with 26 additions and 5 deletions

View File

@@ -39,6 +39,24 @@ import org.alfresco.service.namespace.QName;
*/ */
public class AVMServiceTest extends AVMServiceTestBase public class AVMServiceTest extends AVMServiceTestBase
{ {
/**
* Test goofy paths.
*/
public void testGoofyPaths()
{
try
{
setupBasicTree();
fService.getFileInputStream(-1, "main://a/b/c/foo").close();
fService.getDirectoryListing(-1, "main:/a/");
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
/** /**
* Test getting deleted names. * Test getting deleted names.
*/ */

View File

@@ -519,18 +519,21 @@ class AVMStoreImpl implements AVMStore, Serializable
{ {
throw new AVMException("Invalid path: " + path); throw new AVMException("Invalid path: " + path);
} }
if (path.length() > 1) while (path.startsWith("/"))
{ {
path = path.substring(1); path = path.substring(1);
} }
String[] pathElements = path.split("/"); while (path.endsWith("/"))
{
path = path.substring(0, path.length() - 1);
}
String[] pathElements = path.split("/+");
// Grab the root node to start the lookup. // Grab the root node to start the lookup.
DirectoryNode dir = null; DirectoryNode dir = null;
// Versions less than 0 mean get current. // Versions less than 0 mean get current.
if (version < 0) if (version < 0)
{ {
dir = fRoot; // TODO How to factor out this kind of Hibernate goofiness. dir = fRoot;
// (DirectoryNode)AVMNodeUnwrapper.Unwrap(fRoot);
} }
else else
{ {
@@ -539,7 +542,7 @@ class AVMStoreImpl implements AVMStore, Serializable
// Add an entry for the root. // Add an entry for the root.
result.add(dir, "", write); result.add(dir, "", write);
dir = (DirectoryNode)result.getCurrentNode(); dir = (DirectoryNode)result.getCurrentNode();
if (pathElements.length == 0) if (pathElements.length == 1 && pathElements[0].equals(""))
{ {
return result; return result;
} }