1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.resources.app.workbench; |
35 |
|
|
36 |
|
import info.magnolia.resourceloader.Resource; |
37 |
|
|
38 |
|
import java.io.IOException; |
39 |
|
import java.io.Reader; |
40 |
|
|
41 |
|
import org.apache.commons.io.IOUtils; |
42 |
|
|
43 |
|
import org.apache.commons.lang.NotImplementedException; |
44 |
|
|
45 |
|
import com.vaadin.data.util.AbstractProperty; |
46 |
|
|
47 |
|
|
48 |
|
@link |
49 |
|
@link |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 5 |
Complexity Density: 1 |
|
51 |
|
public class ResourceContentProperty extends AbstractProperty<String> { |
52 |
|
|
53 |
|
private final Resource resource; |
54 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
0 |
public ResourceContentProperty(Resource resource) {... |
56 |
0 |
this.resource = resource; |
57 |
|
} |
58 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
59 |
|
@Override... |
60 |
|
public Class<String> getType() { |
61 |
|
return String.class; |
62 |
|
} |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 4 |
Complexity Density: 1 |
|
64 |
0 |
@Override... |
65 |
|
public String getValue() { |
66 |
0 |
try (final Reader reader = resource.openReader()) { |
67 |
0 |
return IOUtils.toString(reader); |
68 |
|
} catch (IOException e) { |
69 |
0 |
throw new RuntimeException(e); |
70 |
|
} |
71 |
|
} |
72 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
73 |
|
@Override... |
74 |
|
public boolean isReadOnly() { |
75 |
|
return true; |
76 |
|
} |
77 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
78 |
|
@Override... |
79 |
|
public void setValue(String newValue) throws ReadOnlyException { |
80 |
|
throw new NotImplementedException("doesn't support write operations yet"); |
81 |
|
} |
82 |
|
|
83 |
|
} |
84 |
|
|