I added page in the xwiki through Rest Api in following way. Would somebody
please advise me how to add user to the xwiki system in the similiar way.
public void add()
{
final String CONTENT = "Content 101";
final String TITLE = "Title 101";
final String PARENT = "Private.WebHome";
ObjectFactory objectFactory = new ObjectFactory();
Page page = objectFactory.createPage();
page.setContent(CONTENT);
page.setTitle(TITLE);
page.setParent(PARENT);
HttpClient httpClient = new HttpClient();
httpClient.getState().setCredentials(AuthScope.ANY, new
UsernamePasswordCredentials("admin", "admin"));
httpClient.getParams().setAuthenticationPreemptive(true);
JAXBContext context;
try {
context = JAXBContext.newInstance("org.xwiki.rest.model.jaxb");
Marshaller marshaller = context.createMarshaller();
Unmarshaller unmarshaller = context.createUnmarshaller();
PutMethod putMethod = new
PutMethod("http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Private/pages/NewPage001");
putMethod.addRequestHeader("Accept",
MediaType.APPLICATION_XML.toString());
StringWriter writer = new StringWriter();
marshaller.marshal(page, writer);
RequestEntity entity;
entity = new StringRequestEntity(writer.toString(),
MediaType.APPLICATION_XML.toString(), "UTF-8");
putMethod.setRequestEntity(entity);
httpClient.executeMethod(putMethod);
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (HttpException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
--
View this message in context:
http://xwiki.475771.n2.nabble.com/Adding-user-through-Rest-API-tp5206186p52…
Sent from the XWiki- Users mailing list archive at
Nabble.com.