1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rest.internal.resources.comments

File CommentResourceImpl.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

2
9
1
1
69
38
3
0.33
9
1
3

Classes

Class Line # Actions
CommentResourceImpl 44 9 0% 3 12
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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 $Id: 1027e78fc59cd9ef96b3b425fbbf8a86525c18ba $
41    */
42    @Component
43    @Named("org.xwiki.rest.internal.resources.comments.CommentResourceImpl")
 
44    public class CommentResourceImpl extends XWikiResource implements CommentResource
45    {
 
46  0 toggle @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    }