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 javax.inject.Inject; |
23 |
|
import javax.inject.Singleton; |
24 |
|
|
25 |
|
import org.xwiki.component.annotation.Component; |
26 |
|
import org.xwiki.context.Execution; |
27 |
|
import org.xwiki.extension.repository.CoreExtensionRepository; |
28 |
|
import org.xwiki.extension.repository.ExtensionRepository; |
29 |
|
import org.xwiki.extension.repository.InstalledExtensionRepository; |
30 |
|
import org.xwiki.extension.repository.LocalExtensionRepository; |
31 |
|
import org.xwiki.extension.repository.rating.Ratable; |
32 |
|
import org.xwiki.extension.repository.rating.RatableExtensionRepository; |
33 |
|
import org.xwiki.extension.repository.search.AdvancedSearchable; |
34 |
|
import org.xwiki.extension.repository.search.Searchable; |
35 |
|
import org.xwiki.script.internal.safe.ScriptSafeProvider; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
43 |
|
@Component |
44 |
|
@Singleton |
|
|
| 77.8% |
Uncovered Elements: 8 (36) |
Complexity: 9 |
Complexity Density: 0.47 |
|
45 |
|
public class ExtensionRepositoryScriptSafeProvider extends AbstractScriptSafeProvider<ExtensionRepository> |
46 |
|
{ |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
@Inject |
51 |
|
@SuppressWarnings("rawtypes") |
52 |
|
private ScriptSafeProvider defaultSafeProvider; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
@Inject |
58 |
|
private Execution execution; |
59 |
|
|
|
|
| 77.1% |
Uncovered Elements: 8 (35) |
Complexity: 9 |
Complexity Density: 0.47 |
|
60 |
1620 |
@Override... |
61 |
|
public <S> S get(ExtensionRepository unsafe) |
62 |
|
{ |
63 |
1620 |
ExtensionRepository safe; |
64 |
|
|
65 |
|
|
66 |
1620 |
if (unsafe instanceof CoreExtensionRepository) { |
67 |
1185 |
safe = |
68 |
|
new SafeCoreExtensionRepository<CoreExtensionRepository>((CoreExtensionRepository) unsafe, |
69 |
|
this.defaultSafeProvider, this.execution, hasProgrammingRights()); |
70 |
435 |
} else if (unsafe instanceof InstalledExtensionRepository) { |
71 |
80 |
safe = |
72 |
|
new SafeInstalledExtensionRepository<InstalledExtensionRepository>( |
73 |
|
(InstalledExtensionRepository) unsafe, this.defaultSafeProvider, this.execution, |
74 |
|
hasProgrammingRights()); |
75 |
355 |
} else if (unsafe instanceof LocalExtensionRepository) { |
76 |
242 |
safe = |
77 |
|
new SafeLocalExtensionRepository<LocalExtensionRepository>((LocalExtensionRepository) unsafe, |
78 |
|
this.defaultSafeProvider, this.execution, hasProgrammingRights()); |
79 |
113 |
} else if (unsafe instanceof AdvancedSearchable) { |
80 |
110 |
if (unsafe instanceof Ratable) { |
81 |
97 |
safe = |
82 |
|
new SafeAdvancedSearchableRatableExtensionRepository<ExtensionRepository>(unsafe, |
83 |
|
this.defaultSafeProvider, this.execution, hasProgrammingRights()); |
84 |
|
} else { |
85 |
13 |
safe = |
86 |
|
new SafeAdvancedSearchableExtensionRepository<ExtensionRepository>(unsafe, |
87 |
|
this.defaultSafeProvider, this.execution, hasProgrammingRights()); |
88 |
|
} |
89 |
3 |
} else if (unsafe instanceof Searchable) { |
90 |
0 |
if (unsafe instanceof Ratable) { |
91 |
0 |
safe = |
92 |
|
new SafeSearchableRatableExtensionRepository<ExtensionRepository>(unsafe, this.defaultSafeProvider, |
93 |
|
this.execution, hasProgrammingRights()); |
94 |
|
} else { |
95 |
0 |
safe = |
96 |
|
new SafeSearchableExtensionRepository<ExtensionRepository>(unsafe, this.defaultSafeProvider, |
97 |
|
this.execution, hasProgrammingRights()); |
98 |
|
} |
99 |
3 |
} else if (unsafe instanceof Ratable) { |
100 |
0 |
safe = |
101 |
|
new SafeRatableExtensionRepository<RatableExtensionRepository>((RatableExtensionRepository) unsafe, |
102 |
|
this.defaultSafeProvider, this.execution, hasProgrammingRights()); |
103 |
|
} else { |
104 |
3 |
safe = |
105 |
|
new SafeExtensionRepository<ExtensionRepository>(unsafe, this.defaultSafeProvider, this.execution, |
106 |
|
hasProgrammingRights()); |
107 |
|
} |
108 |
|
|
109 |
1620 |
return (S) safe; |
110 |
|
} |
111 |
|
} |