use of se.inera.intyg.clinicalprocess.healthcond.certificate.getmedicalcertificate.v1.GetMedicalCertificateResponseType in project webcert by sklintyg.
the class GetMedicalCertificateResponderStub method getMedicalCertificate.
@Override
@StubLatencyAware
@StubModeAware
public GetMedicalCertificateResponseType getMedicalCertificate(String logicalAddress, GetMedicalCertificateRequestType request) {
GetMedicalCertificateResponseType response = new GetMedicalCertificateResponseType();
CertificateHolder intygResponse = intygStore.getIntygForCertificateId(request.getCertificateId());
if (intygResponse != null) {
response.setMeta(ModelConverter.toCertificateMetaType(intygResponse));
attachCertificateDocument(intygResponse, response);
if (intygResponse.isRevoked()) {
response.setResult(ResultTypeUtil.errorResult(ErrorIdType.REVOKED, String.format("Certificate '%s' has been revoked", intygResponse.getId())));
} else {
response.setResult(ResultTypeUtil.okResult());
}
} else {
response.setResult(ResultTypeUtil.errorResult(ErrorIdType.VALIDATION_ERROR, "Intyg not found in stub"));
}
return response;
}
Aggregations