diff --git a/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/endpoint/GetAssertions.java b/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/endpoint/GetAssertions.java index 9350483d..f448efa0 100644 --- a/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/endpoint/GetAssertions.java +++ b/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/endpoint/GetAssertions.java @@ -128,7 +128,7 @@ public String endpointBody(final Request the_request, final Response the_respons the_response.header("Content-Type", "application/zip"); the_response.header("Content-Disposition", "attachment; filename*=UTF-8''assertions_" + suffix + ".zip"); - getAssertions(os, suffix); + getAssertions(os, "", suffix); os.close(); ok(the_response); @@ -158,7 +158,7 @@ public String endpointBody(final Request the_request, final Response the_respons * @param zos an output stream (to become a zip file) * @param suffix requested file type: "csv" or "json" */ - public static void getAssertions(final ZipOutputStream zos, String suffix) + public static void getAssertions(final ZipOutputStream zos, String directory, String suffix) throws IOException { final String prefix = "[getAssertions]"; @@ -180,7 +180,9 @@ public static void getAssertions(final ZipOutputStream zos, String suffix) // Remove non-word characters for saving into .zip file; set up the zip next entry. final String sanitizedContestName = cr.getContestName().replaceAll("[\\W]", ""); - zos.putNextEntry(new ZipEntry(sanitizedContestName + "_assertions." + suffix)); + // If we have a nonempty directory, add "/" to it (apparently this is platform independent). + final String dirString = directory.isBlank() ? "" : directory + "/"; + zos.putNextEntry(new ZipEntry(dirString + sanitizedContestName + "_assertions." + suffix)); // Make the request. final GetAssertionsRequest getAssertionsRequest = new GetAssertionsRequest( diff --git a/server/eclipse-project/src/main/java/us/freeandfair/corla/controller/AuditReport.java b/server/eclipse-project/src/main/java/us/freeandfair/corla/controller/AuditReport.java index 93857ef2..651ec4e4 100644 --- a/server/eclipse-project/src/main/java/us/freeandfair/corla/controller/AuditReport.java +++ b/server/eclipse-project/src/main/java/us/freeandfair/corla/controller/AuditReport.java @@ -2,18 +2,10 @@ package us.freeandfair.corla.controller; import java.io.OutputStream; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Paths; import java.io.IOException; -import org.apache.commons.csv.CSVFormat; -import org.apache.commons.csv.CSVParser; -import org.apache.commons.csv.CSVRecord; -import java.io.Reader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -33,13 +25,11 @@ import us.freeandfair.corla.report.StateReport; import us.freeandfair.corla.model.DoSDashboard; import us.freeandfair.corla.persistence.Persistence; -//import us.freeandfair.corla.query.CSVParser; import us.freeandfair.corla.query.ExportQueries; import static au.org.democracydevelopers.corla.endpoint.GetAssertions.CSV_SUFFIX; import static au.org.democracydevelopers.corla.endpoint.GetAssertions.JSON_SUFFIX; import static au.org.democracydevelopers.corla.endpoint.GetAssertions.getAssertions; -//import us.freeandfair.corla.query.Reader; /** * Find the data for a report and format it to be rendered into a presentation @@ -229,11 +219,11 @@ public static void generateZip(final OutputStream os, List selectedRepor } if ("assertions_json".equalsIgnoreCase(reportName)) { - getAssertions(zos, JSON_SUFFIX); + getAssertions(zos, "assertions-json", JSON_SUFFIX); } if ("assertions_csv".equalsIgnoreCase(reportName)) { - getAssertions(zos, CSV_SUFFIX); + getAssertions(zos, "assertions-csv", CSV_SUFFIX); } } } catch (IOException e) {