mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
Added two more special purpose calls, to improve flatten performance from
rotten to ok. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3809 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
dfe49bf51b
commit
14ebe1726f
@ -1285,4 +1285,38 @@ public class AVMRepository
|
|||||||
}
|
}
|
||||||
dir.link(name, child);
|
dir.link(name, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove name without leaving behind a deleted node. Dangerous
|
||||||
|
* if used unwisely.
|
||||||
|
* @param lDir The layered directory node.
|
||||||
|
* @param name The name of the child.
|
||||||
|
*/
|
||||||
|
public void flatten(AVMNodeDescriptor lDir, String name)
|
||||||
|
{
|
||||||
|
AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(lDir.getId());
|
||||||
|
if (!(node instanceof LayeredDirectoryNode))
|
||||||
|
{
|
||||||
|
throw new AVMWrongTypeException("Not a Layered Directory.");
|
||||||
|
}
|
||||||
|
LayeredDirectoryNode dir = (LayeredDirectoryNode)node;
|
||||||
|
if (!dir.getIsNew())
|
||||||
|
{
|
||||||
|
throw new AVMException("Directory has not already been copied.");
|
||||||
|
}
|
||||||
|
dir.flatten(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force a copy on write.
|
||||||
|
* @param path The path to force.
|
||||||
|
*/
|
||||||
|
public void forceCopy(String path)
|
||||||
|
{
|
||||||
|
fLookupCount.set(1);
|
||||||
|
String [] pathParts = SplitPath(path);
|
||||||
|
AVMStore store = getAVMStoreByName(pathParts[0]);
|
||||||
|
// Just force a copy if needed by looking up in write mode.
|
||||||
|
store.lookup(-1, pathParts[1], true, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1083,4 +1083,35 @@ public class AVMServiceImpl implements AVMService
|
|||||||
}
|
}
|
||||||
fAVMRepository.link(parent, name, child);
|
fAVMRepository.link(parent, name, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flatten a direct child of a layered directory. This does
|
||||||
|
* the equivalent of removing the given child from the directory
|
||||||
|
* and then doing an uncover. This routine makes many dangerous
|
||||||
|
* assumptions and is only for use by AVMSyncService. Don't use it
|
||||||
|
* if you don't know precisely what you are doing.
|
||||||
|
* @param lDir The layered directory node.
|
||||||
|
* @param name The name to flatten.
|
||||||
|
*/
|
||||||
|
public void flatten(AVMNodeDescriptor lDir, String name)
|
||||||
|
{
|
||||||
|
if (lDir == null || name == null)
|
||||||
|
{
|
||||||
|
throw new AVMBadArgumentException("Illegal Null Argument.");
|
||||||
|
}
|
||||||
|
fAVMRepository.flatten(lDir, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force copy on write of a path.
|
||||||
|
* @param path The path to force.
|
||||||
|
*/
|
||||||
|
public void forceCopy(String path)
|
||||||
|
{
|
||||||
|
if (path == null)
|
||||||
|
{
|
||||||
|
throw new AVMBadArgumentException("Null Path.");
|
||||||
|
}
|
||||||
|
fAVMRepository.forceCopy(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -593,6 +593,8 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
fAVMService.forceCopy(layer.getPath());
|
||||||
|
layer = fAVMService.lookup(-1, layer.getPath());
|
||||||
// Grab the listing
|
// Grab the listing
|
||||||
Map<String, AVMNodeDescriptor> underListing =
|
Map<String, AVMNodeDescriptor> underListing =
|
||||||
fAVMService.getDirectoryListing(underlying, true);
|
fAVMService.getDirectoryListing(underlying, true);
|
||||||
@ -608,16 +610,14 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
|||||||
// We've found an identity so flatten it.
|
// We've found an identity so flatten it.
|
||||||
if (topNode.getId() == bottomNode.getId())
|
if (topNode.getId() == bottomNode.getId())
|
||||||
{
|
{
|
||||||
fAVMService.removeNode(layer.getPath(), name);
|
fAVMService.flatten(layer, name);
|
||||||
fAVMService.uncover(layer.getPath(), name);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Otherwise recursively flatten the children.
|
// Otherwise recursively flatten the children.
|
||||||
if (flatten(topNode, bottomNode))
|
if (flatten(topNode, bottomNode))
|
||||||
{
|
{
|
||||||
fAVMService.removeNode(layer.getPath(), name);
|
fAVMService.flatten(layer, name);
|
||||||
fAVMService.uncover(layer.getPath(), name);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -59,6 +59,12 @@ public interface LayeredDirectoryNode extends DirectoryNode, Layered
|
|||||||
*/
|
*/
|
||||||
public void uncover(Lookup lPath, String name);
|
public void uncover(Lookup lPath, String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove name without leaving behind a deleted node.
|
||||||
|
* @param name The name of the child to flatten.
|
||||||
|
*/
|
||||||
|
public void flatten(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the indirection.
|
* Set the indirection.
|
||||||
* @param indirection
|
* @param indirection
|
||||||
|
@ -832,4 +832,17 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
|||||||
ChildEntry newChild = new ChildEntryImpl(name, this, node);
|
ChildEntry newChild = new ChildEntryImpl(name, this, node);
|
||||||
AVMContext.fgInstance.fChildEntryDAO.save(newChild);
|
AVMContext.fgInstance.fChildEntryDAO.save(newChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove name without leaving behind a deleted node.
|
||||||
|
* @param name The name of the child to flatten.
|
||||||
|
*/
|
||||||
|
public void flatten(String name)
|
||||||
|
{
|
||||||
|
ChildEntry entry = AVMContext.fgInstance.fChildEntryDAO.getByNameParent(name, this);
|
||||||
|
if (entry != null)
|
||||||
|
{
|
||||||
|
AVMContext.fgInstance.fChildEntryDAO.delete(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -696,4 +696,21 @@ public interface AVMService
|
|||||||
* @param child The child node to link.
|
* @param child The child node to link.
|
||||||
*/
|
*/
|
||||||
public void link(AVMNodeDescriptor parent, String name, AVMNodeDescriptor child);
|
public void link(AVMNodeDescriptor parent, String name, AVMNodeDescriptor child);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flatten a direct child of a layered directory. This does
|
||||||
|
* the equivalent of removing the given child from the directory
|
||||||
|
* and then doing an uncover. This routine makes many dangerous
|
||||||
|
* assumptions and is only for use by AVMSyncService. Don't use it
|
||||||
|
* if you don't know precisely what you are doing.
|
||||||
|
* @param lDir The layered directory node.
|
||||||
|
* @param name The name to flatten.
|
||||||
|
*/
|
||||||
|
public void flatten(AVMNodeDescriptor lDir, String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force copy on write of a path.
|
||||||
|
* @param path The path to force.
|
||||||
|
*/
|
||||||
|
public void forceCopy(String path);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user