Search in sources :

Example 1 with CallbackResponse

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

the class NextStepsController method validate.

@PostMapping(path = "/validate", consumes = APPLICATION_JSON_VALUE, produces = { APPLICATION_JSON_VALUE })
public ResponseEntity<CallbackResponse> validate(@RequestHeader(value = "Authorization") String authToken, @Validated({ ApplicationCreatedGroup.class, ApplicationUpdatedGroup.class, ApplicationReviewedGroup.class }) @RequestBody CallbackRequest callbackRequest, BindingResult bindingResult, HttpServletRequest request) {
    logRequest(request.getRequestURI(), callbackRequest);
    CallbackResponse callbackResponse;
    Optional<String> newState = stateChangeService.getChangedStateForCaseReview(callbackRequest.getCaseDetails().getData());
    if (newState.isPresent()) {
        callbackResponse = callbackResponseTransformer.transformWithConditionalStateChange(callbackRequest, newState);
    } else {
        if (bindingResult.hasErrors()) {
            log.error(CASE_ID_ERROR, callbackRequest.getCaseDetails().getId(), bindingResult);
            throw new BadRequestException("Invalid payload", bindingResult);
        }
        CCDData ccdData = ccdBeanTransformer.transform(callbackRequest);
        FeesResponse feesResponse = feeService.getAllFeesData(ccdData.getIht().getNetValueInPounds(), ccdData.getFee().getExtraCopiesOfGrant(), ccdData.getFee().getOutsideUKGrantCopies());
        if (feesResponse.getTotalAmount().doubleValue() > 0) {
            solicitorPaymentMethodValidationRule.validate(callbackRequest.getCaseDetails());
            CreditAccountPayment creditAccountPayment = creditAccountPaymentTransformer.transform(callbackRequest.getCaseDetails(), feesResponse);
            PaymentResponse paymentResponse = paymentsService.getCreditAccountPaymentResponse(authToken, creditAccountPayment);
            CallbackResponse creditPaymentResponse = eventValidationService.validatePaymentResponse(callbackRequest.getCaseDetails(), paymentResponse, creditAccountPaymentValidationRule);
            if (creditPaymentResponse.getErrors().isEmpty()) {
                callbackResponse = callbackResponseTransformer.transformForSolicitorComplete(callbackRequest, feesResponse, paymentResponse);
            } else {
                callbackResponse = creditPaymentResponse;
            }
        } else {
            callbackResponse = callbackResponseTransformer.transformForSolicitorComplete(callbackRequest, feesResponse, null);
        }
    }
    return ResponseEntity.ok(callbackResponse);
}
Also used : CreditAccountPayment(uk.gov.hmcts.probate.model.payments.CreditAccountPayment) CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) AfterSubmitCallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.AfterSubmitCallbackResponse) FeesResponse(uk.gov.hmcts.probate.model.fee.FeesResponse) BadRequestException(uk.gov.hmcts.probate.exception.BadRequestException) CCDData(uk.gov.hmcts.probate.model.ccd.CCDData) PaymentResponse(uk.gov.hmcts.probate.model.payments.PaymentResponse) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with CallbackResponse

use of uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse 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 3 with CallbackResponse

use of uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse 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)

Example 4 with CallbackResponse

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

the class ProbateManController method resetSearch.

@PostMapping(path = "/legacy/resetSearch", consumes = APPLICATION_JSON_VALUE, produces = { APPLICATION_JSON_VALUE })
public ResponseEntity<CallbackResponse> resetSearch(@RequestBody CallbackRequest callbackRequest, BindingResult bindingResult, HttpServletRequest request) {
    log.info("submitting legacy search - invalid action");
    List<String> errors = Arrays.asList(businessValidationMessageService.generateError(SUBMISSION_NOT_ALLOWED, "legacyCaseSubmissionNotAllowed").getMessage());
    CallbackResponse callbackResponse = CallbackResponse.builder().errors(errors).build();
    return ResponseEntity.ok(callbackResponse);
}
Also used : CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 5 with CallbackResponse

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

the class BusinessValidationController method solsValidateAdmon.

@PostMapping(path = "/sols-validate-admon", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<CallbackResponse> solsValidateAdmon(@Validated({ ApplicationAdmonGroup.class }) @RequestBody CallbackRequest callbackRequest, BindingResult bindingResult, HttpServletRequest request) {
    logRequest(request.getRequestURI(), callbackRequest);
    validateForPayloadErrors(callbackRequest, bindingResult);
    numberOfApplyingExecutorsValidationRule.validate(callbackRequest.getCaseDetails());
    CallbackResponse response = eventValidationService.validateRequest(callbackRequest, allValidationRules);
    if (response.getErrors().isEmpty()) {
        caseDataTransformer.transformCaseDataForValidateAdmon(callbackRequest);
        Optional<String> newState = stateChangeService.getChangedStateForAdmonUpdate(callbackRequest.getCaseDetails().getData());
        response = getCallbackResponseForGenerateAndUpload(callbackRequest, newState, LEGAL_STATEMENT_ADMON, ADMON_WILL_NAME);
    }
    return ResponseEntity.ok(response);
}
Also used : CallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse) AfterSubmitCallbackResponse(uk.gov.hmcts.probate.model.ccd.raw.response.AfterSubmitCallbackResponse) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

CallbackResponse (uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse)174 Test (org.junit.Test)137 Document (uk.gov.hmcts.probate.model.ccd.raw.Document)77 UploadDocument (uk.gov.hmcts.probate.model.ccd.raw.UploadDocument)59 ScannedDocument (uk.gov.hmcts.probate.model.ccd.raw.ScannedDocument)58 ResponseCaseData (uk.gov.hmcts.probate.model.ccd.raw.response.ResponseCaseData)29 ArrayList (java.util.ArrayList)28 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)24 PostMapping (org.springframework.web.bind.annotation.PostMapping)24 CaseData (uk.gov.hmcts.probate.model.ccd.raw.request.CaseData)23 AfterSubmitCallbackResponse (uk.gov.hmcts.probate.model.ccd.raw.response.AfterSubmitCallbackResponse)22 CallbackRequest (uk.gov.hmcts.probate.model.ccd.raw.request.CallbackRequest)20 CaseDetails (uk.gov.hmcts.probate.model.ccd.raw.request.CaseDetails)20 CollectionMember (uk.gov.hmcts.probate.model.ccd.raw.CollectionMember)13 CCDData (uk.gov.hmcts.probate.model.ccd.CCDData)7 SendLetterResponse (uk.gov.hmcts.reform.sendletter.api.SendLetterResponse)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 SolsAddress (uk.gov.hmcts.probate.model.ccd.raw.SolsAddress)6 CaveatCallbackRequest (uk.gov.hmcts.probate.model.ccd.caveat.request.CaveatCallbackRequest)5 DocumentLink (uk.gov.hmcts.probate.model.ccd.raw.DocumentLink)5