AVMNodeDescriptor now can be asked what type of deleted node it is via isDeletedFile() and

isDeletedDirectory().


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4571 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-12-11 17:45:36 +00:00
parent 7a6e213ebd
commit f80dcdd7e4
10 changed files with 96 additions and 13 deletions

View File

@@ -37,7 +37,7 @@ public class AVMCrawlTestP extends AVMServiceTestBase
{
int n = 8; // Number of Threads.
int m = 32; // How many multiples of content to start with.
long runTime = 21600000; // 6 hours.
long runTime = 3600000; // 6 hours.
fService.purgeAVMStore("main");
BulkLoader loader = new BulkLoader();
loader.setAvmService(fService);

View File

@@ -3351,6 +3351,7 @@ public class AVMServiceTest extends AVMServiceTestBase
fService.removeNode("main:/a/b/c", "foo");
AVMNodeDescriptor desc = fService.lookup(-1, "main:/a/b/c/foo", true);
assertTrue(desc.isDeleted());
assertTrue(desc.isDeletedFile());
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/a/b/c", true);
assertEquals(2, listing.size());
assertTrue(listing.get("foo").isDeleted());
@@ -3373,6 +3374,7 @@ public class AVMServiceTest extends AVMServiceTestBase
fService.removeNode("main:/layer/b/c", "bar");
desc = fService.lookup(-1, "main:/layer/b/c/bar", true);
assertTrue(desc.isDeleted());
assertTrue(desc.isDeletedFile());
listing = fService.getDirectoryListing(-1, "main:/layer/b/c", true);
assertEquals(2, listing.size());
assertTrue(listing.get("foo").isDeleted());

View File

@@ -23,4 +23,9 @@ package org.alfresco.repo.avm;
*/
public interface DeletedNode extends AVMNode
{
/**
* Get the type of node that this is a deleted placeholder for
* @return The type of node that was deleted.
*/
public int getDeletedType();
}

View File

@@ -26,6 +26,11 @@ import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
public class DeletedNodeImpl extends AVMNodeImpl implements DeletedNode
{
private static final long serialVersionUID = 7283526790174482993L;
/**
* The type of node that this is a deleted node for.
*/
private int fDeletedType;
/**
* For Hibernate's use.
@@ -44,7 +49,23 @@ public class DeletedNodeImpl extends AVMNodeImpl implements DeletedNode
{
super(id, store);
}
/**
* Setter.
*/
public void setDeletedType(int type)
{
fDeletedType = type;
}
/**
* Getter.
*/
public int getDeletedType()
{
return fDeletedType;
}
/**
* This should never be called.
*/
@@ -87,7 +108,8 @@ public class DeletedNodeImpl extends AVMNodeImpl implements DeletedNode
false,
-1,
false,
-1);
-1,
fDeletedType);
}
/**
@@ -114,7 +136,8 @@ public class DeletedNodeImpl extends AVMNodeImpl implements DeletedNode
false,
-1,
false,
-1);
-1,
fDeletedType);
}
/**
@@ -143,7 +166,8 @@ public class DeletedNodeImpl extends AVMNodeImpl implements DeletedNode
false,
-1,
false,
-1);
-1,
fDeletedType);
}
/**

View File

@@ -568,11 +568,12 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
}
if (child != null && (indirect || child.getStoreNew() == null || child.getAncestor() != null))
{
AVMNode ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(),
DeletedNodeImpl ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(),
lPath.getAVMStore());
AVMDAOs.Instance().fAVMNodeDAO.save(ghost);
AVMDAOs.Instance().fAVMNodeDAO.flush();
ghost.setAncestor(child);
ghost.setDeletedType(child.getType());
this.putChild(name, ghost);
}
else
@@ -682,6 +683,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
fPrimaryIndirection,
fLayerID,
fOpacity,
-1,
-1);
}
@@ -710,6 +712,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
fPrimaryIndirection,
fLayerID,
fOpacity,
-1,
-1);
}
@@ -749,6 +752,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
fPrimaryIndirection,
fLayerID,
fOpacity,
-1,
-1);
}

View File

@@ -161,7 +161,8 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
false,
-1,
false,
0);
0,
-1);
}
/**
@@ -188,7 +189,8 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
false,
-1,
false,
0);
0,
-1);
}
/**
@@ -217,7 +219,8 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
false,
-1,
false,
0);
0,
-1);
}
/**

View File

@@ -232,11 +232,12 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
AVMDAOs.Instance().fChildEntryDAO.delete(entry);
if (child.getStoreNew() == null || child.getAncestor() != null)
{
AVMNode ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(),
DeletedNodeImpl ghost = new DeletedNodeImpl(lPath.getAVMStore().getAVMRepository().issueID(),
lPath.getAVMStore());
AVMDAOs.Instance().fAVMNodeDAO.save(ghost);
AVMDAOs.Instance().fAVMNodeDAO.flush();
ghost.setAncestor(child);
ghost.setDeletedType(child.getType());
putChild(name, ghost);
}
else
@@ -363,6 +364,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
false,
-1,
false,
-1,
-1);
}
@@ -390,6 +392,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
false,
-1,
false,
-1,
-1);
}
@@ -419,6 +422,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
false,
-1,
false,
-1,
-1);
}

View File

@@ -194,7 +194,8 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
false,
-1,
false,
getLength());
getLength(),
-1);
}
/**
@@ -221,7 +222,8 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
false,
-1,
false,
getFileLength());
getFileLength(),
-1);
}
/**
@@ -250,7 +252,8 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
false,
-1,
false,
getFileLength());
getFileLength(),
-1);
}
/**

View File

@@ -50,6 +50,7 @@
proxy="DeletedNode"
lazy="true"
discriminator-value="deletednode">
<property name="deletedType" type="int"/>
</subclass>
<!-- Directories, two flavors. -->
<subclass name="DirectoryNodeImpl"

View File

@@ -112,6 +112,12 @@ public class AVMNodeDescriptor implements Serializable
*/
private boolean fOpacity;
/**
* The type of node that this is a deleted node for.
* Only for DeletedNode.
*/
private int fDeletedType;
/**
* Make one up.
* @param path The looked up path.
@@ -128,6 +134,7 @@ public class AVMNodeDescriptor implements Serializable
* @param isPrimary Whether this is a primary indirection.
* @param layerID The layer id.
* @param length The file length.
* @param deletedType The type of node that was deleted.
*/
public AVMNodeDescriptor(String path,
String name,
@@ -144,7 +151,8 @@ public class AVMNodeDescriptor implements Serializable
boolean isPrimary,
long layerID,
boolean opacity,
long length)
long length,
int deletedType)
{
fPath = path;
fName = name;
@@ -162,6 +170,7 @@ public class AVMNodeDescriptor implements Serializable
fLayerID = layerID;
fLength = length;
fOpacity = opacity;
fDeletedType = deletedType;
}
/**
@@ -442,4 +451,32 @@ public class AVMNodeDescriptor implements Serializable
{
return (int)fID;
}
/**
* Get the type of node that a deleted node is standing in for.
*/
public int getDeletedType()
{
return fDeletedType;
}
/**
* Is this a deleted directory?
*/
public boolean isDeletedDirectory()
{
return fType == AVMNodeType.DELETED_NODE &&
(fDeletedType == AVMNodeType.LAYERED_DIRECTORY ||
fDeletedType == AVMNodeType.PLAIN_DIRECTORY);
}
/**
* Is this a deleted file?
*/
public boolean isDeletedFile()
{
return fType == AVMNodeType.DELETED_NODE &&
(fDeletedType == AVMNodeType.LAYERED_FILE ||
fDeletedType == AVMNodeType.PLAIN_FILE);
}
}