AnsweredAssumed Answered

Copy nodes - duplicates

Question asked by gjovanov on Oct 2, 2009
Latest reply on Oct 30, 2009 by openpj
Hi!
We have a very specific situation where we want to copy only children nodes recursively from a given source to a given destination space. The problem is that the source children spaces can already be contained in the destination space. And the when we copy them, for the common spaces we get duplicates in the destination whereas the duplicates occur with the name: "Copy of" + original-name. What we want to achieve is FILE_SYSTEM-copy-like operation as if when a space already exist within the destination should be skipped and it should continue to its children.

e.g. first we copy Designs children spaces:
/Company Home/Templates/Design/01-Offer/…
                                                /02-Testing/…
                                                /03-Design/…

to the destination:
/Company Home/Projects/Kiss/

as a result we get:
/Company Home/Projects/Kiss/01-Offer/
                                          /02-Testing/
                                          /03-Design/

and then we want to copy Developments children spaces:
/Company Home/Templates/Development/01-Offer/…
                                                         /02-Testing/…
                                                         /04-Development/…

also to the same destination:
/Company Home/Projects/Kiss/

and as a result we get:
/Company Home/Projects/Kiss/01-Offer/..
                                          /Copy of 01-Offer/..
                                          /02-Testing/…
                                          /Copy of 02-Testing/…
                                          /03-Design/..
                                          /04-Development/…

Even though we would expect the following result:
/Company Home/Projects/Kiss/01-Offer/..
                                          /02-Testing/…
                                          /03-Design/..
                                          /04-Development/…

we use the CMLCopy command for every child within the source folder:

        CMLCopy copy = new CMLCopy();
        copy.setTo(destinationChildReference);
        copy.setChildren(true);
        copy.setAssociationType(Constants.ASSOC_CONTAINS);
        copy.setWhere(new Predicate(new Reference[] { sourceReference }, STORE, null));
       

        CML cml = new CML();
        cml.setCopy(new CMLCopy[] { copy });

        getRepositoryService().update(cml);


Any suggestions?

Outcomes