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

File ModificationsResourceImpl.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
22
1
1
92
58
3
0.14
22
1
3

Classes

Class Line # Actions
ModificationsResourceImpl 46 22 0% 3 2
0.9292%
 

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;
21   
22    import java.sql.Timestamp;
23    import java.util.Date;
24    import java.util.List;
25   
26    import javax.inject.Named;
27   
28    import org.xwiki.component.annotation.Component;
29    import org.xwiki.query.Query;
30    import org.xwiki.query.QueryException;
31    import org.xwiki.rest.XWikiResource;
32    import org.xwiki.rest.XWikiRestException;
33    import org.xwiki.rest.internal.DomainObjectFactory;
34    import org.xwiki.rest.internal.Utils;
35    import org.xwiki.rest.model.jaxb.History;
36    import org.xwiki.rest.model.jaxb.HistorySummary;
37    import org.xwiki.rest.resources.ModificationsResource;
38   
39    import com.xpn.xwiki.doc.rcs.XWikiRCSNodeId;
40   
41    /**
42    * @version $Id: 8cac10ba1170a216c2411d9ce3d24ba94f24110e $
43    */
44    @Component
45    @Named("org.xwiki.rest.internal.resources.ModificationsResourceImpl")
 
46    public class ModificationsResourceImpl extends XWikiResource implements ModificationsResource
47    {
 
48  1 toggle @Override
49    public History getModifications(String wikiName, Integer start, Integer number, String order, Long ts,
50    Boolean withPrettyNames) throws XWikiRestException
51    {
52  1 try {
53  1 History history = new History();
54   
55  1 String query = String.format("select doc.space, doc.name, doc.language, rcs.id, rcs.date, rcs.author,"
56    + " rcs.comment from XWikiRCSNodeInfo as rcs, XWikiDocument as doc where rcs.id.docId = doc.id and"
57    + " rcs.date > :date order by rcs.date %s, rcs.id.version1 %s, rcs.id.version2 %s",
58    order, order, order);
59   
60  1 List<Object> queryResult = null;
61  1 queryResult = queryManager.createQuery(query, Query.XWQL).bindValue("date", new Date(ts)).setLimit(number)
62    .setOffset(start).setWiki(wikiName).execute();
63   
64  1 for (Object object : queryResult) {
65  25 Object[] fields = (Object[]) object;
66   
67  25 String spaceId = (String) fields[0];
68  25 List<String> spaces = Utils.getSpacesFromSpaceId(spaceId);
69  25 String pageName = (String) fields[1];
70  25 String language = (String) fields[2];
71  25 if (language.equals("")) {
72  25 language = null;
73    }
74  25 XWikiRCSNodeId nodeId = (XWikiRCSNodeId) fields[3];
75  25 Timestamp timestamp = (Timestamp) fields[4];
76  25 Date modified = new Date(timestamp.getTime());
77  25 String modifier = (String) fields[5];
78  25 String comment = (String) fields[6];
79   
80  25 HistorySummary historySummary = DomainObjectFactory.createHistorySummary(objectFactory,
81    uriInfo.getBaseUri(), wikiName, spaces, pageName, language, nodeId.getVersion(), modifier,
82    modified, comment, Utils.getXWikiApi(componentManager), withPrettyNames);
83   
84  25 history.getHistorySummaries().add(historySummary);
85    }
86   
87  1 return history;
88    } catch (QueryException e) {
89  0 throw new XWikiRestException(e);
90    }
91    }
92    }