1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.filter.instance.input; |
21 |
|
|
22 |
|
import java.lang.reflect.ParameterizedType; |
23 |
|
import java.util.Arrays; |
24 |
|
import java.util.Collection; |
25 |
|
import java.util.List; |
26 |
|
import java.util.Locale; |
27 |
|
import java.util.Map; |
28 |
|
import java.util.Stack; |
29 |
|
|
30 |
|
import javax.inject.Inject; |
31 |
|
|
32 |
|
import org.apache.commons.lang3.ArrayUtils; |
33 |
|
import org.xwiki.component.phase.Initializable; |
34 |
|
import org.xwiki.component.phase.InitializationException; |
35 |
|
import org.xwiki.component.util.ReflectionUtils; |
36 |
|
import org.xwiki.filter.FilterDescriptorManager; |
37 |
|
import org.xwiki.filter.FilterEventParameters; |
38 |
|
import org.xwiki.filter.FilterException; |
39 |
|
import org.xwiki.filter.descriptor.FilterStreamDescriptor; |
40 |
|
import org.xwiki.model.EntityType; |
41 |
|
import org.xwiki.model.reference.EntityReference; |
42 |
|
|
43 |
|
|
44 |
|
@param@link |
45 |
|
@version |
46 |
|
@since |
47 |
|
|
|
|
| 72.1% |
Uncovered Elements: 12 (43) |
Complexity: 25 |
Complexity Density: 1.39 |
|
48 |
|
public abstract class AbstractInstanceInputEventGenerator<F> implements InstanceInputEventGenerator, Initializable |
49 |
|
{ |
50 |
|
@Inject |
51 |
|
private FilterDescriptorManager filterDescriptorManager; |
52 |
|
|
53 |
|
private List<Class<?>> filerInterfaces; |
54 |
|
|
55 |
|
protected Map<String, Object> properties; |
56 |
|
|
57 |
|
protected Object filter; |
58 |
|
|
59 |
|
protected F proxyFilter; |
60 |
|
|
61 |
|
protected String currentWiki; |
62 |
|
|
63 |
|
protected Stack<String> currentSpaces = new Stack<String>(); |
64 |
|
|
65 |
|
protected EntityReference currentReference; |
66 |
|
|
67 |
|
protected FilterStreamDescriptor descriptor; |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
69 |
5 |
@Override... |
70 |
|
public void initialize() throws InitializationException |
71 |
|
{ |
72 |
|
|
73 |
5 |
ParameterizedType genericType = |
74 |
|
(ParameterizedType) ReflectionUtils.resolveType(AbstractInstanceInputEventGenerator.class, getClass()); |
75 |
5 |
this.filerInterfaces = |
76 |
|
Arrays.<Class<?>>asList(ReflectionUtils.getTypeClass(genericType.getActualTypeArguments()[0])); |
77 |
|
} |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
79 |
0 |
@Override... |
80 |
|
public FilterStreamDescriptor getDescriptor() |
81 |
|
{ |
82 |
0 |
return this.descriptor; |
83 |
|
} |
84 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
0 |
protected void setDescriptor(FilterStreamDescriptor descriptor)... |
86 |
|
{ |
87 |
0 |
this.descriptor = descriptor; |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
2 |
@Override... |
91 |
|
public Collection<Class<?>> getFilterInterfaces() throws FilterException |
92 |
|
{ |
93 |
2 |
return this.filerInterfaces; |
94 |
|
} |
95 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
96 |
1 |
@Override... |
97 |
|
public void setWikiFarmParameters(FilterEventParameters parameters) throws FilterException |
98 |
|
{ |
99 |
|
|
100 |
|
} |
101 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
102 |
1 |
@Override... |
103 |
|
public void setWikiParameters(String name, FilterEventParameters parameters) throws FilterException |
104 |
|
{ |
105 |
|
|
106 |
|
} |
107 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
108 |
3 |
@Override... |
109 |
|
public void setWikiSpaceParameters(String name, FilterEventParameters parameters) throws FilterException |
110 |
|
{ |
111 |
|
|
112 |
|
} |
113 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
114 |
0 |
@Override... |
115 |
|
public void setWikiDocumentParameters(String name, FilterEventParameters parameters) throws FilterException |
116 |
|
{ |
117 |
|
|
118 |
|
} |
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
120 |
1 |
@Override... |
121 |
|
public void setProperties(Map<String, Object> properties) |
122 |
|
{ |
123 |
1 |
this.properties = properties; |
124 |
|
} |
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
126 |
1 |
@Override... |
127 |
|
public void setFilter(Object filter) |
128 |
|
{ |
129 |
1 |
this.filter = filter; |
130 |
1 |
this.proxyFilter = this.filterDescriptorManager.createFilterProxy(filter, |
131 |
|
this.filerInterfaces.toArray(ArrayUtils.EMPTY_CLASS_ARRAY)); |
132 |
|
} |
133 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
134 |
1 |
@Override... |
135 |
|
public void beginWikiFarm(FilterEventParameters parameters) throws FilterException |
136 |
|
{ |
137 |
|
} |
138 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
139 |
1 |
@Override... |
140 |
|
public void endWikiFarm(FilterEventParameters parameters) throws FilterException |
141 |
|
{ |
142 |
|
} |
143 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
144 |
1 |
@Override... |
145 |
|
public void beginWiki(String name, FilterEventParameters parameters) throws FilterException |
146 |
|
{ |
147 |
1 |
this.currentWiki = name; |
148 |
1 |
this.currentReference = new EntityReference(this.currentWiki, EntityType.WIKI); |
149 |
|
} |
150 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
151 |
1 |
@Override... |
152 |
|
public void endWiki(String name, FilterEventParameters parameters) throws FilterException |
153 |
|
{ |
154 |
1 |
this.currentWiki = null; |
155 |
1 |
this.currentReference = this.currentReference.getParent(); |
156 |
|
} |
157 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
158 |
3 |
@Override... |
159 |
|
public void beginWikiSpace(String name, FilterEventParameters parameters) throws FilterException |
160 |
|
{ |
161 |
3 |
this.currentSpaces.push(name); |
162 |
3 |
this.currentReference = new EntityReference(name, EntityType.SPACE, this.currentReference); |
163 |
|
} |
164 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
165 |
3 |
@Override... |
166 |
|
public void endWikiSpace(String name, FilterEventParameters parameters) throws FilterException |
167 |
|
{ |
168 |
3 |
this.currentSpaces.pop(); |
169 |
3 |
this.currentReference = this.currentReference.getParent(); |
170 |
|
} |
171 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
172 |
3 |
@Override... |
173 |
|
public void beginWikiDocument(String name, FilterEventParameters parameters) throws FilterException |
174 |
|
{ |
175 |
3 |
this.currentReference = new EntityReference(name, EntityType.DOCUMENT, this.currentReference); |
176 |
|
} |
177 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
178 |
3 |
@Override... |
179 |
|
public void endWikiDocument(String name, FilterEventParameters parameters) throws FilterException |
180 |
|
{ |
181 |
3 |
this.currentReference = this.currentReference.getParent(); |
182 |
|
} |
183 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
184 |
0 |
@Override... |
185 |
|
public void beginWikiDocumentLocale(Locale locale, FilterEventParameters parameters) throws FilterException |
186 |
|
{ |
187 |
|
|
188 |
|
} |
189 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
190 |
0 |
@Override... |
191 |
|
public void endWikiDocumentLocale(Locale locale, FilterEventParameters parameters) throws FilterException |
192 |
|
{ |
193 |
|
} |
194 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
195 |
0 |
@Override... |
196 |
|
public void beginWikiDocumentRevision(String version, FilterEventParameters parameters) throws FilterException |
197 |
|
{ |
198 |
|
|
199 |
|
} |
200 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
201 |
0 |
@Override... |
202 |
|
public void endWikiDocumentRevision(String version, FilterEventParameters parameters) throws FilterException |
203 |
|
{ |
204 |
|
|
205 |
|
} |
206 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
207 |
0 |
@Override... |
208 |
|
public void beginUnknwon(String id, FilterEventParameters parameters) throws FilterException |
209 |
|
{ |
210 |
|
} |
211 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
212 |
0 |
@Override... |
213 |
|
public void endUnknwon(String id, FilterEventParameters parameters) throws FilterException |
214 |
|
{ |
215 |
|
} |
216 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
217 |
0 |
@Override... |
218 |
|
public void onUnknwon(String id, FilterEventParameters parameters) throws FilterException |
219 |
|
{ |
220 |
|
} |
221 |
|
} |