use of org.apache.cxf.binding.corba.types.CorbaObjectHandler in project cxf by apache.
the class CorbaStreamFaultOutInterceptor method setUserExceptionFromFaultDetail.
protected void setUserExceptionFromFaultDetail(CorbaMessage message, org.w3c.dom.Element faultDetail, RaisesType exType, OperationInfo opInfo, DataWriter<XMLStreamWriter> writer, ServiceInfo service) throws Exception {
QName exIdlType = exType.getException();
QName elName = new QName("", exIdlType.getLocalPart());
MessagePartInfo faultPart = getFaultMessagePartInfo(opInfo, elName);
// faultDetailt.getFirstChild() skips the "detail" element
Object fault = extractPartsInfoFromDetail((Element) faultDetail.getFirstChild(), exType);
CorbaFaultStreamWriter faultWriter = new CorbaFaultStreamWriter(orb, exType, message.getCorbaTypeMap(), service);
writer.write(fault, faultPart, faultWriter);
CorbaObjectHandler[] objs = faultWriter.getCorbaObjects();
CorbaStreamable streamable = message.createStreamableObject(objs[0], elName);
message.setStreamableException(streamable);
}
use of org.apache.cxf.binding.corba.types.CorbaObjectHandler in project cxf by apache.
the class CorbaStreamOutEndingInterceptor method handleOutBoundMessage.
private void handleOutBoundMessage(CorbaMessage message, BindingOperationInfo boi) {
OperationInfo opInfo = boi.getOperationInfo();
OperationType opType = boi.getExtensor(OperationType.class);
List<ParamType> paramTypes = opType.getParam();
MessageInfo outMsgInfo = opInfo.getOutput();
String wrapNSUri = null;
boolean wrap = false;
if (boi.isUnwrappedCapable()) {
wrap = true;
if (outMsgInfo != null) {
wrapNSUri = getWrappedParamNamespace(outMsgInfo);
if (!CorbaUtils.isElementFormQualified(service, wrapNSUri)) {
wrapNSUri = "";
}
}
}
CorbaStreamWriter writer = (CorbaStreamWriter) message.getContent(XMLStreamWriter.class);
CorbaObjectHandler[] objs = writer.getCorbaObjects();
int count = 0;
int msgIndex = 0;
ArgType returnParam = opType.getReturn();
if (returnParam != null) {
QName retName;
if (wrap) {
retName = new QName(wrapNSUri, returnParam.getName());
} else {
retName = getMessageParamQName(outMsgInfo, returnParam.getName(), msgIndex);
}
QName retIdlType = returnParam.getIdltype();
CorbaObjectHandler obj = CorbaHandlerUtils.initializeObjectHandler(orb, retName, retIdlType, typeMap, service);
CorbaStreamable streamable = message.createStreamableObject(obj, retName);
message.setStreamableReturn(streamable);
msgIndex++;
}
for (Iterator<ParamType> iter = paramTypes.iterator(); iter.hasNext(); ) {
ParamType param = iter.next();
QName idlType = param.getIdltype();
QName paramName;
CorbaObjectHandler obj = null;
if (param.getMode().equals(ModeType.OUT)) {
if (wrap) {
paramName = new QName(wrapNSUri, param.getName());
} else {
paramName = getMessageParamQName(outMsgInfo, param.getName(), msgIndex);
}
obj = CorbaHandlerUtils.initializeObjectHandler(orb, paramName, idlType, typeMap, service);
msgIndex++;
} else {
obj = objs[count++];
paramName = obj.getName();
}
CorbaStreamable streamable = message.createStreamableObject(obj, paramName);
ModeType paramMode = param.getMode();
if (paramMode.value().equals("in")) {
streamable.setMode(org.omg.CORBA.ARG_IN.value);
} else if (paramMode.value().equals("inout")) {
streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
}
// default mode is out
message.addStreamableArgument(streamable);
}
}
use of org.apache.cxf.binding.corba.types.CorbaObjectHandler in project cxf by apache.
the class CorbaObjectReader method readSequence.
// CHECKSTYLE:ON
public void readSequence(CorbaObjectHandler obj) throws CorbaBindingException {
if (obj instanceof CorbaOctetSequenceHandler) {
int length = stream.read_ulong();
byte[] value = new byte[length];
stream.read_octet_array(value, 0, length);
((CorbaOctetSequenceHandler) obj).setValue(value);
} else {
CorbaSequenceHandler sequenceObj = (CorbaSequenceHandler) obj;
List<CorbaObjectHandler> seqElements = sequenceObj.getElements();
int length = stream.read_ulong();
List<CorbaObjectHandler> elements = new ArrayList<>(length);
// object that is in the input stream.
if (sequenceObj.getTemplateElement() != null) {
sequenceObj.clear();
CorbaObjectHandler template = sequenceObj.getTemplateElement();
for (int i = 0; i < length; ++i) {
CorbaObjectHandler seqElement;
if (i < seqElements.size()) {
seqElement = seqElements.get(i);
} else {
seqElement = initializeCorbaObjectHandler(template);
}
read(seqElement);
elements.add(seqElement);
}
sequenceObj.setElements(elements);
} else {
// We have a bounded sequence and the object should already be pre-built
for (int i = 0; i < length; ++i) {
read(seqElements.get(i));
}
sequenceObj.setElements(seqElements.subList(0, length));
}
}
}
use of org.apache.cxf.binding.corba.types.CorbaObjectHandler in project cxf by apache.
the class CorbaObjectReader method initializeCorbaObjectHandler.
private CorbaObjectHandler initializeCorbaObjectHandler(CorbaObjectHandler template) {
Constructor<?> templateConstructor = template.getClass().getDeclaredConstructors()[0];
Object[] params = new Object[4];
// of a sequence and needs to have the name "item" in order
if (template.isRecursive()) {
// Revisit: Is this always the case?
params[0] = new QName("item");
} else {
params[0] = template.getName();
}
params[1] = template.getIdlType();
params[2] = template.getTypeCode();
params[3] = template.getType();
CorbaObjectHandler handler = null;
try {
handler = (CorbaObjectHandler) templateConstructor.newInstance(params);
// the template object.
if (template instanceof CorbaAnyHandler) {
((CorbaAnyHandler) handler).setTypeMap(((CorbaAnyHandler) template).getTypeMap());
}
} catch (java.lang.Exception ex) {
throw new CorbaBindingException("Unable to instantiate sequence element", ex);
}
if (template instanceof CorbaSequenceHandler) {
CorbaSequenceHandler templateSeq = (CorbaSequenceHandler) template;
((CorbaSequenceHandler) handler).setTemplateElement(templateSeq.getTemplateElement());
} else if (template instanceof CorbaStructHandler) {
CorbaStructHandler templateStruct = (CorbaStructHandler) template;
CorbaStructHandler struct = (CorbaStructHandler) handler;
struct.setRecursive(template.isRecursive());
List<CorbaObjectHandler> members = templateStruct.getMembers();
for (int i = 0; i < members.size(); i++) {
CorbaObjectHandler member = initializeCorbaObjectHandler(members.get(i));
struct.addMember(member);
}
} else if (template instanceof CorbaArrayHandler) {
CorbaArrayHandler templateArray = (CorbaArrayHandler) template;
CorbaArrayHandler array = (CorbaArrayHandler) handler;
List<CorbaObjectHandler> elements = templateArray.getElements();
for (int i = 0; i < elements.size(); i++) {
CorbaObjectHandler element = initializeCorbaObjectHandler(elements.get(i));
array.addElement(element);
}
} else if (template instanceof CorbaUnionHandler) {
CorbaUnionHandler templateUnion = (CorbaUnionHandler) template;
CorbaUnionHandler union = (CorbaUnionHandler) handler;
union.setRecursive(template.isRecursive());
union.setDiscriminator(initializeCorbaObjectHandler(templateUnion.getDiscriminator()));
List<CorbaObjectHandler> cases = templateUnion.getCases();
for (int i = 0; i < cases.size(); i++) {
union.addCase(initializeCorbaObjectHandler(cases.get(i)));
}
}
return handler;
}
use of org.apache.cxf.binding.corba.types.CorbaObjectHandler in project cxf by apache.
the class CorbaObjectWriter method writeAny.
public void writeAny(CorbaAnyHandler anyHandler) throws CorbaBindingException {
CorbaObjectHandler containedType = anyHandler.getAnyContainedType();
Any a = anyHandler.getValue();
// This is true if we have an empty any
if (containedType != null) {
a.type(containedType.getTypeCode());
OutputStream os = a.create_output_stream();
CorbaObjectWriter writer = new CorbaObjectWriter(os);
writer.write(containedType);
a.read_value(os.create_input_stream(), containedType.getTypeCode());
}
stream.write_any(a);
}
Aggregations