Added link call to AVMService. It essentially creates a hard link

without the bad aftertaste.  It's needed for the AVMSyncService's
update method which will move new versions of nodes from one AVM
tree to another.  Also a checkpoint for AVMSyncService. One can safely
call compare and get back an empty List of AVMDifferences.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3784 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-09-13 19:26:11 +00:00
parent be34b01c07
commit 7fd363c599
10 changed files with 284 additions and 2 deletions

View File

@@ -27,7 +27,9 @@ import java.util.TreeMap;
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
import org.alfresco.service.cmr.avm.AVMCycleException;
import org.alfresco.service.cmr.avm.AVMException;
import org.alfresco.service.cmr.avm.AVMExistsException;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
/**
* A layered directory node. A layered directory node points at
@@ -616,6 +618,10 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
public void uncover(Lookup lPath, String name)
{
ChildEntry entry = AVMContext.fgInstance.fChildEntryDAO.getByNameParent(name, this);
if (entry.getChild().getType() != AVMNodeType.DELETED_NODE)
{
throw new AVMException("One can only uncover deleted nodes.");
}
if (entry != null)
{
AVMContext.fgInstance.fChildEntryDAO.delete(entry);
@@ -759,4 +765,39 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
{
fOpacity = opacity;
}
/**
* Link a node with the given id into this directory.
* @param lPath The Lookup for this.
* @param name The name to give the node.
* @param id The id of the node to insert.
*/
public void link(Lookup lPath, String name, long id)
{
AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(id);
if (node == null)
{
throw new AVMNotFoundException("Not Found: " + id);
}
// Look for an existing child of that name.
AVMNode existing = lookupChild(lPath, name, -1, false, true);
if (existing != null)
{
if (existing.getType() != AVMNodeType.DELETED_NODE)
{
// If the existing child is not a DELETED_NODE it's an error.
throw new AVMExistsException(name + " exists.");
}
// Only if the existing DELETED_NODE child exists directly in this
// directory do we delete it.
if (directlyContains(existing))
{
ChildEntry entry = AVMContext.fgInstance.fChildEntryDAO.getByNameParent(name, this);
AVMContext.fgInstance.fChildEntryDAO.delete(entry);
}
}
// Make the new ChildEntry and save.
ChildEntry newChild = new ChildEntryImpl(name, this, node);
AVMContext.fgInstance.fChildEntryDAO.save(newChild);
}
}