Last modified by Pascal Bastien on 2016/04/05 10:38

From version 29.3
edited by Guillaume Lerouge
on 2014/09/18 11:42
To version 30.1
edited by Pascal Bastien
on 2016/04/05 10:38
Change comment: Add a grrovy script to empty old Sandbox pages deleted from Trash bin

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.GuillaumeLerouge
1 +xwiki:XWiki.pbas
ExtensionCode.ExtensionClass[0]
Description
... ... @@ -21,6 +21,35 @@
21 21  
22 22  {{image reference="ReinitSandbox_main.png"/}}
23 23  
24 +== Addon: ==
25 +To empty old Sandbox pages deleted from Trash bin, you can add this piece of code in scheduler task:
26 +{{code}}
27 +// set to 1 if you want to empty the trash bin for the whole wiki
28 +def emptybin = 1
29 +// Empty old Sandbox pages deleted from Trash bin
30 +def query = "select distinct ddoc.fullName from XWikiDeletedDocument as ddoc where ddoc.fullName like 'Sandbox.%'"
31 +
32 +def trashed = xwiki.search(query)
33 +if(trashed.size() > 0) {
34 + def deleted = 0
35 + println "<strong>Trashed documents:</strong>\n"
36 + for(trash in trashed) {
37 + println "* " + trash + " (" + xwiki.getDeletedDocuments(trash, "").size() + " versions)"
38 + if (emptybin == 1)
39 + xwiki.getDeletedDocuments(trash, "").each{
40 + xwiki.getXWiki().getRecycleBinStore().deleteFromRecycleBin(
41 + xwiki.getDocument(it.fullName).document,
42 + it.getId(),
43 + context,
44 + true);
45 + deleted++;
46 + }
47 + }
48 + if (emptybin == 1) println "\nDeleted <strong>" + deleted + "</strong> trashed document. Trash bin is now empty."
49 +}
50 +else println "Everything's clean. No trashed document found."
51 +{{/code}}
52 +
24 24  Know bugs:
25 25  * English translation to be improved... :-)
26 26  * --copy from ##SanboxTemplate.WebHome## copies only one language (because of copyDocument function limitation)-- (fixed by 1.0 version)
ExtensionCode.ExtensionVersionClass[0]
Release Notes

Get Connected