use of org.w3._2007.rif.Payload in project camel by apache.
the class Soap12DataFormatAdapter method doUnmarshal.
@Override
public Object doUnmarshal(Exchange exchange, InputStream stream, Object rootObject) throws IOException {
if (rootObject.getClass() != Envelope.class) {
throw new RuntimeCamelException("Expected Soap Envelope but got " + rootObject.getClass());
}
Envelope envelope = (Envelope) rootObject;
Header header = envelope.getHeader();
if (header != null) {
List<Object> returnHeaders;
List<Object> anyHeaderElements = envelope.getHeader().getAny();
if (null != anyHeaderElements && !(getDataFormat().isIgnoreUnmarshalledHeaders())) {
if (getDataFormat().isIgnoreJAXBElement()) {
returnHeaders = new ArrayList<Object>();
for (Object headerEl : anyHeaderElements) {
returnHeaders.add(JAXBIntrospector.getValue(headerEl));
}
} else {
returnHeaders = anyHeaderElements;
}
exchange.getOut().setHeader(SoapJaxbDataFormat.SOAP_UNMARSHALLED_HEADER_LIST, returnHeaders);
}
}
List<Object> anyElement = envelope.getBody().getAny();
if (anyElement.size() == 0) {
// No parameter so return null
return null;
}
Object payloadEl = anyElement.get(0);
Object payload = JAXBIntrospector.getValue(payloadEl);
if (payload instanceof Fault) {
Exception exception = createExceptionFromFault((Fault) payload);
exchange.setException(exception);
return null;
} else {
return getDataFormat().isIgnoreJAXBElement() ? payload : payloadEl;
}
}
use of org.w3._2007.rif.Payload in project hale by halestudio.
the class ModelRifToRifTranslator method translate.
/**
* @see com.onespatial.jrc.tns.oml_to_rif.api.Translator#translate(Object)
* which this method implements.
* @param source
* {@link ModelRifDocument}
* @return {@link Document}
* @throws TranslationException
* if any exceptions are thrown during translation.
*/
@Override
public Document translate(ModelRifDocument source) throws TranslationException {
final Document document = factory.createDocument();
Payload payload = factory.createPayload();
document.setPayload(payload);
GroupContents group = factory.createGroupContents();
payload.setGroup(group);
for (ModelSentence s : source.getSentences()) {
group.getSentence().add(buildSentence(s));
}
return document;
}
Aggregations