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

DMP-4115: Create POST /audio/metadata endpoint #2227

Merged
merged 12 commits into from
Nov 11, 2024
Merged

Conversation

Ben-Edwards-cgi
Copy link
Contributor

Links

Jira

Change description

Create a new endpoint in the darts-api, as defined in the LLD:-
[https://tools.hmcts.net/confluence/pages/viewpage.action?pageId=1682839618#AudioAPILLD-POST/audios/metadata]

This will allow the darts-proxy or darts-gateway to upload audio files directly to storage and so skip an extra transfer.

This should replicate the addAudio call in AudioController but skip uploading of the file.

To test this, an audio file needs to be renamed into a guid before being uploaded into the inbound blob storage. Then, hit the new /audios/metadata endpoint, referencing this audio file. The inbound to unstructured automated task will then need to run before the audio will be able to be previewed in the DARTS portal. 
h4. Acceptance Criteria

GIVEN 

an audio file exists in the inbound blob storage

WHEN

a request is made to /audios/metadata endpoint for this audio

THEN 

check the audio file appears in DARTS portal with the relevant metadata displayed

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[X] No

"spring.servlet.multipart.max-request-size=4MB",
})
@SuppressWarnings({"PMD.DoNotUseThreads", "PMD.AvoidInstantiatingObjectsInLoops", "PMD.AvoidThrowingRawExceptionTypes"})
class AudioControllerAddAudioMetaDataNoSessionITest extends IntegrationBase {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing, but think the general pattern is to put IntTest at the end of the test name instead of ITest. Could it be changed to make consistent with everything else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

String checksum = dataManagementApi.getChecksum(DatastoreContainerType.INBOUND, guid);
if (!checksum.equals(addAudioMetadataRequest.getChecksum())) {
throw new DartsApiException(AudioApiError.FAILED_TO_ADD_AUDIO_META_DATA,
String.format("Checksum in DETs (%s) does not match the one passed in the API request (%s).",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we talking about DETS here? It's nothing to do with DETS is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was left over from the first iteration I have updated the message :)


if (!exists) {
throw new DartsApiException(CommonApiError.NOT_FOUND,
String.format("Blob %s does not exist in container %s was not found.", blobId, containerName));
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this sentence make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated :)


if (checksumByte == null) {
throw new DartsApiException(CommonApiError.NOT_FOUND,
String.format("Blob %s does not exist in container %s does not contain a checksum.", blobId, containerName));
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this sentence make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated :)

}

@Test
void negativeGetChecksumChecksumNotFound() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Checksum in test name twice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is by design getChecksum is the method name checksumNotFound is the what we are testing

@Ben-Edwards-cgi Ben-Edwards-cgi enabled auto-merge (squash) November 7, 2024 10:14
@hmcts-jenkins-cnp hmcts-jenkins-cnp bot requested a deployment to preview November 7, 2024 10:14 Abandoned
@Ben-Edwards-cgi Ben-Edwards-cgi merged commit 7636164 into master Nov 11, 2024
10 checks passed
@Ben-Edwards-cgi Ben-Edwards-cgi deleted the DMP-4115 branch November 11, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants