This exposes DeletedNodes through AVMService via calls for lookup

and directory listing that take an includeLinks flag.  Original calls 
(w/o a flag) should have unchanged behavior. 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3752 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-09-11 00:00:57 +00:00
parent 8a95b09b98
commit 5e0378deb2
12 changed files with 329 additions and 92 deletions

View File

@@ -207,7 +207,7 @@ public class AVMRepository
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(srcPath); String [] pathParts = SplitPath(srcPath);
AVMStore srcRepo = getAVMStoreByName(pathParts[0]); AVMStore srcRepo = getAVMStoreByName(pathParts[0]);
Lookup sPath = srcRepo.lookup(version, pathParts[1], false); Lookup sPath = srcRepo.lookup(version, pathParts[1], false, false);
// Lookup the destination directory. // Lookup the destination directory.
fLookupCount.set(1); fLookupCount.set(1);
pathParts = SplitPath(dstPath); pathParts = SplitPath(dstPath);
@@ -276,7 +276,7 @@ public class AVMRepository
AVMStore srcRepo = getAVMStoreByName(pathParts[0]); AVMStore srcRepo = getAVMStoreByName(pathParts[0]);
Lookup sPath = srcRepo.lookupDirectory(-1, pathParts[1], true); Lookup sPath = srcRepo.lookupDirectory(-1, pathParts[1], true);
DirectoryNode srcDir = (DirectoryNode)sPath.getCurrentNode(); DirectoryNode srcDir = (DirectoryNode)sPath.getCurrentNode();
AVMNode srcNode = srcDir.lookupChild(sPath, srcName, -1, true); AVMNode srcNode = srcDir.lookupChild(sPath, srcName, -1, true, false);
if (srcNode == null) if (srcNode == null)
{ {
throw new AVMNotFoundException("Not found: " + srcName); throw new AVMNotFoundException("Not found: " + srcName);
@@ -286,7 +286,7 @@ public class AVMRepository
AVMStore dstRepo = getAVMStoreByName(pathParts[0]); AVMStore dstRepo = getAVMStoreByName(pathParts[0]);
Lookup dPath = dstRepo.lookupDirectory(-1, pathParts[1], true); Lookup dPath = dstRepo.lookupDirectory(-1, pathParts[1], true);
DirectoryNode dstDir = (DirectoryNode)dPath.getCurrentNode(); DirectoryNode dstDir = (DirectoryNode)dPath.getCurrentNode();
AVMNode dstNode = dstDir.lookupChild(dPath, dstName, -1, true); AVMNode dstNode = dstDir.lookupChild(dPath, dstName, -1, true, false);
if (dstNode != null) if (dstNode != null)
{ {
throw new AVMExistsException("Node exists: " + dstName); throw new AVMExistsException("Node exists: " + dstName);
@@ -487,14 +487,16 @@ public class AVMRepository
* Get a listing of a directory. * Get a listing of a directory.
* @param version The version to look under. * @param version The version to look under.
* @param path The path to the directory. * @param path The path to the directory.
* @param includeDeleted Whether to see DeletedNodes.
* @return A List of FolderEntries. * @return A List of FolderEntries.
*/ */
public SortedMap<String, AVMNodeDescriptor> getListing(int version, String path) public SortedMap<String, AVMNodeDescriptor> getListing(int version, String path,
boolean includeDeleted)
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0]); AVMStore store = getAVMStoreByName(pathParts[0]);
return store.getListing(version, pathParts[1]); return store.getListing(version, pathParts[1], includeDeleted);
} }
/** /**
@@ -503,12 +505,13 @@ public class AVMRepository
* @param path The path to the directory to list. * @param path The path to the directory to list.
* @return A Map of names to descriptors. * @return A Map of names to descriptors.
*/ */
public SortedMap<String, AVMNodeDescriptor> getListingDirect(int version, String path) public SortedMap<String, AVMNodeDescriptor> getListingDirect(int version, String path,
boolean includeDeleted)
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0]); AVMStore store = getAVMStoreByName(pathParts[0]);
return store.getListingDirect(version, pathParts[1]); return store.getListingDirect(version, pathParts[1], includeDeleted);
} }
/** /**
@@ -516,7 +519,7 @@ public class AVMRepository
* @param dir The directory node descriptor. * @param dir The directory node descriptor.
* @return A SortedMap listing. * @return A SortedMap listing.
*/ */
public SortedMap<String, AVMNodeDescriptor> getListing(AVMNodeDescriptor dir) public SortedMap<String, AVMNodeDescriptor> getListing(AVMNodeDescriptor dir, boolean includeDeleted)
{ {
fLookupCount.set(1); fLookupCount.set(1);
AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(dir.getId()); AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(dir.getId());
@@ -526,7 +529,7 @@ public class AVMRepository
throw new AVMWrongTypeException("Not a directory."); throw new AVMWrongTypeException("Not a directory.");
} }
DirectoryNode dirNode = (DirectoryNode)node; DirectoryNode dirNode = (DirectoryNode)node;
return dirNode.getListing(dir); return dirNode.getListing(dir, includeDeleted);
} }
/** /**
@@ -674,9 +677,10 @@ public class AVMRepository
* Lookup a node. * Lookup a node.
* @param version The version to look under. * @param version The version to look under.
* @param path The path to lookup. * @param path The path to lookup.
* @param includeDeleted Whether to see DeletedNodes.
* @return A lookup object. * @return A lookup object.
*/ */
public Lookup lookup(int version, String path) public Lookup lookup(int version, String path, boolean includeDeleted)
{ {
Integer count = fLookupCount.get(); Integer count = fLookupCount.get();
try try
@@ -695,7 +699,7 @@ public class AVMRepository
} }
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0]); AVMStore store = getAVMStoreByName(pathParts[0]);
Lookup result = store.lookup(version, pathParts[1], false); Lookup result = store.lookup(version, pathParts[1], false, includeDeleted);
return result; return result;
} }
finally finally
@@ -713,7 +717,7 @@ public class AVMRepository
* @param name The name of the child to lookup. * @param name The name of the child to lookup.
* @return The child's descriptor. * @return The child's descriptor.
*/ */
public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name) public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name, boolean includeDeleted)
{ {
fLookupCount.set(0); fLookupCount.set(0);
AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(dir.getId()); AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(dir.getId());
@@ -727,7 +731,7 @@ public class AVMRepository
throw new AVMWrongTypeException("Not a directory."); throw new AVMWrongTypeException("Not a directory.");
} }
DirectoryNode dirNode = (DirectoryNode)node; DirectoryNode dirNode = (DirectoryNode)node;
return dirNode.lookupChild(dir, name); return dirNode.lookupChild(dir, name, includeDeleted);
} }
/** /**
@@ -741,7 +745,7 @@ public class AVMRepository
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0]); AVMStore store = getAVMStoreByName(pathParts[0]);
Lookup lookup = store.lookup(version, pathParts[1], false); Lookup lookup = store.lookup(version, pathParts[1], false, false);
return new LayeringDescriptor(!lookup.getDirectlyContained(), return new LayeringDescriptor(!lookup.getDirectlyContained(),
lookup.getAVMStore().getDescriptor(), lookup.getAVMStore().getDescriptor(),
lookup.getFinalStore().getDescriptor()); lookup.getFinalStore().getDescriptor());

View File

@@ -107,12 +107,30 @@ public class AVMServiceImpl implements AVMService
* @param path The path to lookup. * @param path The path to lookup.
*/ */
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(int version, String path) public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(int version, String path)
{
return getDirectoryListing(version, path, false);
}
/**
* Get a listing of a Folder by name, with the option of seeing
* Deleted Nodes.
* @param version The version id to look in.
* @param path The simple absolute path to the file node.
* @param includeDeleted Whether to see Deleted Nodes.
* @return A Map of names to descriptors.
* @throws AVMNotFoundException If <code>path</code> is not found.
* @throws AVMWrongTypeException If <code>path</code> contains a non-terminal
* component that is not a directory, or if <code>path</code> is not pointing
* at a directory.
*/
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(int version, String path,
boolean includeDeleted)
{ {
if (path == null) if (path == null)
{ {
throw new AVMBadArgumentException("Null path."); throw new AVMBadArgumentException("Null path.");
} }
return fAVMRepository.getListing(version, path); return fAVMRepository.getListing(version, path, includeDeleted);
} }
/** /**
@@ -128,26 +146,59 @@ public class AVMServiceImpl implements AVMService
*/ */
public SortedMap<String, AVMNodeDescriptor> public SortedMap<String, AVMNodeDescriptor>
getDirectoryListingDirect(int version, String path) getDirectoryListingDirect(int version, String path)
{
return getDirectoryListingDirect(version, path, false);
}
/**
* Get the listing of nodes contained directly in a directory. This is the
* same as getDirectoryListing for PlainDirectories, but returns only those that
* are directly contained in a layered directory. This has the option of
* seeing Deleted Nodes.
* @param version The version to look up.
* @param path The full path to get listing for.
* @param includeDeleted Whether to see Deleted Nodes.
* @return A Map of names to descriptors.
* @throws AVMNotFoundException If <code>path</code> does not exist.
* @throws AVMWrongTypeException If <code>path</code> contains any non-directory
* elements.
*/
public SortedMap<String, AVMNodeDescriptor>
getDirectoryListingDirect(int version, String path, boolean includeDeleted)
{ {
if (path == null) if (path == null)
{ {
throw new AVMBadArgumentException("Null path."); throw new AVMBadArgumentException("Null path.");
} }
return fAVMRepository.getListingDirect(version, path); return fAVMRepository.getListingDirect(version, path, includeDeleted);
} }
/** /**
* Get a directory listing from a node descriptor. * Get a directory listing from a node descriptor.
* @param dir The directory node descriptor. * @param dir The directory node descriptor.
* @return A Map of names to node descriptors. * @return A Map of names to node descriptors.
*/ */
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(AVMNodeDescriptor dir) public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(AVMNodeDescriptor dir)
{
return getDirectoryListing(dir, false);
}
/**
* Get a directory listing from a node descriptor, with the option of
* seeing deleted nodes.
* @param dir The directory node descriptor.
* @param includeDeleted Whether to see Deleted Nodes.
* @return A Map of names to node descriptors.
* @throws AVMNotFoundException If the descriptor is stale.
* @throws AVMWrongTypeException If the descriptor does not point at a directory.
*/
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(AVMNodeDescriptor dir,
boolean includeDeleted)
{ {
if (dir == null) if (dir == null)
{ {
throw new AVMBadArgumentException("Null descriptor."); throw new AVMBadArgumentException("Null descriptor.");
} }
return fAVMRepository.getListing(dir); return fAVMRepository.getListing(dir, includeDeleted);
} }
/** /**
@@ -398,12 +449,29 @@ public class AVMServiceImpl implements AVMService
* @return A Descriptor. * @return A Descriptor.
*/ */
public AVMNodeDescriptor lookup(int version, String path) public AVMNodeDescriptor lookup(int version, String path)
{
return lookup(version, path, false);
}
/**
* Lookup a node by version ids and path, with the option of
* seeing Deleted Nodes.
* @param version The version id to look under.
* @param path The simple absolute path to the parent directory.
* @param includeDeleted Whether to see Deleted Nodes.
* @return An AVMNodeDescriptor.
* @throws AVMNotFoundException If <code>path</code> does not exist or
* if <code>version</code> does not exist.
* @throws AVMWrongTypeException If <code>path</code> contains a non-terminal
* element that is not a directory.
*/
public AVMNodeDescriptor lookup(int version, String path, boolean includeDeleted)
{ {
if (path == null) if (path == null)
{ {
throw new AVMBadArgumentException("Path is null."); throw new AVMBadArgumentException("Path is null.");
} }
Lookup lookup = fAVMRepository.lookup(version, path); Lookup lookup = fAVMRepository.lookup(version, path, includeDeleted);
return lookup.getCurrentNode().getDescriptor(lookup); return lookup.getCurrentNode().getDescriptor(lookup);
} }
@@ -414,12 +482,28 @@ public class AVMServiceImpl implements AVMService
* @return The node descriptor of the child. * @return The node descriptor of the child.
*/ */
public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name) public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name)
{
return lookup(dir, name, false);
}
/**
* Lookup a node from a directory node, with the option of seeing
* Deleted Nodes.
* @param dir The descriptor for the directory node.
* @param name The name to lookup.
* @param includeDeleted Whether to see Deleted Nodes.
* @return The descriptor for the child.
* @throws AVMNotFoundException If <code>name</code> does not exist or
* if <code>dir</code> is dangling.
* @throws AVMWrongTypeException If <code>dir</code> does not refer to a directory.
*/
public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name, boolean includeDeleted)
{ {
if (dir == null || name == null) if (dir == null || name == null)
{ {
throw new AVMBadArgumentException("Illegal null argument."); throw new AVMBadArgumentException("Illegal null argument.");
} }
return fAVMRepository.lookup(dir, name); return fAVMRepository.lookup(dir, name, includeDeleted);
} }
/** /**

View File

@@ -2398,4 +2398,57 @@ public class AVMServiceTest extends AVMServiceTestBase
fail(); fail();
} }
} }
/**
* Test lookup and listing of deleted files.
*/
public void testDeleted()
{
try
{
setupBasicTree();
fService.createLayeredDirectory("main:/a", "main:/", "layer");
// Delete something in regular directory.
fService.removeNode("main:/a/b/c", "foo");
AVMNodeDescriptor desc = fService.lookup(-1, "main:/a/b/c/foo", true);
assertTrue(desc.isDeleted());
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/a/b/c", true);
assertEquals(2, listing.size());
assertTrue(listing.get("foo").isDeleted());
AVMNodeDescriptor dir = fService.lookup(-1, "main:/a/b/c", true);
desc = fService.lookup(dir, "foo", true);
assertTrue(desc.isDeleted());
listing = fService.getDirectoryListing(dir, true);
assertEquals(2, listing.size());
assertTrue(listing.get("foo").isDeleted());
desc = fService.lookup(-1, "main:/layer/b/c/foo", true);
assertTrue(desc.isDeleted());
listing = fService.getDirectoryListing(-1, "main:/layer/b/c", true);
assertEquals(2, listing.size());
assertTrue(listing.get("foo").isDeleted());
dir = fService.lookup(-1, "main:/layer/b/c", true);
listing = fService.getDirectoryListing(dir, true);
assertEquals(2, listing.size());
assertTrue(listing.get("foo").isDeleted());
// Delete something in a layer.
fService.removeNode("main:/layer/b/c", "bar");
desc = fService.lookup(-1, "main:/layer/b/c/bar", true);
assertTrue(desc.isDeleted());
listing = fService.getDirectoryListing(-1, "main:/layer/b/c", true);
assertEquals(2, listing.size());
assertTrue(listing.get("foo").isDeleted());
assertTrue(listing.get("bar").isDeleted());
listing = fService.getDirectoryListingDirect(-1, "main:/layer/b/c", true);
assertEquals(1, listing.size());
assertTrue(listing.get("bar").isDeleted());
dir = fService.lookup(-1, "main:/layer/b/c", true);
desc = fService.lookup(dir, "bar", true);
assertTrue(desc.isDeleted());
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
} }

View File

@@ -133,14 +133,14 @@ public class AVMServiceTestBase extends TestCase
} }
builder.append(path.substring(path.lastIndexOf('/') + 1)); builder.append(path.substring(path.lastIndexOf('/') + 1));
builder.append(' '); builder.append(' ');
AVMNodeDescriptor desc = fService.lookup(version, path); AVMNodeDescriptor desc = fService.lookup(version, path, true);
builder.append(desc.toString()); builder.append(desc.toString());
builder.append('\n'); builder.append('\n');
if (desc.getType() == AVMNodeType.PLAIN_DIRECTORY || if (desc.getType() == AVMNodeType.PLAIN_DIRECTORY ||
(desc.getType() == AVMNodeType.LAYERED_DIRECTORY && followLinks)) (desc.getType() == AVMNodeType.LAYERED_DIRECTORY && followLinks))
{ {
String basename = path.endsWith("/") ? path : path + "/"; String basename = path.endsWith("/") ? path : path + "/";
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(version, path); Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(version, path, true);
for (String name : listing.keySet()) for (String name : listing.keySet())
{ {
builder.append(recursiveList(basename + name, version, indent + 2, followLinks)); builder.append(recursiveList(basename + name, version, indent + 2, followLinks));

View File

@@ -111,17 +111,21 @@ public interface AVMStore
* Get a listing of the designated directory. * Get a listing of the designated directory.
* @param version The version to look under. * @param version The version to look under.
* @param path The path to the directory. * @param path The path to the directory.
* @param includeDeleted Whether to see Deleted nodes.
* @return A listing. * @return A listing.
*/ */
public SortedMap<String, AVMNodeDescriptor> getListing(int version, String path); public SortedMap<String, AVMNodeDescriptor> getListing(int version, String path,
boolean includeDeleted);
/** /**
* Get the list of nodes directly contained in a directory. * Get the list of nodes directly contained in a directory.
* @param version The version to look under. * @param version The version to look under.
* @param path The path to the directory. * @param path The path to the directory.
* @param includeDeleted Whether to see Deleted nodes.
* @return A Map of names to descriptors. * @return A Map of names to descriptors.
*/ */
public SortedMap<String, AVMNodeDescriptor> getListingDirect(int version, String path); public SortedMap<String, AVMNodeDescriptor> getListingDirect(int version, String path,
boolean includeDeleted);
/** /**
* Get the names of the deleted nodes in a directory. * Get the names of the deleted nodes in a directory.
@@ -182,9 +186,10 @@ public interface AVMStore
* @param version The version to look under. * @param version The version to look under.
* @param path The path to the node. * @param path The path to the node.
* @param write Whether this is in a write context. * @param write Whether this is in a write context.
* @param includeDeleted Whether to see Deleted nodes.
* @return A Lookup object. * @return A Lookup object.
*/ */
public Lookup lookup(int version, String path, boolean write); public Lookup lookup(int version, String path, boolean write, boolean includeDeleted);
/** /**
* Lookup a directory. * Lookup a directory.

View File

@@ -170,7 +170,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
{ {
Lookup lPath = lookupDirectory(-1, path, true); Lookup lPath = lookupDirectory(-1, path, true);
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
if (dir.lookupChild(lPath, name, -1, true) != null) if (dir.lookupChild(lPath, name, -1, true, false) != null)
{ {
throw new AVMExistsException("Child exists: " + name); throw new AVMExistsException("Child exists: " + name);
} }
@@ -203,7 +203,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
{ {
Lookup lPath = lookupDirectory(-1, dstPath, true); Lookup lPath = lookupDirectory(-1, dstPath, true);
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
if (dir.lookupChild(lPath, name, -1, true) != null) if (dir.lookupChild(lPath, name, -1, true, false) != null)
{ {
throw new AVMExistsException("Child exists: " + name); throw new AVMExistsException("Child exists: " + name);
} }
@@ -237,7 +237,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
{ {
Lookup lPath = lookupDirectory(-1, path, true); Lookup lPath = lookupDirectory(-1, path, true);
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
if (dir.lookupChild(lPath, name, -1, true) != null) if (dir.lookupChild(lPath, name, -1, true, false) != null)
{ {
throw new AVMExistsException("Child exists: " + name); throw new AVMExistsException("Child exists: " + name);
} }
@@ -263,7 +263,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
{ {
Lookup lPath = lookupDirectory(-1, path, true); Lookup lPath = lookupDirectory(-1, path, true);
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
if (dir.lookupChild(lPath, name, -1, true) != null) if (dir.lookupChild(lPath, name, -1, true, false) != null)
{ {
throw new AVMExistsException("Child exists: " + name); throw new AVMExistsException("Child exists: " + name);
} }
@@ -289,7 +289,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
{ {
Lookup lPath = lookupDirectory(-1, dstPath, true); Lookup lPath = lookupDirectory(-1, dstPath, true);
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
if (dir.lookupChild(lPath, name, -1, true) != null) if (dir.lookupChild(lPath, name, -1, true, false) != null)
{ {
throw new AVMExistsException("Child exists: " + name); throw new AVMExistsException("Child exists: " + name);
} }
@@ -350,11 +350,12 @@ public class AVMStoreImpl implements AVMStore, Serializable
* @param path The path to the directory. * @param path The path to the directory.
* @return A List of FolderEntries. * @return A List of FolderEntries.
*/ */
public SortedMap<String, AVMNodeDescriptor> getListing(int version, String path) public SortedMap<String, AVMNodeDescriptor> getListing(int version, String path,
boolean includeDeleted)
{ {
Lookup lPath = lookupDirectory(version, path, false); Lookup lPath = lookupDirectory(version, path, false);
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
Map<String, AVMNode> listing = dir.getListing(lPath); Map<String, AVMNode> listing = dir.getListing(lPath, includeDeleted);
return translateListing(listing, lPath); return translateListing(listing, lPath);
} }
@@ -364,7 +365,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
* @param path The path to the directory. * @param path The path to the directory.
* @return A Map of names to descriptors. * @return A Map of names to descriptors.
*/ */
public SortedMap<String, AVMNodeDescriptor> getListingDirect(int version, String path) public SortedMap<String, AVMNodeDescriptor> getListingDirect(int version, String path,
boolean includeDeleted)
{ {
Lookup lPath = lookupDirectory(version, path, false); Lookup lPath = lookupDirectory(version, path, false);
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
@@ -372,7 +374,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
{ {
return new TreeMap<String, AVMNodeDescriptor>(); return new TreeMap<String, AVMNodeDescriptor>();
} }
Map<String, AVMNode> listing = dir.getListingDirect(lPath); Map<String, AVMNode> listing = dir.getListingDirect(lPath, includeDeleted);
return translateListing(listing, lPath); return translateListing(listing, lPath);
} }
@@ -442,7 +444,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
{ {
Lookup lPath = lookupDirectory(-1, path, true); Lookup lPath = lookupDirectory(-1, path, true);
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
if (dir.lookupChild(lPath, name, -1, true) == null) if (dir.lookupChild(lPath, name, -1, true, false) == null)
{ {
throw new AVMNotFoundException("Does not exist: " + name); throw new AVMNotFoundException("Does not exist: " + name);
} }
@@ -457,7 +459,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public void uncover(String dirPath, String name) public void uncover(String dirPath, String name)
{ {
Lookup lPath = lookup(-1, dirPath, true); Lookup lPath = lookup(-1, dirPath, true, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
if (node.getType() != AVMNodeType.LAYERED_DIRECTORY) if (node.getType() != AVMNodeType.LAYERED_DIRECTORY)
{ {
@@ -532,7 +534,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
* @param write Whether this is in the context of a write. * @param write Whether this is in the context of a write.
* @return A Lookup object. * @return A Lookup object.
*/ */
public Lookup lookup(int version, String path, boolean write) public Lookup lookup(int version, String path, boolean write, boolean includeDeleted)
{ {
// Make up a Lookup to hold the results. // Make up a Lookup to hold the results.
Lookup result = new Lookup(this, fName); Lookup result = new Lookup(this, fName);
@@ -571,7 +573,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
// before the end. // before the end.
for (int i = 0; i < pathElements.length - 1; i++) for (int i = 0; i < pathElements.length - 1; i++)
{ {
AVMNode child = dir.lookupChild(result, pathElements[i], version, write); AVMNode child = dir.lookupChild(result, pathElements[i], version, write, includeDeleted);
if (child == null) if (child == null)
{ {
throw new AVMNotFoundException("Not found: " + pathElements[i]); throw new AVMNotFoundException("Not found: " + pathElements[i]);
@@ -586,7 +588,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
dir = (DirectoryNode)result.getCurrentNode(); dir = (DirectoryNode)result.getCurrentNode();
} }
// Now look up the last element. // Now look up the last element.
AVMNode child = dir.lookupChild(result, pathElements[pathElements.length - 1], version, write); AVMNode child = dir.lookupChild(result, pathElements[pathElements.length - 1], version, write,
includeDeleted);
if (child == null) if (child == null)
{ {
throw new AVMNotFoundException("Not found: " + pathElements[pathElements.length - 1]); throw new AVMNotFoundException("Not found: " + pathElements[pathElements.length - 1]);
@@ -625,7 +628,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
{ {
// Just do a regular lookup and assert that the last element // Just do a regular lookup and assert that the last element
// is a directory. // is a directory.
Lookup lPath = lookup(version, path, write); Lookup lPath = lookup(version, path, write, false);
if (lPath.getCurrentNode().getType() != AVMNodeType.PLAIN_DIRECTORY && if (lPath.getCurrentNode().getType() != AVMNodeType.PLAIN_DIRECTORY &&
lPath.getCurrentNode().getType() != AVMNodeType.LAYERED_DIRECTORY) lPath.getCurrentNode().getType() != AVMNodeType.LAYERED_DIRECTORY)
{ {
@@ -642,7 +645,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public String getIndirectionPath(int version, String path) public String getIndirectionPath(int version, String path)
{ {
Lookup lPath = lookup(version, path, false); Lookup lPath = lookup(version, path, false, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
if (node.getType() == AVMNodeType.LAYERED_DIRECTORY) if (node.getType() == AVMNodeType.LAYERED_DIRECTORY)
{ {
@@ -840,7 +843,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public void setOpacity(String path, boolean opacity) public void setOpacity(String path, boolean opacity)
{ {
Lookup lPath = lookup(-1, path, true); Lookup lPath = lookup(-1, path, true, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
if (!(node instanceof LayeredDirectoryNode)) if (!(node instanceof LayeredDirectoryNode))
{ {
@@ -850,6 +853,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
node.updateModTime(); node.updateModTime();
} }
// TODO Does it make sense to set properties on DeletedNodes?
/** /**
* Set a property on a node. * Set a property on a node.
* @param path The path to the node. * @param path The path to the node.
@@ -858,7 +862,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public void setNodeProperty(String path, QName name, PropertyValue value) public void setNodeProperty(String path, QName name, PropertyValue value)
{ {
Lookup lPath = lookup(-1, path, true); Lookup lPath = lookup(-1, path, true, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
node.setProperty(name, value); node.setProperty(name, value);
} }
@@ -870,7 +874,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public void setNodeProperties(String path, Map<QName, PropertyValue> properties) public void setNodeProperties(String path, Map<QName, PropertyValue> properties)
{ {
Lookup lPath = lookup(-1, path, true); Lookup lPath = lookup(-1, path, true, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
node.setProperties(properties); node.setProperties(properties);
} }
@@ -884,7 +888,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public PropertyValue getNodeProperty(int version, String path, QName name) public PropertyValue getNodeProperty(int version, String path, QName name)
{ {
Lookup lPath = lookup(version, path, false); Lookup lPath = lookup(version, path, false, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
return node.getProperty(name); return node.getProperty(name);
} }
@@ -897,7 +901,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public Map<QName, PropertyValue> getNodeProperties(int version, String path) public Map<QName, PropertyValue> getNodeProperties(int version, String path)
{ {
Lookup lPath = lookup(version, path, false); Lookup lPath = lookup(version, path, false, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
return node.getProperties(); return node.getProperties();
} }
@@ -909,7 +913,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public void deleteNodeProperty(String path, QName name) public void deleteNodeProperty(String path, QName name)
{ {
Lookup lPath = lookup(-1, path, true); Lookup lPath = lookup(-1, path, true, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
node.deleteProperty(name); node.deleteProperty(name);
} }
@@ -920,7 +924,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public void deleteNodeProperties(String path) public void deleteNodeProperties(String path)
{ {
Lookup lPath = lookup(-1, path, true); Lookup lPath = lookup(-1, path, true, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
node.deleteProperties(); node.deleteProperties();
} }
@@ -994,7 +998,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public ContentData getContentDataForRead(int version, String path) public ContentData getContentDataForRead(int version, String path)
{ {
Lookup lPath = lookup(version, path, false); Lookup lPath = lookup(version, path, false, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
if (!(node instanceof FileNode)) if (!(node instanceof FileNode))
{ {
@@ -1010,7 +1014,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public ContentData getContentDataForWrite(String path) public ContentData getContentDataForWrite(String path)
{ {
Lookup lPath = lookup(-1, path, true); Lookup lPath = lookup(-1, path, true, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
if (!(node instanceof FileNode)) if (!(node instanceof FileNode))
{ {
@@ -1026,7 +1030,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public void setContentData(String path, ContentData data) public void setContentData(String path, ContentData data)
{ {
Lookup lPath = lookup(-1, path, true); Lookup lPath = lookup(-1, path, true, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
if (!(node instanceof FileNode)) if (!(node instanceof FileNode))
{ {
@@ -1042,7 +1046,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public void addAspect(String path, QName aspectName) public void addAspect(String path, QName aspectName)
{ {
Lookup lPath = lookup(-1, path, true); Lookup lPath = lookup(-1, path, true, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
if (AVMContext.fgInstance.fAVMAspectNameDAO.exists(node, aspectName)) if (AVMContext.fgInstance.fAVMAspectNameDAO.exists(node, aspectName))
{ {
@@ -1063,7 +1067,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public List<QName> getAspects(int version, String path) public List<QName> getAspects(int version, String path)
{ {
Lookup lPath = lookup(version, path, false); Lookup lPath = lookup(version, path, false, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
List<AVMAspectName> names = List<AVMAspectName> names =
AVMContext.fgInstance.fAVMAspectNameDAO.get(node); AVMContext.fgInstance.fAVMAspectNameDAO.get(node);
@@ -1082,7 +1086,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public void removeAspect(String path, QName aspectName) public void removeAspect(String path, QName aspectName)
{ {
Lookup lPath = lookup(-1, path, true); Lookup lPath = lookup(-1, path, true, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
AVMContext.fgInstance.fAVMAspectNameDAO.delete(node, aspectName); AVMContext.fgInstance.fAVMAspectNameDAO.delete(node, aspectName);
AspectDefinition def = AVMContext.fgInstance.getDictionaryService().getAspect(aspectName); AspectDefinition def = AVMContext.fgInstance.getDictionaryService().getAspect(aspectName);
@@ -1103,7 +1107,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public boolean hasAspect(int version, String path, QName aspectName) public boolean hasAspect(int version, String path, QName aspectName)
{ {
Lookup lPath = lookup(version, path, false); Lookup lPath = lookup(version, path, false, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
return AVMContext.fgInstance.fAVMAspectNameDAO.exists(node, aspectName); return AVMContext.fgInstance.fAVMAspectNameDAO.exists(node, aspectName);
} }
@@ -1115,7 +1119,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public void setACL(String path, DbAccessControlList acl) public void setACL(String path, DbAccessControlList acl)
{ {
Lookup lPath = lookup(-1, path, true); Lookup lPath = lookup(-1, path, true, false);
AVMNode node = lPath.getCurrentNode(); AVMNode node = lPath.getCurrentNode();
node.setAcl(acl); node.setAcl(acl);
} }
@@ -1128,7 +1132,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
*/ */
public DbAccessControlList getACL(int version, String path) public DbAccessControlList getACL(int version, String path)
{ {
Lookup lPath = lookup(version, path, false); Lookup lPath = lookup(version, path, false, false);
return lPath.getCurrentNode().getAcl(); return lPath.getCurrentNode().getAcl();
} }
} }

View File

@@ -49,7 +49,8 @@ public interface DirectoryNode extends AVMNode
* @param version The version to look under. * @param version The version to look under.
* @param write Whether this is occuring in a write context. * @param write Whether this is occuring in a write context.
*/ */
public AVMNode lookupChild(Lookup lPath, String name, int version, boolean write); public AVMNode lookupChild(Lookup lPath, String name, int version, boolean write,
boolean includeDeleted);
/** /**
* Lookup a child node using an AVMNodeDescriptor as context. * Lookup a child node using an AVMNodeDescriptor as context.
@@ -57,7 +58,7 @@ public interface DirectoryNode extends AVMNode
* @param name The name of the child to lookup. * @param name The name of the child to lookup.
* @return The descriptor for the looked up child. * @return The descriptor for the looked up child.
*/ */
public AVMNodeDescriptor lookupChild(AVMNodeDescriptor mine, String name); public AVMNodeDescriptor lookupChild(AVMNodeDescriptor mine, String name, boolean includeDeleted);
/** /**
* Remove a child directly. No copy is possible. * Remove a child directly. No copy is possible.
@@ -71,21 +72,22 @@ public interface DirectoryNode extends AVMNode
* @param lPath The lookup context. * @param lPath The lookup context.
* @return A SortedMap of names to DirectoryEntries. * @return A SortedMap of names to DirectoryEntries.
*/ */
public Map<String, AVMNode> getListing(Lookup lPath); public Map<String, AVMNode> getListing(Lookup lPath, boolean includeDeleted);
/** /**
* Get a listing of the nodes directly contained by a directory. * Get a listing of the nodes directly contained by a directory.
* @param lPath The Lookup to this directory. * @param lPath The Lookup to this directory.
* @return A Map of names to nodes. * @return A Map of names to nodes.
*/ */
public Map<String, AVMNode> getListingDirect(Lookup lPath); public Map<String, AVMNode> getListingDirect(Lookup lPath, boolean includeDeleted);
/** /**
* Get a listing from a directory specified by an AVMNodeDescriptor. * Get a listing from a directory specified by an AVMNodeDescriptor.
* @param dir The directory to list. * @param dir The directory to list.
* @return A Map of names to node descriptors * @return A Map of names to node descriptors
*/ */
public SortedMap<String, AVMNodeDescriptor> getListing(AVMNodeDescriptor dir); public SortedMap<String, AVMNodeDescriptor> getListing(AVMNodeDescriptor dir,
boolean includeDeleted);
/** /**
* Get the names of nodes deleted in this directory. * Get the names of nodes deleted in this directory.

View File

@@ -304,7 +304,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
* @return A Map from names to nodes. This is a sorted Map. * @return A Map from names to nodes. This is a sorted Map.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Map<String, AVMNode> getListing(Lookup lPath) public Map<String, AVMNode> getListing(Lookup lPath, boolean includeDeleted)
{ {
// Get the base listing from the thing we indirect to. // Get the base listing from the thing we indirect to.
Map<String, AVMNode> listing = null; Map<String, AVMNode> listing = null;
@@ -318,7 +318,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
{ {
Lookup lookup = AVMRepository.GetInstance().lookupDirectory(-1, getUnderlying(lPath)); Lookup lookup = AVMRepository.GetInstance().lookupDirectory(-1, getUnderlying(lPath));
DirectoryNode dir = (DirectoryNode)lookup.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lookup.getCurrentNode();
listing = dir.getListing(lookup); listing = dir.getListing(lookup, includeDeleted);
} }
catch (AVMException re) catch (AVMException re)
{ {
@@ -332,7 +332,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
} }
for (ChildEntry entry : AVMContext.fgInstance.fChildEntryDAO.getByParent(this)) for (ChildEntry entry : AVMContext.fgInstance.fChildEntryDAO.getByParent(this))
{ {
if (entry.getChild().getType() == AVMNodeType.DELETED_NODE) if (!includeDeleted && entry.getChild().getType() == AVMNodeType.DELETED_NODE)
{ {
listing.remove(entry.getName()); listing.remove(entry.getName());
} }
@@ -349,12 +349,12 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
* @param lPath The Lookup to this directory. * @param lPath The Lookup to this directory.
* @return A Map of names to nodes. * @return A Map of names to nodes.
*/ */
public Map<String, AVMNode> getListingDirect(Lookup lPath) public Map<String, AVMNode> getListingDirect(Lookup lPath, boolean includeDeleted)
{ {
Map<String, AVMNode> listing = new HashMap<String, AVMNode>(); Map<String, AVMNode> listing = new HashMap<String, AVMNode>();
for (ChildEntry entry : AVMContext.fgInstance.fChildEntryDAO.getByParent(this)) for (ChildEntry entry : AVMContext.fgInstance.fChildEntryDAO.getByParent(this))
{ {
if (entry.getChild().getType() != AVMNodeType.DELETED_NODE) if (includeDeleted || entry.getChild().getType() != AVMNodeType.DELETED_NODE)
{ {
listing.put(entry.getName(), entry.getChild()); listing.put(entry.getName(), entry.getChild());
} }
@@ -365,9 +365,11 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
/** /**
* Get a listing from a directory node descriptor. * Get a listing from a directory node descriptor.
* @param dir The directory node descriptor. * @param dir The directory node descriptor.
* @param includeDeleted Should DeletedNodes be shown.
* @return A Map of names to node descriptors. * @return A Map of names to node descriptors.
*/ */
public SortedMap<String, AVMNodeDescriptor> getListing(AVMNodeDescriptor dir) public SortedMap<String, AVMNodeDescriptor> getListing(AVMNodeDescriptor dir,
boolean includeDeleted)
{ {
if (dir.getPath() == null || dir.getIndirection() == null) if (dir.getPath() == null || dir.getIndirection() == null)
{ {
@@ -381,7 +383,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
{ {
Lookup lookup = AVMRepository.GetInstance().lookupDirectory(-1, dir.getIndirection()); Lookup lookup = AVMRepository.GetInstance().lookupDirectory(-1, dir.getIndirection());
DirectoryNode dirNode = (DirectoryNode)lookup.getCurrentNode(); DirectoryNode dirNode = (DirectoryNode)lookup.getCurrentNode();
Map<String, AVMNode> listing = dirNode.getListing(lookup); Map<String, AVMNode> listing = dirNode.getListing(lookup, includeDeleted);
for (String name : listing.keySet()) for (String name : listing.keySet())
{ {
baseListing.put(name, baseListing.put(name,
@@ -400,7 +402,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
List<ChildEntry> children = AVMContext.fgInstance.fChildEntryDAO.getByParent(this); List<ChildEntry> children = AVMContext.fgInstance.fChildEntryDAO.getByParent(this);
for (ChildEntry child : children) for (ChildEntry child : children)
{ {
if (child.getChild().getType() == AVMNodeType.DELETED_NODE) if (!includeDeleted && child.getChild().getType() == AVMNodeType.DELETED_NODE)
{ {
baseListing.remove(child.getName()); baseListing.remove(child.getName());
} }
@@ -442,12 +444,13 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
* @return The child or null if not found. * @return The child or null if not found.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public AVMNode lookupChild(Lookup lPath, String name, int version, boolean write) public AVMNode lookupChild(Lookup lPath, String name, int version, boolean write,
boolean includeDeleted)
{ {
ChildEntry entry = AVMContext.fgInstance.fChildEntryDAO.getByNameParent(name, this); ChildEntry entry = AVMContext.fgInstance.fChildEntryDAO.getByNameParent(name, this);
if (entry != null) if (entry != null)
{ {
if (entry.getChild().getType() == AVMNodeType.DELETED_NODE) if (!includeDeleted && entry.getChild().getType() == AVMNodeType.DELETED_NODE)
{ {
return null; return null;
} }
@@ -463,7 +466,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
{ {
Lookup lookup = AVMRepository.GetInstance().lookupDirectory(-1, getUnderlying(lPath)); Lookup lookup = AVMRepository.GetInstance().lookupDirectory(-1, getUnderlying(lPath));
DirectoryNode dir = (DirectoryNode)lookup.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lookup.getCurrentNode();
AVMNode retVal = dir.lookupChild(lookup, name, -1, false); AVMNode retVal = dir.lookupChild(lookup, name, -1, false, includeDeleted);
lPath.setFinalStore(lookup.getFinalStore()); lPath.setFinalStore(lookup.getFinalStore());
return retVal; return retVal;
} }
@@ -483,7 +486,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
* @param name The name to lookup, * @param name The name to lookup,
* @return The node descriptor. * @return The node descriptor.
*/ */
public AVMNodeDescriptor lookupChild(AVMNodeDescriptor mine, String name) public AVMNodeDescriptor lookupChild(AVMNodeDescriptor mine, String name, boolean includeDeleted)
{ {
if (mine.getPath() == null || mine.getIndirection() == null) if (mine.getPath() == null || mine.getIndirection() == null)
{ {
@@ -492,7 +495,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
ChildEntry entry = AVMContext.fgInstance.fChildEntryDAO.getByNameParent(name, this); ChildEntry entry = AVMContext.fgInstance.fChildEntryDAO.getByNameParent(name, this);
if (entry != null) if (entry != null)
{ {
if (entry.getChild().getType() == AVMNodeType.DELETED_NODE) if (!includeDeleted && entry.getChild().getType() == AVMNodeType.DELETED_NODE)
{ {
return null; return null;
} }
@@ -509,7 +512,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
{ {
Lookup lookup = AVMRepository.GetInstance().lookupDirectory(-1, mine.getIndirection()); Lookup lookup = AVMRepository.GetInstance().lookupDirectory(-1, mine.getIndirection());
DirectoryNode dir = (DirectoryNode)lookup.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lookup.getCurrentNode();
AVMNode child = dir.lookupChild(lookup, name, -1, false); AVMNode child = dir.lookupChild(lookup, name, -1, false, includeDeleted);
if (child == null) if (child == null)
{ {
return null; return null;
@@ -547,7 +550,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
} }
else else
{ {
child = lookupChild(lPath, name, -1, false); child = lookupChild(lPath, name, -1, false, false);
} }
AVMNode ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(), AVMNode ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(),
lPath.getAVMStore()); lPath.getAVMStore());

View File

@@ -78,7 +78,7 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
public AVMNode copy(Lookup lPath) public AVMNode copy(Lookup lPath)
{ {
// LayeredFileNodes are always copied. // LayeredFileNodes are always copied.
Lookup lookup = AVMRepository.GetInstance().lookup(-1, fIndirection); Lookup lookup = AVMRepository.GetInstance().lookup(-1, fIndirection, false);
AVMNode indirect = lookup.getCurrentNode(); AVMNode indirect = lookup.getCurrentNode();
if (indirect.getType() != AVMNodeType.LAYERED_FILE && if (indirect.getType() != AVMNodeType.LAYERED_FILE &&
indirect.getType() != AVMNodeType.PLAIN_FILE) indirect.getType() != AVMNodeType.PLAIN_FILE)
@@ -249,7 +249,7 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
*/ */
public ContentData getContentData(Lookup lPath) public ContentData getContentData(Lookup lPath)
{ {
Lookup lookup = lPath.getAVMStore().getAVMRepository().lookup(-1, getIndirection()); Lookup lookup = lPath.getAVMStore().getAVMRepository().lookup(-1, getIndirection(), false);
AVMNode node = lookup.getCurrentNode(); AVMNode node = lookup.getCurrentNode();
if (!(node instanceof FileNode)) if (!(node instanceof FileNode))
{ {

View File

@@ -93,13 +93,13 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
* @return The listing. * @return The listing.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Map<String, AVMNode> getListing(Lookup lPath) public Map<String, AVMNode> getListing(Lookup lPath, boolean includeDeleted)
{ {
Map<String, AVMNode> result = new HashMap<String, AVMNode>(); Map<String, AVMNode> result = new HashMap<String, AVMNode>();
List<ChildEntry> children = AVMContext.fgInstance.fChildEntryDAO.getByParent(this); List<ChildEntry> children = AVMContext.fgInstance.fChildEntryDAO.getByParent(this);
for (ChildEntry child : children) for (ChildEntry child : children)
{ {
if (child.getChild().getType() == AVMNodeType.DELETED_NODE) if (!includeDeleted && child.getChild().getType() == AVMNodeType.DELETED_NODE)
{ {
continue; continue;
} }
@@ -113,9 +113,9 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
* @param lPath The Lookup to this directory. * @param lPath The Lookup to this directory.
* @return A Map of names to nodes. * @return A Map of names to nodes.
*/ */
public Map<String, AVMNode> getListingDirect(Lookup lPath) public Map<String, AVMNode> getListingDirect(Lookup lPath, boolean includeDeleted)
{ {
return getListing(lPath); return getListing(lPath, includeDeleted);
} }
/** /**
@@ -123,7 +123,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
* @param dir The directory node descriptor. * @param dir The directory node descriptor.
* @return A Map of names to node descriptors. * @return A Map of names to node descriptors.
*/ */
public SortedMap<String, AVMNodeDescriptor> getListing(AVMNodeDescriptor dir) public SortedMap<String, AVMNodeDescriptor> getListing(AVMNodeDescriptor dir, boolean includeDeleted)
{ {
if (dir.getPath() == null) if (dir.getPath() == null)
{ {
@@ -133,7 +133,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
List<ChildEntry> children = AVMContext.fgInstance.fChildEntryDAO.getByParent(this); List<ChildEntry> children = AVMContext.fgInstance.fChildEntryDAO.getByParent(this);
for (ChildEntry child : children) for (ChildEntry child : children)
{ {
if (child.getChild().getType() == AVMNodeType.DELETED_NODE) if (!includeDeleted && child.getChild().getType() == AVMNodeType.DELETED_NODE)
{ {
continue; continue;
} }
@@ -161,10 +161,12 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
* @return The child or null. * @return The child or null.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public AVMNode lookupChild(Lookup lPath, String name, int version, boolean write) public AVMNode lookupChild(Lookup lPath, String name, int version, boolean write,
boolean includeDeleted)
{ {
ChildEntry entry = AVMContext.fgInstance.fChildEntryDAO.getByNameParent(name, this); ChildEntry entry = AVMContext.fgInstance.fChildEntryDAO.getByNameParent(name, this);
if (entry == null || entry.getChild().getType() == AVMNodeType.DELETED_NODE) if (entry == null ||
(!includeDeleted && entry.getChild().getType() == AVMNodeType.DELETED_NODE))
{ {
return null; return null;
} }
@@ -179,14 +181,15 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
* @param name The name of the child to lookup. * @param name The name of the child to lookup.
* @return A node descriptor for the child. * @return A node descriptor for the child.
*/ */
public AVMNodeDescriptor lookupChild(AVMNodeDescriptor mine, String name) public AVMNodeDescriptor lookupChild(AVMNodeDescriptor mine, String name, boolean includeDeleted)
{ {
if (mine.getPath() == null) if (mine.getPath() == null)
{ {
throw new AVMBadArgumentException("Path is null."); throw new AVMBadArgumentException("Path is null.");
} }
ChildEntry entry = AVMContext.fgInstance.fChildEntryDAO.getByNameParent(name, this); ChildEntry entry = AVMContext.fgInstance.fChildEntryDAO.getByNameParent(name, this);
if (entry == null || entry.getChild().getType() == AVMNodeType.DELETED_NODE) if (entry == null ||
(!includeDeleted && entry.getChild().getType() == AVMNodeType.DELETED_NODE))
{ {
return null; return null;
} }

View File

@@ -284,6 +284,14 @@ public class AVMNodeDescriptor implements Serializable
return (fType == AVMNodeType.LAYERED_DIRECTORY ); return (fType == AVMNodeType.LAYERED_DIRECTORY );
} }
/**
* Is this a deleted node.
* @return Whether this node is a deleted node.
*/
public boolean isDeleted()
{
return fType == AVMNodeType.DELETED_NODE;
}
/** /**
* Get the user who last modified this node. * Get the user who last modified this node.
@@ -399,6 +407,8 @@ public class AVMNodeDescriptor implements Serializable
return "[LF:" + fID + ":" + fIndirection + "]"; return "[LF:" + fID + ":" + fIndirection + "]";
case AVMNodeType.LAYERED_DIRECTORY : case AVMNodeType.LAYERED_DIRECTORY :
return "[LD:" + fID + ":" + fIndirection + "]"; return "[LD:" + fID + ":" + fIndirection + "]";
case AVMNodeType.DELETED_NODE :
return "[DN:" + fID + "]";
default : default :
throw new AVMException("Internal Error."); throw new AVMException("Internal Error.");
} }

View File

@@ -24,7 +24,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.SortedMap; import java.util.SortedMap;
import org.alfresco.repo.domain.DbAccessControlList;
import org.alfresco.repo.domain.PropertyValue; import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
@@ -71,6 +70,21 @@ public interface AVMService
*/ */
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(int version, String path); public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(int version, String path);
/**
* Get a listing of a Folder by name, with the option of seeing
* Deleted Nodes.
* @param version The version id to look in.
* @param path The simple absolute path to the file node.
* @param includeDeleted Whether to see Deleted Nodes.
* @return A Map of names to descriptors.
* @throws AVMNotFoundException If <code>path</code> is not found.
* @throws AVMWrongTypeException If <code>path</code> contains a non-terminal
* component that is not a directory, or if <code>path</code> is not pointing
* at a directory.
*/
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(int version, String path,
boolean includeDeleted);
/** /**
* Get the listing of nodes contained directly in a directory. This is the * Get the listing of nodes contained directly in a directory. This is the
* same as getDirectoryListing for PlainDirectories, but returns only those that * same as getDirectoryListing for PlainDirectories, but returns only those that
@@ -85,6 +99,22 @@ public interface AVMService
public SortedMap<String, AVMNodeDescriptor> public SortedMap<String, AVMNodeDescriptor>
getDirectoryListingDirect(int version, String path); getDirectoryListingDirect(int version, String path);
/**
* Get the listing of nodes contained directly in a directory. This is the
* same as getDirectoryListing for PlainDirectories, but returns only those that
* are directly contained in a layered directory. This has the option of
* seeing Deleted Nodes.
* @param version The version to look up.
* @param path The full path to get listing for.
* @param includeDeleted Whether to see Deleted Nodes.
* @return A Map of names to descriptors.
* @throws AVMNotFoundException If <code>path</code> does not exist.
* @throws AVMWrongTypeException If <code>path</code> contains any non-directory
* elements.
*/
public SortedMap<String, AVMNodeDescriptor>
getDirectoryListingDirect(int version, String path, boolean includeDeleted);
/** /**
* Get a directory listing from a node descriptor. * Get a directory listing from a node descriptor.
* @param dir The directory node descriptor. * @param dir The directory node descriptor.
@@ -95,6 +125,18 @@ public interface AVMService
*/ */
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(AVMNodeDescriptor dir); public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(AVMNodeDescriptor dir);
/**
* Get a directory listing from a node descriptor, with the option of
* seeing deleted nodes.
* @param dir The directory node descriptor.
* @param includeDeleted Whether to see Deleted Nodes.
* @return A Map of names to node descriptors.
* @throws AVMNotFoundException If the descriptor is stale.
* @throws AVMWrongTypeException If the descriptor does not point at a directory.
*/
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(AVMNodeDescriptor dir,
boolean includeDeleted);
/** /**
* Get the names of nodes that have been deleted in a directory. * Get the names of nodes that have been deleted in a directory.
* @param version The version to look under. * @param version The version to look under.
@@ -318,6 +360,20 @@ public interface AVMService
*/ */
public AVMNodeDescriptor lookup(int version, String path); public AVMNodeDescriptor lookup(int version, String path);
/**
* Lookup a node by version ids and path, with the option of
* seeing Deleted Nodes.
* @param version The version id to look under.
* @param path The simple absolute path to the parent directory.
* @param includeDeleted Whether to see Deleted Nodes.
* @return An AVMNodeDescriptor.
* @throws AVMNotFoundException If <code>path</code> does not exist or
* if <code>version</code> does not exist.
* @throws AVMWrongTypeException If <code>path</code> contains a non-terminal
* element that is not a directory.
*/
public AVMNodeDescriptor lookup(int version, String path, boolean includeDeleted);
/** /**
* Lookup a node from a directory node. * Lookup a node from a directory node.
* @param dir The descriptor for the directory node. * @param dir The descriptor for the directory node.
@@ -329,6 +385,19 @@ public interface AVMService
*/ */
public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name); public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name);
/**
* Lookup a node from a directory node, with the option of seeing
* Deleted Nodes.
* @param dir The descriptor for the directory node.
* @param name The name to lookup.
* @param includeDeleted Whether to see Deleted Nodes.
* @return The descriptor for the child.
* @throws AVMNotFoundException If <code>name</code> does not exist or
* if <code>dir</code> is dangling.
* @throws AVMWrongTypeException If <code>dir</code> does not refer to a directory.
*/
public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name, boolean includeDeleted);
/** /**
* Get the indirection path for a layered file or directory. * Get the indirection path for a layered file or directory.
* @param version The version number to get. * @param version The version number to get.