Changes for page RefactoringRESTXML
Last modified by Thomas Mortagne on 2022/08/08 11:05
From version 1.11
edited by Thomas Mortagne
on 2022/08/08 11:00
on 2022/08/08 11:00
Change comment:
There is no comment for this version
To version 1.12
edited by Thomas Mortagne
on 2022/08/08 11:02
on 2022/08/08 11:02
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,6 +1,5 @@ 1 1 {{groovy}} 2 2 import org.xwiki.model.reference.*; 3 -import java.io.*; 4 4 import javax.xml.bind.*; 5 5 6 6 // Create a request to move a page using the standard API ... ... @@ -16,10 +16,11 @@ 16 16 var restJobRequest = services.component.getInstance(org.xwiki.rest.internal.ModelFactory.class).toRestJobRequest(moveRequest); 17 17 18 18 // Serialize the REST job request into an XML content 19 -StringWriter writer = new StringWriter(); 20 -JAXBContext context = JAXBContext.newInstance("org.xwiki.rest.model.jaxb"); 21 -Marshaller marshaller = context.createMarshaller(); 22 -marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); 18 +var writer = new java.io.StringWriter(); 19 +var context = javax.xml.bind.JAXBContext.newInstance("org.xwiki.rest.model.jaxb"); 20 +var marshaller = context.createMarshaller(); 21 +// Format the XML to make the example more readable but the XML obviously does not need to be formatter in the request 22 +marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); 23 23 marshaller.marshal(restJobRequest, writer); 24 24 25 25 println "{{code language='xml'}}"