AnsweredAssumed Answered

tricky question: dealing with one node in multiple spaces

Question asked by esource on May 31, 2010
I have a node called DocumentA in SpaceA.  I have a SpaceB and SpaceC on which I Run Action the following javascript:

var testfile=companyhome.childByNamePath("SpaceA/DocumentA");
space.addNode(testfile);
space.save();

DocumentA now appears in both SpaceA, SpaceB and SpaceC.  If I now delete the node DocumentA in SpaceA, an image of DocumentA still remains in SpaceB and SpaceC which when I try to access it gives me an error message.  How can I prevent this from happening? 

I found I cannot override the actual deletion but I can at least know when someone is attempting to delete a node by implementing a behavior and watching for onDelete or beforeDelete. 

So my next solution is to copy the node DocumentA to SpaceB before it is deleted and also to then add this DocumentA to SpaceC and then delete the old references to DocumentA in SpaceB and SpaceC.  Will this work?  Does anyone else have any other ideas?

What is the best way to manage this situation?

Outcomes