Hello,
I have to copy many pages to identical sub-wikis. When I use the refactoring service, the links are modified to point to the original wiki. Is there a way to stop that from happening? For the moment I’m putting velocity tags at the beginning and end of all the pages I have to copy, but that makes it hard for users to modify them using WYSIWYG.
Thanks
Indeed there is an option for that in Rename/Move UI but not in Copy (and seems the default is true).
If you are using the refactoring service in a script you can control that in the CopyRequest object with setUpdateLinks(false)
.
Thank you for the prompt reply.
If I might take a bit more of your time.
I’m using a script, it looks like this :
#set($target=$services.model.resolveDocument($espace, $wref))
#set($source=$services.model.resolveDocument($espace))
#set($job=$services.refactoring.copyAs($source, $target))
How would I change it to incorporate your suggestion?
Thanks again!
You need to first create a copy request using:
#set ($copyAsRequest = $services.refactoring.requestFactory.createCopyAsRequest($source, $target))
that you will then pass to copyAs
but before that you can configure various things on it like $copyAsRequest.setUpdateLinks(false)
.
1 Like
FWIW the documentation is here: https://extensions.xwiki.org/xwiki/bin/view/Extension/Refactoring%20Module
I’ve now added an example for your use case:
#set ($source = $services.model.resolveDocument('Path.To.Source.WebHome'))
#set ($destination = $services.model.resolveDocument('Path.To.New.WebHome'))
#set ($copyAsRequest = $services.refactoring.requestFactory.createCopyAsRequest($source, $destination))
#set ($discard = $copyAsRequest.setAutoRedirect(false))
$services.refactoring.copyAs($copyAsRequest).join()
1 Like