Search in sources :

Example 6 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class SendMessageToCareResponderImplTest method testSendRequestToServiceFailedNotFound.

@Test
public void testSendRequestToServiceFailedNotFound() throws WebCertServiceException {
    when(arendeService.processIncomingMessage(any())).thenThrow(new WebCertServiceException(WebCertServiceErrorCodeEnum.DATA_NOT_FOUND, ""));
    SendMessageToCareResponseType response = responder.sendMessageToCare(DEFAULT_LOGICAL_ADDRESS, createNewRequest());
    assertNotNull(response.getResult());
    assertEquals(ResultCodeType.ERROR, response.getResult().getResultCode());
    assertEquals(ErrorIdType.VALIDATION_ERROR, response.getResult().getErrorId());
}
Also used : SendMessageToCareResponseType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToCare.v2.SendMessageToCareResponseType) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) Test(org.junit.Test)

Example 7 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class SendMessageToCareResponderImplTest method testSendRequestToServiceFailedNotSigned.

@Test
public void testSendRequestToServiceFailedNotSigned() throws WebCertServiceException {
    when(arendeService.processIncomingMessage(any())).thenThrow(new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, ""));
    SendMessageToCareResponseType response = responder.sendMessageToCare(DEFAULT_LOGICAL_ADDRESS, createNewRequest());
    assertNotNull(response.getResult());
    assertEquals(ResultCodeType.ERROR, response.getResult().getResultCode());
    assertEquals(ErrorIdType.VALIDATION_ERROR, response.getResult().getErrorId());
}
Also used : SendMessageToCareResponseType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToCare.v2.SendMessageToCareResponseType) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) Test(org.junit.Test)

Example 8 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class ArendeConverterTest method testDecorateArendeFromUtkastHsaNotResponding.

@Test
public void testDecorateArendeFromUtkastHsaNotResponding() {
    Utkast utkast = new Utkast();
    utkast.setIntygsTyp("intygstyp");
    utkast.setEnhetsId("enhetsid");
    utkast.setSignatur(mock(Signatur.class));
    when(utkast.getSignatur().getSigneradAv()).thenReturn("signeratav");
    when(hsaEmployeeService.getEmployee(anyString(), eq(null))).thenThrow(new WebServiceException());
    try {
        ArendeConverter.decorateArendeFromUtkast(new Arende(), utkast, LocalDateTime.now(), hsaEmployeeService);
        fail("Should throw");
    } catch (WebCertServiceException e) {
        assertEquals(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, e.getErrorCode());
    }
}
Also used : Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) WebServiceException(javax.xml.ws.WebServiceException) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) Test(org.junit.Test)

Example 9 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class IntygModuleApiController method revokeSignedIntyg.

/**
 * Issues a request to Intygstjanst to revoke the signed intyg.
 *
 * @param intygsId The id of the intyg to revoke
 * @param param    A JSON struct containing an optional message
 */
@POST
@Path("/{intygsTyp}/{intygsId}/aterkalla")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response revokeSignedIntyg(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId, RevokeSignedIntygParameter param) {
    validateRevokeAuthority(intygsTyp);
    if (authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).features(AuthoritiesConstants.FEATURE_MAKULERA_INTYG_KRAVER_ANLEDNING).isVerified() && !param.isValid()) {
        LOG.warn("Request to revoke '{}' is not valid", intygsId);
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload");
    }
    IntygServiceResult result = revokeIntyg(intygsTyp, intygsId, param);
    return Response.ok(result).build();
}
Also used : IntygServiceResult(se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 10 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class IntygModuleApiController method createReplacement.

/**
 * Create a copy that is a replacement (ersättning) of an existing certificate.
 */
@POST
@Path("/{intygsTyp}/{intygsId}/ersatt")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response createReplacement(CopyIntygRequest request, @PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String orgIntygsId) {
    validateReplaceAuthority(intygsTyp);
    LOG.debug("Attempting to create a replacement of {} with id '{}'", intygsTyp, orgIntygsId);
    if (!request.isValid()) {
        LOG.error("Request to create replacement of '{}' is not valid", orgIntygsId);
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload");
    }
    CreateReplacementCopyRequest serviceRequest = createReplacementCopyRequest(orgIntygsId, intygsTyp, request);
    CreateReplacementCopyResponse serviceResponse = copyUtkastService.createReplacementCopy(serviceRequest);
    LOG.debug("Created a new replacement draft with id: '{}' and type: {}, replacing certificate with id '{}'.", serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType(), orgIntygsId);
    CopyIntygResponse response = new CopyIntygResponse(serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType());
    return Response.ok().entity(response).build();
}
Also used : CopyIntygResponse(se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygResponse) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Aggregations

WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)85 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)35 Test (org.junit.Test)16 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)16 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)14 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)14 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)13 OptimisticLockException (javax.persistence.OptimisticLockException)12 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)11 Personnummer (se.inera.intyg.schemas.contract.Personnummer)10 SignaturTicket (se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket)10 Path (javax.ws.rs.Path)9 Produces (javax.ws.rs.Produces)9 SekretessStatus (se.inera.intyg.webcert.common.model.SekretessStatus)9 OptimisticLockingFailureException (org.springframework.dao.OptimisticLockingFailureException)7 Transactional (org.springframework.transaction.annotation.Transactional)7 POST (javax.ws.rs.POST)6 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)6 Signatur (se.inera.intyg.webcert.persistence.utkast.model.Signatur)6 LocalDateTime (java.time.LocalDateTime)5