Search in sources :

Example 1 with Document

use of uk.gov.hmcts.probate.model.ccd.raw.Document in project probate-back-office by hmcts.

the class DocumentController method generateGrantDraftReissue.

@PostMapping(path = "/generate-grant-draft-reissue", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<CallbackResponse> generateGrantDraftReissue(@RequestBody CallbackRequest callbackRequest) {
    Document document;
    final CaseDetails caseDetails = callbackRequest.getCaseDetails();
    final CaseData caseData = caseDetails.getData();
    registryDetailsService.getRegistryDetails(caseDetails);
    // so we use html/pdf template instead.
    if (useHtmlPdfGeneratorForReissue(caseData)) {
        document = documentGeneratorService.getDocument(callbackRequest, DocumentStatus.PREVIEW, DocumentIssueType.REISSUE);
    } else {
        document = documentGeneratorService.generateGrantReissue(callbackRequest, DocumentStatus.PREVIEW, Optional.of(DocumentIssueType.REISSUE));
    }
    return ResponseEntity.ok(callbackResponseTransformer.addDocuments(callbackRequest, Arrays.asList(document), null, null));
}
Also used : CaseData(uk.gov.hmcts.probate.model.ccd.raw.request.CaseData) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with Document

use of uk.gov.hmcts.probate.model.ccd.raw.Document in project probate-back-office by hmcts.

the class DocumentController method generateGrantReissue.

@PostMapping(path = "/generate-grant-reissue", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<CallbackResponse> generateGrantReissue(@RequestBody CallbackRequest callbackRequest) throws NotificationClientException {
    final List<Document> documents = new ArrayList<>();
    Document grantDocument;
    Document coversheet;
    final CaseDetails caseDetails = callbackRequest.getCaseDetails();
    final CaseData caseData = caseDetails.getData();
    registryDetailsService.getRegistryDetails(caseDetails);
    // so we use html/pdf template instead.
    if (useHtmlPdfGeneratorForReissue(caseData)) {
        grantDocument = documentGeneratorService.getDocument(callbackRequest, DocumentStatus.FINAL, DocumentIssueType.REISSUE);
        coversheet = pdfManagementService.generateAndUpload(callbackRequest, DocumentType.GRANT_COVER);
    } else {
        grantDocument = documentGeneratorService.generateGrantReissue(callbackRequest, DocumentStatus.FINAL, Optional.of(DocumentIssueType.REISSUE));
        coversheet = documentGeneratorService.generateCoversheet(callbackRequest);
    }
    documents.add(grantDocument);
    documents.add(coversheet);
    String letterId = null;
    if (caseData.isSendForBulkPrintingRequested() && !EDGE_CASE_NAME.equals(caseData.getCaseType())) {
        letterId = bulkPrintService.optionallySendToBulkPrint(callbackRequest, coversheet, grantDocument, true);
    }
    String pdfSize = getPdfSize(caseData);
    if (caseData.isGrantReissuedEmailNotificationRequested()) {
        documents.add(notificationService.generateGrantReissue(callbackRequest));
    }
    log.info("{} documents generated: {}", documents.size(), documents);
    return ResponseEntity.ok(callbackResponseTransformer.addDocuments(callbackRequest, documents, letterId, pdfSize));
}
Also used : CaseData(uk.gov.hmcts.probate.model.ccd.raw.request.CaseData) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) ArrayList(java.util.ArrayList) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 3 with Document

use of uk.gov.hmcts.probate.model.ccd.raw.Document in project probate-back-office by hmcts.

the class DocumentController method generateDepositReceipt.

@PostMapping(path = "/generate-deposit-receipt", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<WillLodgementCallbackResponse> generateDepositReceipt(@RequestBody WillLodgementCallbackRequest callbackRequest) {
    Document document;
    DocumentType template = WILL_LODGEMENT_DEPOSIT_RECEIPT;
    Registry registry = registriesProperties.getRegistries().get(NEWCASTLE);
    callbackRequest.getCaseDetails().setNewcastleRegistryAddress(String.join(" ", registry.getAddressLine1(), registry.getAddressLine2(), registry.getAddressLine3(), registry.getTown(), registry.getPostcode()));
    document = pdfManagementService.generateAndUpload(callbackRequest, template);
    return ResponseEntity.ok(willLodgementCallbackResponseTransformer.addDocuments(callbackRequest, Arrays.asList(document)));
}
Also used : DocumentType(uk.gov.hmcts.probate.model.DocumentType) Registry(uk.gov.hmcts.probate.config.properties.registries.Registry) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 4 with Document

use of uk.gov.hmcts.probate.model.ccd.raw.Document in project probate-back-office by hmcts.

the class NotificationController method sendCaseStoppedNotification.

@PostMapping(path = "/case-stopped")
public ResponseEntity<CallbackResponse> sendCaseStoppedNotification(@Validated({ EmailAddressNotifyValidationRule.class }) @RequestBody CallbackRequest callbackRequest) throws NotificationClientException {
    CaseDetails caseDetails = callbackRequest.getCaseDetails();
    CaseData caseData = caseDetails.getData();
    CallbackResponse response = CallbackResponse.builder().errors(new ArrayList<>()).build();
    Document document;
    List<Document> documents = new ArrayList<>();
    String letterId = null;
    if (caseData.isCaveatStopNotificationRequested() && caseData.isCaveatStopEmailNotificationRequested()) {
        response = eventValidationService.validateEmailRequest(callbackRequest, emailAddressNotifyValidationRules);
        if (response.getErrors().isEmpty()) {
            log.info("Initiate call to send caveat email for case id {} ", callbackRequest.getCaseDetails().getId());
            document = notificationService.sendEmail(CASE_STOPPED_CAVEAT, caseDetails);
            documents.add(document);
            log.info("Successful response for caveat email for case id {} ", callbackRequest.getCaseDetails().getId());
        }
    } else if (caseData.isCaveatStopNotificationRequested() && !caseData.isCaveatStopEmailNotificationRequested()) {
        Document coversheet = documentGeneratorService.generateCoversheet(callbackRequest);
        documents.add(coversheet);
        log.info("Initiate call to generate Caveat stopped document for case id {} ", callbackRequest.getCaseDetails().getId());
        Map<String, Object> placeholders = gorDocmosisService.caseDataForStoppedMatchedCaveat(callbackRequest.getCaseDetails());
        Document caveatRaisedDoc = pdfManagementService.generateDocmosisDocumentAndUpload(placeholders, DocumentType.CAVEAT_STOPPED);
        documents.add(caveatRaisedDoc);
        log.info("Successful response for caveat stopped document for case id {} ", callbackRequest.getCaseDetails().getId());
        if (caseData.isCaveatStopSendToBulkPrintRequested()) {
            log.info("Initiate call to bulk print for Caveat stopped document and coversheet for case id {} ", callbackRequest.getCaseDetails().getId());
            SendLetterResponse sendLetterResponse = bulkPrintService.sendToBulkPrintForGrant(callbackRequest, caveatRaisedDoc, coversheet);
            letterId = sendLetterResponse != null ? sendLetterResponse.letterId.toString() : null;
            response = eventValidationService.validateBulkPrintResponse(letterId, bulkPrintValidationRules);
        }
    } else {
        response = eventValidationService.validateEmailRequest(callbackRequest, emailAddressNotifyValidationRules);
        if (response.getErrors().isEmpty()) {
            log.info("Initiate call to notify applicant for case id {} ", callbackRequest.getCaseDetails().getId());
            document = notificationService.sendEmail(CASE_STOPPED, caseDetails);
            documents.add(document);
            log.info("Successful response from notify for case id {} ", callbackRequest.getCaseDetails().getId());
        }
    }
    if (response.getErrors().isEmpty()) {
        response = callbackResponseTransformer.caseStopped(callbackRequest, documents, letterId);
    }
    return ResponseEntity.ok(response);
}
Also used : CaseData(uk.gov.hmcts.probate.model.ccd.raw.request.CaseData) CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) ArrayList(java.util.ArrayList) ProbateDocument(uk.gov.hmcts.reform.probate.model.ProbateDocument) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) Map(java.util.Map) SendLetterResponse(uk.gov.hmcts.reform.sendletter.api.SendLetterResponse) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 5 with Document

use of uk.gov.hmcts.probate.model.ccd.raw.Document in project probate-back-office by hmcts.

the class NotificationController method sendApplicationReceivedNotification.

@PostMapping(path = "/application-received")
public ResponseEntity<ProbateDocument> sendApplicationReceivedNotification(@RequestBody CallbackRequest callbackRequest) throws NotificationClientException {
    CaseDetails caseDetails = callbackRequest.getCaseDetails();
    CaseData caseData = callbackRequest.getCaseDetails().getData();
    if (isDigitalApplication(caseData) && isAnEmailAddressPresent(caseData)) {
        CallbackResponse response = eventValidationService.validateEmailRequest(callbackRequest, emailAddressNotifyValidationRules);
        if (response.getErrors().isEmpty()) {
            Document sentEmailAsDocument = notificationService.sendEmail(APPLICATION_RECEIVED, caseDetails);
            return ResponseEntity.ok(buildProbateDocument(sentEmailAsDocument));
        }
    }
    log.info("No email sent or document returned to case: {}", caseDetails.getId());
    return ResponseEntity.ok(null);
}
Also used : CaseData(uk.gov.hmcts.probate.model.ccd.raw.request.CaseData) CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) CaseDetails(uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails) ProbateDocument(uk.gov.hmcts.reform.probate.model.ProbateDocument) Document(uk.gov.hmcts.probate.model.ccd.raw.Document) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

Document (uk.gov.hmcts.probate.model.ccd.raw.Document)185 Test (org.junit.Test)143 ScannedDocument (uk.gov.hmcts.probate.model.ccd.raw.ScannedDocument)90 CallbackResponse (uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse)77 UploadDocument (uk.gov.hmcts.probate.model.ccd.raw.UploadDocument)71 ArrayList (java.util.ArrayList)47 CaseDetails (uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails)41 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)38 CallbackRequest (uk.gov.hmcts.probate.model.ccd.raw.request.CallbackRequest)36 SendLetterResponse (uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)30 CaseData (uk.gov.hmcts.probate.model.ccd.raw.request.CaseData)28 DocumentType (uk.gov.hmcts.probate.model.DocumentType)25 CaveatCallbackRequest (uk.gov.hmcts.probate.model.ccd.caveat.request.CaveatCallbackRequest)22 ResponseCaseData (uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)21 CaveatCallbackResponse (uk.gov.hmcts.probate.model.ccd.caveat.response.CaveatCallbackResponse)21 DocumentLink (uk.gov.hmcts.probate.model.ccd.raw.DocumentLink)19 LetterV3 (uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3)17 CollectionMember (uk.gov.hmcts.probate.model.ccd.raw.CollectionMember)15 SolsAddress (uk.gov.hmcts.probate.model.ccd.raw.SolsAddress)14