cancel
Showing results for 
Search instead for 
Did you mean: 

copy folder with all its content to destination node

sakshik
Star Contributor
Star Contributor

var docNodeId = <argument from api>

var docNode = search.findNode("workspace://SpaceStore/"+docNodeId);

.....

docNode.copy(objDestNode);

This code works if  <argument from api> is node id of a file

.

This code doesn't work if  <argument from api> is node id of a folder. It just creates an empty folder with the same name as that of  <argument from api>

How do I copy a folder with all its content to a destination node?

1 ACCEPTED ANSWER

hardik1512
Star Contributor
Star Contributor

You can try deep copy.

copy(destination, deepCopy)

pass true in second parameter.

View answer in original post

2 REPLIES 2

hardik1512
Star Contributor
Star Contributor

You can try deep copy.

copy(destination, deepCopy)

pass true in second parameter.

mehe
Elite Collaborator
Elite Collaborator

...But be careful. I think the copy will be excuted in a single transaction - so you will be creating large transaction when copying a big folder structure and such transactions are not good for Solr performance. You could use a tool like batch-executer to split this up in smaller parts.