1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension.script.internal.safe; |
21 |
|
|
22 |
|
import java.util.Collection; |
23 |
|
import java.util.Map; |
24 |
|
|
25 |
|
import org.xwiki.context.Execution; |
26 |
|
import org.xwiki.extension.Extension; |
27 |
|
import org.xwiki.extension.ExtensionDependency; |
28 |
|
import org.xwiki.extension.ExtensionId; |
29 |
|
import org.xwiki.extension.LocalExtension; |
30 |
|
import org.xwiki.extension.ResolveException; |
31 |
|
import org.xwiki.extension.repository.LocalExtensionRepository; |
32 |
|
import org.xwiki.extension.repository.LocalExtensionRepositoryException; |
33 |
|
import org.xwiki.script.internal.safe.ScriptSafeProvider; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@param |
39 |
|
@version |
40 |
|
@since |
41 |
|
|
|
|
| 14% |
Uncovered Elements: 37 (43) |
Complexity: 16 |
Complexity Density: 0.59 |
|
42 |
|
public class SafeLocalExtensionRepository<T extends LocalExtensionRepository> extends |
43 |
|
SafeAdvancedSearchableExtensionRepository<T> implements LocalExtensionRepository |
44 |
|
{ |
45 |
|
|
46 |
|
@param |
47 |
|
@param |
48 |
|
@param |
49 |
|
@param |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
51 |
242 |
public SafeLocalExtensionRepository(T repository, ScriptSafeProvider<?> safeProvider, Execution execution,... |
52 |
|
boolean hasProgrammingRight) |
53 |
|
{ |
54 |
242 |
super(repository, safeProvider, execution, hasProgrammingRight); |
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
0 |
@Override... |
60 |
|
public int countExtensions() |
61 |
|
{ |
62 |
0 |
return getWrapped().countExtensions(); |
63 |
|
} |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
0 |
@Override... |
66 |
|
public LocalExtension getLocalExtension(ExtensionId extensionId) |
67 |
|
{ |
68 |
0 |
return safe(getWrapped().getLocalExtension(extensionId)); |
69 |
|
} |
70 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
71 |
0 |
@Override... |
72 |
|
public Collection<LocalExtension> getLocalExtensions() |
73 |
|
{ |
74 |
0 |
return safe(getWrapped().getLocalExtensions()); |
75 |
|
} |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
77 |
0 |
@Override... |
78 |
|
public LocalExtension storeExtension(Extension extension) |
79 |
|
{ |
80 |
0 |
if (!this.hasProgrammingRight) { |
81 |
0 |
setError(new UnsupportedOperationException(FORBIDDEN)); |
82 |
|
|
83 |
0 |
return null; |
84 |
|
} |
85 |
|
|
86 |
0 |
setError(null); |
87 |
|
|
88 |
0 |
try { |
89 |
0 |
return safe(getWrapped().storeExtension(extension)); |
90 |
|
} catch (LocalExtensionRepositoryException e) { |
91 |
0 |
setError(e); |
92 |
|
} |
93 |
|
|
94 |
0 |
return null; |
95 |
|
} |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
97 |
0 |
@Override... |
98 |
|
public void removeExtension(LocalExtension extension) |
99 |
|
{ |
100 |
0 |
if (!this.hasProgrammingRight) { |
101 |
0 |
setError(new UnsupportedOperationException(FORBIDDEN)); |
102 |
|
} |
103 |
|
|
104 |
0 |
setError(null); |
105 |
|
|
106 |
0 |
try { |
107 |
0 |
getWrapped().removeExtension(extension); |
108 |
|
} catch (ResolveException e) { |
109 |
0 |
setError(e); |
110 |
|
} |
111 |
|
} |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
28 |
@Override... |
114 |
|
public LocalExtension resolve(ExtensionDependency extensionDependency) |
115 |
|
{ |
116 |
28 |
return (LocalExtension) super.resolve(extensionDependency); |
117 |
|
} |
118 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
119 |
161 |
@Override... |
120 |
|
public LocalExtension resolve(ExtensionId extensionId) |
121 |
|
{ |
122 |
161 |
return (LocalExtension) super.resolve(extensionId); |
123 |
|
} |
124 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
125 |
0 |
@Override... |
126 |
|
public Collection<LocalExtension> getLocalExtensionVersions(String id) |
127 |
|
{ |
128 |
0 |
return safe(getWrapped().getLocalExtensionVersions(id)); |
129 |
|
} |
130 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
131 |
0 |
@Override... |
132 |
|
public void setProperties(LocalExtension localExtension, Map<String, Object> properties) |
133 |
|
{ |
134 |
0 |
if (!this.hasProgrammingRight) { |
135 |
0 |
setError(new UnsupportedOperationException(FORBIDDEN)); |
136 |
|
} |
137 |
|
|
138 |
0 |
setError(null); |
139 |
|
|
140 |
0 |
try { |
141 |
0 |
getWrapped().setProperties(localExtension, properties); |
142 |
|
} catch (LocalExtensionRepositoryException e) { |
143 |
0 |
setError(e); |
144 |
|
} |
145 |
|
} |
146 |
|
} |