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.resources.setup; |
35 |
|
|
36 |
|
import info.magnolia.cms.util.ClasspathResourcesUtil; |
37 |
|
import info.magnolia.module.InstallContext; |
38 |
|
import info.magnolia.module.delta.AbstractRepositoryTask; |
39 |
|
import info.magnolia.module.delta.TaskExecutionException; |
40 |
|
import info.magnolia.module.resources.ResourceTypes; |
41 |
|
|
42 |
|
import org.apache.commons.lang3.StringUtils; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
|
|
| 75.7% |
Uncovered Elements: 9 (37) |
Complexity: 13 |
Complexity Density: 0.59 |
|
47 |
|
public class InstallTextResourcesTask extends AbstractRepositoryTask { |
48 |
|
|
49 |
|
protected String pattern; |
50 |
|
protected String template; |
51 |
|
private final String modelClass; |
52 |
|
private boolean processed = true; |
53 |
|
private final boolean preserveResourcesParameters; |
54 |
|
private boolean stripExtension; |
55 |
|
private String encoding = InstallTextResourceTask.DEFAULT_ENCODING; |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
57 |
1 |
public InstallTextResourcesTask(String pattern) {... |
58 |
1 |
this(pattern, null, false); |
59 |
|
} |
60 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
0 |
public InstallTextResourcesTask(String pattern, String template) {... |
62 |
0 |
this(pattern, template, false); |
63 |
|
} |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
0 |
public InstallTextResourcesTask(String pattern, String template, String encoding) {... |
66 |
0 |
this(pattern, template, encoding, false); |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
1 |
public InstallTextResourcesTask(String pattern, String template, boolean preserveResourcesParameters) {... |
70 |
1 |
this(pattern, template, true, null, preserveResourcesParameters); |
71 |
|
} |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
73 |
0 |
public InstallTextResourcesTask(String pattern, String template, String encoding, boolean preserveResourcesParameters) {... |
74 |
0 |
this(pattern, template, encoding, true, null, preserveResourcesParameters); |
75 |
|
} |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
1 |
public InstallTextResourcesTask(String pattern, String template, boolean processed, String modelClass, boolean preserveResourcesParameters) {... |
78 |
1 |
this("Install text resources", "Installs all resources matching the " + pattern + " pattern.", InstallTextResourceTask.DEFAULT_ENCODING, pattern, template, processed, modelClass, preserveResourcesParameters); |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
1 |
public InstallTextResourcesTask(String pattern, String template, String encoding, boolean processed, String modelClass, boolean preserveResourcesParameters) {... |
82 |
1 |
this("Install text resources", "Installs all resources matching the " + pattern + " pattern.", encoding, pattern, template, processed, modelClass, preserveResourcesParameters); |
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
2 |
public InstallTextResourcesTask(String taskName, String taskDescription, String encoding, String pattern, String template, boolean processed,... |
86 |
|
String modelClass, boolean preserveResourcesParameters) { |
87 |
2 |
this(taskName, taskDescription, encoding, pattern, template, processed, modelClass, preserveResourcesParameters, true); |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
90 |
3 |
public InstallTextResourcesTask(String taskName, String taskDescription, String encoding, String pattern, String template, boolean processed,... |
91 |
|
String modelClass, boolean preserveResourcesParameters, boolean stripExtension) { |
92 |
3 |
super(taskName, taskDescription); |
93 |
3 |
this.encoding = encoding; |
94 |
3 |
this.pattern = pattern; |
95 |
3 |
this.template = template; |
96 |
3 |
this.modelClass = modelClass; |
97 |
3 |
this.processed = processed; |
98 |
3 |
this.preserveResourcesParameters = preserveResourcesParameters; |
99 |
3 |
this.stripExtension = stripExtension; |
100 |
|
} |
101 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
102 |
2 |
@Override... |
103 |
|
public void doExecute(InstallContext ctx) throws TaskExecutionException { |
104 |
2 |
final String[] resources = findResources(); |
105 |
|
|
106 |
4 |
for (int i = 0; i < resources.length; i++) { |
107 |
2 |
String resource = resources[i]; |
108 |
2 |
String template = StringUtils.isNotEmpty(this.template) ? this.template : ResourceTypes.determineType(resource, processed); |
109 |
2 |
new InstallTextResourceTask(resource, template, encoding, null, null, null, modelClass, preserveResourcesParameters, stripExtension).execute(ctx); |
110 |
|
} |
111 |
|
} |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
0 |
protected String[] findResources() {... |
114 |
0 |
return ClasspathResourcesUtil.findResources(pattern); |
115 |
|
} |
116 |
|
|
117 |
|
} |