1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.doc; |
21 |
|
|
22 |
|
import java.util.Date; |
23 |
|
import java.util.List; |
24 |
|
import java.util.Locale; |
25 |
|
import java.util.Map; |
26 |
|
|
27 |
|
import org.dom4j.Document; |
28 |
|
import org.suigeneris.jrcs.rcs.Version; |
29 |
|
import org.xwiki.context.Execution; |
30 |
|
import org.xwiki.model.reference.DocumentReference; |
31 |
|
import org.xwiki.model.reference.EntityReference; |
32 |
|
import org.xwiki.rendering.block.XDOM; |
33 |
|
import org.xwiki.rendering.syntax.Syntax; |
34 |
|
|
35 |
|
import com.xpn.xwiki.XWikiContext; |
36 |
|
import com.xpn.xwiki.XWikiException; |
37 |
|
import com.xpn.xwiki.objects.BaseObject; |
38 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
39 |
|
import com.xpn.xwiki.store.XWikiStoreInterface; |
40 |
|
import com.xpn.xwiki.web.Utils; |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
@link |
55 |
|
@link |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
@version |
61 |
|
@since |
62 |
|
|
|
|
| 0% |
Uncovered Elements: 107 (107) |
Complexity: 47 |
Complexity Density: 0.81 |
|
63 |
|
public class LazyXWikiDocument extends XWikiDocument |
64 |
|
{ |
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
private XWikiDocument document; |
69 |
|
|
70 |
|
|
71 |
|
@deprecated@link |
72 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
73 |
0 |
@Deprecated... |
74 |
|
public LazyXWikiDocument() |
75 |
|
{ |
76 |
|
|
77 |
|
} |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
79 |
0 |
public LazyXWikiDocument(DocumentReference documentReference)... |
80 |
|
{ |
81 |
0 |
super(documentReference); |
82 |
|
} |
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
@return |
88 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 6 |
Complexity Density: 0.35 |
|
89 |
0 |
private XWikiDocument getDocument()... |
90 |
|
{ |
91 |
0 |
if (this.document == null) { |
92 |
|
|
93 |
0 |
XWikiContext context = |
94 |
|
(XWikiContext) Utils.getComponent(Execution.class).getContext().getProperty("xwikicontext"); |
95 |
|
|
96 |
0 |
XWikiDocument doc = new XWikiDocument(getDocumentReference(), getLocale()); |
97 |
|
|
98 |
0 |
String currentWiki = context.getWikiId(); |
99 |
0 |
try { |
100 |
|
|
101 |
0 |
context.setWikiId(getDocumentReference().getWikiReference().getName()); |
102 |
|
|
103 |
0 |
if (this.version == null) { |
104 |
0 |
this.document = context.getWiki().getDocument(doc, context); |
105 |
|
} else { |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
0 |
doc = context.getWiki().getNotCacheStore().loadXWikiDoc(doc, context); |
110 |
0 |
if (doc.getRCSVersion().equals(this.version)) { |
111 |
|
|
112 |
0 |
this.document = doc; |
113 |
|
} else { |
114 |
|
|
115 |
0 |
try { |
116 |
0 |
this.document = |
117 |
|
context.getWiki().getVersioningStore() |
118 |
|
.loadXWikiDoc(doc, this.version.toString(), context); |
119 |
|
} catch (XWikiException e) { |
120 |
|
|
121 |
0 |
this.document = doc; |
122 |
|
} |
123 |
|
} |
124 |
|
} |
125 |
|
} catch (XWikiException e) { |
126 |
0 |
throw new RuntimeException("Failed to get document [" + this + "]", e); |
127 |
|
} finally { |
128 |
0 |
context.setWikiId(currentWiki); |
129 |
|
} |
130 |
|
} |
131 |
|
|
132 |
0 |
return this.document; |
133 |
|
} |
134 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
135 |
0 |
@Override... |
136 |
|
public Version getRCSVersion() |
137 |
|
{ |
138 |
0 |
if (this.version == null) { |
139 |
0 |
return getDocument().getRCSVersion(); |
140 |
|
} else { |
141 |
0 |
return this.version; |
142 |
|
} |
143 |
|
} |
144 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
145 |
0 |
@Override... |
146 |
|
public String getContent() |
147 |
|
{ |
148 |
0 |
return getDocument().getContent(); |
149 |
|
} |
150 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
151 |
0 |
@Override... |
152 |
|
public Map<DocumentReference, List<BaseObject>> getXObjects() |
153 |
|
{ |
154 |
0 |
return getDocument().getXObjects(); |
155 |
|
} |
156 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
157 |
0 |
@Override... |
158 |
|
public BaseClass getXClass() |
159 |
|
{ |
160 |
0 |
return getDocument().getXClass(); |
161 |
|
} |
162 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
163 |
0 |
@Override... |
164 |
|
public String getXClassXML() |
165 |
|
{ |
166 |
0 |
return getDocument().getXClassXML(); |
167 |
|
} |
168 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
169 |
0 |
@Override... |
170 |
|
public DocumentReference getAuthorReference() |
171 |
|
{ |
172 |
0 |
return getDocument().getAuthorReference(); |
173 |
|
} |
174 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
175 |
0 |
@Override... |
176 |
|
public DocumentReference getContentAuthorReference() |
177 |
|
{ |
178 |
0 |
return getDocument().getContentAuthorReference(); |
179 |
|
} |
180 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
181 |
0 |
@Override... |
182 |
|
public DocumentReference getCreatorReference() |
183 |
|
{ |
184 |
0 |
return super.getCreatorReference(); |
185 |
|
} |
186 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
187 |
0 |
@Override... |
188 |
|
public Date getDate() |
189 |
|
{ |
190 |
0 |
return getDocument().getDate(); |
191 |
|
} |
192 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
193 |
0 |
@Override... |
194 |
|
public Date getCreationDate() |
195 |
|
{ |
196 |
0 |
return getDocument().getCreationDate(); |
197 |
|
} |
198 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
199 |
0 |
@Override... |
200 |
|
public Date getContentUpdateDate() |
201 |
|
{ |
202 |
0 |
return getDocument().getContentUpdateDate(); |
203 |
|
} |
204 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
205 |
0 |
@Override... |
206 |
|
public String getMeta() |
207 |
|
{ |
208 |
0 |
return getDocument().getMeta(); |
209 |
|
} |
210 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
211 |
0 |
@Override... |
212 |
|
public String getTitle() |
213 |
|
{ |
214 |
0 |
return getDocument().getTitle(); |
215 |
|
} |
216 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
217 |
0 |
@Override... |
218 |
|
public String getFormat() |
219 |
|
{ |
220 |
0 |
return getDocument().getFormat(); |
221 |
|
} |
222 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
223 |
0 |
@Override... |
224 |
|
public Locale getDefaultLocale() |
225 |
|
{ |
226 |
0 |
return getDocument().getDefaultLocale(); |
227 |
|
} |
228 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
229 |
0 |
@Override... |
230 |
|
public int getTranslation() |
231 |
|
{ |
232 |
0 |
return getDocument().getTranslation(); |
233 |
|
} |
234 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
235 |
0 |
@Override... |
236 |
|
public String getCustomClass() |
237 |
|
{ |
238 |
0 |
return getDocument().getCustomClass(); |
239 |
|
} |
240 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
241 |
0 |
@Override... |
242 |
|
public EntityReference getRelativeParentReference() |
243 |
|
{ |
244 |
0 |
return getDocument().getRelativeParentReference(); |
245 |
|
} |
246 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
247 |
0 |
@Override... |
248 |
|
public DocumentReference getParentReference() |
249 |
|
{ |
250 |
0 |
return getDocument().getParentReference(); |
251 |
|
} |
252 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
253 |
0 |
@Override... |
254 |
|
public int getElements() |
255 |
|
{ |
256 |
0 |
return getDocument().getElements(); |
257 |
|
} |
258 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
259 |
0 |
@Override... |
260 |
|
public String getDefaultTemplate() |
261 |
|
{ |
262 |
0 |
return getDocument().getDefaultTemplate(); |
263 |
|
} |
264 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
265 |
0 |
@Override... |
266 |
|
public String getValidationScript() |
267 |
|
{ |
268 |
0 |
return getDocument().getValidationScript(); |
269 |
|
} |
270 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
271 |
0 |
@Override... |
272 |
|
public String getComment() |
273 |
|
{ |
274 |
0 |
return getDocument().getComment(); |
275 |
|
} |
276 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
277 |
0 |
@Override... |
278 |
|
public Syntax getSyntax() |
279 |
|
{ |
280 |
0 |
return getDocument().getSyntax(); |
281 |
|
} |
282 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
283 |
0 |
@Override... |
284 |
|
public Boolean isHidden() |
285 |
|
{ |
286 |
0 |
return getDocument().isHidden(); |
287 |
|
} |
288 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
289 |
0 |
@Override... |
290 |
|
public XWikiDocumentArchive getDocumentArchive() |
291 |
|
{ |
292 |
0 |
return getDocument().getDocumentArchive(); |
293 |
|
} |
294 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
295 |
0 |
@Override... |
296 |
|
public void loadArchive(XWikiContext context) throws XWikiException |
297 |
|
{ |
298 |
0 |
getDocument().loadArchive(context); |
299 |
|
} |
300 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
301 |
0 |
@Override... |
302 |
|
public XWikiDocumentArchive getDocumentArchive(XWikiContext context) throws XWikiException |
303 |
|
{ |
304 |
0 |
return getDocument().getDocumentArchive(context); |
305 |
|
} |
306 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
307 |
0 |
@Override... |
308 |
|
public XWikiStoreInterface getStore() |
309 |
|
{ |
310 |
0 |
return getDocument().getStore(); |
311 |
|
} |
312 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
313 |
0 |
@Override... |
314 |
|
public long getId() |
315 |
|
{ |
316 |
0 |
return getDocument().getId(); |
317 |
|
} |
318 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
319 |
0 |
@Override... |
320 |
|
public XWikiStoreInterface getStore(XWikiContext context) |
321 |
|
{ |
322 |
0 |
return getDocument().getStore(context); |
323 |
|
} |
324 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
325 |
0 |
@Override... |
326 |
|
public XDOM getXDOM() |
327 |
|
{ |
328 |
0 |
return getDocument().getXDOM(); |
329 |
|
} |
330 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
331 |
0 |
@Override... |
332 |
|
public String getTags(XWikiContext context) |
333 |
|
{ |
334 |
0 |
return getDocument().getTags(context); |
335 |
|
} |
336 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
337 |
0 |
@Override... |
338 |
|
public List<String> getTagsPossibleValues(XWikiContext context) |
339 |
|
{ |
340 |
0 |
return getDocument().getTagsPossibleValues(context); |
341 |
|
} |
342 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
343 |
0 |
@Override... |
344 |
|
public boolean isFromCache() |
345 |
|
{ |
346 |
0 |
return getDocument().isFromCache(); |
347 |
|
} |
348 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
349 |
0 |
@Override... |
350 |
|
public boolean isMostRecent() |
351 |
|
{ |
352 |
0 |
return getDocument().isMostRecent(); |
353 |
|
} |
354 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
355 |
0 |
@Override... |
356 |
|
public Document toXMLDocument(boolean bWithObjects, boolean bWithRendering, boolean bWithAttachmentContent, |
357 |
|
boolean bWithVersions, XWikiContext context) throws XWikiException |
358 |
|
{ |
359 |
0 |
return getDocument() |
360 |
|
.toXMLDocument(bWithObjects, bWithRendering, bWithAttachmentContent, bWithVersions, context); |
361 |
|
} |
362 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
363 |
0 |
@Override... |
364 |
|
public Object getWikiNode() |
365 |
|
{ |
366 |
0 |
return getDocument().getWikiNode(); |
367 |
|
} |
368 |
|
} |