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.Provider; |
24 |
|
|
25 |
|
import org.xwiki.extension.distribution.internal.job.DistributionJob; |
26 |
|
import org.xwiki.extension.distribution.internal.job.DistributionJobStatus; |
27 |
|
import org.xwiki.job.annotation.Serializable; |
28 |
|
import org.xwiki.rendering.block.Block; |
29 |
|
import org.xwiki.template.TemplateManager; |
30 |
|
import org.xwiki.wiki.descriptor.WikiDescriptorManager; |
31 |
|
|
32 |
|
@Serializable |
|
|
| 83.3% |
Uncovered Elements: 6 (36) |
Complexity: 15 |
Complexity Density: 0.83 |
|
33 |
|
public abstract class AbstractDistributionStep implements DistributionStep |
34 |
|
{ |
35 |
|
@Inject |
36 |
|
protected transient TemplateManager renderer; |
37 |
|
|
38 |
|
@Inject |
39 |
|
protected transient Provider<WikiDescriptorManager> wikiDescriptorManagerProvider; |
40 |
|
|
41 |
|
private final String stepId; |
42 |
|
|
43 |
|
protected DistributionJob distributionJob; |
44 |
|
|
45 |
|
private State state; |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
12 |
public AbstractDistributionStep(String stepId)... |
48 |
|
{ |
49 |
12 |
this.stepId = stepId; |
50 |
|
} |
51 |
|
|
|
|
| 92.9% |
Uncovered Elements: 1 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
52 |
12 |
@Override... |
53 |
|
public void initialize(DistributionJob distributionJob) |
54 |
|
{ |
55 |
12 |
this.distributionJob = distributionJob; |
56 |
|
|
57 |
|
|
58 |
12 |
DistributionJobStatus< ? > previousStatus = this.distributionJob.getPreviousStatus(); |
59 |
|
|
60 |
12 |
if (previousStatus != null |
61 |
|
&& previousStatus.getDistributionExtension().equals( |
62 |
|
this.distributionJob.getStatus().getDistributionExtension())) { |
63 |
8 |
DistributionStep previousStep = previousStatus.getStep(getId()); |
64 |
|
|
65 |
8 |
if (previousStep != null) { |
66 |
8 |
setState(previousStep.getState()); |
67 |
|
} |
68 |
|
} |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
12 |
if (getState() == null) { |
73 |
2 |
prepare(); |
74 |
|
} |
75 |
|
} |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
43 |
@Override... |
78 |
|
public String getId() |
79 |
|
{ |
80 |
43 |
return this.stepId; |
81 |
|
} |
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
83 |
52 |
@Override... |
84 |
|
public State getState() |
85 |
|
{ |
86 |
52 |
return this.state; |
87 |
|
} |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
89 |
16 |
@Override... |
90 |
|
public void setState(State stepState) |
91 |
|
{ |
92 |
16 |
this.state = stepState; |
93 |
|
} |
94 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
95 |
5 |
protected String getWiki()... |
96 |
|
{ |
97 |
5 |
return this.distributionJob.getRequest().getWiki(); |
98 |
|
} |
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
100 |
1 |
protected boolean isMainWiki()... |
101 |
|
{ |
102 |
1 |
return this.wikiDescriptorManagerProvider.get().getMainWikiId().equals(getWiki()); |
103 |
|
} |
104 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
105 |
2 |
protected String getNamespace()... |
106 |
|
{ |
107 |
2 |
String wiki = getWiki(); |
108 |
|
|
109 |
2 |
return wiki == null ? null : "wiki:" + getWiki(); |
110 |
|
} |
111 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
0 |
protected String getTemplate()... |
113 |
|
{ |
114 |
0 |
return "distribution/" + getId() + ".wiki"; |
115 |
|
} |
116 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
117 |
0 |
@Override... |
118 |
|
public Block execute() |
119 |
|
{ |
120 |
0 |
return this.renderer.executeNoException(getTemplate()); |
121 |
|
} |
122 |
|
} |