1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.blossom.setup; |
35 |
|
|
36 |
|
import javax.jcr.Property; |
37 |
|
import javax.jcr.RepositoryException; |
38 |
|
import javax.jcr.Session; |
39 |
|
|
40 |
|
import org.apache.commons.lang.ArrayUtils; |
41 |
|
|
42 |
|
import info.magnolia.module.InstallContext; |
43 |
|
import info.magnolia.module.delta.AbstractTask; |
44 |
|
import info.magnolia.module.delta.TaskExecutionException; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@since |
50 |
|
|
|
|
| 93.8% |
Uncovered Elements: 1 (16) |
Complexity: 4 |
Complexity Density: 0.33 |
|
51 |
|
public class MultiCheckAndModifyPropertyValueTask extends AbstractTask { |
52 |
|
|
53 |
|
private final String nodePath; |
54 |
|
private final String propertyName; |
55 |
|
private final String[] expectedValues; |
56 |
|
private final String newValue; |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
58 |
5 |
public MultiCheckAndModifyPropertyValueTask(String name, String description, String nodePath, String propertyName, String[] expectedValues, String newValue) {... |
59 |
5 |
super(name, description); |
60 |
5 |
this.nodePath = nodePath; |
61 |
5 |
this.propertyName = propertyName; |
62 |
5 |
this.newValue = newValue; |
63 |
5 |
this.expectedValues = expectedValues; |
64 |
|
} |
65 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
66 |
5 |
@Override... |
67 |
|
public void execute(InstallContext installContext) throws TaskExecutionException { |
68 |
5 |
String propertyPath = nodePath + "/" + propertyName; |
69 |
5 |
try { |
70 |
5 |
Session session = installContext.getConfigJCRSession(); |
71 |
5 |
Property property = session.getProperty(propertyPath); |
72 |
5 |
if (ArrayUtils.contains(expectedValues, property.getString())) { |
73 |
3 |
property.setValue(newValue); |
74 |
|
} |
75 |
|
} catch (RepositoryException e) { |
76 |
0 |
installContext.error("Could not check property " + propertyPath + ", should be set to " + newValue, e); |
77 |
|
} |
78 |
|
} |
79 |
|
} |