1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rest.internal.resources.comments; |
21 |
|
|
22 |
|
import java.util.Vector; |
23 |
|
|
24 |
|
import javax.inject.Named; |
25 |
|
import javax.ws.rs.WebApplicationException; |
26 |
|
import javax.ws.rs.core.Response.Status; |
27 |
|
|
28 |
|
import org.xwiki.component.annotation.Component; |
29 |
|
import org.xwiki.rest.XWikiResource; |
30 |
|
import org.xwiki.rest.XWikiRestException; |
31 |
|
import org.xwiki.rest.internal.DomainObjectFactory; |
32 |
|
import org.xwiki.rest.internal.Utils; |
33 |
|
import org.xwiki.rest.model.jaxb.Comment; |
34 |
|
import org.xwiki.rest.resources.comments.CommentResource; |
35 |
|
|
36 |
|
import com.xpn.xwiki.XWikiException; |
37 |
|
import com.xpn.xwiki.api.Document; |
38 |
|
|
39 |
|
|
40 |
|
@version |
41 |
|
|
42 |
|
@Component |
43 |
|
@Named("org.xwiki.rest.internal.resources.comments.CommentResourceImpl") |
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.33 |
|
44 |
|
public class CommentResourceImpl extends XWikiResource implements CommentResource |
45 |
|
{ |
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
46 |
0 |
@Override... |
47 |
|
public Comment getComment(String wikiName, String spaceName, String pageName, Integer id, Integer start, |
48 |
|
Integer number, Boolean withPrettyNames) throws XWikiRestException |
49 |
|
{ |
50 |
0 |
try { |
51 |
0 |
DocumentInfo documentInfo = getDocumentInfo(wikiName, spaceName, pageName, null, null, true, false); |
52 |
|
|
53 |
0 |
Document doc = documentInfo.getDocument(); |
54 |
|
|
55 |
0 |
Vector<com.xpn.xwiki.api.Object> xwikiComments = doc.getComments(); |
56 |
|
|
57 |
0 |
for (com.xpn.xwiki.api.Object xwikiComment : xwikiComments) { |
58 |
0 |
if (id.equals(xwikiComment.getNumber())) { |
59 |
0 |
return DomainObjectFactory.createComment(objectFactory, uriInfo.getBaseUri(), doc, xwikiComment, |
60 |
|
Utils.getXWikiApi(componentManager), withPrettyNames); |
61 |
|
} |
62 |
|
} |
63 |
|
|
64 |
0 |
throw new WebApplicationException(Status.NOT_FOUND); |
65 |
|
} catch (XWikiException e) { |
66 |
0 |
throw new XWikiRestException(e); |
67 |
|
} |
68 |
|
} |
69 |
|
} |