Reinitialize Sandbox Application
Reinitializes the SandBox space by using a SandBox space template |
Type | XAR |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
Provides an application to reinitialize periodically the SandBox space by overwriting it with clean pages located in another space.
This application provides the following:
- A page to launch manually (and/or by scheduler) the SandBox reinitialisation, in SandboxTemplate.ReinitSandboxMacro
- A template space of Sandbox (i.e. list of clean Sandbox pages):
- SandboxTemplate.WebHome (all languages are present)
- SandboxTemplate.TestPage1
- SandboxTemplate.TestPage2
- SandboxTemplate.TestPage3
- Configured to forbid access to the SandboxTemplate space for XWikiAllGroup and Unregistered Users (SandboxTemplate.WebPreferences)
- A Scheduler job to launch automatically the reinitialisation, in Scheduler/Reinit Sandbox from SandboxTemplate
If you click on "Reinitialisation of Sandbox space (without confirmation)" in SandboxTemplate.ReinitSandboxMacro, the macro will
- erase ALL Sandbox space pages
- overwrite Sandbox by this space SandboxTemplate
- and unhide Sandbox space
Of course, it is recommended to backup your Sandbox space before and test with this link: "Mode Debug: 'Reinitialisation of Sandbox space' (without modification)"
With 1.1 version, it is possible to reinitialize periodically another space (rather than Sandbox) by overwriting it with an another space (rather than SandboxTemplate): to manipulate with caution!.
Addon:
To empty old Sandbox pages deleted from Trash bin, you can add this piece of code in scheduler task:
// set to 1 if you want to empty the trash bin for the whole wiki
def emptybin = 1
// Empty old Sandbox pages deleted from Trash bin
def query = "select distinct ddoc.fullName from XWikiDeletedDocument as ddoc where ddoc.fullName like 'Sandbox.%'"
def trashed = xwiki.search(query)
if(trashed.size() > 0) {
def deleted = 0
println "<strong>Trashed documents:</strong>\n"
for(trash in trashed) {
println "* " + trash + " (" + xwiki.getDeletedDocuments(trash, "").size() + " versions)"
if (emptybin == 1)
xwiki.getDeletedDocuments(trash, "").each{
xwiki.getXWiki().getRecycleBinStore().deleteFromRecycleBin(
xwiki.getDocument(it.fullName).document,
it.getId(),
context,
true);
deleted++;
}
}
if (emptybin == 1) println "\nDeleted <strong>" + deleted + "</strong> trashed document. Trash bin is now empty."
}
else println "Everything's clean. No trashed document found."
Know bugs:
- English translation to be improved... :-)
copy from SanboxTemplate.WebHome copies only one language (because of copyDocument function limitation)(fixed by 1.0 version)
Prerequisites & Installation Instructions
By default the macro is not scheduled. You must schedule it and choose periodicity in ... scheduler.