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

@@ -25,7 +25,9 @@ import java.util.SortedMap;
import java.util.TreeMap;
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
import org.alfresco.service.cmr.avm.AVMExistsException;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
/**
* A plain directory. No monkey tricks except for possiblyCopy.
@@ -400,5 +402,36 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
false,
-1);
}
/**
* Link a node with the given id into this directory.
* @param lPath The Lookup for this directory.
* @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)
{
// Assure that the incoming node exists.
AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(id);
if (node == null)
{
throw new AVMNotFoundException("Node not found: " + id);
}
// Check for an existing child by the given name.
ChildEntry child = AVMContext.fgInstance.fChildEntryDAO.getByNameParent(name, this);
if (child != null)
{
if (child.getChild().getType() != AVMNodeType.DELETED_NODE)
{
// It's an error if there is a non DELETED_NODE child.
throw new AVMExistsException(name + " exists.");
}
// Get rid of the DELETED_NODE child.
AVMContext.fgInstance.fChildEntryDAO.delete(child);
}
// Make the new entry and save.
ChildEntry newChild = new ChildEntryImpl(name, this, node);
AVMContext.fgInstance.fChildEntryDAO.save(newChild);
}
}