Search in sources :

Example 36 with WebServiceException

use of javax.xml.ws.WebServiceException in project webcert by sklintyg.

the class HealthCheckServiceImplTest method testCheckPrivatlakarportalException.

@Test
public void testCheckPrivatlakarportalException() {
    when(privatlakarportalPingForConfiguration.pingForConfiguration(eq(PP_LOGICAL_ADDRESS), any(PingForConfigurationType.class))).thenThrow(new WebServiceException());
    HealthStatus res = service.checkPrivatlakarportal();
    assertNotNull(res);
    assertFalse(res.isOk());
    assertNotNull(res.getMeasurement());
}
Also used : PingForConfigurationType(se.riv.itintegration.monitoring.v1.PingForConfigurationType) WebServiceException(javax.xml.ws.WebServiceException) HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) Test(org.junit.Test)

Example 37 with WebServiceException

use of javax.xml.ws.WebServiceException in project webcert by sklintyg.

the class HealthCheckServiceImplTest method testCheckIntygstjanstException.

@Test
public void testCheckIntygstjanstException() {
    when(intygstjanstPingForConfiguration.pingForConfiguration(eq(IT_LOGICAL_ADDRESS), any(PingForConfigurationType.class))).thenThrow(new WebServiceException());
    HealthStatus res = service.checkIntygstjanst();
    assertNotNull(res);
    assertFalse(res.isOk());
    assertNotNull(res.getMeasurement());
}
Also used : PingForConfigurationType(se.riv.itintegration.monitoring.v1.PingForConfigurationType) WebServiceException(javax.xml.ws.WebServiceException) HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) Test(org.junit.Test)

Example 38 with WebServiceException

use of javax.xml.ws.WebServiceException in project webcert by sklintyg.

the class IntygServiceImpl method getIntygData.

/**
 * Builds a IntygContentHolder by first trying to get the Intyg from intygstjansten. If
 * not found or the Intygstjanst couldn't be reached, the local Utkast - if available -
 * will be used instead.
 * <p>
 * Note that even when found, we check if we need to decorate the response with data from the utkast in order
 * to mitigate async send states. (E.g. a send may be in resend due to 3rd party issues, in that case decorate with
 * data about sent state from the Utkast)
 *
 * @param relations
 */
private IntygContentHolder getIntygData(String intygId, String typ, boolean relations) {
    try {
        CertificateResponse certificate = modelFacade.getCertificate(intygId, typ);
        String internalIntygJsonModel = certificate.getInternalModel();
        final Personnummer personId = certificate.getUtlatande().getGrundData().getPatient().getPersonId();
        // INTYG-4086: Patient object populated according to ruleset for the intygstyp at hand.
        // Since an FK-intyg never will have anything other than personId, try to fetch all using ruleset
        Patient newPatientData = patientDetailsResolver.resolvePatient(personId, typ);
        Utlatande utlatande = null;
        boolean patientNameChanged = false;
        boolean patientAddressChanged = false;
        try {
            utlatande = moduleRegistry.getModuleApi(typ).getUtlatandeFromJson(internalIntygJsonModel);
            patientNameChanged = patientDetailsResolver.isPatientNamedChanged(utlatande.getGrundData().getPatient(), newPatientData);
            patientAddressChanged = patientDetailsResolver.isPatientAddressChanged(utlatande.getGrundData().getPatient(), newPatientData);
        } catch (IOException e) {
            LOG.error("Failed to getUtlatandeFromJson intygsId {} while checking for updated patient information", intygId);
        }
        // parameters were available.
        if (newPatientData != null) {
            // Get the module api and use the "updateBeforeSave" to update the outbound "model" with the
            // Patient object.
            ModuleApi moduleApi = moduleRegistry.getModuleApi(typ);
            // INTYG-5354, INTYG-5380: Don't use incomplete address from external data sources (PU/js).
            if (!completeAddressProvided(newPatientData)) {
                // Use the old address data.
                Patient oldPatientData = utlatande.getGrundData().getPatient();
                copyOldAddressToNewPatientData(oldPatientData, newPatientData);
            }
            internalIntygJsonModel = moduleApi.updateBeforeSave(internalIntygJsonModel, newPatientData);
        }
        utkastIntygDecorator.decorateWithUtkastStatus(certificate);
        Relations certificateRelations = intygRelationHelper.getRelationsForIntyg(intygId);
        final SekretessStatus sekretessStatus = patientDetailsResolver.getSekretessStatus(personId);
        if (SekretessStatus.UNDEFINED.equals(sekretessStatus)) {
            throw new WebCertServiceException(WebCertServiceErrorCodeEnum.PU_PROBLEM, "Sekretesstatus could not be fetched from the PU service");
        }
        final boolean sekretessmarkering = SekretessStatus.TRUE.equals(sekretessStatus);
        Utkast utkast = utkastRepository.findOneByIntygsIdAndIntygsTyp(intygId, typ);
        final LocalDateTime created = utkast != null ? utkast.getSkapad() : null;
        return IntygContentHolder.builder().setContents(internalIntygJsonModel).setUtlatande(certificate.getUtlatande()).setStatuses(certificate.getMetaData().getStatus()).setRevoked(certificate.isRevoked()).setRelations(certificateRelations).setCreated(created).setDeceased(isDeceased(personId)).setSekretessmarkering(sekretessmarkering).setPatientNameChangedInPU(patientNameChanged).setPatientAddressChangedInPU(patientAddressChanged).build();
    } catch (IntygModuleFacadeException me) {
        // It's possible the Intygstjanst hasn't received the Intyg yet, look for it locally before rethrowing
        // exception
        Utkast utkast = utkastRepository.findOneByIntygsIdAndIntygsTyp(intygId, typ);
        if (utkast == null) {
            throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, me);
        }
        return buildIntygContentHolderForUtkast(utkast, relations);
    } catch (WebServiceException wse) {
        // Something went wrong communication-wise, try to find a matching Utkast instead.
        Utkast utkast = utkastRepository.findOneByIntygsIdAndIntygsTyp(intygId, typ);
        if (utkast == null) {
            throw new WebCertServiceException(WebCertServiceErrorCodeEnum.DATA_NOT_FOUND, "Cannot get intyg. Intygstjansten was not reachable and the Utkast could " + "not be found, perhaps it was issued by a non-webcert system?");
        }
        return buildIntygContentHolderForUtkast(utkast, relations);
    } catch (ModuleNotFoundException | ModuleException e) {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, e);
    }
}
Also used : ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) ChronoLocalDateTime(java.time.chrono.ChronoLocalDateTime) LocalDateTime(java.time.LocalDateTime) ModuleNotFoundException(se.inera.intyg.common.support.modules.registry.ModuleNotFoundException) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) WebServiceException(javax.xml.ws.WebServiceException) CertificateResponse(se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) IOException(java.io.IOException) IntygModuleFacadeException(se.inera.intyg.webcert.web.service.intyg.converter.IntygModuleFacadeException) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) Personnummer(se.inera.intyg.schemas.contract.Personnummer) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ModuleException(se.inera.intyg.common.support.modules.support.api.exception.ModuleException)

Example 39 with WebServiceException

use of javax.xml.ws.WebServiceException in project narayana by jbosstm.

the class XTSServiceTestInterpreter method processCommandBlock.

/**
 * execute a block of commands by recursively executing each embedded command list. results are
 * verified and bound to command variables in accordance with embedded bind commands. command
 * variable references in embedded command lists are substituted with the corresponding bound
 * values before recursive execution is performed.
 *
 * @param commandList
 * @param resultsList
 * @throws WebServiceException
 */
private void processCommandBlock(List<String> commandList, List<String> resultsList, HashMap<String, String> bindings) throws WebServiceException {
    // break up the command block into a list of nested command lists. successive command lists will
    // be separated by a "next" or "bind" command. the block will be terminated by an "endblock" command.
    // nested commands may themselves be block commands.
    List<List<String>> subcommandsList = new ArrayList<List<String>>();
    List<String> subcommands = new ArrayList<String>();
    // each subcommand list needs to start with next or bind
    subcommands.add("next");
    int size = commandList.size();
    int depth = 0;
    int idx;
    for (idx = 0; idx < size; idx++) {
        String command = commandList.get(idx);
        if (depth > 0) {
            // track nesting levels
            if (command.equals("block")) {
                depth++;
            } else if (command.equals("endblock")) {
                depth--;
            }
            subcommands.add(command);
        } else {
            if (command.equals("block")) {
                // add nested block command to sublist
                subcommands.add(command);
                depth++;
            } else if (command.equals("next")) {
                // create new sublist starting with next
                subcommandsList.add(subcommands);
                subcommands = new ArrayList<String>();
                subcommands.add(command);
            } else if (command.equals("bindings")) {
                // create new sublist starting with bind
                subcommandsList.add(subcommands);
                subcommands = new ArrayList<String>();
                subcommands.add(command);
            } else if (command.equals("endblock")) {
                // should be at end of commandlist
                if (idx != size - 1) {
                    throw new WebServiceException("block commands reached endblock before end of block list");
                }
                subcommandsList.add(subcommands);
            } else {
                // just append command to current subcommands list
                subcommands.add(command);
            }
        }
    }
    // ok, we should have a list of command lists all starting with either next or bind
    // now we execute each next command list in turn after substituting bound variables
    // of the form $xxx and we execute each bind command list by testing result values
    // against literals or binding result values to variables and possibly outputting
    // results to the global results list
    List<String> subresultsList = null;
    size = subcommandsList.size();
    for (idx = 0; idx < size; idx++) {
        subcommands = subcommandsList.get(idx);
        String command = subcommands.remove(0);
        if (command.equals("next")) {
            subresultsList = new ArrayList<String>();
            bindCommands(subcommands, bindings);
            processCommands(subcommands, subresultsList);
        } else if (command.equals("bindings")) {
            bindResults(subcommands, subresultsList, resultsList, bindings);
        }
    }
    resultsList.addAll(subresultsList);
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 40 with WebServiceException

use of javax.xml.ws.WebServiceException in project scout.rt by eclipse.

the class PortProducer method provide.

/**
 * Creates a new Port to interact with the webservice endpoint.
 */
@Override
public PORT provide() {
    try {
        // Create the service
        final Constructor<? extends Service> constructor = m_serviceClazz.getConstructor(URL.class, QName.class);
        @SuppressWarnings("unchecked") final SERVICE service = (SERVICE) constructor.newInstance(m_wsdlLocation, new QName(m_targetNamespace, m_serviceName));
        // Install the handler chain
        service.setHandlerResolver(new HandlerResolver() {

            @Override
            public List<Handler> getHandlerChain(final PortInfo portInfo) {
                final List<Handler<? extends MessageContext>> handlerChain = new ArrayList<>();
                m_initializer.initHandlers(handlerChain);
                for (int i = 0; i < handlerChain.size(); i++) {
                    handlerChain.set(i, proxyHandler(handlerChain.get(i)));
                }
                @SuppressWarnings("unchecked") final List<Handler> handlers = TypeCastUtility.castValue(handlerChain, List.class);
                return handlers;
            }
        });
        // Install implementor specific webservice features
        final List<WebServiceFeature> webServiceFeatures = new ArrayList<>();
        m_initializer.initWebServiceFeatures(webServiceFeatures);
        // Create the port
        return service.getPort(m_portTypeClazz, CollectionUtility.toArray(webServiceFeatures, WebServiceFeature.class));
    } catch (final ReflectiveOperationException e) {
        throw new WebServiceException("Failed to instantiate webservice stub.", e);
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) PortInfo(javax.xml.ws.handler.PortInfo) HandlerResolver(javax.xml.ws.handler.HandlerResolver) WebServiceFeature(javax.xml.ws.WebServiceFeature) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

WebServiceException (javax.xml.ws.WebServiceException)378 Test (org.junit.Test)115 SOAPException (javax.xml.soap.SOAPException)59 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)59 SOAPMessage (javax.xml.soap.SOAPMessage)57 ConnectException (java.net.ConnectException)48 ErrorCode (org.olat.modules.vitero.model.ErrorCode)48 URL (java.net.URL)46 SOAPElement (javax.xml.soap.SOAPElement)46 IOException (java.io.IOException)43 SOAPBody (javax.xml.soap.SOAPBody)34 ArrayList (java.util.ArrayList)32 SOAPBodyElement (javax.xml.soap.SOAPBodyElement)32 BindingProvider (javax.xml.ws.BindingProvider)31 Retry (io.github.resilience4j.retry.Retry)29 Service (javax.xml.ws.Service)29 QName (javax.xml.namespace.QName)27 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)21 DataHandler (javax.activation.DataHandler)17 RetryConfig (io.github.resilience4j.retry.RetryConfig)16