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.Collections; |
24 |
|
import java.util.Map; |
25 |
|
|
26 |
|
import org.xwiki.context.Execution; |
27 |
|
import org.xwiki.extension.ExtensionDependency; |
28 |
|
import org.xwiki.extension.ExtensionId; |
29 |
|
import org.xwiki.extension.InstallException; |
30 |
|
import org.xwiki.extension.InstalledExtension; |
31 |
|
import org.xwiki.extension.LocalExtension; |
32 |
|
import org.xwiki.extension.UninstallException; |
33 |
|
import org.xwiki.extension.repository.InstalledExtensionRepository; |
34 |
|
import org.xwiki.extension.repository.result.IterableResult; |
35 |
|
import org.xwiki.extension.repository.search.ExtensionQuery; |
36 |
|
import org.xwiki.extension.repository.search.SearchException; |
37 |
|
import org.xwiki.script.internal.safe.ScriptSafeProvider; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@param |
43 |
|
@version |
44 |
|
@since |
45 |
|
|
|
|
| 6.8% |
Uncovered Elements: 55 (59) |
Complexity: 23 |
Complexity Density: 0.61 |
|
46 |
|
public class SafeInstalledExtensionRepository<T extends InstalledExtensionRepository> |
47 |
|
extends SafeAdvancedSearchableExtensionRepository<T> implements InstalledExtensionRepository |
48 |
|
{ |
49 |
|
|
50 |
|
@param |
51 |
|
@param |
52 |
|
@param |
53 |
|
@param |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
80 |
public SafeInstalledExtensionRepository(T repository, ScriptSafeProvider<?> safeProvider, Execution execution,... |
56 |
|
boolean hasProgrammingRight) |
57 |
|
{ |
58 |
80 |
super(repository, safeProvider, execution, hasProgrammingRight); |
59 |
|
} |
60 |
|
|
61 |
|
|
62 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
0 |
@Override... |
64 |
|
public int countExtensions() |
65 |
|
{ |
66 |
0 |
return getWrapped().countExtensions(); |
67 |
|
} |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
0 |
@Override... |
70 |
|
public InstalledExtension getInstalledExtension(ExtensionId extensionId) |
71 |
|
{ |
72 |
0 |
return safe(getWrapped().getInstalledExtension(extensionId)); |
73 |
|
} |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
75 |
0 |
@Override... |
76 |
|
public InstalledExtension getInstalledExtension(String feature, String namespace) |
77 |
|
{ |
78 |
0 |
return safe(getWrapped().getInstalledExtension(feature, namespace)); |
79 |
|
} |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
0 |
@Override... |
82 |
|
public InstalledExtension installExtension(LocalExtension extension, String namespace, boolean dependency) |
83 |
|
{ |
84 |
0 |
return installExtension(extension, namespace, dependency, Collections.<String, Object>emptyMap()); |
85 |
|
} |
86 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
87 |
0 |
@Override... |
88 |
|
public InstalledExtension installExtension(LocalExtension extension, String namespace, boolean dependency, |
89 |
|
Map<String, Object> properties) |
90 |
|
{ |
91 |
0 |
if (!this.hasProgrammingRight) { |
92 |
0 |
setError(new UnsupportedOperationException(FORBIDDEN)); |
93 |
|
|
94 |
0 |
return null; |
95 |
|
} |
96 |
|
|
97 |
0 |
setError(null); |
98 |
|
|
99 |
0 |
try { |
100 |
0 |
return safe(getWrapped().installExtension(extension, namespace, dependency, properties)); |
101 |
|
} catch (InstallException e) { |
102 |
0 |
setError(e); |
103 |
|
} |
104 |
|
|
105 |
0 |
return null; |
106 |
|
} |
107 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
108 |
0 |
@Override... |
109 |
|
public void uninstallExtension(InstalledExtension extension, String namespace) |
110 |
|
{ |
111 |
0 |
if (!this.hasProgrammingRight) { |
112 |
0 |
setError(new UnsupportedOperationException(FORBIDDEN)); |
113 |
|
|
114 |
0 |
return; |
115 |
|
} |
116 |
|
|
117 |
0 |
setError(null); |
118 |
|
|
119 |
0 |
try { |
120 |
0 |
getWrapped().uninstallExtension(extension, namespace); |
121 |
|
} catch (UninstallException e) { |
122 |
0 |
setError(e); |
123 |
|
} |
124 |
|
} |
125 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
126 |
0 |
@Override... |
127 |
|
public Collection<InstalledExtension> getBackwardDependencies(String feature, String namespace) |
128 |
|
{ |
129 |
0 |
setError(null); |
130 |
|
|
131 |
0 |
try { |
132 |
0 |
return safe(getWrapped().getBackwardDependencies(feature, namespace)); |
133 |
|
} catch (Exception e) { |
134 |
0 |
setError(e); |
135 |
|
} |
136 |
|
|
137 |
0 |
return null; |
138 |
|
} |
139 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
140 |
0 |
@Override... |
141 |
|
public Map<String, Collection<InstalledExtension>> getBackwardDependencies(ExtensionId extensionId) |
142 |
|
{ |
143 |
0 |
setError(null); |
144 |
|
|
145 |
0 |
try { |
146 |
0 |
return safe(getWrapped().getBackwardDependencies(extensionId)); |
147 |
|
} catch (Exception e) { |
148 |
0 |
setError(e); |
149 |
|
} |
150 |
|
|
151 |
0 |
return null; |
152 |
|
} |
153 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
154 |
0 |
@Override... |
155 |
|
public Collection<InstalledExtension> getInstalledExtensions() |
156 |
|
{ |
157 |
0 |
return safe(getWrapped().getInstalledExtensions()); |
158 |
|
} |
159 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
160 |
0 |
@Override... |
161 |
|
public Collection<InstalledExtension> getInstalledExtensions(String namespace) |
162 |
|
{ |
163 |
0 |
return safe(getWrapped().getInstalledExtensions(namespace)); |
164 |
|
} |
165 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
166 |
0 |
@Override... |
167 |
|
public InstalledExtension resolve(ExtensionDependency extensionDependency) |
168 |
|
{ |
169 |
0 |
return (InstalledExtension) super.resolve(extensionDependency); |
170 |
|
} |
171 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
172 |
0 |
@Override... |
173 |
|
public InstalledExtension resolve(ExtensionId extensionId) |
174 |
|
{ |
175 |
0 |
return (InstalledExtension) super.resolve(extensionId); |
176 |
|
} |
177 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
178 |
0 |
@Override... |
179 |
|
public IterableResult<InstalledExtension> searchInstalledExtensions(String pattern, String namespace, int offset, |
180 |
|
int nb) throws SearchException |
181 |
|
{ |
182 |
0 |
return safe(getWrapped().searchInstalledExtensions(pattern, namespace, offset, nb)); |
183 |
|
} |
184 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
185 |
0 |
@Override... |
186 |
|
public IterableResult<InstalledExtension> searchInstalledExtensions(String namespace, ExtensionQuery query) |
187 |
|
throws SearchException |
188 |
|
{ |
189 |
0 |
return safe(getWrapped().searchInstalledExtensions(namespace, query)); |
190 |
|
} |
191 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
192 |
8 |
@Override... |
193 |
|
public IterableResult<InstalledExtension> searchInstalledExtensions(ExtensionQuery query) throws SearchException |
194 |
|
{ |
195 |
8 |
return safe(getWrapped().searchInstalledExtensions(query)); |
196 |
|
} |
197 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
198 |
0 |
@Override... |
199 |
|
public IterableResult<InstalledExtension> searchInstalledExtensions(Collection<String> namespaces, |
200 |
|
ExtensionQuery query) throws SearchException |
201 |
|
{ |
202 |
0 |
return safe(getWrapped().searchInstalledExtensions(namespaces, query)); |
203 |
|
} |
204 |
|
} |