1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.velocity.internal; |
21 |
|
|
22 |
|
import java.util.Properties; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
import javax.inject.Singleton; |
26 |
|
|
27 |
|
import org.apache.commons.lang3.exception.ExceptionUtils; |
28 |
|
import org.apache.velocity.tools.generic.ListTool; |
29 |
|
import org.apache.velocity.tools.generic.MathTool; |
30 |
|
import org.apache.velocity.tools.generic.NumberTool; |
31 |
|
import org.apache.velocity.tools.generic.SortTool; |
32 |
|
import org.xwiki.component.annotation.Component; |
33 |
|
import org.xwiki.component.phase.Initializable; |
34 |
|
import org.xwiki.component.phase.InitializationException; |
35 |
|
import org.xwiki.configuration.ConfigurationSource; |
36 |
|
import org.xwiki.text.StringUtils; |
37 |
|
import org.xwiki.velocity.VelocityConfiguration; |
38 |
|
import org.xwiki.velocity.internal.util.RestrictParseLocationEventHandler; |
39 |
|
import org.xwiki.velocity.introspection.DeprecatedCheckUberspector; |
40 |
|
import org.xwiki.velocity.introspection.MethodArgumentsUberspector; |
41 |
|
import org.xwiki.velocity.introspection.SecureUberspector; |
42 |
|
import org.xwiki.velocity.tools.CollectionsTool; |
43 |
|
import org.xwiki.velocity.tools.ComparisonDateTool; |
44 |
|
import org.xwiki.velocity.tools.EscapeTool; |
45 |
|
import org.xwiki.velocity.tools.JSONTool; |
46 |
|
import org.xwiki.velocity.tools.RegexTool; |
47 |
|
import org.xwiki.velocity.tools.URLTool; |
48 |
|
import org.xwiki.velocity.tools.nio.NIOTool; |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
@version |
54 |
|
@since |
55 |
|
|
56 |
|
@Component |
57 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (33) |
Complexity: 3 |
Complexity Density: 0.1 |
|
58 |
|
public class DefaultVelocityConfiguration implements Initializable, VelocityConfiguration |
59 |
|
{ |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
private static final String PREFIX = "velocity."; |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
protected Properties defaultTools = new Properties(); |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
@Inject |
74 |
|
private ConfigurationSource configuration; |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
private Properties defaultProperties = new Properties(); |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
|
81 |
1392 |
@Override... |
82 |
|
public void initialize() throws InitializationException |
83 |
|
{ |
84 |
|
|
85 |
1392 |
this.defaultTools.setProperty("listtool", ListTool.class.getName()); |
86 |
1392 |
this.defaultTools.setProperty("numbertool", NumberTool.class.getName()); |
87 |
1392 |
this.defaultTools.setProperty("datetool", ComparisonDateTool.class.getName()); |
88 |
1392 |
this.defaultTools.setProperty("mathtool", MathTool.class.getName()); |
89 |
1392 |
this.defaultTools.setProperty("sorttool", SortTool.class.getName()); |
90 |
1392 |
this.defaultTools.setProperty("escapetool", EscapeTool.class.getName()); |
91 |
1392 |
this.defaultTools.setProperty("regextool", RegexTool.class.getName()); |
92 |
1392 |
this.defaultTools.setProperty("collectionstool", CollectionsTool.class.getName()); |
93 |
1392 |
this.defaultTools.setProperty("stringtool", StringUtils.class.getName()); |
94 |
1392 |
this.defaultTools.setProperty("jsontool", JSONTool.class.getName()); |
95 |
1392 |
this.defaultTools.setProperty("urltool", URLTool.class.getName()); |
96 |
1392 |
this.defaultTools.setProperty("exceptiontool", ExceptionUtils.class.getName()); |
97 |
1392 |
this.defaultTools.setProperty("niotool", NIOTool.class.getName()); |
98 |
|
|
99 |
|
|
100 |
1392 |
this.defaultProperties.setProperty("directive.set.null.allowed", Boolean.TRUE.toString()); |
101 |
1392 |
this.defaultProperties.setProperty("velocimacro.messages.on", Boolean.FALSE.toString()); |
102 |
1392 |
this.defaultProperties.setProperty("velocimacro.max.depth", "100"); |
103 |
1392 |
this.defaultProperties.setProperty("resource.manager.logwhenfound", Boolean.FALSE.toString()); |
104 |
1392 |
this.defaultProperties.setProperty("velocimacro.permissions.allow.inline.local.scope", Boolean.TRUE.toString()); |
105 |
|
|
106 |
1392 |
this.defaultProperties.setProperty("eventhandler.include.class", |
107 |
|
RestrictParseLocationEventHandler.class.getName()); |
108 |
|
|
109 |
1392 |
this.defaultProperties.setProperty("runtime.introspector.uberspect", StringUtils.join( |
110 |
|
new String[] { SecureUberspector.class.getName(), DeprecatedCheckUberspector.class.getName(), |
111 |
|
MethodArgumentsUberspector.class.getName() }, ',')); |
112 |
|
|
113 |
1392 |
this.defaultProperties.setProperty("template.provide.scope.control", Boolean.TRUE.toString()); |
114 |
1392 |
this.defaultProperties.setProperty("macro.provide.scope.control", Boolean.TRUE.toString()); |
115 |
|
} |
116 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
117 |
318 |
@Override... |
118 |
|
public Properties getProperties() |
119 |
|
{ |
120 |
|
|
121 |
318 |
Properties props = new Properties(); |
122 |
318 |
props.putAll(this.defaultProperties); |
123 |
318 |
props.putAll(this.configuration.getProperty(PREFIX + "properties", Properties.class)); |
124 |
318 |
return props; |
125 |
|
} |
126 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
127 |
1362 |
@Override... |
128 |
|
public Properties getTools() |
129 |
|
{ |
130 |
|
|
131 |
1362 |
Properties props = new Properties(); |
132 |
1362 |
props.putAll(this.defaultTools); |
133 |
1362 |
props.putAll(this.configuration.getProperty(PREFIX + "tools", Properties.class)); |
134 |
1362 |
return props; |
135 |
|
} |
136 |
|
} |