cancel
Showing results for 
Search instead for 
Did you mean: 

Copy a node with childs

spilby
Confirmed Champ
Confirmed Champ
Hi,

I need to copy a node and the childs to another folder that exists. The node contains other nodes and documents, and I need to copy all of them. But I have two questions.

1. I found the CopyService.copy and the FileFolderService.copy. What's the difference? Someone recommends me one or another? Maybe filefolderservice is only for documents?

2.  I only need to use one of these methods? The copy of the main node copy all the childs or I need to iterate? And copy all, the properties, the aspects, etc. Or I need to call other methods for a complete copy?

Thanks a lot!
2 REPLIES 2

sanket
Champ on-the-rise
Champ on-the-rise
FileFolderService internally uses copyService for copying the files/folders. Below is the code snapshot of FileFolderServiceImpl.java file; by default the parameter for copy children is true. So fileFolderService always copies the children.


  try
            {
                // Copy the node.  The cm:name will be dropped and reset later.
                targetNodeRef = copyService.copy(
                        sourceNodeRef,
                        targetParentRef,
                        assocTypeQname,
                        qname,
                        true);
            }
            catch (DuplicateChildNodeNameException e)
            {
                throw new FileExistsException(targetParentRef, newName);
            }


While in copyService, you can pass the boolean parameter (true/false) for copying children.

spilby
Confirmed Champ
Confirmed Champ
Perfect! Thanks, Sanket! Smiley Happy