diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/processes/RestApi.java b/server/src/main/java/au/org/aodn/ogcapi/server/processes/RestApi.java index 9154a9e1..354a0aa2 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/processes/RestApi.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/processes/RestApi.java @@ -71,7 +71,7 @@ public ResponseEntity execute( // email faster // It must only be sent once AWS Batch has accepted the job and returned // a job id, otherwise we promise the user a file that will never be produced. - restServices.notifyUser(recipient, uuid, startDate, endDate, multiPolygon, collectionTitle, fullMetadataLink, suggestedCitation); + restServices.notifyUser(recipient, uuid, key, startDate, endDate, multiPolygon, collectionTitle, fullMetadataLink, suggestedCitation, outputFormat); var value = new InlineValue(response.getBody()); var status = new InlineValue(Integer.toString(HttpStatus.OK.value())); diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/processes/RestServices.java b/server/src/main/java/au/org/aodn/ogcapi/server/processes/RestServices.java index 158571e2..b91f163c 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/processes/RestServices.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/processes/RestServices.java @@ -49,15 +49,16 @@ public RestServices(BatchClient batchClient, ObjectMapper objectMapper, String b this.batchJobQueue = batchJobQueue; } - public void notifyUser(String recipient, String uuid, String startDate, String endDate, Object multiPolygon, String collectionTitle, + public void notifyUser(String recipient, String uuid, String key, String startDate, String endDate, Object multiPolygon, String collectionTitle, String fullMetadataLink, - String suggestedCitation) { + String suggestedCitation, + String outputFormat) { String aodnInfoSender = "no.reply@aodn.org.au"; try (SesClient ses = SesClient.builder().build()) { var subject = Content.builder().data("Start processing data file whose uuid is: " + uuid).build(); - var content = Content.builder().data(generateStartedEmailContent(uuid, startDate, endDate, multiPolygon, collectionTitle, fullMetadataLink, suggestedCitation)).build(); + var content = Content.builder().data(generateStartedEmailContent(uuid, key, startDate, endDate, multiPolygon, collectionTitle, fullMetadataLink, suggestedCitation, outputFormat)).build(); var destination = Destination.builder().toAddresses(recipient).build(); var body = Body.builder().html(content).build(); @@ -148,14 +149,17 @@ private String submitJob(String jobName, String jobQueue, String jobDefinition, return jobId; } - private String generateStartedEmailContent( + // package-private so JobStartedEmailPreview (test scope) can render it + String generateStartedEmailContent( String uuid, + String key, String startDate, String endDate, Object multipolygon, String collectionTitle, String fullMetadataLink, - String suggestedCitation + String suggestedCitation, + String outputFormat ) { try (InputStream inputStream = getClass().getResourceAsStream("/job-started-email.html")) { @@ -174,10 +178,16 @@ private String generateStartedEmailContent( objectMapper ); + // Keys arrive comma-separated; show one per line. Absent means "all files". + String keysDisplay = (key != null && !key.isBlank()) ? key.replace(",", "
") : "*"; + // Replace all variables in one chain return template .replace("{{HEADER_IMG}}", EmailUtils.readBase64Image("header.txt")) .replace("{{collectionTitle}}", collectionTitle != null ? collectionTitle : "") + .replace("{{uuid}}", uuid != null ? uuid : "") + .replace("{{keys}}", keysDisplay) + .replace("{{outputFormat}}", outputFormat != null ? outputFormat.toUpperCase() : "") .replace("{{subsettingSection}}", subsettingSection) .replace("{{BBOX_IMG}}", EmailUtils.readBase64Image("bbox.txt")) .replace("{{POLYGON_IMG}}", EmailUtils.readBase64Image("polygon.txt")) diff --git a/server/src/main/resources/job-started-email.html b/server/src/main/resources/job-started-email.html index 0294eb72..e94c0f42 100644 --- a/server/src/main/resources/job-started-email.html +++ b/server/src/main/resources/job-started-email.html @@ -30,7 +30,7 @@ - +