AnsweredAssumed Answered

Copy of node with CopyService

Question asked by ventus85 on Sep 13, 2011
Latest reply on Sep 13, 2011 by ventus85
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/CopyService.html

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

Outcomes