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;
}
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);
}
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);
}
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;
}
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);
}
}
Aggregations