Search in sources :

Example 1 with SendMessageToRecipientResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientResponseType 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 2 with SendMessageToRecipientResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientResponseType in project webcert by sklintyg.

the class SendMessageToRecipientProcessorTest method buildResponse.

private SendMessageToRecipientResponseType buildResponse(ResultType result) {
    SendMessageToRecipientResponseType response = new SendMessageToRecipientResponseType();
    response.setResult(result);
    return response;
}
Also used : SendMessageToRecipientResponseType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientResponseType)

Aggregations

SendMessageToRecipientResponseType (se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientResponseType)2 JAXBException (javax.xml.bind.JAXBException)1 WebServiceException (javax.xml.ws.WebServiceException)1 PermanentException (se.inera.intyg.webcert.common.sender.exception.PermanentException)1 TemporaryException (se.inera.intyg.webcert.common.sender.exception.TemporaryException)1 SendMessageToRecipientType (se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType)1 ResultType (se.riv.clinicalprocess.healthcond.certificate.v3.ResultType)1