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.url; |
21 |
|
|
22 |
|
import java.lang.reflect.ParameterizedType; |
23 |
|
import java.net.URL; |
24 |
|
|
25 |
|
import javax.inject.Inject; |
26 |
|
import javax.inject.Singleton; |
27 |
|
|
28 |
|
import org.xwiki.component.annotation.Component; |
29 |
|
import org.xwiki.component.manager.ComponentLookupException; |
30 |
|
import org.xwiki.component.manager.ComponentManager; |
31 |
|
import org.xwiki.component.util.DefaultParameterizedType; |
32 |
|
import org.xwiki.model.reference.EntityReference; |
33 |
|
import org.xwiki.rest.XWikiRestException; |
34 |
|
import org.xwiki.rest.url.ParametrizedRestURLGenerator; |
35 |
|
import org.xwiki.rest.url.RestURLGenerator; |
36 |
|
|
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
41 |
|
@Component |
42 |
|
@Singleton |
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.4 |
|
43 |
|
public class DefaultRestURLGenerator implements RestURLGenerator |
44 |
|
{ |
45 |
|
@Inject |
46 |
|
private ComponentManager componentManager; |
47 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
48 |
1083 |
@Override... |
49 |
|
public URL getURL(EntityReference entityReference) throws XWikiRestException |
50 |
|
{ |
51 |
1083 |
try { |
52 |
1083 |
ParameterizedType type = new DefaultParameterizedType(null, ParametrizedRestURLGenerator.class, |
53 |
|
entityReference.getClass()); |
54 |
1083 |
ParametrizedRestURLGenerator parametrizedRestURLGenerator = componentManager.getInstance(type); |
55 |
1083 |
return parametrizedRestURLGenerator.getURL(entityReference); |
56 |
|
} catch (ComponentLookupException e) { |
57 |
0 |
throw new XWikiRestException(String.format("Unsupported entity type: [%s]", entityReference.getClass()), e); |
58 |
|
} |
59 |
|
} |
60 |
|
} |