Wiki source code of largeExportBySpace
Last modified by Tobias Wintrich on 2026/01/16 15:05
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{groovy}} | ||
| 2 | |||
| 3 | import com.xpn.xwiki.*; | ||
| 4 | import com.xpn.xwiki.doc.*; | ||
| 5 | import com.xpn.xwiki.plugin.packaging.*; | ||
| 6 | import java.util.zip.*; | ||
| 7 | import com.xpn.xwiki.util.Util; | ||
| 8 | |||
| 9 | def getXAR(String filename, XWikiContext context) { | ||
| 10 | def request = xcontext.getRequest(); | ||
| 11 | def export = xcontext.getXWiki().getPluginApi("package", xcontext.getContext()); | ||
| 12 | spaces = request.getParameterMap().get("spaces"); | ||
| 13 | export.setWithVersions(true); | ||
| 14 | export.setAuthorName("XWiki.Admin"); | ||
| 15 | export.setDescription(""); | ||
| 16 | export.setLicence(""); | ||
| 17 | export.setVersion(""); | ||
| 18 | export.setBackupPack(true); | ||
| 19 | export.setName("backup"); | ||
| 20 | def pack = export.getPackage(); | ||
| 21 | for(space in spaces){ | ||
| 22 | for(docName in xwiki.getSpaceDocsName(space)){ | ||
| 23 | println "* Exported ${docName} page of space ${space}." | ||
| 24 | pack.add(space+"."+docName, com.xpn.xwiki.plugin.packaging.DocumentInfo.ACTION_OVERWRITE, xcontext.getContext()); | ||
| 25 | } | ||
| 26 | } | ||
| 27 | if(request.dir){ | ||
| 28 | pack.exportToDir(new File(filename), xcontext.getContext()); | ||
| 29 | }else{ | ||
| 30 | pack.export(new FileOutputStream(new File(filename)), xcontext.getContext()); | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | if (request.filename) { | ||
| 35 | getXAR(request.filename,xcontext.getContext()) | ||
| 36 | xcontext.put('displayForm',false) | ||
| 37 | println "{{success}}Export is now finished. Check in the logs for any error{{/success}}" | ||
| 38 | } else { | ||
| 39 | println "== Large Export ==" | ||
| 40 | xcontext.put('displayForm',true) | ||
| 41 | } | ||
| 42 | {{/groovy}} | ||
| 43 | |||
| 44 | {{velocity}} | ||
| 45 | |||
| 46 | #set($displayForm = $xcontext.get('displayForm')) | ||
| 47 | #if($displayForm) | ||
| 48 | {{html clean="false" wiki="true"}} | ||
| 49 | <form action="" method="get"> | ||
| 50 | <table border="0"> | ||
| 51 | <tr> | ||
| 52 | <td>File/directory to write to:</td><td><input type="text" name="filename" size="60" /></td> | ||
| 53 | </tr> | ||
| 54 | </table> | ||
| 55 | #foreach($space in $xwiki.getSpaces()) | ||
| 56 | * $space <input type="checkbox" name="spaces" value="$space"/> | ||
| 57 | #end | ||
| 58 | |||
| 59 | * **Don't zip files, output to directory.** <input type="checkbox" name="dir"/> | ||
| 60 | <br/> | ||
| 61 | <input type="submit" name="Export" /> | ||
| 62 | </form> | ||
| 63 | {{/html}} | ||
| 64 | #end | ||
| 65 | {{/velocity}} |