My goal is to be able to rename any document from outside of xwiki.
I understood that this is possible through refactoring Job mechanism.
As I need to perform the operation from outside the xwiki, I started from this nice snippet that is simplifying the Xml code generation :
And then I save xml content generated in a file output.xml and call :
curl -i --user "myuser:mypassword" -X PUT -H "Content-Type: text/xml" "http://localhost:8081/xwiki/rest/jobs?jobType=refactoring/move&async=false" --upload-file output.xml
answer from webservice looks fine (1), except that it performs no change on my xwiki instance.
I tried to identify problems in job info in my tomcat/work/Catalina/localhost/xwiki/jobs/status/refactoring/*/JOBID directory without success,
So I made some tries(2) but so far no document changed their name from external request.
My conclusion is that maybe I am not able to target my document and request to rename a document that does not exist.
Could you please tell me in that situation (I use extensions Index Tree Macro+Tree Macro) what identify correctly the document place ?
a) var source = new SpaceReference(“xwiki”, “Dossier”, “renaming”);
b) var source = new SpaceReference(“xwiki”, “Main”, “renaming”);
c) var source = new DocumentReference(“xwiki”, “Main”, “renaming”);
d) var source = new DocumentReference(“xwiki”, “Dossier”, “renaming”);
When I renamed a page in the “Dossier” space from interface, I saw in job status log :
<string>destination</string>
<org.xwiki.model.reference.DocumentReference>
<name>newDocName</name>
<parent class="org.xwiki.model.reference.SpaceReference">
<name>Main</name>
<parent class="org.xwiki.model.reference.WikiReference">
<name>xwiki</name>
<type>WIKI</type>
</parent>
<type>SPACE</type>
</parent>
<type>DOCUMENT</type>
</org.xwiki.model.reference.DocumentReference>
</entry>
but when I use the snippet it generates :
<key>destination</key>
<value>
<org.xwiki.model.reference.SpaceReference xmlns="" xmlns:ns2="http://www.xwiki.org">
<name>newDocName</name>
<parent class="org.xwiki.model.reference.SpaceReference">
<name>Dossier</name>
<parent class="org.xwiki.model.reference.WikiReference">
<name>xwiki</name>
<type>WIKI</type>
</parent>
<type>SPACE</type>
</parent>
<type>SPACE</type>
</org.xwiki.model.reference.SpaceReference>
</value>
Maybe Document and Space difference is an issue ?
Thanks a lot in advance!
(1) call to rest jobs endpoint :
HTTP/1.1 200
Content-Script-Type: text/javascript
Set-Cookie: JSESSIONID=9E66762AAD06F7DF3B821D061FZZZZZZZ; Path=/xwiki; HttpOnly
Date: Wed, 12 Jul 2023 18:12:08 GMT
Accept-Ranges: bytes
Server: Restlet-Framework/2.3.12
XWiki-User: xwiki:XWiki.admin
XWiki-Version: 14.10.13
XWiki-Form-Token: BGiefMG6ciemIwScxxZZZZZ
Content-Type: application/xml;charset=UTF-8
Content-Language: en
Transfer-Encoding: chunked
followed by an xml content that include
<state>FINISHED</state>
(2) some tries :
- to make use of PageReference or DocumentReference instead of SpaceReference in snippet XML generation
- to make use of Main as SPACE instead of “Dossier” as the parent Directory
- to make different call with Rename or Move as JobType parameter and MoveRequest/RenameRequest in snippet…