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 javax.inject.Inject; |
23 |
|
import javax.inject.Named; |
24 |
|
import javax.inject.Provider; |
25 |
|
|
26 |
|
import org.slf4j.Logger; |
27 |
|
import org.xwiki.component.annotation.Component; |
28 |
|
import org.xwiki.component.annotation.InstantiationStrategy; |
29 |
|
import org.xwiki.component.descriptor.ComponentInstantiationStrategy; |
30 |
|
|
31 |
|
import com.xpn.xwiki.XWikiContext; |
32 |
|
import com.xpn.xwiki.XWikiException; |
33 |
|
import com.xpn.xwiki.plugin.rightsmanager.RightsManager; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
41 |
|
@Component |
42 |
|
@Named(FirstAdminUserStep.ID) |
43 |
|
@InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP) |
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 6 |
Complexity Density: 0.75 |
|
44 |
|
public class FirstAdminUserStep extends AbstractDistributionStep |
45 |
|
{ |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
public static final String ID = "firstadminuser"; |
50 |
|
|
51 |
|
@Inject |
52 |
|
private transient Logger logger; |
53 |
|
|
54 |
|
@Inject |
55 |
|
private transient Provider<XWikiContext> xcontextProvider; |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
0 |
public FirstAdminUserStep()... |
61 |
|
{ |
62 |
0 |
super(ID); |
63 |
|
} |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 5 |
Complexity Density: 0.71 |
|
65 |
0 |
@Override... |
66 |
|
public void prepare() |
67 |
|
{ |
68 |
0 |
if (getState() == null) { |
69 |
0 |
setState(State.COMPLETED); |
70 |
|
|
71 |
0 |
if (isMainWiki()) { |
72 |
0 |
try { |
73 |
0 |
if (RightsManager.getInstance().countAllGlobalUsersOrGroups(true, null, |
74 |
|
this.xcontextProvider.get()) == 0) { |
75 |
|
|
76 |
0 |
setState(null); |
77 |
|
} |
78 |
|
} catch (XWikiException e) { |
79 |
0 |
this.logger.error("Failed to count global users", e); |
80 |
|
} |
81 |
|
} |
82 |
|
} |
83 |
|
} |
84 |
|
} |