Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing package structure #574

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/java/org/ladocuploader/app/cli/SubmissionTransfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void transferSubmissionBatch(List<Submission> submissionsBatch) {
String batchSeq = Long.toString(transmissionRepository.nextValueBatchSequence());
String batchIndex = Strings.padStart(batchSeq, BATCH_INDEX_LEN, '0');
UUID uuid = UUID.randomUUID();
String zipFileName = batchIndex + ".zip.gpg";
String zipFileName = batchIndex + ".zip";
log.info(String.format("Beginning transfer of %s: batch %s", uuid, batchIndex));

// Stats on transfers
Expand Down Expand Up @@ -160,7 +160,7 @@ private void transferSubmissionBatch(List<Submission> submissionsBatch) {

// Encrypt and transfer
byte[] data = pgpEncryptor.signAndEncryptPayload(zipFileName);
ftpsClient.uploadFile(zipFileName, data);
ftpsClient.uploadFile(zipFileName + ".gpg", data);
} catch (IOException ex) {
throw new IllegalStateException(ex);
} finally {
Expand Down Expand Up @@ -199,7 +199,7 @@ private void packageUploadedDocuments(String batchIndex, ZipOutputStream zos, St
docUploadFilename = "%s_%s".formatted(filecount, docUploadFilename);
}

ZipEntry docEntry = new ZipEntry(subfolder + "/" + docUploadFilename);
ZipEntry docEntry = new ZipEntry(batchIndex + "/" + subfolder + "/" + docUploadFilename);
docEntry.setSize(userFile.getFilesize().longValue());
zos.putNextEntry(docEntry);

Expand All @@ -217,8 +217,8 @@ private void packageUploadedDocuments(String batchIndex, ZipOutputStream zos, St
private void packageSnapApplication(String batchIndex, ZipOutputStream zos, StringBuilder docMeta, Submission submission, String subfolder) throws IOException {
byte[] file = pdfService.getFilledOutPDF(submission); // TODO Handle generate-pdf crashes
String fileName = "SNAP_application.pdf";
zos.putNextEntry(new ZipEntry(subfolder + "/"));
ZipEntry entry = new ZipEntry(subfolder + "/" + fileName);
zos.putNextEntry(new ZipEntry(batchIndex + "/" + subfolder + "/"));
ZipEntry entry = new ZipEntry(batchIndex + "/" + subfolder + "/" + fileName);
entry.setSize(file.length);
zos.putNextEntry(entry);
zos.write(file);
Expand All @@ -233,7 +233,7 @@ private String generateMetaDataEntry(String batchIndex, String subfolder, String
String formattedFilename = removeFileExtension(filename);
String formattedBirthdate = formatBirthdate(submission.getInputData());
String formattedSubmissionDate = submission.getSubmittedAt().format(MMDDYYYY_HHMMSS);
String fileLocation = String.format("\"%s/%s/%s\",", batchIndex, subfolder, filename);
String fileLocation = String.format("%s/%s/%s,", batchIndex, subfolder, filename);

return "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n"
.formatted(
Expand Down
Loading