Search in sources :

Example 6 with CorbaObjectHandler

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);
}
Also used : CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) QName(javax.xml.namespace.QName) CorbaFaultStreamWriter(org.apache.cxf.binding.corba.runtime.CorbaFaultStreamWriter) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Example 7 with CorbaObjectHandler

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);
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) ArgType(org.apache.cxf.binding.corba.wsdl.ArgType) CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) QName(javax.xml.namespace.QName) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType) MessageInfo(org.apache.cxf.service.model.MessageInfo) CorbaStreamWriter(org.apache.cxf.binding.corba.runtime.CorbaStreamWriter) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) ModeType(org.apache.cxf.binding.corba.wsdl.ModeType) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType)

Example 8 with CorbaObjectHandler

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));
        }
    }
}
Also used : CorbaOctetSequenceHandler(org.apache.cxf.binding.corba.types.CorbaOctetSequenceHandler) CorbaSequenceHandler(org.apache.cxf.binding.corba.types.CorbaSequenceHandler) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) ArrayList(java.util.ArrayList)

Example 9 with CorbaObjectHandler

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;
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) QName(javax.xml.namespace.QName) CorbaSequenceHandler(org.apache.cxf.binding.corba.types.CorbaSequenceHandler) CorbaStructHandler(org.apache.cxf.binding.corba.types.CorbaStructHandler) CorbaUnionHandler(org.apache.cxf.binding.corba.types.CorbaUnionHandler) CorbaArrayHandler(org.apache.cxf.binding.corba.types.CorbaArrayHandler) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) ArrayList(java.util.ArrayList) List(java.util.List) CorbaAnyHandler(org.apache.cxf.binding.corba.types.CorbaAnyHandler)

Example 10 with CorbaObjectHandler

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);
}
Also used : CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) OutputStream(org.omg.CORBA.portable.OutputStream) Any(org.omg.CORBA.Any)

Aggregations

CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)16 QName (javax.xml.namespace.QName)10 CorbaStreamable (org.apache.cxf.binding.corba.CorbaStreamable)4 TypeCode (org.omg.CORBA.TypeCode)4 OutputStream (org.omg.CORBA.portable.OutputStream)4 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)3 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)3 CorbaSequenceHandler (org.apache.cxf.binding.corba.types.CorbaSequenceHandler)3 ModeType (org.apache.cxf.binding.corba.wsdl.ModeType)3 ParamType (org.apache.cxf.binding.corba.wsdl.ParamType)3 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)3 Test (org.junit.Test)3 Any (org.omg.CORBA.Any)3 InputStream (org.omg.CORBA.portable.InputStream)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)2 CorbaFaultStreamWriter (org.apache.cxf.binding.corba.runtime.CorbaFaultStreamWriter)2 CorbaStreamWriter (org.apache.cxf.binding.corba.runtime.CorbaStreamWriter)2 CorbaArrayHandler (org.apache.cxf.binding.corba.types.CorbaArrayHandler)2