Search in sources :

Example 1 with TemporaryException

use of se.inera.intyg.webcert.common.sender.exception.TemporaryException in project webcert by sklintyg.

the class NotificationWSClient method sendStatusUpdate.

public void sendStatusUpdate(CertificateStatusUpdateForCareType request, @Header(NotificationRouteHeaders.LOGISK_ADRESS) String logicalAddress) throws TemporaryException, PermanentException {
    LOG.debug("Sending status update to '{}' for intyg '{}'", logicalAddress, request.getUtlatande().getUtlatandeId().getExtension());
    CertificateStatusUpdateForCareResponseType response = null;
    try {
        response = statusUpdateForCareClient.certificateStatusUpdateForCare(logicalAddress, request);
    } catch (Exception e) {
        LOG.warn("Exception occured when sending status update: {}", e.getMessage());
        throw new TemporaryException(e);
    }
    ResultType result = response.getResult();
    switch(result.getResultCode()) {
        case ERROR:
            if (ErrorIdType.TECHNICAL_ERROR.equals(result.getErrorId())) {
                throw new TemporaryException(String.format("NotificationWSClient failed with error code: %s and message %s", result.getErrorId(), result.getResultText()));
            } else {
                throw new PermanentException(String.format("NotificationWSClient failed with non-recoverable error code: %s and message %s", result.getErrorId(), result.getResultText()));
            }
        case INFO:
            LOG.info("NotificationWSClient got message:" + result.getResultText());
            break;
        case OK:
            break;
    }
}
Also used : TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) ResultType(se.riv.clinicalprocess.healthcond.certificate.v1.ResultType) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException)

Example 2 with TemporaryException

use of se.inera.intyg.webcert.common.sender.exception.TemporaryException in project webcert by sklintyg.

the class SendMessageToRecipientProcessor method process.

public void process(@Body String xmlBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException {
    try {
        SendMessageToRecipientType parameters = SendMessageToRecipientTypeConverter.fromXml(xmlBody);
        SendMessageToRecipientResponseType response = sendMessageToRecipientResponder.sendMessageToRecipient(logicalAddress, parameters);
        ResultType result = response.getResult();
        switch(result.getResultCode()) {
            case OK:
            case INFO:
                return;
            case ERROR:
                switch(result.getErrorId()) {
                    case REVOKED:
                    case VALIDATION_ERROR:
                        LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as PermanentException", intygsId, result.getResultText(), result.getErrorId());
                        throw new PermanentException(result.getResultText());
                    case APPLICATION_ERROR:
                    case TECHNICAL_ERROR:
                        LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as TemporaryException", intygsId, result.getResultText(), result.getErrorId());
                        throw new TemporaryException(result.getResultText());
                }
        }
    } catch (JAXBException e) {
        LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Rethrowing as PermanentException", intygsId, e.getMessage());
        throw new PermanentException(e.getMessage());
    } catch (WebServiceException e) {
        LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Will retry", intygsId, e.getMessage());
        throw new TemporaryException(e.getMessage());
    }
}
Also used : TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException) WebServiceException(javax.xml.ws.WebServiceException) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) JAXBException(javax.xml.bind.JAXBException) SendMessageToRecipientType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType) ResultType(se.riv.clinicalprocess.healthcond.certificate.v3.ResultType) SendMessageToRecipientResponseType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientResponseType)

Example 3 with TemporaryException

use of se.inera.intyg.webcert.common.sender.exception.TemporaryException in project webcert by sklintyg.

the class NotificationWSClient method sendStatusUpdate.

public void sendStatusUpdate(CertificateStatusUpdateForCareType request, @Header(NotificationRouteHeaders.LOGISK_ADRESS) String logicalAddress) throws TemporaryException, PermanentException {
    LOG.debug("Sending status update with version 2 to '{}' for intyg '{}'", logicalAddress, request.getIntyg().getIntygsId().getExtension());
    CertificateStatusUpdateForCareResponseType response = null;
    try {
        response = statusUpdateForCareClient.certificateStatusUpdateForCare(logicalAddress, request);
    } catch (Exception e) {
        LOG.warn("Exception occured when sending status update: {}", e.getMessage());
        throw new TemporaryException(e);
    }
    ResultType result = response.getResult();
    switch(result.getResultCode()) {
        case ERROR:
            if (ErrorIdType.TECHNICAL_ERROR.equals(result.getErrorId())) {
                throw new TemporaryException(String.format("NotificationWSClient failed with error code: %s and message %s", result.getErrorId(), result.getResultText()));
            } else {
                throw new PermanentException(String.format("NotificationWSClient failed with non-recoverable error code: %s and message %s", result.getErrorId(), result.getResultText()));
            }
        case INFO:
            LOG.info("NotificationWSClient got message:" + result.getResultText());
            break;
        case OK:
            break;
    }
}
Also used : TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) CertificateStatusUpdateForCareResponseType(se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareResponseType) ResultType(se.riv.clinicalprocess.healthcond.certificate.v3.ResultType) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException)

Example 4 with TemporaryException

use of se.inera.intyg.webcert.common.sender.exception.TemporaryException in project webcert by sklintyg.

the class RouteTest method testTemporaryException.

@Test(expected = CamelExecutionException.class)
public void testTemporaryException() throws InterruptedException {
    // Given
    revokeProcessor.whenAnyExchangeReceived(new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            throw new TemporaryException("");
        }
    });
    storeProcessor.expectedMessageCount(0);
    sendProcessor.expectedMessageCount(0);
    revokeProcessor.expectedMessageCount(1);
    sendMessageProcessor.expectedMessageCount(0);
    temporaryErrorHandlerEndpoint.expectedMessageCount(1);
    permanentErrorHandlerEndpoint.expectedMessageCount(0);
    // When
    producerTemplate.sendBodyAndHeaders(MESSAGE_BODY, ImmutableMap.<String, Object>of(Constants.MESSAGE_TYPE, Constants.REVOKE_MESSAGE));
    // Then
    assertIsSatisfied(storeProcessor);
    assertIsSatisfied(sendProcessor);
    assertIsSatisfied(revokeProcessor);
    assertIsSatisfied(sendMessageProcessor);
    assertIsSatisfied(temporaryErrorHandlerEndpoint);
    assertIsSatisfied(permanentErrorHandlerEndpoint);
}
Also used : TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException) TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) Test(org.junit.Test)

Example 5 with TemporaryException

use of se.inera.intyg.webcert.common.sender.exception.TemporaryException in project webcert by sklintyg.

the class CertificateSendProcessor method process.

public void process(@Body String skickatAv, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.PERSON_ID) String personId, @Header(Constants.RECIPIENT) String recipient, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException {
    SendCertificateToRecipientResponseType response;
    try {
        response = sendServiceClient.sendCertificate(intygsId, personId, skickatAv, recipient, logicalAddress);
        final ResultType result = response.getResult();
        final String resultText = result.getResultText();
        if (ResultCodeType.ERROR == result.getResultCode()) {
            LOG.warn("Error occured when trying to send intyg '{}'; {}", intygsId, resultText);
            switch(result.getErrorId()) {
                case APPLICATION_ERROR:
                case TECHNICAL_ERROR:
                    throw new TemporaryException(resultText);
                case REVOKED:
                case VALIDATION_ERROR:
                    throw new PermanentException(resultText);
            }
        } else {
            if (ResultCodeType.INFO.equals(result.getResultCode())) {
                LOG.warn("Warning occured when trying to send intyg '{}'; {}. Will not requeue.", intygsId, resultText);
            }
        }
    } catch (WebServiceException e) {
        LOG.warn("Call to send intyg {} caused an error: {}. Will retry", intygsId, e.getMessage());
        throw new TemporaryException(e.getMessage());
    }
}
Also used : TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException) SendCertificateToRecipientResponseType(se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType) WebServiceException(javax.xml.ws.WebServiceException) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) ResultType(se.riv.clinicalprocess.healthcond.certificate.v3.ResultType)

Aggregations

TemporaryException (se.inera.intyg.webcert.common.sender.exception.TemporaryException)7 PermanentException (se.inera.intyg.webcert.common.sender.exception.PermanentException)6 WebServiceException (javax.xml.ws.WebServiceException)3 ResultType (se.riv.clinicalprocess.healthcond.certificate.v3.ResultType)3 JAXBException (javax.xml.bind.JAXBException)1 Test (org.junit.Test)1 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)1 ExternalServiceCallException (se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException)1 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)1 PersonSvar (se.inera.intyg.infra.integration.pu.model.PersonSvar)1 Personnummer (se.inera.intyg.schemas.contract.Personnummer)1 CertificateStatusUpdateForCareResponseType (se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareResponseType)1 SendCertificateToRecipientResponseType (se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType)1 SendMessageToRecipientResponseType (se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientResponseType)1 SendMessageToRecipientType (se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType)1 ResultType (se.riv.clinicalprocess.healthcond.certificate.v1.ResultType)1