Search in sources :

Example 1 with XNode

use of org.apache.cxf.tools.validator.internal.model.XNode in project cxf by apache.

the class WSDLRefValidator method collectValidationPointsForPortTypes.

private void collectValidationPointsForPortTypes() {
    for (QName ptName : portTypeRefNames) {
        PortType portType = getPortType(ptName);
        if (portType == null) {
            vResults.addError(new Message("NO_PORTTYPE", LOG, ptName));
            continue;
        }
        XNode vPortTypeNode = getXNode(portType);
        for (Operation operation : getOperations(portType).values()) {
            XNode vOperationNode = getOperationXNode(vPortTypeNode, operation.getName());
            if (operation.getInput() == null) {
                vResults.addError(new Message("WRONG_MEP", LOG, operation.getName(), portType.getQName()));
                continue;
            }
            javax.wsdl.Message inMsg = operation.getInput().getMessage();
            if (inMsg == null) {
                addWarning("Operation " + operation.getName() + " in PortType: " + portType.getQName() + " has no input message");
            } else {
                XNode vInMsgNode = getXNode(inMsg);
                vInMsgNode.setFailurePoint(getInputXNode(vOperationNode, operation.getInput().getName()));
                vNodes.add(vInMsgNode);
                messageRefNames.add(inMsg.getQName());
            }
            if (operation.getOutput() != null) {
                javax.wsdl.Message outMsg = operation.getOutput().getMessage();
                if (outMsg == null) {
                    addWarning("Operation " + operation.getName() + " in PortType: " + portType.getQName() + " has no output message");
                } else {
                    XNode vOutMsgNode = getXNode(outMsg);
                    vOutMsgNode.setFailurePoint(getOutputXNode(vOperationNode, operation.getOutput().getName()));
                    vNodes.add(vOutMsgNode);
                    messageRefNames.add(outMsg.getQName());
                }
            }
            for (Iterator<?> iter = operation.getFaults().values().iterator(); iter.hasNext(); ) {
                Fault fault = (Fault) iter.next();
                javax.wsdl.Message faultMsg = fault.getMessage();
                XNode vFaultMsgNode = getXNode(faultMsg);
                vFaultMsgNode.setFailurePoint(getFaultXNode(vOperationNode, fault.getName()));
                vNodes.add(vFaultMsgNode);
                messageRefNames.add(faultMsg.getQName());
            }
        }
    }
}
Also used : XMessage(org.apache.cxf.tools.validator.internal.model.XMessage) Message(org.apache.cxf.common.i18n.Message) QName(javax.xml.namespace.QName) XNode(org.apache.cxf.tools.validator.internal.model.XNode) Fault(javax.wsdl.Fault) XFault(org.apache.cxf.tools.validator.internal.model.XFault) Operation(javax.wsdl.Operation) XOperation(org.apache.cxf.tools.validator.internal.model.XOperation) BindingOperation(javax.wsdl.BindingOperation) PortType(javax.wsdl.PortType) XPortType(org.apache.cxf.tools.validator.internal.model.XPortType)

Example 2 with XNode

use of org.apache.cxf.tools.validator.internal.model.XNode in project cxf by apache.

the class WSDLRefValidator method getXNode.

private XNode getXNode(Service service, Port port) {
    XNode vService = getXNode(service);
    XPort pNode = new XPort();
    pNode.setName(port.getName());
    pNode.setParentNode(vService);
    return pNode;
}
Also used : XNode(org.apache.cxf.tools.validator.internal.model.XNode) XPort(org.apache.cxf.tools.validator.internal.model.XPort)

Example 3 with XNode

use of org.apache.cxf.tools.validator.internal.model.XNode in project cxf by apache.

the class WSDLRefValidatorTest method testWSDLImport2.

@Test
public void testWSDLImport2() throws Exception {
    String wsdl = getClass().getResource("resources/physicalpt.wsdl").toURI().toString();
    WSDLRefValidator validator = new WSDLRefValidator(getWSDL(wsdl), null);
    assertTrue(validator.isValid());
    String expected = "/wsdl:definitions[@targetNamespace='http://schemas.apache.org/yoko/idl/OptionsPT']" + "/wsdl:portType[@name='foo.bar']";
    Set<String> xpath = new HashSet<>();
    for (XNode node : validator.vNodes) {
        xpath.add(node.toString());
    }
    assertTrue(xpath.contains(expected));
}
Also used : XNode(org.apache.cxf.tools.validator.internal.model.XNode) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with XNode

use of org.apache.cxf.tools.validator.internal.model.XNode in project cxf by apache.

the class WSDLRefValidator method isValid.

public boolean isValid() {
    try {
        loadServices();
        collectValidationPoints();
        List<Document> wsdlDocs = getWSDLDocuments();
        for (XNode vNode : vNodes) {
            if (!isExist(wsdlDocs, vNode)) {
                // System.out.println("Fail: " + vNode.getXPath());
                FailureLocation loc = getFailureLocation(wsdlDocs, vNode.getFailurePoint());
                vResults.addError(new Message("FAILED_AT_POINT", LOG, loc.getLocation().getLineNumber(), loc.getLocation().getColumnNumber(), loc.getDocumentURI(), vNode.getPlainText()));
            }
        }
    } catch (Exception e) {
        this.vResults.addError(e.getMessage());
        return false;
    }
    return vResults.isSuccessful();
}
Also used : FailureLocation(org.apache.cxf.tools.validator.internal.model.FailureLocation) XMessage(org.apache.cxf.tools.validator.internal.model.XMessage) Message(org.apache.cxf.common.i18n.Message) XNode(org.apache.cxf.tools.validator.internal.model.XNode) Document(org.w3c.dom.Document) URISyntaxException(java.net.URISyntaxException) ToolException(org.apache.cxf.tools.common.ToolException)

Example 5 with XNode

use of org.apache.cxf.tools.validator.internal.model.XNode in project cxf by apache.

the class WSDLRefValidator method getBindings.

private Map<QName, XNode> getBindings(Service service) {
    Map<QName, XNode> bindings = new HashMap<>();
    if (service.getPorts().values().isEmpty()) {
        throw new ToolException("Service " + service.getQName() + " does not contain any usable ports");
    }
    Collection<Port> ports = CastUtils.cast(service.getPorts().values());
    for (Port port : ports) {
        Binding binding = port.getBinding();
        bindings.put(binding.getQName(), getXNode(service, port));
        if (WSDLConstants.NS_WSDL11.equals(binding.getQName().getNamespaceURI())) {
            throw new ToolException("Binding " + binding.getQName().getLocalPart() + " namespace set improperly.");
        }
    }
    return bindings;
}
Also used : XBinding(org.apache.cxf.tools.validator.internal.model.XBinding) Binding(javax.wsdl.Binding) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) XNode(org.apache.cxf.tools.validator.internal.model.XNode) XPort(org.apache.cxf.tools.validator.internal.model.XPort) Port(javax.wsdl.Port) ToolException(org.apache.cxf.tools.common.ToolException)

Aggregations

XNode (org.apache.cxf.tools.validator.internal.model.XNode)6 QName (javax.xml.namespace.QName)3 ToolException (org.apache.cxf.tools.common.ToolException)3 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2 Binding (javax.wsdl.Binding)2 BindingOperation (javax.wsdl.BindingOperation)2 Message (org.apache.cxf.common.i18n.Message)2 XBinding (org.apache.cxf.tools.validator.internal.model.XBinding)2 XMessage (org.apache.cxf.tools.validator.internal.model.XMessage)2 XPort (org.apache.cxf.tools.validator.internal.model.XPort)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Fault (javax.wsdl.Fault)1 Operation (javax.wsdl.Operation)1 Port (javax.wsdl.Port)1 PortType (javax.wsdl.PortType)1 Service (javax.wsdl.Service)1 FailureLocation (org.apache.cxf.tools.validator.internal.model.FailureLocation)1 XFault (org.apache.cxf.tools.validator.internal.model.XFault)1