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 |
|
import java.util.ArrayList; |
24 |
|
import java.util.List; |
25 |
|
|
26 |
|
import javax.inject.Inject; |
27 |
|
import javax.inject.Named; |
28 |
|
|
29 |
|
import org.xwiki.resource.ResourceReferenceSerializer; |
30 |
|
import org.xwiki.resource.SerializeResourceReferenceException; |
31 |
|
import org.xwiki.resource.UnsupportedResourceReferenceException; |
32 |
|
import org.xwiki.url.ExtendedURL; |
33 |
|
import org.xwiki.url.URLNormalizer; |
34 |
|
import org.xwiki.vfs.VfsResourceReference; |
35 |
|
|
36 |
|
|
37 |
|
@link |
38 |
|
@link |
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.17 |
|
43 |
|
public abstract class AbstractVfsResourceReferenceSerializer |
44 |
|
implements ResourceReferenceSerializer<VfsResourceReference, ExtendedURL> |
45 |
|
{ |
46 |
|
@Inject |
47 |
|
@Named("contextpath") |
48 |
|
private URLNormalizer<ExtendedURL> extendedURLNormalizer; |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
50 |
4 |
@Override... |
51 |
|
public ExtendedURL serialize(VfsResourceReference resourceReference) |
52 |
|
throws SerializeResourceReferenceException, UnsupportedResourceReferenceException |
53 |
|
{ |
54 |
4 |
List<String> segments = new ArrayList<>(); |
55 |
|
|
56 |
|
|
57 |
4 |
segments.add("vfs"); |
58 |
|
|
59 |
|
|
60 |
4 |
segments.add(makeAbsolute(resourceReference.getURI()).toString()); |
61 |
|
|
62 |
|
|
63 |
4 |
segments.addAll(resourceReference.getPathSegments()); |
64 |
|
|
65 |
|
|
66 |
4 |
ExtendedURL extendedURL = new ExtendedURL(segments, resourceReference.getParameters()); |
67 |
|
|
68 |
|
|
69 |
4 |
return this.extendedURLNormalizer.normalize(extendedURL); |
70 |
|
} |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
@param |
76 |
|
@return |
77 |
|
|
78 |
|
protected abstract URI makeAbsolute(URI uri); |
79 |
|
} |