Search in sources :

Example 46 with If

use of org.w3._2007.rif.If in project camel by apache.

the class Soap12DataFormatAdapter method doMarshal.

@Override
public Object doMarshal(Exchange exchange, Object inputObject, OutputStream stream, String soapAction) throws IOException {
    Body body = objectFactory.createBody();
    Header header = objectFactory.createHeader();
    Throwable exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class);
    if (exception == null) {
        exception = exchange.getIn().getHeader(Exchange.EXCEPTION_CAUGHT, Throwable.class);
    }
    final List<Object> bodyContent;
    List<Object> headerContent = new ArrayList<Object>();
    if (exception != null) {
        bodyContent = new ArrayList<Object>();
        bodyContent.add(createFaultFromException(exception));
    } else {
        if (!dataFormat.isIgnoreUnmarshalledHeaders()) {
            List<Object> inboundSoapHeaders = (List<Object>) exchange.getIn().getHeader(SoapJaxbDataFormat.SOAP_UNMARSHALLED_HEADER_LIST);
            if (null != inboundSoapHeaders) {
                headerContent.addAll(inboundSoapHeaders);
            }
        }
        bodyContent = getDataFormat().createContentFromObject(inputObject, soapAction, headerContent);
    }
    for (Object elem : bodyContent) {
        body.getAny().add(elem);
    }
    for (Object elem : headerContent) {
        header.getAny().add(elem);
    }
    Envelope envelope = new Envelope();
    if (headerContent.size() > 0) {
        envelope.setHeader(header);
    }
    envelope.setBody(body);
    JAXBElement<Envelope> envelopeEl = objectFactory.createEnvelope(envelope);
    return envelopeEl;
}
Also used : Header(org.w3._2003._05.soap_envelope.Header) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Envelope(org.w3._2003._05.soap_envelope.Envelope) Body(org.w3._2003._05.soap_envelope.Body)

Example 47 with If

use of org.w3._2007.rif.If in project camel by apache.

the class Soap12DataFormatAdapter method createFaultFromException.

/**
     * Creates a SOAP fault from the exception and populates the message as well
     * as the detail. The detail object is read from the method getFaultInfo of
     * the throwable if present
     * 
     * @param exception the cause exception
     * @return SOAP fault from given Throwable
     */
@SuppressWarnings("unchecked")
private JAXBElement<Fault> createFaultFromException(final Throwable exception) {
    WebFault webFault = exception.getClass().getAnnotation(WebFault.class);
    if (webFault == null || webFault.targetNamespace() == null) {
        throw new RuntimeException("The exception " + exception.getClass().getName() + " needs to have an WebFault annotation with name and targetNamespace", exception);
    }
    QName name = new QName(webFault.targetNamespace(), webFault.name());
    Object faultObject;
    try {
        Method method = exception.getClass().getMethod("getFaultInfo");
        faultObject = method.invoke(exception);
    } catch (Exception e) {
        throw new RuntimeCamelException("Exception while trying to get fault details", e);
    }
    Fault fault = new Fault();
    Faultcode code = new Faultcode();
    code.setValue(FAULT_CODE_SERVER);
    fault.setCode(code);
    Reasontext text = new Reasontext();
    text.setValue(exception.getMessage());
    text.setLang("en");
    fault.setReason(new Faultreason().withText(text));
    Detail detailEl = new ObjectFactory().createDetail();
    @SuppressWarnings("rawtypes") JAXBElement<?> faultDetailContent = new JAXBElement(name, faultObject.getClass(), faultObject);
    detailEl.getAny().add(faultDetailContent);
    fault.setDetail(detailEl);
    return new ObjectFactory().createFault(fault);
}
Also used : Reasontext(org.w3._2003._05.soap_envelope.Reasontext) QName(javax.xml.namespace.QName) Fault(org.w3._2003._05.soap_envelope.Fault) WebFault(javax.xml.ws.WebFault) Method(java.lang.reflect.Method) JAXBElement(javax.xml.bind.JAXBElement) SOAPException(javax.xml.soap.SOAPException) RuntimeCamelException(org.apache.camel.RuntimeCamelException) IOException(java.io.IOException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) WebFault(javax.xml.ws.WebFault) Faultcode(org.w3._2003._05.soap_envelope.Faultcode) ObjectFactory(org.w3._2003._05.soap_envelope.ObjectFactory) RuntimeCamelException(org.apache.camel.RuntimeCamelException) Faultreason(org.w3._2003._05.soap_envelope.Faultreason) Detail(org.w3._2003._05.soap_envelope.Detail)

Example 48 with If

use of org.w3._2007.rif.If in project webcert by sklintyg.

the class FragaSvarServiceImpl method sendFragaSvarToExternalParty.

private void sendFragaSvarToExternalParty(final FragaSvar fragaSvar) {
    // Send to external party (FK)
    SendMedicalCertificateAnswerType sendType = new SendMedicalCertificateAnswerType();
    AnswerToFkType answer = FKAnswerConverter.convert(fragaSvar);
    sendType.setAnswer(answer);
    // Remove ASAP.
    if ("true".equalsIgnoreCase(forceFullstandigtNamn)) {
        answer.getLakarutlatande().getPatient().setFullstandigtNamn("---");
    }
    AttributedURIType logicalAddress = new AttributedURIType();
    logicalAddress.setValue(sendAnswerToFkLogicalAddress);
    SendMedicalCertificateAnswerResponseType response;
    try {
        response = sendAnswerToFKClient.sendMedicalCertificateAnswer(logicalAddress, sendType);
    } catch (SOAPFaultException e) {
        LOGGER.error("Failed to send answer to FK, error was: " + e.getMessage());
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, e.getMessage());
    }
    if (!response.getResult().getResultCode().equals(ResultCodeEnum.OK)) {
        LOGGER.error("Failed to send answer to FK, result was " + response.getResult().getErrorText());
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, response.getResult().getErrorText());
    }
    monitoringService.logAnswerSent(fragaSvar.getExternReferens(), fragaSvar.getInternReferens(), (fragaSvar.getIntygsReferens() == null) ? null : fragaSvar.getIntygsReferens().getIntygsId(), fragaSvar.getVardAktorHsaId(), fragaSvar.getAmne());
    // Notify stakeholders
    sendNotification(fragaSvar, NotificationEvent.NEW_ANSWER_FROM_CARE);
}
Also used : SendMedicalCertificateAnswerResponseType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType) AttributedURIType(org.w3.wsaddressing10.AttributedURIType) AnswerToFkType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType) SendMedicalCertificateAnswerType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 49 with If

use of org.w3._2007.rif.If in project airavata by apache.

the class StorageCreator method createStorage.

// The target site must have storage factory deployed with bes factory
public StorageClient createStorage() throws Exception {
    if (factoryUrl == null) {
        throw new Exception("Cannot create Storage Factory Url");
    }
    EndpointReferenceType sfEpr = WSUtilities.makeServiceEPR(factoryUrl, StorageFactory.SMF_PORT);
    String dn = findServerName(factoryUrl, sfEpr);
    WSUtilities.addServerIdentity(sfEpr, dn);
    secProps.getETDSettings().setReceiver(new X500Principal(dn));
    secProps.getETDSettings().setIssuerCertificateChain(secProps.getCredential().getCertificateChain());
    // TODO: remove it afterwards
    if (userName != null) {
        secProps.getETDSettings().getRequestedUserAttributes2().put("xlogin", new String[] { userName });
    }
    StorageFactoryClient sfc = new StorageFactoryClient(sfEpr, secProps);
    if (log.isDebugEnabled()) {
        log.debug("Using storage factory at <" + sfc.getUrl() + ">");
    }
    StorageClient sc = null;
    try {
        sc = sfc.createSMS(getCreateSMSDocument());
        String addr = sc.getEPR().getAddress().getStringValue();
        log.info(addr);
    } catch (Exception ex) {
        log.error("Could not create storage", ex);
        throw new Exception(ex);
    }
    return sc;
}
Also used : EndpointReferenceType(org.w3.x2005.x08.addressing.EndpointReferenceType) X500Principal(javax.security.auth.x500.X500Principal) StorageClient(de.fzj.unicore.uas.client.StorageClient) StorageFactoryClient(de.fzj.unicore.uas.client.StorageFactoryClient)

Example 50 with If

use of org.w3._2007.rif.If in project airavata by apache.

the class BESJobSubmissionTask method cancelJob.

/**
 * EndpointReference need to be saved to make cancel work.
 *
 * @param processContext
 * @throws GFacException
 */
public boolean cancelJob(ProcessContext processContext) throws GFacException {
    try {
        String activityEpr = processContext.getJobModel().getJobDescription();
        // initSecurityProperties(processContext);
        EndpointReferenceType eprt = EndpointReferenceType.Factory.parse(activityEpr);
        JobSubmissionProtocol protocol = processContext.getJobSubmissionProtocol();
        String interfaceId = processContext.getApplicationInterfaceDescription().getApplicationInterfaceId();
        String factoryUrl = null;
        if (protocol.equals(JobSubmissionProtocol.UNICORE)) {
            UnicoreJobSubmission unicoreJobSubmission = GFacUtils.getUnicoreJobSubmission(interfaceId);
            factoryUrl = unicoreJobSubmission.getUnicoreEndPointURL();
        }
        EndpointReferenceType epr = EndpointReferenceType.Factory.newInstance();
        epr.addNewAddress().setStringValue(factoryUrl);
        FactoryClient factory = new FactoryClient(epr, secProperties);
        factory.terminateActivity(eprt);
        return true;
    } catch (Exception e) {
        throw new GFacException(e.getLocalizedMessage(), e);
    }
}
Also used : JobSubmissionProtocol(org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol) UnicoreJobSubmission(org.apache.airavata.model.appcatalog.computeresource.UnicoreJobSubmission) FactoryClient(de.fzj.unicore.bes.client.FactoryClient) EndpointReferenceType(org.w3.x2005.x08.addressing.EndpointReferenceType) GFacException(org.apache.airavata.gfac.core.GFacException) URISyntaxException(java.net.URISyntaxException) CredentialStoreException(org.apache.airavata.credential.store.store.CredentialStoreException) TaskException(org.apache.airavata.gfac.core.task.TaskException) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) JSchException(com.jcraft.jsch.JSchException) RegistryException(org.apache.airavata.registry.cpi.RegistryException) AiravataException(org.apache.airavata.common.exception.AiravataException) GFacException(org.apache.airavata.gfac.core.GFacException) SSHApiException(org.apache.airavata.gfac.core.SSHApiException) IOException(java.io.IOException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Aggregations

Actuate (org.n52.shetland.w3c.xlink.Actuate)15 Show (org.n52.shetland.w3c.xlink.Show)15 ActuateType (org.w3.x1999.xlink.ActuateType)15 ShowType (org.w3.x1999.xlink.ShowType)15 Reference (org.n52.shetland.w3c.xlink.Reference)14 Type (org.n52.shetland.w3c.xlink.Type)14 TypeType (org.w3.x1999.xlink.TypeType)14 IOException (java.io.IOException)13 XmlObject (org.apache.xmlbeans.XmlObject)11 AbstractCRSType (net.opengis.gml.x32.AbstractCRSType)10 CodeType (net.opengis.gml.x32.CodeType)10 EXExtentType (org.isotc211.x2005.gmd.EXExtentType)10 ProvideAndRegisterDocumentSetRequestType (ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)9 ArrayList (java.util.ArrayList)8 CIResponsiblePartyPropertyType (org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType)8 CIResponsiblePartyType (org.isotc211.x2005.gmd.CIResponsiblePartyType)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 BaseUnitType (net.opengis.gml.x32.BaseUnitType)6 VerticalDatumPropertyType (net.opengis.gml.x32.VerticalDatumPropertyType)5 VerticalDatumType (net.opengis.gml.x32.VerticalDatumType)5