diff --git a/service/src/main/java/uk/gov/hmcts/reform/fpl/handlers/ManageDocumentsUploadedEventHandler.java b/service/src/main/java/uk/gov/hmcts/reform/fpl/handlers/ManageDocumentsUploadedEventHandler.java index cd8040c9ec4..26d7dab6822 100644 --- a/service/src/main/java/uk/gov/hmcts/reform/fpl/handlers/ManageDocumentsUploadedEventHandler.java +++ b/service/src/main/java/uk/gov/hmcts/reform/fpl/handlers/ManageDocumentsUploadedEventHandler.java @@ -129,7 +129,7 @@ private void sendNotification(final ManageDocumentsUploadedEvent event, Set newDocumentNames = documentsToBeSent.values().stream().flatMap(List::stream) .map(Element::getValue) - .map(NotifyDocumentUploaded::getName) + .map(NotifyDocumentUploaded::getNameForNotification) .collect(toList()); if (!newDocumentNames.isEmpty()) { diff --git a/service/src/main/java/uk/gov/hmcts/reform/fpl/model/configuration/DocumentUploadedNotificationConfiguration.java b/service/src/main/java/uk/gov/hmcts/reform/fpl/model/configuration/DocumentUploadedNotificationConfiguration.java index e93d5b0524b..5dec3538e77 100644 --- a/service/src/main/java/uk/gov/hmcts/reform/fpl/model/configuration/DocumentUploadedNotificationConfiguration.java +++ b/service/src/main/java/uk/gov/hmcts/reform/fpl/model/configuration/DocumentUploadedNotificationConfiguration.java @@ -41,8 +41,6 @@ public class DocumentUploadedNotificationConfiguration { .sendToDesignatedLA(ConfidentialLevel.LA) .sendToSecondaryLA(ConfidentialLevel.LA) .sendToLegalRepresentative(ConfidentialLevel.LA) - .sendToJudge(ConfidentialLevel.CTSC) - .sendToCTSC(ConfidentialLevel.CTSC) .sendToCafcassRepresentative(ConfidentialLevel.LA) .sendToTranslationTeam(ConfidentialLevel.CTSC) .build(); diff --git a/service/src/main/java/uk/gov/hmcts/reform/fpl/model/interfaces/NotifyDocumentUploaded.java b/service/src/main/java/uk/gov/hmcts/reform/fpl/model/interfaces/NotifyDocumentUploaded.java index 5b7c595b980..67b763fe773 100644 --- a/service/src/main/java/uk/gov/hmcts/reform/fpl/model/interfaces/NotifyDocumentUploaded.java +++ b/service/src/main/java/uk/gov/hmcts/reform/fpl/model/interfaces/NotifyDocumentUploaded.java @@ -1,11 +1,13 @@ package uk.gov.hmcts.reform.fpl.model.interfaces; +import com.fasterxml.jackson.annotation.JsonIgnore; import uk.gov.hmcts.reform.fpl.model.common.DocumentReference; public interface NotifyDocumentUploaded { DocumentReference getDocument(); - default String getName() { + @JsonIgnore + default String getNameForNotification() { return getDocument().getFilename(); } } diff --git a/service/src/main/java/uk/gov/hmcts/reform/fpl/service/document/ManageDocumentService.java b/service/src/main/java/uk/gov/hmcts/reform/fpl/service/document/ManageDocumentService.java index 6992fef24a5..2c2f0842d64 100644 --- a/service/src/main/java/uk/gov/hmcts/reform/fpl/service/document/ManageDocumentService.java +++ b/service/src/main/java/uk/gov/hmcts/reform/fpl/service/document/ManageDocumentService.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.tuple.Pair; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -88,6 +89,7 @@ import static uk.gov.hmcts.reform.fpl.utils.ElementUtils.getDynamicListSelectedValue; import static uk.gov.hmcts.reform.fpl.utils.ElementUtils.unwrapElements; +@Slf4j @Service @RequiredArgsConstructor(onConstructor_ = {@Autowired}) public class ManageDocumentService { @@ -1165,26 +1167,37 @@ public ManageDocumentsUploadedEvent buildManageDocumentsUploadedEvent(CaseData c for(DocumentType documentType : DocumentType.values()) { for(ConfidentialLevel confidentialLevel : resultMapByConfidentialLevel.keySet()) { - String fieldName = documentType.getBaseFieldNameResolver().apply(confidentialLevel); - - List documentList = ObjectHelper.getFieldValue(caseData, fieldName, List.class); - List documentListBefore = ObjectHelper.getFieldValue(caseDataBefore, fieldName, List.class); - - if (DocumentType.COURT_BUNDLE.equals(documentType) || DocumentType.CASE_SUMMARY.equals(documentType) - || DocumentType.POSITION_STATEMENTS.equals(documentType) - || DocumentType.SKELETON_ARGUMENTS.equals(documentType)) { - // TODO - } else { - // Handle ManagedDocument list - for (Object document : documentList) { - if (documentListBefore.contains(document)) { - Map>> resultMap = - resultMapByConfidentialLevel.get(confidentialLevel); - - if (resultMap.containsKey(documentType)) { - resultMap.get(documentType).add((Element) document); + if (documentType.getBaseFieldNameResolver() != null) { + String fieldName = documentType.getBaseFieldNameResolver().apply(confidentialLevel); + + try { + List documentList = Optional.ofNullable(ObjectHelper + .getFieldValue(caseData, fieldName, List.class)).orElse(List.of()); + List documentListBefore = Optional.ofNullable(ObjectHelper + .getFieldValue(caseDataBefore, fieldName, List.class)).orElse(List.of()); + + if (DocumentType.COURT_BUNDLE.equals(documentType) || DocumentType.CASE_SUMMARY.equals(documentType) + || DocumentType.POSITION_STATEMENTS.equals(documentType) + || DocumentType.SKELETON_ARGUMENTS.equals(documentType)) { + // TODO + } else { + // Handle ManagedDocument list + for (Object document : documentList) { + if (!documentListBefore.contains(document)) { + Map>> newDocMap = + resultMapByConfidentialLevel.get(confidentialLevel); + + List> docList = + Optional.ofNullable(newDocMap.get(documentType)).orElse(new ArrayList<>()); + + docList.add((Element) document); + newDocMap.putIfAbsent(documentType, docList); + } } } + } catch (NoSuchMethodException e) { + log.error("Case File View: No getter for {}. Check configuration of document type: {}", + fieldName, documentType); } } }