From 6fe38207bd47cf64754a6348ca9cfb16d3031d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olov=20Ylinenp=C3=A4=C3=A4?= Date: Wed, 27 Nov 2024 13:49:47 +0100 Subject: [PATCH] feat(emm): hint download type in parameter --- emm/src/main/java/whelk/Dump.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/emm/src/main/java/whelk/Dump.java b/emm/src/main/java/whelk/Dump.java index 8ef6bab1da..63ed9ace49 100644 --- a/emm/src/main/java/whelk/Dump.java +++ b/emm/src/main/java/whelk/Dump.java @@ -69,6 +69,7 @@ public class Dump { private static final String DUMP_END_MARKER = DUMP_END_MARKER_NO_NEWLINE + "\n"; // Must be 17 bytes private static final String JSON_CONTENT_TYPE = "application/json"; private static final int GZIP_BUF_SIZE = 64 * 1024; + private static final String ND_JSON_LD_GZ_EXT = ".jsonld.gz"; public static void sendDumpResponse(Whelk whelk, String apiBaseUrl, HttpServletRequest req, HttpServletResponse res) throws IOException, SQLException { String selection = req.getParameter("selection"); @@ -110,7 +111,7 @@ private static void sendDumpEntryPoint(String apiBaseUrl, String selection, Http responseObject.put("@context", contexts); responseObject.put("type", "Collection"); responseObject.put("id", apiBaseUrl + "?selection=" + selection); - responseObject.put("url", apiBaseUrl + "?selection=" + selection + "&download"); + responseObject.put("url", apiBaseUrl + "?selection=" + selection + "&download=" + ND_JSON_LD_GZ_EXT); var first = new LinkedHashMap<>(); first.put("type", "CollectionPage"); first.put("id", apiBaseUrl + "?selection=" + selection + "&offset=0"); @@ -284,7 +285,7 @@ private static void sendFormattedResponse(Whelk whelk, String apiBaseUrl, String } private static void sendDumpDownloadResponse(Whelk whelk, String apiBaseUrl, String dump, Path dumpFilePath, HttpServletResponse res) { - String filename = Unicode.stripSuffix(dumpFilePath.getFileName().toString(), ".dump") + ".ndjsonld.gz"; + String filename = Unicode.stripSuffix(dumpFilePath.getFileName().toString(), ".dump") + ND_JSON_LD_GZ_EXT; res.setHeader("Content-Disposition", "attachment; filename=" + filename); res.setHeader("Content-Type", "application/octet-stream");