Skip to content

Commit

Permalink
add attachmentKey to the form fill request DTO
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Balcaen committed Apr 2, 2024
1 parent ef4983d commit af70b2d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Void handleRequest(final S3EventNotification input, final Context context

input.getRecords().forEach(s3EventNotificationRecord -> {
var key = s3EventNotificationRecord.getS3().getObject().getKey();
var formFillRequest = new FormFillRequestDTO(extractEmailId(key), extractFormKey(key));
var formFillRequest = new FormFillRequestDTO(extractEmailId(key), extractFormKey(key), key);
sqsProducerService.send(formFillRequest);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
package com.levio.awsdemo.formrequestpreprocessor.service;

public class FormFillRequestDTO {
/**
* The ID of the email which initiated the request
*/
String emailId;

/**
* The key to the form to be filled
*/
String formKey;

/**
* The key to the attachment to parse
*/
String attachmentKey;

public FormFillRequestDTO(String emailId, String formKey) {
public FormFillRequestDTO(String emailId, String formKey, String attachmentKey) {
this.emailId = emailId;
this.formKey = formKey;
this.attachmentKey = attachmentKey;
}

public String toJson() {
return "{" +
"\"emailId\":\"" + emailId + "\"," +
"\"formKey\":\"" + formKey + "\"" +
"\"attachmentKey\":\"" + attachmentKey + "\"" +
"}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public Void handleRequest(final SQSEvent input, final Context context) {
}

var emailId = formFillRequest.getEmailId();
var attachmentKey = formFillRequest.getAttachmentKey();
var formKey = formFillRequest.getFormKey();
var questionsMapper = retrieveDocumentMapper(formKey);

Expand All @@ -75,7 +76,7 @@ public Void handleRequest(final SQSEvent input, final Context context) {
String sender = ((InternetAddress) message.getFrom()[0]).getAddress();
String subject = message.getSubject();

String content = s3Service.getFile(formKey +"/attachment/" + emailId + ".txt");
String content = s3Service.getFile(attachmentKey);

questionsMapper.entrySet().parallelStream()
.forEach(positionQuestionAnswerMapper -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ public class FormFillRequestDTO {

@JsonProperty("formKey") // Map JSON property to field
private String formKey;

@JsonProperty("attachmentKey")
private String attachmentKey;
}

0 comments on commit af70b2d

Please sign in to comment.