1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.vfs.internal; |
21 |
|
|
22 |
|
import java.lang.reflect.Type; |
23 |
|
import java.net.URI; |
24 |
|
|
25 |
|
import javax.inject.Inject; |
26 |
|
import javax.inject.Named; |
27 |
|
import javax.inject.Provider; |
28 |
|
import javax.inject.Singleton; |
29 |
|
|
30 |
|
import org.xwiki.component.annotation.Component; |
31 |
|
import org.xwiki.component.manager.ComponentLookupException; |
32 |
|
import org.xwiki.component.manager.ComponentManager; |
33 |
|
import org.xwiki.component.util.DefaultParameterizedType; |
34 |
|
import org.xwiki.resource.ResourceReferenceSerializer; |
35 |
|
import org.xwiki.resource.SerializeResourceReferenceException; |
36 |
|
import org.xwiki.resource.UnsupportedResourceReferenceException; |
37 |
|
import org.xwiki.url.ExtendedURL; |
38 |
|
import org.xwiki.vfs.VfsResourceReference; |
39 |
|
|
40 |
|
|
41 |
|
@link@link |
42 |
|
|
43 |
|
@version |
44 |
|
@since |
45 |
|
|
46 |
|
@Component |
47 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
48 |
|
public class VfsResourceReferenceSerializer extends AbstractVfsResourceReferenceSerializer |
49 |
|
{ |
50 |
|
private static final Type TYPE = new DefaultParameterizedType(null, |
51 |
|
ResourceReferenceSerializer.class, VfsResourceReference.class, ExtendedURL.class); |
52 |
|
|
53 |
|
@Inject |
54 |
|
@Named("context") |
55 |
|
private Provider<ComponentManager> componentManagerProvider; |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
57 |
4 |
@Override... |
58 |
|
public ExtendedURL serialize(VfsResourceReference resourceReference) |
59 |
|
throws SerializeResourceReferenceException, UnsupportedResourceReferenceException |
60 |
|
{ |
61 |
4 |
ExtendedURL extendedURL; |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
4 |
URI uri = resourceReference.getURI(); |
69 |
4 |
try { |
70 |
4 |
ResourceReferenceSerializer<VfsResourceReference, ExtendedURL> schemeSpecificSerializer = |
71 |
|
this.componentManagerProvider.get().getInstance(TYPE, uri.getScheme()); |
72 |
3 |
extendedURL = schemeSpecificSerializer.serialize(resourceReference); |
73 |
|
} catch (ComponentLookupException e) { |
74 |
1 |
extendedURL = super.serialize(resourceReference); |
75 |
|
} |
76 |
|
|
77 |
4 |
return extendedURL; |
78 |
|
} |
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
1 |
@Override... |
81 |
|
protected URI makeAbsolute(URI uri) |
82 |
|
{ |
83 |
|
|
84 |
1 |
return uri; |
85 |
|
} |
86 |
|
} |