From 39555f083db82459eec5c652eebe27ea797f37e6 Mon Sep 17 00:00:00 2001 From: Marcus Aspin Date: Thu, 12 Oct 2023 21:03:41 +0000 Subject: [PATCH] PI-1558 Update PSR extension to PDF when complete Previously, an empty PDF would be uploaded to the Alfresco when the initial draft was started. Following the recent changes, Delius now uploads a .doc file instead as the draft. However, the filename remains the same after the report is completed. So currently we end up with a PDF document saved as e.g. ``` Nat Short format pre-sentence report_13102023_112036_Larson_D_X729742.doc ``` This PR updates the extension to .pdf before saving --- .../hmpps/integrations/delius/document/DocumentService.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentService.kt b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentService.kt index 20a4d95550..f16a165c78 100644 --- a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentService.kt +++ b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentService.kt @@ -47,14 +47,15 @@ class DocumentService( throw ConflictException("Court report ${courtReport.id} not for ${hmppsEvent.personReference.findCrn()}") } + document.name = document.name.replace(Regex("\\.doc$"), ".pdf") + document.lastSaved = ZonedDateTime.now() + document.lastUpdatedUserId = ServiceContext.servicePrincipal()!!.userId + alfrescoClient.releaseDocument(document.alfrescoId) alfrescoClient.updateDocument( document.alfrescoId, populateBodyValues(hmppsEvent, document, file) ) - - document.lastSaved = ZonedDateTime.now() - document.lastUpdatedUserId = ServiceContext.servicePrincipal()!!.userId } private fun populateBodyValues(