AnsweredAssumed Answered

Multiple parents for document and deletion trouble- addchild

Question asked by annakan on Mar 10, 2011
Latest reply on Apr 29, 2013 by heiko.robert
Hello all.

We need to be able to have a document inside two folders (one as work-flow basis, the other as filing/"storage").

Looking around the forum ( and doc we built an action that take the target folder (where the "duplicate" should land) as a parameter.

We use the nodeapi.addChild API to create a new association of type ASSOC_CONTAINS between the target folder and the document, with the document name, like this
ChildAssociationRef ref =  this.nodeService.addChild(destinationParent, actionedUponNodeRef, ContentModel.ASSOC_CONTAINS, destinationAssocQName); 

In the object browser the two relationship look the same, except for the "primary" attribute.

But when we delete the document from the "source" folder, although alfresco properly warns us about multiple containments, the document disappears from the source folder but notfrom the "target" folder.
Well, not exactly, in fact a "proxy" seems to be left over in the target folder (and is persistent there) but attempting to inspect it or delete it brings an errors saying that the underlying node as been destroyed.

We suppose some "proxy" object is properly created in each folder with the addchild call but not deleted when the document is deleted from one of the folder.

If we do it the other way, deleting the document from the "target" folder, no warning is issued (is that because the relationship is not 'primary' ?) and we can then delete the document from the "source" folder without the "duplicate location" warning.

  • Are we supposed to do something to the relationship we create to get the proper behavior ?

  • Can we and shall we  set primary=true on both relationship ? and if yes, how ?

  • Should we do something upon deletion ? (would be weird since alfresco seems to know there is multiple parenthood  and be ready to handle that).

  • Is there some example of that ? (For instance in the record management "extension" of alfresco ?)

  • Did somebody successfully implement such a behavior or action that gives multiple containment to a document ?
We think it is a very important and smart feature of alfresco to be able to host a document into multiple folder with various deletion strategy, allowing different views on the content and states of the document depending on the usage or population. For instance a document can be archived/stored by an assistant while pending a contractual review process, giving at the same time a unified view of the documents in the "store" and an object of work-flow into multiple spaces.

We eagerly awaits any pointers or code sample or technical explanation that would un-stuck us. :)

Thanks a lot for your time.

EDIT : using the node browser we saw that at first the two documents nodes are identical save for the "primary" attribute but when we delete from the source folder the "document proxy" in the target folder becomes a link toward an "archive:" storagespace.
It looks like the deletion command do some extra hard-wired tricks in that case that are not generic enough, maybe leftovers from the record management functionality ?

And by the way, doing the same thing with javascript gives the same behavior.
var duplicateFolder = space.childByNamePath("Duplicate"); 

What can we do to have the proper basic behavior of deletion ?