General Actions:
Log-in
Wiki:
Courses
▼
:
Document Index
»
Space:
Admin
▼
:
Document Index
»
Page:
ExportFromDateGroovy
Search
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
ExportFromDateGroovy
Wiki source code of
ExportFromDateGroovy
Last modified by
Hal Eden
on 2010/08/19 07:32
Content
·
Comments
(0)
·
Attachments
(0)
·
History
·
Information
Hide line numbers
1: 2: import com.xpn.xwiki.*; 3: import com.xpn.xwiki.plugin.packaging.*; 4: import org.apache.commons.lang.StringUtils; 5: 6: public class Test3 { 7: 8: def result = "" 9: 10: public addToResult(str) { 11: result = "${result}${str}\n"; 12: } 13: 14: public String export(context, xwiki, request, response) { 15: result = ""; 16: addToResult("Starting export") 17: addToResult("Creating package") 18: def pack = new Package() 19: if (request.versions=="1") 20: pack.setWithVersions(true) 21: else 22: pack.setWithVersions(false) 23: if (request.backup=="1") 24: pack.setBackupPack(true) 25: else 26: pack.setBackupPack(false) 27: 28: addToResult("Adding documents") 29: def sql = "" 30: if (request.date!="") { 31: def sqldate = "doc.date>'$request.date'" 32: if (sql=="") 33: sql += "where ${sqldate}" 34: else 35: sql += " and ${sqldate}" 36: } 37: if (request.space!="") { 38: def spacelist1 = StringUtils.split(request.space," ,") 39: def spacelist = StringUtils.join(spacelist1,"','") 40: def sqlspace = "doc.space in ('${spacelist}')" 41: if (sql=="") 42: sql += "where ${sqlspace}" 43: else 44: sql += " and ${sqlspace}" 45: } 46: 47: addToResult(sql); 48: def start = 0 49: def nb = 0 50: if (request.start) { 51: start = xwiki.parseInt(request.start) 52: if (request.end) { 53: nb = xwiki.parseInt(request.end) - start + 1 54: } 55: } 56: for(docName in xwiki.searchDocuments(sql, nb, start)){ 57: addToResult("* ${docName}") 58: if (request.confirm) 59: pack.add(xwiki.getDocument(docName).document, 0, context.context) 60: } 61: 62: if (request.confirm) { 63: try { 64: response.setContentType("application/xwiki") 65: pack.export(response.getOutputStream(), context.context) 66: context.setFinished(true) 67: } catch (Exception e) { 68: addToResult("Error exporting") 69: addToResult(e.getMessage()) 70: } 71: addToResult("Finished.") 72: } 73: return result; 74: } 75: 76: }
Welcome
Welcome to this XWiki!
Quick Links
DSSF 2008
DCNM 2009
HCCF 2010
Document Index
Sandbox
My Recent Modifications
ASSIGNMENTNAME