cancel
Showing results for 
Search instead for 
Did you mean: 

How to move a node while keeping primary child relationship?

nicolasraoul
Star Contributor
Star Contributor
Hello all,

I transform original.txt into a PDF, and I want this PDF to be a primary child of original.txt, but stored in a different space.
My Java code uses NodeService.createNode to create the PDF, and it works well, it is indeed a primary child.

Now I wrote a FileFolderService.move code line to move the PDF to a different space, it works, but the PDF is not a primary child of original.txt anymore.
How can I move the PDF to a different space while allowing it to keep being a primary child of original.txt ?

If you need it, here is the code:
ChildAssociationRef associationToPublished = nodeService.createNode(
    original,
    QName.createQName("http://www.my.co.jp/", "approvedVersion"),
    QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "test"),
    QName.createQName("http://www.my.co.jp/", "approvedDocument"));
NodeRef published = associationToPublished.getChildRef();
fileFolderService.move(published, publicationSpace, "published.pdf");

Note: I need the primary relationship so that the publication is removed if the original is removed, without policies.

Thanks!
1 REPLY 1

nicolasraoul
Star Contributor
Star Contributor
Does not seem possible.
I just ended up using a policy.