cancel
Showing results for 
Search instead for 
Did you mean: 

Copy of node with CopyService

ventus85
Champ in-the-making
Champ in-the-making
Hi!

I need to copy a node in a different space.
I have seen that there is this interface http://dev.alfresco.com/resource/docs/java/repository/org/alfresco/service/cmr/repository/CopyServic...

I don't understand what are the parameters for copy.

Parameters:
        sourceNodeRef - the node reference used as the source of the copy
        targetParentNodeRef - the intended parent of the new node
        assocTypeQName - the type of the new child assoc
        assocQName - the qualified name of the child association from the parent to the new node
        copyChildren - indicates that the children of the node should also be copied
    Returns:
        the new node reference


If I have this function:

public void copyNode(String refSource, String parentRef, boolean copyChildren) {

Reference sourceNodeRef = getReference(refSource);
ParentReference parentReference = new ParentReference(sourceNodeRef.getStore(), sourceNodeRef.getUuid(), sourceNodeRef.getPath(),Constants.ASSOC_CONTAINS, Constants.ASSOC_CHILDREN);

CMLCopy copy = new CMLCopy(parentReference, parentRef, Constants.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"), null, null, copyChildren);

//…
}

refSource is my source node, parentRef is my destination (i.e parent of the new node).
What I wrong?
The type of the new child assoc is good? and the qualified name?

thank you very much
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
If you use Explorer or Share you should use the cm namespace.  

The association to use is ASSOC_CONTAINS.   cm:contains or Constants.ASSOC_CONTAINS

The QName is the new name of your document.  .  so in your example QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy") has the name cm:copy     Substitute "copy" with whatever is appropriate.

ventus85
Champ in-the-making
Champ in-the-making
Thank you. Now I try to see my code