Skip to content

Commit

Permalink
Merge pull request #73 from pagopa/fix-pdf-gen
Browse files Browse the repository at this point in the history
bug: [fix-pdf-gen] metadata null exception
  • Loading branch information
pasqualespica authored Jun 24, 2024
2 parents d0d7a39 + 62b775e commit 52b187d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,17 @@ private static void checkOrCreateAttachments(Receipt receipt) {
String dateFormatted = LocalDate.now().format(DateTimeFormatter.ofPattern(blobNameDateFormat));
String blobName = String.format(blobNameFormat, TEMPLATE_PREFIX, dateFormatted, receipt.getEventId(), PAYER_TEMPLATE_SUFFIX);
receipt.setMdAttach(ReceiptMetadata.builder().name(blobName).build());
} else if (!receiptMetadataExist(receipt.getMdAttachPayer())){
String dateFormatted = LocalDate.now().format(DateTimeFormatter.ofPattern(blobNameDateFormat));
String blobName = String.format(blobNameFormat, TEMPLATE_PREFIX, dateFormatted, receipt.getEventId(), PAYER_TEMPLATE_SUFFIX);
receipt.setMdAttachPayer(ReceiptMetadata.builder().name(blobName).build());
} else {
if (!receiptMetadataExist(receipt.getMdAttachPayer())){
String dateFormatted = LocalDate.now().format(DateTimeFormatter.ofPattern(blobNameDateFormat));
String blobName = String.format(blobNameFormat, TEMPLATE_PREFIX, dateFormatted, receipt.getEventId(), PAYER_TEMPLATE_SUFFIX);
receipt.setMdAttachPayer(ReceiptMetadata.builder().name(blobName).build());
}
if (!receiptMetadataExist(receipt.getMdAttach())) {
String dateFormatted = LocalDate.now().format(DateTimeFormatter.ofPattern(blobNameDateFormat));
String blobName = String.format(blobNameFormat, TEMPLATE_PREFIX, dateFormatted, receipt.getEventId(), DEBTOR_TEMPLATE_SUFFIX);
receipt.setMdAttach(ReceiptMetadata.builder().name(blobName).build());
}
}
} else {
if (!receiptMetadataExist(receipt.getMdAttach())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ public BlobStorageResponse savePdfToBlobStorage(InputStream pdf, String fileName

//Create the container and return a container client object
BlobContainerClient blobContainerClient = this.blobServiceClient.getBlobContainerClient(containerName);
String fileNamePdf = fileName + FILE_EXTENSION;

//Get a reference to a blob
BlobClient blobClient = blobContainerClient.getBlobClient(fileName);
BlobClient blobClient = blobContainerClient.getBlobClient(fileNamePdf);

//Upload the blob
Response<BlockBlobItem> blockBlobItemResponse = blobClient.uploadWithResponse(
Expand Down

0 comments on commit 52b187d

Please sign in to comment.