Skip to content

PO-5607 create AbstractBaisFileProcessorService#92

Open
samnaylorcgi wants to merge 12 commits into
masterfrom
PO-5607
Open

PO-5607 create AbstractBaisFileProcessorService#92
samnaylorcgi wants to merge 12 commits into
masterfrom
PO-5607

Conversation

@samnaylorcgi

Copy link
Copy Markdown
Contributor

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")

[ ] Yes
[x] No

@samnaylorcgi
samnaylorcgi requested a review from a team July 23, 2026 13:47
@samnaylorcgi
samnaylorcgi force-pushed the PO-5607 branch 3 times, most recently from 5176ccf to 3dd099f Compare July 23, 2026 13:58
import org.springframework.context.annotation.Configuration;

@Configuration
public class BlobStorageBeanConfiguration {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment on lines +19 to +21
public class BlobStorageService {

private final BlobServiceClient blobServiceClient;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment around the blobstore item


private final BlobServiceClient blobServiceClient;

public UUID upload(String containerName, Path file, String expectedChecksum) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we pass a Path here should we be passing Binary Data / InputStreams instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread src/main/resources/application.yaml Outdated
try (ByteArrayOutputStream downloadStream = new ByteArrayOutputStream()) {
baisSftpClient.downloadFile(config.getSftpUsername(), fileName, downloadStream);

byte[] downloadedBytes = downloadStream.toByteArray();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be final please (just to enforce it can not change)


String fileChecksum = calculateChecksum(new ByteArrayInputStream(downloadedBytes));

supersedePreviousFailures(fileName, fileChecksum);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants