1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.diff.script; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
import javax.inject.Named; |
26 |
|
import javax.inject.Singleton; |
27 |
|
|
28 |
|
import org.xwiki.component.annotation.Component; |
29 |
|
import org.xwiki.context.Execution; |
30 |
|
import org.xwiki.diff.DiffConfiguration; |
31 |
|
import org.xwiki.diff.DiffException; |
32 |
|
import org.xwiki.diff.DiffManager; |
33 |
|
import org.xwiki.diff.DiffResult; |
34 |
|
import org.xwiki.diff.MergeConfiguration; |
35 |
|
import org.xwiki.diff.MergeException; |
36 |
|
import org.xwiki.diff.MergeResult; |
37 |
|
import org.xwiki.diff.internal.DefaultDiffResult; |
38 |
|
import org.xwiki.diff.internal.DefaultMergeResult; |
39 |
|
import org.xwiki.script.service.ScriptService; |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
@version |
45 |
|
@since |
46 |
|
|
47 |
|
@Component |
48 |
|
@Named("diff") |
49 |
|
@Singleton |
|
|
| 11.1% |
Uncovered Elements: 16 (18) |
Complexity: 6 |
Complexity Density: 0.43 |
|
50 |
|
public class DiffScriptService implements ScriptService |
51 |
|
{ |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
static final String DIFF_ERROR_KEY = "scriptservice.diff.error"; |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
@Inject |
61 |
|
private Execution execution; |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
@Inject |
67 |
|
private DiffManager diffManager; |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
@Inject |
73 |
|
@Named("diff.display") |
74 |
|
private ScriptService diffDisplayScriptService; |
75 |
|
|
76 |
|
|
77 |
|
@return |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
79 |
7 |
public ScriptService getDisplay()... |
80 |
|
{ |
81 |
7 |
return this.diffDisplayScriptService; |
82 |
|
} |
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
@param |
88 |
|
@param |
89 |
|
@param |
90 |
|
@param |
91 |
|
@return |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
93 |
0 |
public <E> DiffResult<E> diff(List<E> previous, List<E> next, DiffConfiguration<E> configuration)... |
94 |
|
{ |
95 |
0 |
DiffResult<E> result; |
96 |
0 |
try { |
97 |
0 |
result = this.diffManager.diff(previous, next, configuration); |
98 |
|
} catch (DiffException e) { |
99 |
0 |
result = new DefaultDiffResult<E>(previous, next); |
100 |
0 |
result.getLog().error("Failed to execute diff", e); |
101 |
|
} |
102 |
|
|
103 |
0 |
return result; |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
@param |
110 |
|
@param |
111 |
|
@param |
112 |
|
@param |
113 |
|
@param |
114 |
|
@return |
115 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
116 |
0 |
public <E> MergeResult<E> merge(List<E> commonAncestor, List<E> next, List<E> current,... |
117 |
|
MergeConfiguration<E> configuration) |
118 |
|
{ |
119 |
0 |
MergeResult<E> result; |
120 |
0 |
try { |
121 |
0 |
result = this.diffManager.merge(commonAncestor, next, current, configuration); |
122 |
|
} catch (MergeException e) { |
123 |
0 |
result = new DefaultMergeResult<E>(commonAncestor, next, current); |
124 |
0 |
result.getLog().error("Failed to execute merge", e); |
125 |
|
} |
126 |
|
|
127 |
0 |
return result; |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
@return |
134 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
0 |
public Exception getLastError()... |
136 |
|
{ |
137 |
0 |
return (Exception) this.execution.getContext().getProperty(DIFF_ERROR_KEY); |
138 |
|
} |
139 |
|
} |