<
From version < 18.1 >
edited by Ludovic Dubost
on 2010/01/16
To version < 19.1 >
edited by Fabio Mancinelli
on 2010/01/18
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.ludovic
1 +XWiki.fmancinelli
Content
... ... @@ -82,10 +82,18 @@
82 82  
83 83  If you use this approach (Apache HTTP Client + JAXB) you will find yourself writing some code like this:
84 84  
85 -{{code language="none"}}
85 +{{code language="java"}}
86 +import javax.xml.bind.JAXBContext;
87 +import javax.xml.bind.Unmarshaller;
88 +
89 +import org.apache.commons.httpclient.HttpClient;
90 +import org.apache.commons.httpclient.methods.GetMethod;
91 +import org.xwiki.rest.model.jaxb.Page;
92 +
93 +...
86 86  HttpClient httpClient = new HttpClient();
87 87  JAXBContext context = JAXBContext.newInstance("org.xwiki.rest.model.jaxb");
88 -unmarshaller = context.createUnmarshaller();
96 +Unmarshaller unmarshaller = context.createUnmarshaller();
89 89  
90 90  GetMethod getMethod = new GetMethod("http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome");
91 91  getMethod.addRequestHeader("Accept", "application/xml");
... ... @@ -100,7 +100,7 @@
100 100  
101 101  By using curl, the previous example would have been:
102 102  
103 -{{code language="none"}}
111 +{{code language="xml"}}
104 104  $ curl http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome
105 105  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
106 106  <page xmlns="http://www.xwiki.org">
... ... @@ -130,7 +130,7 @@
130 130  
131 131  On the contrary, by specifying Admin credentials you gain access to the actual page:
132 132  
133 -{{code language="none"}}
141 +{{code language="xml"}}
134 134  $ curl -u Admin:admin http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/PrivatePage
135 135  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
136 136  <page xmlns="http://www.xwiki.org">
... ... @@ -149,7 +149,7 @@
149 149  
150 150  For example, in order to create a page you might do the following:
151 151  
152 -{{code language="none"}}
160 +{{code language="xml"}}
153 153  $ curl -u Admin:admin -X PUT -d "@newpage.xml" -H "Content-Type: application/xml" http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/NewPage
154 154  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
155 155  <page xmlns="http://www.xwiki.org">
... ... @@ -168,7 +168,7 @@
168 168  
169 169  Where newpage.xml is an XML file containing
170 170  
171 -{{code language="none"}}
179 +{{code language="xml"}}
172 172  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
173 173  <page xmlns="http://www.xwiki.org">
174 174   <title>Hello world</title>

Get Connected