On Tue, Apr 23, 2019 at 10:48 AM Harold Putman
<[email protected]> wrote:
>
> Ah OK, thanks Woonsan. That's how I will handle it then.
>
> I was enticed by the documentation to believe that it might be easier.

:-)

> https://docs.adobe.com/docs/en/spec/jsr170/javadocs/jcr-2.0/javax/jcr/Workspace.html#copy(java.lang.String,%20java.lang.String)
> "When a node N is copied to a location where a node N' already exists, the 
> repository may either immediately throw an ItemExistsException or attempt to 
> update the node N' by selectively replacing part of its subgraph with a copy 
> of the relevant part of the subgraph of N. If the node types of N and N' are 
> compatible, the implementation supports update-on-copy for these node types 
> and no other errors occur, then the copy will succeed. Otherwise an 
> ItemExistsException is thrown."
>
> In practice it is probably better to have control over what is being copied, 
> which I guess is what the implementers decided.

I think so, too. Thanks for sharing the statement in the spec. Good to
be refreshed with that.

Woonsan

>
>
> Harold Putman
>
>
> ________________________________
> From: Woonsan Ko <[email protected]>
> Sent: Tuesday, April 23, 2019 9:25 AM
> To: [email protected]
> Subject: Re: Copy over an existing node
>
> On Tue, Apr 23, 2019 at 4:54 AM Harold Putman <[email protected]> 
> wrote:
> >
> > I want to copy a source node over a destination node that already exists.
> > If I just do
> >     workspace.copy(sourcePath, targetPath);
> > I get an ItemExistsException.
> > I was hoping to  create a new version by
> >    VersionManager vm = workspace.getVersionManager();
> >    vm.checkout(targetPath);
> >    workspace.copy(sourcePath, targetPath);
> >    vm.checkin(targetPath);
> > but still I get a ItemExistsException.
> >
> > What is the right way to do this?
>
> Iterating properties and child nodes of the source node and copy each
> of those to the target node?
> Copying properties is quite straightforward.
> 'Copying child nodes' is probably your requirement specific.
> Sometimes, I removed child nodes first and add new ones. Or sometimes
> I resolve the mapping child nodes somehow and copy the properties if
> found, etc.
>
> Regards,
>
> Woonsan
>
> >
> >
> > Harold Putman

Reply via email to