AnsweredAssumed Answered

How to copy a set of nodes into another destination node

Question asked by sergio on Nov 28, 2006
Latest reply on Apr 14, 2008 by raju_myadam
Hi all.

The usual question for today about WS….

I want to copy at once a set of nodes (instead of a single node) into a destination node. I tried the following code


Reference ref = new Reference();
ref.setStore(STORE);
ref.setPath("/app:company_home/cm:Committenti/cm:Test/*");


The folder named "Test" under the folder named "Committenti" under the root of the company home contains three files (nodes) I want to copy at once under the company home itself, as the following code shows:

ParentReference destinationFolder = new ParentReference();
destinationFolder.setStore(STORE);
destinationFolder.setPath("/app:company_home");
destinationFolder.setAssociationType(Constants.ASSOC_CONTAINS);
destinationFolder.setChildName("pippo");

Predicate pred = new Predicate();
pred.setStore(STORE);
pred.setNodes(new Reference[]{ref});
     
CMLCopy copy = new CMLCopy();
copy.setTo(destinationFolder);
copy.setWhere(pred);
     
CML cml = new CML();
cml.setCopy(new CMLCopy[]{copy});
     
UpdateResult[] result = repositoryService.update(cml); 


Unfortunately the Reference class can contain only one node but in this case I have to manipulate three nodes.

My question is: what is the best solution to copy more than one node at once into a destination node?

Many thanks to all.

Best regards,

Sergio

Outcomes