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.nio.file.Path; |
24 |
|
|
25 |
|
import javax.inject.Inject; |
26 |
|
import javax.inject.Named; |
27 |
|
import javax.inject.Singleton; |
28 |
|
|
29 |
|
import org.xwiki.component.annotation.Component; |
30 |
|
import org.xwiki.properties.converter.Converter; |
31 |
|
import org.xwiki.resource.ResourceReferenceSerializer; |
32 |
|
import org.xwiki.vfs.VfsException; |
33 |
|
import org.xwiki.vfs.VfsPathFactory; |
34 |
|
import org.xwiki.vfs.VfsPermissionChecker; |
35 |
|
import org.xwiki.vfs.VfsResourceReference; |
36 |
|
|
37 |
|
import net.java.truevfs.access.TPath; |
38 |
|
|
39 |
|
|
40 |
|
@link |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
@version |
48 |
|
@since |
49 |
|
|
50 |
|
@Component |
51 |
|
@Singleton |
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.33 |
|
52 |
|
public class DefaultVfsPathFactory implements VfsPathFactory |
53 |
|
{ |
54 |
|
@Inject |
55 |
|
private VfsPermissionChecker permissionChecker; |
56 |
|
|
57 |
|
@Inject |
58 |
|
private Converter<VfsResourceReference> vfsResourceReferenceConverter; |
59 |
|
|
60 |
|
@Inject |
61 |
|
@Named("truevfs") |
62 |
|
private ResourceReferenceSerializer<VfsResourceReference, URI> trueVfsResourceReferenceSerializer; |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
64 |
0 |
@Override... |
65 |
|
public Path create(URI uri) throws VfsException |
66 |
|
{ |
67 |
0 |
try { |
68 |
0 |
VfsResourceReference reference = |
69 |
|
this.vfsResourceReferenceConverter.convert(VfsResourceReference.class, uri.toString()); |
70 |
0 |
this.permissionChecker.checkPermission(reference); |
71 |
0 |
URI trueVFSURI = this.trueVfsResourceReferenceSerializer.serialize(reference); |
72 |
0 |
return new TPath(trueVFSURI); |
73 |
|
} catch (Exception e) { |
74 |
0 |
throw new VfsException(String.format("Failed to create Path instance for [%s]", uri.toString()), e); |
75 |
|
} |
76 |
|
} |
77 |
|
} |