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.net.URI; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
import javax.inject.Named; |
26 |
|
import javax.inject.Provider; |
27 |
|
import javax.inject.Singleton; |
28 |
|
|
29 |
|
import org.xwiki.component.annotation.Component; |
30 |
|
import org.xwiki.component.manager.ComponentLookupException; |
31 |
|
import org.xwiki.component.manager.ComponentManager; |
32 |
|
import org.xwiki.component.util.DefaultParameterizedType; |
33 |
|
import org.xwiki.resource.ResourceReferenceSerializer; |
34 |
|
import org.xwiki.resource.SerializeResourceReferenceException; |
35 |
|
import org.xwiki.resource.UnsupportedResourceReferenceException; |
36 |
|
import org.xwiki.vfs.VfsResourceReference; |
37 |
|
|
38 |
|
|
39 |
|
@link@link |
40 |
|
@link |
41 |
|
|
42 |
|
@version |
43 |
|
@since |
44 |
|
|
45 |
|
@Component |
46 |
|
@Named("truevfs") |
47 |
|
@Singleton |
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.33 |
|
48 |
|
public class URIVfsResourceReferenceSerializer implements ResourceReferenceSerializer<VfsResourceReference, URI> |
49 |
|
{ |
50 |
|
@Inject |
51 |
|
@Named("context") |
52 |
|
private Provider<ComponentManager> componentManagerProvider; |
53 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
54 |
5 |
@Override... |
55 |
|
public URI serialize(VfsResourceReference reference) |
56 |
|
throws SerializeResourceReferenceException, UnsupportedResourceReferenceException |
57 |
|
{ |
58 |
5 |
URI resultURI; |
59 |
|
|
60 |
5 |
try { |
61 |
5 |
ResourceReferenceSerializer<VfsResourceReference, URI> serializer = |
62 |
|
this.componentManagerProvider.get().getInstance(new DefaultParameterizedType(null, |
63 |
|
ResourceReferenceSerializer.class, VfsResourceReference.class, URI.class), |
64 |
|
String.format("truevfs/%s", reference.getURI().getScheme())); |
65 |
5 |
resultURI = serializer.serialize(reference); |
66 |
|
} catch (ComponentLookupException e) { |
67 |
|
|
68 |
0 |
resultURI = reference.toURI(); |
69 |
|
} |
70 |
|
|
71 |
5 |
return resultURI; |
72 |
|
} |
73 |
|
} |