Wiki source code of Cache
Last modified by Thomas Mortagne on 2018/05/30 10:38
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{groovy}} | ||
2 | def documentReference = services.model.resolveDocument('FlamingoThemes.Iceberg') | ||
3 | |||
4 | def documentInfos(document) { | ||
5 | println 'isnew: ' + document.isNew() | ||
6 | println 'document title size: ' + document.title.length() | ||
7 | println 'document content size: ' + document.content.length() | ||
8 | |||
9 | println 'document objects:' | ||
10 | for (objectsEntry in document.getXObjects().entrySet()) { | ||
11 | println '* ' + objectsEntry.key + ' (' + (objectsEntry.value ? objectsEntry.value.size() : 'null') + ')' | ||
12 | } | ||
13 | |||
14 | println '' | ||
15 | |||
16 | println 'document attachments:' | ||
17 | for (attachment in document.attachmentList) { | ||
18 | println '* ' + attachment.filename | ||
19 | } | ||
20 | |||
21 | println '' | ||
22 | |||
23 | println 'document attachments to remove:' | ||
24 | for (attachment in document.attachmentsToRemove) { | ||
25 | println '* ' + attachment.attachment.filename | ||
26 | } | ||
27 | } | ||
28 | |||
29 | def protectedXWiki = xwiki.getXWiki() | ||
30 | def cachedDocument = protectedXWiki.getDocument(documentReference, xcontext.context) | ||
31 | |||
32 | println '= Cached document =' | ||
33 | |||
34 | documentInfos(cachedDocument) | ||
35 | |||
36 | println '= Original cached document =' | ||
37 | |||
38 | documentInfos(cachedDocument.originalDocument) | ||
39 | |||
40 | println '= Database document =' | ||
41 | |||
42 | def databaseDocument = protectedXWiki.hibernateStore.loadXWikiDoc(new com.xpn.xwiki.doc.XWikiDocument(documentReference), xcontext.context) | ||
43 | |||
44 | documentInfos(databaseDocument) | ||
45 | {{/groovy}} |