Search in sources :

Example 6 with Comments

use of org.xwiki.rest.model.jaxb.Comments in project xwiki-platform by xwiki.

the class CommentsVersionResourceImpl method getCommentsVersion.

@Override
public Comments getCommentsVersion(String wikiName, String spaceName, String pageName, String version, Integer start, Integer number, Boolean withPrettyNames) throws XWikiRestException {
    try {
        DocumentInfo documentInfo = getDocumentInfo(wikiName, spaceName, pageName, null, version, true, false);
        Document doc = documentInfo.getDocument();
        Comments comments = objectFactory.createComments();
        Vector<com.xpn.xwiki.api.Object> xwikiComments = doc.getComments();
        RangeIterable<com.xpn.xwiki.api.Object> ri = new RangeIterable<com.xpn.xwiki.api.Object>(xwikiComments, start, number);
        for (com.xpn.xwiki.api.Object xwikiComment : ri) {
            comments.getComments().add(DomainObjectFactory.createComment(objectFactory, uriInfo.getBaseUri(), doc, xwikiComment, Utils.getXWikiApi(componentManager), withPrettyNames));
        }
        return comments;
    } catch (XWikiException e) {
        throw new XWikiRestException(e);
    }
}
Also used : RangeIterable(org.xwiki.rest.internal.RangeIterable) Comments(org.xwiki.rest.model.jaxb.Comments) XWikiRestException(org.xwiki.rest.XWikiRestException) Document(com.xpn.xwiki.api.Document) XWikiException(com.xpn.xwiki.XWikiException)

Aggregations

Comments (org.xwiki.rest.model.jaxb.Comments)6 GetMethod (org.apache.commons.httpclient.methods.GetMethod)4 Test (org.junit.Test)4 CommentsResource (org.xwiki.rest.resources.comments.CommentsResource)4 AbstractHttpTest (org.xwiki.test.rest.framework.AbstractHttpTest)4 PostMethod (org.apache.commons.httpclient.methods.PostMethod)3 XWikiException (com.xpn.xwiki.XWikiException)2 Document (com.xpn.xwiki.api.Document)2 XWikiRestException (org.xwiki.rest.XWikiRestException)2 RangeIterable (org.xwiki.rest.internal.RangeIterable)2 Comment (org.xwiki.rest.model.jaxb.Comment)2 NameValuePair (org.apache.commons.httpclient.NameValuePair)1