use of org.xwiki.rest.model.jaxb.ObjectFactory in project xwiki-platform by xwiki.
the class AbstractHttpTest method setUp.
@Before
public void setUp() throws Exception {
random = new Random();
JAXBContext context = JAXBContext.newInstance("org.xwiki.rest.model.jaxb");
marshaller = context.createMarshaller();
unmarshaller = context.createUnmarshaller();
objectFactory = new ObjectFactory();
// Make sure guest does not have edit right
Page page = this.testUtils.rest().page(new DocumentReference("xwiki", "XWiki", "XWikiPreferences"));
org.xwiki.rest.model.jaxb.Object rightObject = this.testUtils.rest().object("XWiki.XWikiGlobalRights");
rightObject.withProperties(this.testUtils.rest().property("users", "XWiki.XWikiGuest"), this.testUtils.rest().property("levels", "edit"), this.testUtils.rest().property("allow", "0"));
Objects objects = new Objects();
objects.withObjectSummaries(rightObject);
page.setObjects(objects);
this.testUtils.rest().save(page);
// Init solr utils
this.solrUtils = new SolrTestUtils(this.testUtils);
}
use of org.xwiki.rest.model.jaxb.ObjectFactory in project xwiki-platform by xwiki.
the class WikiManagerRestTest method setUp.
@Before
public void setUp() throws Exception {
random = new Random();
JAXBContext context = JAXBContext.newInstance("org.xwiki.rest.model.jaxb");
marshaller = context.createMarshaller();
unmarshaller = context.createUnmarshaller();
objectFactory = new ObjectFactory();
// Access once the wiki to make sure the DW is run on main wiki before messing with it
HttpClient httpClient = new HttpClient();
GetMethod getMethod = new GetMethod("http://localhost:" + port + "/xwiki/");
getMethod.setFollowRedirects(true);
httpClient.executeMethod(getMethod);
}
use of org.xwiki.rest.model.jaxb.ObjectFactory in project xwiki-platform by xwiki.
the class TextPlainTagsReader method readFrom.
@Override
public Tags readFrom(Class<Tags> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
ObjectFactory objectFactory = new ObjectFactory();
Tags tags = objectFactory.createTags();
String text = getEntityAsString(entityStream);
String[] tagNames = text.split(" |,|\\||\\r?\\n");
for (String tagName : tagNames) {
Tag tag = objectFactory.createTag();
tag.setName(tagName);
tags.getTags().add(tag);
}
return tags;
}
use of org.xwiki.rest.model.jaxb.ObjectFactory in project xwiki-platform by xwiki.
the class FormUrlEncodedCommentReader method readFrom.
@Override
public Comment readFrom(Class<Comment> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
ObjectFactory objectFactory = new ObjectFactory();
Comment comment = objectFactory.createComment();
Representation representation = new InputRepresentation(entityStream, org.restlet.data.MediaType.APPLICATION_WWW_FORM);
Form form = new Form(representation);
/*
* If the form is empty then it might have happened that some filter has invalidated the entity stream. Try to
* read data using getParameter()
*/
if (form.getNames().isEmpty()) {
HttpServletRequest httpServletRequest = ServletUtils.getRequest(Request.getCurrent());
try {
comment.setReplyTo(Integer.parseInt(httpServletRequest.getParameter(COMMENT_REPLYTO_FIELD_NAME)));
} catch (NumberFormatException e) {
// Just ignore, there won't be a reply to.
}
comment.setText(httpServletRequest.getParameter(COMMENT_TEXT_FIELD_NAME));
} else {
try {
comment.setReplyTo(Integer.parseInt(form.getFirstValue(COMMENT_REPLYTO_FIELD_NAME)));
} catch (NumberFormatException e) {
// Just ignore, there won't be a reply to.
}
comment.setText(form.getFirstValue(COMMENT_TEXT_FIELD_NAME));
}
return comment;
}
use of org.xwiki.rest.model.jaxb.ObjectFactory in project xwiki-platform by xwiki.
the class TextPlainCommentReader method readFrom.
@Override
public Comment readFrom(Class<Comment> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
ObjectFactory objectFactory = new ObjectFactory();
Comment comment = objectFactory.createComment();
String text = getEntityAsString(entityStream);
comment.setText(text);
return comment;
}
Aggregations