Search in sources :

Example 1 with CertificateStatusUpdateForCareResponseType

use of se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v1.CertificateStatusUpdateForCareResponseType in project webcert by sklintyg.

the class CertificateStatusUpdateForCareResponderStub method certificateStatusUpdateForCare.

@Override
public CertificateStatusUpdateForCareResponseType certificateStatusUpdateForCare(String logicalAddress, CertificateStatusUpdateForCareType request) {
    counter.incrementAndGet();
    String utlatandeId = getUtlatandeId(request);
    LOG.debug("utlatandeId: " + utlatandeId);
    LOG.debug("numberOfReceivedMessages: " + getNumberOfReceivedMessages());
    if (utlatandeId.startsWith(FALLERAT_MEDDELANDE)) {
        int attempts = increaseAttempts(utlatandeId);
        int numberOfRequestedFailedAttempts = Integer.parseInt(utlatandeId.substring(utlatandeId.length() - 1));
        LOG.debug("attempts: " + attempts);
        LOG.debug("numberOfRequestedFailedAttempts: " + numberOfRequestedFailedAttempts);
        if (attempts < numberOfRequestedFailedAttempts + 1) {
            throw new RuntimeException("Something went wrong");
        }
    }
    store.add(request);
    CertificateStatusUpdateForCareResponseType response = new CertificateStatusUpdateForCareResponseType();
    ResultType result = new ResultType();
    result.setResultCode(ResultCodeType.OK);
    response.setResult(result);
    LOG.debug("Request set to 'OK'");
    return response;
}
Also used : CertificateStatusUpdateForCareResponseType(se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareResponseType) ResultType(se.riv.clinicalprocess.healthcond.certificate.v3.ResultType)

Example 2 with CertificateStatusUpdateForCareResponseType

use of se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v1.CertificateStatusUpdateForCareResponseType in project webcert by sklintyg.

the class NotificationWSClientTest method buildResponse.

private CertificateStatusUpdateForCareResponseType buildResponse(ResultCodeType code, ErrorIdType errorId, String resultText) {
    CertificateStatusUpdateForCareResponseType res = new CertificateStatusUpdateForCareResponseType();
    res.setResult(new ResultType());
    res.getResult().setResultCode(code);
    res.getResult().setErrorId(errorId);
    res.getResult().setResultText(resultText);
    return res;
}
Also used : CertificateStatusUpdateForCareResponseType(se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareResponseType) ResultType(se.riv.clinicalprocess.healthcond.certificate.v3.ResultType)

Example 3 with CertificateStatusUpdateForCareResponseType

use of se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v1.CertificateStatusUpdateForCareResponseType in project webcert by sklintyg.

the class CertificateStatusUpdateForCareResponderStub method certificateStatusUpdateForCare.

@Override
public CertificateStatusUpdateForCareResponseType certificateStatusUpdateForCare(String logicalAddress, CertificateStatusUpdateForCareType request) {
    counter.incrementAndGet();
    String utlatandeId = getUtlatandeId(request);
    LOG.debug("utlatandeId: " + utlatandeId);
    LOG.debug("numberOfReceivedMessages: " + getNumberOfReceivedMessages());
    if (utlatandeId.startsWith(FALLERAT_MEDDELANDE)) {
        int attempts = increaseAttempts(utlatandeId);
        int numberOfRequestedFailedAttempts = Integer.parseInt(utlatandeId.substring(utlatandeId.length() - 1));
        LOG.debug("attempts: " + attempts);
        LOG.debug("numberOfRequestedFailedAttempts: " + numberOfRequestedFailedAttempts);
        if (attempts < numberOfRequestedFailedAttempts + 1) {
            throw new RuntimeException("Something went wrong");
        }
    }
    store.add(request);
    CertificateStatusUpdateForCareResponseType response = new CertificateStatusUpdateForCareResponseType();
    response.setResult(ResultTypeUtil.okResult());
    LOG.debug("Request set to 'OK'");
    return response;
}
Also used : CertificateStatusUpdateForCareResponseType(se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v1.CertificateStatusUpdateForCareResponseType)

Example 4 with CertificateStatusUpdateForCareResponseType

use of se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v1.CertificateStatusUpdateForCareResponseType 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)

Aggregations

CertificateStatusUpdateForCareResponseType (se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareResponseType)3 ResultType (se.riv.clinicalprocess.healthcond.certificate.v3.ResultType)3 PermanentException (se.inera.intyg.webcert.common.sender.exception.PermanentException)1 TemporaryException (se.inera.intyg.webcert.common.sender.exception.TemporaryException)1 CertificateStatusUpdateForCareResponseType (se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v1.CertificateStatusUpdateForCareResponseType)1