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.classes; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Named; |
24 |
|
import javax.ws.rs.WebApplicationException; |
25 |
|
import javax.ws.rs.core.Response.Status; |
26 |
|
|
27 |
|
import org.xwiki.component.annotation.Component; |
28 |
|
import org.xwiki.rest.XWikiResource; |
29 |
|
import org.xwiki.rest.XWikiRestException; |
30 |
|
import org.xwiki.rest.internal.ModelFactory; |
31 |
|
import org.xwiki.rest.internal.Utils; |
32 |
|
import org.xwiki.rest.model.jaxb.Class; |
33 |
|
import org.xwiki.rest.resources.classes.ClassResource; |
34 |
|
|
35 |
|
import com.xpn.xwiki.XWikiException; |
36 |
|
|
37 |
|
|
38 |
|
@version |
39 |
|
|
40 |
|
@Component |
41 |
|
@Named("org.xwiki.rest.internal.resources.classes.ClassResourceImpl") |
|
|
| 75% |
Uncovered Elements: 3 (12) |
Complexity: 3 |
Complexity Density: 0.33 |
|
42 |
|
public class ClassResourceImpl extends XWikiResource implements ClassResource |
43 |
|
{ |
44 |
|
@Inject |
45 |
|
private ModelFactory utils; |
46 |
|
|
|
|
| 72.7% |
Uncovered Elements: 3 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
47 |
28 |
@Override... |
48 |
|
public Class getClass(String wikiName, String className) throws XWikiRestException |
49 |
|
{ |
50 |
28 |
String database = Utils.getXWikiContext(componentManager).getWikiId(); |
51 |
|
|
52 |
28 |
try { |
53 |
28 |
Utils.getXWikiContext(componentManager).setWikiId(wikiName); |
54 |
|
|
55 |
28 |
com.xpn.xwiki.api.Class xwikiClass = Utils.getXWikiApi(componentManager).getClass(className); |
56 |
28 |
if (xwikiClass == null) { |
57 |
0 |
throw new WebApplicationException(Status.NOT_FOUND); |
58 |
|
} |
59 |
|
|
60 |
28 |
return this.utils.toRestClass(uriInfo.getBaseUri(), xwikiClass); |
61 |
|
} catch (XWikiException e) { |
62 |
0 |
throw new XWikiRestException(e); |
63 |
|
} finally { |
64 |
28 |
Utils.getXWikiContext(componentManager).setWikiId(database); |
65 |
|
} |
66 |
|
} |
67 |
|
} |