PO-5607 create AbstractBaisFileProcessorService#92
Conversation
5176ccf to
3dd099f
Compare
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| @Configuration | ||
| public class BlobStorageBeanConfiguration { |
There was a problem hiding this comment.
I think something similar is being done in:
#73
Can we use that approach?
(Just clone the class for now and we can fix the conflict later)
| public class BlobStorageService { | ||
|
|
||
| private final BlobServiceClient blobServiceClient; |
There was a problem hiding this comment.
See previous comment around the blobstore item
|
|
||
| private final BlobServiceClient blobServiceClient; | ||
|
|
||
| public UUID upload(String containerName, Path file, String expectedChecksum) { |
There was a problem hiding this comment.
Why do we pass a Path here should we be passing Binary Data / InputStreams instead?
There was a problem hiding this comment.
My design basically uses a temporary file because we need to use the file multiple times, checksum + upload, so we can avoid downloading the file twice.
There was a problem hiding this comment.
Agreed we should down download the file multiple times but we could load the contents of the file into a final variable that we can then use for processing. (We just need to make sure we don't edit the raw data)
The files are only expected to be a few MB in size and will be downloaded on a dedicated POD (so resource utilisation wont impact users)
| try (ByteArrayOutputStream downloadStream = new ByteArrayOutputStream()) { | ||
| baisSftpClient.downloadFile(config.getSftpUsername(), fileName, downloadStream); | ||
|
|
||
| byte[] downloadedBytes = downloadStream.toByteArray(); |
There was a problem hiding this comment.
Could this be final please (just to enforce it can not change)
|
|
||
| String fileChecksum = calculateChecksum(new ByteArrayInputStream(downloadedBytes)); | ||
|
|
||
| supersedePreviousFailures(fileName, fileChecksum); |
There was a problem hiding this comment.
Could this be done at the end of the flow and added to the same transaction as the one that creates the SOURCE file on the database.
As currently this step could pass (and update records on the database)
But if the next step failed we could have a FAILED_SUPERCEEDED record with nothing that supersedes it
JIRA link (if applicable)
https://tools.hmcts.net/jira/browse/PO-5607
Change description
Create the abstract bais file processor service
Does this PR introduce a breaking change? (check one with "x")