From 55f8c6a0d14a77060803532ac824046558e75457 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Mon, 12 Dec 2011 21:47:52 -0800 Subject: [PATCH] Added txt and json to the generated zip files, at Lucas's request. --- VERSION | 2 +- .../tnoodleServerHandler/ScrambleRequest.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index daaa8b008..3ae5d3e52 100644 --- a/VERSION +++ b/VERSION @@ -1,3 +1,3 @@ # After editing this file, be sure to commit # all your code, and then run "tmt make release -p timer"! -0.1.4 +0.2 diff --git a/webscrambles/src/tnoodleServerHandler/ScrambleRequest.java b/webscrambles/src/tnoodleServerHandler/ScrambleRequest.java index 6126f1824..e4107248b 100644 --- a/webscrambles/src/tnoodleServerHandler/ScrambleRequest.java +++ b/webscrambles/src/tnoodleServerHandler/ScrambleRequest.java @@ -522,8 +522,8 @@ public static ByteArrayOutputStream requestsToZip(String globalTitle, Date gener ZipOutputStream zipOut = new ZipOutputStream(baosZip); zipOut.setComment(globalTitle + " zip created on " + Utils.SDF.format(generationDate)); for(ScrambleRequest scrambleRequest : scrambleRequests) { - String fileName = scrambleRequest.title + ".pdf"; - ZipEntry entry = new ZipEntry(fileName); + String pdfFileName = "pdf/" + scrambleRequest.title + ".pdf"; + ZipEntry entry = new ZipEntry(pdfFileName); zipOut.putNextEntry(entry); PdfReader pdfReader = createPdf(globalTitle, generationDate, scrambleRequest); @@ -532,7 +532,19 @@ public static ByteArrayOutputStream requestsToZip(String globalTitle, Date gener zipOut.write(b); zipOut.closeEntry(); + + String txtFileName = "txt/" + scrambleRequest.title + ".txt"; + entry = new ZipEntry(txtFileName); + zipOut.putNextEntry(entry); + zipOut.write(Utils.join(scrambleRequest.scrambles, "\r\n").getBytes()); + zipOut.closeEntry(); } + + ZipEntry entry = new ZipEntry(globalTitle + ".json"); + zipOut.putNextEntry(entry); + zipOut.write(GSON.toJson(scrambleRequests).getBytes()); + zipOut.closeEntry(); + zipOut.close(); return baosZip;