Wiki source code of Cache

Last modified by Thomas Mortagne on 2018/05/30 10:38

Hide last authors
Thomas Mortagne 25.1 1 {{groovy}}
Thomas Mortagne 29.1 2 def documentReference = services.model.resolveDocument('FlamingoThemes.Iceberg')
Thomas Mortagne 8.1 3
Thomas Mortagne 27.1 4 def documentInfos(document) {
Thomas Mortagne 31.1 5 println 'isnew: ' + document.isNew()
6 println 'document title size: ' + document.title.length()
7 println 'document content size: ' + document.content.length()
Thomas Mortagne 1.1 8
Thomas Mortagne 25.1 9 println 'document objects:'
Thomas Mortagne 28.1 10 for (objectsEntry in document.getXObjects().entrySet()) {
Thomas Mortagne 35.2 11 println '* ' + objectsEntry.key + ' (' + (objectsEntry.value ? objectsEntry.value.size() : 'null') + ')'
Thomas Mortagne 25.1 12 }
Thomas Mortagne 1.1 13
Thomas Mortagne 34.1 14 println ''
15
Thomas Mortagne 35.1 16 println 'document attachments:'
Thomas Mortagne 25.1 17 for (attachment in document.attachmentList) {
Thomas Mortagne 32.1 18 println '* ' + attachment.filename
Thomas Mortagne 25.1 19 }
Thomas Mortagne 37.1 20
Thomas Mortagne 38.1 21 println ''
22
Thomas Mortagne 37.1 23 println 'document attachments to remove:'
24 for (attachment in document.attachmentsToRemove) {
25 println '* ' + attachment.attachment.filename
26 }
Thomas Mortagne 25.1 27 }
Thomas Mortagne 1.1 28
Thomas Mortagne 27.1 29 def protectedXWiki = xwiki.getXWiki()
30 def cachedDocument = protectedXWiki.getDocument(documentReference, xcontext.context)
Thomas Mortagne 23.1 31
Thomas Mortagne 30.1 32 println '= Cached document ='
Thomas Mortagne 23.1 33
Thomas Mortagne 25.1 34 documentInfos(cachedDocument)
Thomas Mortagne 23.1 35
Thomas Mortagne 30.1 36 println '= Original cached document ='
Thomas Mortagne 23.1 37
Thomas Mortagne 25.1 38 documentInfos(cachedDocument.originalDocument)
Thomas Mortagne 23.1 39
Thomas Mortagne 30.1 40 println '= Database document ='
Thomas Mortagne 24.1 41
Thomas Mortagne 27.1 42 def databaseDocument = protectedXWiki.hibernateStore.loadXWikiDoc(new com.xpn.xwiki.doc.XWikiDocument(documentReference), xcontext.context)
Thomas Mortagne 24.1 43
Thomas Mortagne 25.1 44 documentInfos(databaseDocument)
45 {{/groovy}}