1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension.distribution.internal.job.step; |
21 |
|
|
22 |
|
import java.util.Collection; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
import javax.inject.Named; |
26 |
|
|
27 |
|
import org.slf4j.Logger; |
28 |
|
import org.xwiki.component.annotation.Component; |
29 |
|
import org.xwiki.component.annotation.InstantiationStrategy; |
30 |
|
import org.xwiki.component.descriptor.ComponentInstantiationStrategy; |
31 |
|
import org.xwiki.extension.InstalledExtension; |
32 |
|
import org.xwiki.extension.repository.InstalledExtensionRepository; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
40 |
|
@Component |
41 |
|
@Named(OutdatedExtensionsDistributionStep.ID) |
42 |
|
@InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP) |
|
|
| 36.8% |
Uncovered Elements: 24 (38) |
Complexity: 8 |
Complexity Density: 0.33 |
|
43 |
|
public class OutdatedExtensionsDistributionStep extends AbstractDistributionStep |
44 |
|
{ |
45 |
|
public static final String ID = "extension.outdatedextensions"; |
46 |
|
|
47 |
|
@Inject |
48 |
|
private transient InstalledExtensionRepository installedRepository; |
49 |
|
|
50 |
|
@Inject |
51 |
|
private transient Logger logger; |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
53 |
3 |
public OutdatedExtensionsDistributionStep()... |
54 |
|
{ |
55 |
3 |
super(ID); |
56 |
|
} |
57 |
|
|
|
|
| 31.4% |
Uncovered Elements: 24 (35) |
Complexity: 7 |
Complexity Density: 0.3 |
|
58 |
4 |
@Override... |
59 |
|
public void prepare() |
60 |
|
{ |
61 |
4 |
if (getState() == null) { |
62 |
1 |
setState(State.COMPLETED); |
63 |
|
|
64 |
1 |
if (isMainWiki()) { |
65 |
0 |
Collection<InstalledExtension> installedExtensions = this.installedRepository.getInstalledExtensions(); |
66 |
|
|
67 |
|
|
68 |
0 |
for (InstalledExtension extension : installedExtensions) { |
69 |
0 |
Collection<String> installedNamespaces = extension.getNamespaces(); |
70 |
0 |
if (installedNamespaces == null) { |
71 |
0 |
if (!extension.isValid(null)) { |
72 |
0 |
this.logger.debug("Enabling outdate extension step on main wiki " |
73 |
|
+ "because extension [{}] is invalid on root namespace", extension.getId()); |
74 |
|
|
75 |
0 |
setState(null); |
76 |
0 |
break; |
77 |
|
} |
78 |
|
} else { |
79 |
0 |
for (String installedNamespace : installedNamespaces) { |
80 |
0 |
if (!extension.isValid(installedNamespace)) { |
81 |
0 |
this.logger.debug("Enabling outdate extension step on main wiki " |
82 |
|
+ "because extension [{}] is invalid on namespace [{}]", extension.getId(), |
83 |
|
installedNamespace); |
84 |
|
|
85 |
0 |
setState(null); |
86 |
0 |
break; |
87 |
|
} |
88 |
|
} |
89 |
|
} |
90 |
|
} |
91 |
|
} else { |
92 |
1 |
String currentNamespace = getNamespace(); |
93 |
1 |
Collection<InstalledExtension> installedExtensions = |
94 |
|
this.installedRepository.getInstalledExtensions(currentNamespace); |
95 |
|
|
96 |
|
|
97 |
1 |
for (InstalledExtension extension : installedExtensions) { |
98 |
2 |
if (!extension.isValid(currentNamespace)) { |
99 |
0 |
this.logger.debug("Enabling outdate extension step on wiki [{}]" |
100 |
|
+ "because extension [{}] is invalid", getWiki(), extension.getId()); |
101 |
|
|
102 |
0 |
setState(null); |
103 |
0 |
break; |
104 |
|
} |
105 |
|
} |
106 |
|
} |
107 |
|
} |
108 |
|
} |
109 |
|
} |