I am replacing the CrossRepositoryCopyService().copy action since we are going from multiple repo’s to one. So I am replacing this service..
// RECURSIVE copy – but specific for multiple repo’s.
serviceRegistry.getCrossRepositoryCopyService() .copy(src, dst,new_name);
So I started by re-using the FileFolderService to copy a node from A to B. This works great, but it only copies the node & leaves all children of the source untouched (and more importantly un-copied) => Non-recursive copy. The FileFolderService() has no recursive copy action available.
// Non-RECURSIVE copy of one node
FileInfo finf = serviceRegistry.getFileFolderService().copy(src, dst, new_name);
There are quite a lot of copy actions available in Alfresco, but this one seems quite elegant. Also the service name alone gives me some hope of giving me what i need.
Enter the CopyService()
// RECURSIVE copy
NodeRef copy2 = serviceRegistry.getCopyService().copy(src, dst, ContentModel.ASSOC_CHILDREN, QName.createQName(new_name), true);
and since I am here now – it also has a usefull
// NON-RECURSIVE copy
NodeRef copy = this.copyService.copy(src, dst, ContentModel.ASSOC_CHILDREN, QName.createQName(“newname”));
Big thanks to : http://kickjava.com/