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

File ObjectPropertiesResourceImpl.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

2
16
1
1
81
48
3
0.19
16
1
3

Classes

Class Line # Actions
ObjectPropertiesResourceImpl 46 16 0% 3 3
0.8421052784.2%
 

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 javax.inject.Named;
23    import javax.ws.rs.WebApplicationException;
24    import javax.ws.rs.core.Response.Status;
25   
26    import org.xwiki.component.annotation.Component;
27    import org.xwiki.rest.Relations;
28    import org.xwiki.rest.XWikiRestException;
29    import org.xwiki.rest.internal.DomainObjectFactory;
30    import org.xwiki.rest.internal.Utils;
31    import org.xwiki.rest.model.jaxb.Link;
32    import org.xwiki.rest.model.jaxb.Object;
33    import org.xwiki.rest.model.jaxb.Properties;
34    import org.xwiki.rest.resources.objects.ObjectPropertiesResource;
35    import org.xwiki.rest.resources.objects.ObjectResource;
36   
37    import com.xpn.xwiki.XWikiException;
38    import com.xpn.xwiki.api.Document;
39   
40    /**
41    * @version $Id: 00d0ad31477b80d5f7fc04cf01f3eb7aa869c9f5 $
42    */
43    @Component
44    @Named("org.xwiki.rest.internal.resources.objects.ObjectPropertiesResourceImpl")
45   
 
46    public class ObjectPropertiesResourceImpl extends BaseObjectsResource implements ObjectPropertiesResource
47    {
 
48  1 toggle @Override
49    public Properties getObjectProperties(String wikiName, String spaceName, String pageName, String className,
50    Integer objectNumber, Boolean withPrettyNames) throws XWikiRestException
51    {
52  1 try {
53  1 DocumentInfo documentInfo = getDocumentInfo(wikiName, spaceName, pageName, null, null, true, false);
54   
55  1 Document doc = documentInfo.getDocument();
56   
57  1 com.xpn.xwiki.objects.BaseObject baseObject = getBaseObject(doc, className, objectNumber);
58  1 if (baseObject == null) {
59  0 throw new WebApplicationException(Status.NOT_FOUND);
60    }
61   
62  1 Object object = DomainObjectFactory.createObject(objectFactory, uriInfo.getBaseUri(), Utils.getXWikiContext(
63    componentManager), doc, baseObject, false, Utils.getXWikiApi(componentManager), withPrettyNames);
64   
65  1 Properties properties = objectFactory.createProperties();
66  1 properties.getProperties().addAll(object.getProperties());
67   
68  1 String objectUri = Utils.createURI(uriInfo.getBaseUri(), ObjectResource.class, doc.getWiki(),
69    Utils.getSpacesFromSpaceId(doc.getSpace()), doc.getName(), object.getClassName(),
70    object.getNumber()).toString();
71  1 Link objectLink = objectFactory.createLink();
72  1 objectLink.setHref(objectUri);
73  1 objectLink.setRel(Relations.OBJECT);
74  1 properties.getLinks().add(objectLink);
75   
76  1 return properties;
77    } catch (XWikiException e) {
78  0 throw new XWikiRestException(e);
79    }
80    }
81    }