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

File ClassesResourceImpl.java

 

Coverage histogram

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

Code metrics

0
13
1
1
76
42
2
0.15
13
1
2

Classes

Class Line # Actions
ClassesResourceImpl 44 13 0% 2 1
0.928571492.9%
 

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.classes;
21   
22    import java.util.Collections;
23    import java.util.List;
24   
25    import javax.inject.Inject;
26    import javax.inject.Named;
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.ModelFactory;
32    import org.xwiki.rest.internal.RangeIterable;
33    import org.xwiki.rest.internal.Utils;
34    import org.xwiki.rest.model.jaxb.Classes;
35    import org.xwiki.rest.resources.classes.ClassesResource;
36   
37    import com.xpn.xwiki.XWikiException;
38   
39    /**
40    * @version $Id: 16f7adee3008ff48db1348086a482437e492a39c $
41    */
42    @Component
43    @Named("org.xwiki.rest.internal.resources.classes.ClassesResourceImpl")
 
44    public class ClassesResourceImpl extends XWikiResource implements ClassesResource
45    {
46    @Inject
47    private ModelFactory utils;
48   
 
49  2 toggle @Override
50    public Classes getClasses(String wikiName, Integer start, Integer number) throws XWikiRestException
51    {
52  2 String database = Utils.getXWikiContext(componentManager).getWikiId();
53   
54  2 try {
55  2 getXWikiContext().setWikiId(wikiName);
56   
57  2 List<String> classNames = Utils.getXWikiApi(componentManager).getClassList();
58  2 Collections.sort(classNames);
59   
60  2 RangeIterable<String> ri = new RangeIterable<String>(classNames, start, number);
61   
62  2 Classes classes = objectFactory.createClasses();
63   
64  2 for (String className : ri) {
65  50 com.xpn.xwiki.api.Class xwikiClass = Utils.getXWikiApi(componentManager).getClass(className);
66  50 classes.getClazzs().add(this.utils.toRestClass(uriInfo.getBaseUri(), xwikiClass));
67    }
68   
69  2 return classes;
70    } catch (XWikiException e) {
71  0 throw new XWikiRestException(e);
72    } finally {
73  2 Utils.getXWikiContext(componentManager).setWikiId(database);
74    }
75    }
76    }