Search in sources :

Example 6 with FaultInfo

use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.

the class ColocUtilTest method testIsSameFaultInfo.

@Test
public void testIsSameFaultInfo() {
    OperationInfo oi = control.createMock(OperationInfo.class);
    boolean match = ColocUtil.isSameFaultInfo(null, null);
    assertEquals("Should return true", true, match);
    List<FaultInfo> fil1 = new ArrayList<>();
    match = ColocUtil.isSameFaultInfo(fil1, null);
    assertEquals("Should not find a match", false, match);
    match = ColocUtil.isSameFaultInfo(null, fil1);
    assertEquals("Should not find a match", false, match);
    List<FaultInfo> fil2 = new ArrayList<>();
    match = ColocUtil.isSameFaultInfo(fil1, fil2);
    QName fn1 = new QName("A", "B");
    QName fn2 = new QName("C", "D");
    FaultInfo fi1 = new FaultInfo(fn1, null, oi);
    fi1.setProperty(Class.class.getName(), PingMeFault.class);
    fil1.add(fi1);
    FaultInfo fi2 = new FaultInfo(fn2, null, oi);
    fi2.setProperty(Class.class.getName(), FaultDetailT.class);
    match = ColocUtil.isSameFaultInfo(fil1, fil2);
    assertEquals("Should not find a match", false, match);
    FaultInfo fi3 = new FaultInfo(fn2, null, oi);
    fi3.setProperty(Class.class.getName(), PingMeFault.class);
    fil2.add(fi3);
    match = ColocUtil.isSameFaultInfo(fil1, fil2);
    assertEquals("Should find a match", true, match);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with FaultInfo

use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.

the class CorbaStreamFaultInInterceptor method getFaultInfo.

protected FaultInfo getFaultInfo(OperationInfo opInfo, QName faultName) {
    Iterator<FaultInfo> faults = opInfo.getFaults().iterator();
    while (faults.hasNext()) {
        FaultInfo fault = faults.next();
        MessagePartInfo partInfo = fault.getMessageParts().get(0);
        if (partInfo.isElement() && partInfo.getElementQName().getLocalPart().equals(faultName.getLocalPart())) {
            return fault;
        } else if (partInfo.getTypeQName().getLocalPart().equals(faultName.getLocalPart())) {
            return fault;
        }
    }
    return null;
}
Also used : FaultInfo(org.apache.cxf.service.model.FaultInfo) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Example 8 with FaultInfo

use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.

the class CorbaStreamFaultOutInterceptor method getFaultMessagePartInfo.

protected MessagePartInfo getFaultMessagePartInfo(OperationInfo opInfo, QName faultName) {
    Iterator<FaultInfo> faults = opInfo.getFaults().iterator();
    while (faults.hasNext()) {
        FaultInfo fault = faults.next();
        MessagePartInfo partInfo = fault.getMessageParts().get(0);
        if (partInfo.isElement() && partInfo.getElementQName().getLocalPart().equals(faultName.getLocalPart())) {
            return partInfo;
        } else if (partInfo.getTypeQName().getLocalPart().equals(faultName.getLocalPart())) {
            return partInfo;
        }
    }
    return null;
}
Also used : FaultInfo(org.apache.cxf.service.model.FaultInfo) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Example 9 with FaultInfo

use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.

the class MAPAggregatorTest method setUpBindingOperationInfo.

private BindingOperationInfo setUpBindingOperationInfo(String nsuri, String opreq, String opresp, String opfault, Method method) {
    ServiceInfo si = new ServiceInfo();
    InterfaceInfo iinf = new InterfaceInfo(si, new QName(nsuri, method.getDeclaringClass().getSimpleName()));
    OperationInfo opInfo = iinf.addOperation(new QName(nsuri, method.getName()));
    opInfo.setProperty(Method.class.getName(), method);
    opInfo.setInput(opreq, opInfo.createMessage(new QName(nsuri, opreq), Type.INPUT));
    opInfo.setOutput(opresp, opInfo.createMessage(new QName(nsuri, opresp), Type.INPUT));
    FaultInfo finfo = opInfo.addFault(new QName(nsuri, opfault), new QName(nsuri, opfault));
    finfo.addMessagePart("fault");
    return new TestBindingOperationInfo(opInfo);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) QName(javax.xml.namespace.QName) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Method(java.lang.reflect.Method)

Example 10 with FaultInfo

use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.

the class PolicyAnnotationListener method addPolicies.

private void addPolicies(AbstractServiceFactoryBean factory, OperationInfo inf, Method m) {
    if (m == null) {
        return;
    }
    Policy p = m.getAnnotation(Policy.class);
    Policies ps = m.getAnnotation(Policies.class);
    if (p != null || ps != null) {
        List<Policy> list = new ArrayList<>();
        if (p != null) {
            list.add(p);
        }
        if (ps != null) {
            list.addAll(Arrays.asList(ps.value()));
        }
        ListIterator<Policy> it = list.listIterator();
        while (it.hasNext()) {
            p = it.next();
            Policy.Placement place = p.placement();
            if (place == Policy.Placement.DEFAULT) {
                place = Policy.Placement.BINDING_OPERATION;
            }
            ServiceInfo service = inf.getInterface().getService();
            Class<?> cls = m.getDeclaringClass();
            switch(place) {
                case PORT_TYPE_OPERATION:
                    addPolicy(inf, service, p, cls, inf.getName().getLocalPart() + "PortTypeOpPolicy");
                    it.remove();
                    break;
                case PORT_TYPE_OPERATION_INPUT:
                    addPolicy(inf.getInput(), service, p, cls, inf.getName().getLocalPart() + "PortTypeOpInputPolicy");
                    it.remove();
                    break;
                case PORT_TYPE_OPERATION_OUTPUT:
                    addPolicy(inf.getOutput(), service, p, cls, inf.getName().getLocalPart() + "PortTypeOpOutputPolicy");
                    it.remove();
                    break;
                case PORT_TYPE_OPERATION_FAULT:
                    {
                        for (FaultInfo f : inf.getFaults()) {
                            if (p.faultClass().equals(f.getProperty(Class.class.getName()))) {
                                addPolicy(f, service, p, cls, f.getName().getLocalPart() + "PortTypeOpFaultPolicy");
                                it.remove();
                            }
                        }
                        break;
                    }
                default:
            }
        }
        if (!list.isEmpty()) {
            List<Policy> stuff = CastUtils.cast((List<?>) inf.getProperty(EXTRA_POLICIES));
            if (stuff != null) {
                for (Policy p2 : list) {
                    if (!stuff.contains(p2)) {
                        stuff.add(p2);
                    }
                }
            } else {
                inf.setProperty(EXTRA_POLICIES, list);
            }
        }
    }
}
Also used : Policy(org.apache.cxf.annotations.Policy) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) Policies(org.apache.cxf.annotations.Policies) ArrayList(java.util.ArrayList)

Aggregations

FaultInfo (org.apache.cxf.service.model.FaultInfo)27 QName (javax.xml.namespace.QName)12 BindingFaultInfo (org.apache.cxf.service.model.BindingFaultInfo)11 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)11 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)11 OperationInfo (org.apache.cxf.service.model.OperationInfo)10 MessageInfo (org.apache.cxf.service.model.MessageInfo)8 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)7 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 Service (org.apache.cxf.service.Service)3 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)3 UnwrappedOperationInfo (org.apache.cxf.service.model.UnwrappedOperationInfo)3 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 BindingFault (javax.wsdl.BindingFault)2 Fault (javax.wsdl.Fault)2 Input (javax.wsdl.Input)2 Output (javax.wsdl.Output)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2