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

File BaseObjectsResource.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

2
10
3
1
74
41
4
0.4
3.33
3
1.33

Classes

Class Line # Actions
BaseObjectsResource 35 10 0% 4 6
0.660%
 

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.objects;
21   
22    import java.util.ArrayList;
23    import java.util.Collections;
24    import java.util.List;
25   
26    import org.xwiki.model.reference.DocumentReferenceResolver;
27    import org.xwiki.rest.XWikiResource;
28    import org.xwiki.rest.internal.Utils;
29   
30    import com.xpn.xwiki.XWikiException;
31    import com.xpn.xwiki.api.Document;
32    import com.xpn.xwiki.doc.XWikiDocument;
33    import com.xpn.xwiki.objects.BaseObject;
34   
 
35    public class BaseObjectsResource extends XWikiResource
36    {
37    private DocumentReferenceResolver<String> currentMixedDocumentReferenceResolver =
38    com.xpn.xwiki.web.Utils.getComponent(DocumentReferenceResolver.TYPE_STRING, "currentmixed");
39   
 
40  34 toggle protected BaseObject getBaseObject(Document doc, String className, int objectNumber) throws XWikiException
41    {
42  34 XWikiDocument xwikiDocument =
43    Utils.getXWiki(componentManager).getDocument(doc.getDocumentReference(),
44    Utils.getXWikiContext(componentManager));
45   
46  34 return xwikiDocument.getObject(className, objectNumber);
47    }
48   
 
49  13 toggle protected List<BaseObject> getBaseObjects(Document doc) throws XWikiException
50    {
51  13 List<BaseObject> objectList = new ArrayList<BaseObject>();
52   
53  13 XWikiDocument xwikiDocument =
54    Utils.getXWiki(componentManager).getDocument(doc.getDocumentReference(),
55    Utils.getXWikiContext(componentManager));
56   
57  13 for (List<BaseObject> xwikiObjects : xwikiDocument.getXObjects().values()) {
58  13 objectList.addAll(xwikiObjects);
59    }
60   
61  13 return objectList;
62    }
63   
 
64  0 toggle protected List<BaseObject> getBaseObjects(Document doc, String className) throws XWikiException
65    {
66  0 XWikiDocument xwikiDocument = Utils.getXWiki(componentManager).getDocument(doc.getDocumentReference(),
67    Utils.getXWikiContext(componentManager));
68   
69  0 List<BaseObject> xwikiObjects = xwikiDocument.getXObjects(xwikiDocument.resolveClassReference(className));
70   
71    // XWikiDocument#getXObjects return internal list so we make sure to return a safe one
72  0 return xwikiObjects != null ? new ArrayList<BaseObject>(xwikiObjects) : Collections.<BaseObject>emptyList();
73    }
74    }