1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
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.XWikiResource; |
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.Object; |
32 |
|
import org.xwiki.rest.resources.objects.ObjectAtPageVersionResource; |
33 |
|
|
34 |
|
import com.xpn.xwiki.XWikiException; |
35 |
|
import com.xpn.xwiki.api.Document; |
36 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
37 |
|
|
38 |
|
|
39 |
|
@version |
40 |
|
|
41 |
|
@Component |
42 |
|
@Named("org.xwiki.rest.internal.resources.objects.ObjectAtPageVersionResourceImpl") |
|
|
| 76.9% |
Uncovered Elements: 3 (13) |
Complexity: 3 |
Complexity Density: 0.3 |
|
43 |
|
public class ObjectAtPageVersionResourceImpl extends XWikiResource implements ObjectAtPageVersionResource |
44 |
|
{ |
|
|
| 75% |
Uncovered Elements: 3 (12) |
Complexity: 3 |
Complexity Density: 0.3 |
|
45 |
10 |
@Override... |
46 |
|
public Object getObject(String wikiName, String spaceName, String pageName, String version, String className, |
47 |
|
Integer objectNumber, Boolean withPrettyName) throws XWikiRestException |
48 |
|
{ |
49 |
10 |
try { |
50 |
10 |
DocumentInfo documentInfo = getDocumentInfo(wikiName, spaceName, pageName, null, version, true, false); |
51 |
|
|
52 |
10 |
Document doc = documentInfo.getDocument(); |
53 |
|
|
54 |
10 |
XWikiDocument xwikiDocument = Utils.getXWiki(componentManager) |
55 |
|
.getDocument(doc.getDocumentReference(), Utils.getXWikiContext(componentManager)); |
56 |
|
|
57 |
10 |
xwikiDocument = Utils.getXWiki(componentManager) |
58 |
|
.getDocument(xwikiDocument, doc.getVersion(), Utils.getXWikiContext(componentManager)); |
59 |
|
|
60 |
10 |
com.xpn.xwiki.objects.BaseObject baseObject = xwikiDocument.getObject(className, objectNumber); |
61 |
10 |
if (baseObject == null) { |
62 |
0 |
throw new WebApplicationException(Status.NOT_FOUND); |
63 |
|
} |
64 |
|
|
65 |
10 |
return DomainObjectFactory.createObject(objectFactory, uriInfo.getBaseUri(), Utils |
66 |
|
.getXWikiContext(componentManager), doc, baseObject, true, Utils.getXWikiApi(componentManager), |
67 |
|
withPrettyName); |
68 |
|
} catch (XWikiException e) { |
69 |
0 |
throw new XWikiRestException(e); |
70 |
|
} |
71 |
|
} |
72 |
|
} |