Java Code Examples for com.sun.tools.internal.ws.util.xml.XmlUtil#getAttributeOrNull()

The following examples show how to use com.sun.tools.internal.ws.util.xml.XmlUtil#getAttributeOrNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAXWSBindingExtensionHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param context
 * @param jaxwsBinding
 * @param e
 */
private void parseParameter(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding jaxwsBinding, Element e) {
    String part = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.PART_ATTR);
    Element msgPartElm = evaluateXPathNode(e.getOwnerDocument(), part, new NamespaceContextImpl(e));
    Node msgElm = msgPartElm.getParentNode();
    //MessagePart msgPart = new MessagePart();

    String partName = XmlUtil.getAttributeOrNull(msgPartElm, "name");
    String msgName = XmlUtil.getAttributeOrNull((Element)msgElm, "name");
    if ((partName == null) || (msgName == null)) {
        return;
    }

    String element = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.ELEMENT_ATTR);
    String name = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR);

    QName elementName = null;
    if(element != null){
        String uri = e.lookupNamespaceURI(XmlUtil.getPrefix(element));
        elementName = (uri == null)?null:new QName(uri, XmlUtil.getLocalPart(element));
    }

    jaxwsBinding.addParameter(new Parameter(msgName, partName, elementName, name));
}
 
Example 2
Source File: MIMEExtensionHandler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected MIMEContent parseMIMEContent(TWSDLParserContext context, Element e) {
        context.push();
        context.registerNamespaces(e);

        MIMEContent content = new MIMEContent(context.getLocation(e));

        String part = XmlUtil.getAttributeOrNull(e, Constants.ATTR_PART);
        if (part != null) {
            content.setPart(part);
        }

        String type = XmlUtil.getAttributeOrNull(e, Constants.ATTR_TYPE);
        if (type != null) {
            content.setType(type);
        }

        context.pop();
//        context.fireDoneParsingEntity(MIMEConstants.QNAME_CONTENT, content);
        return content;
    }
 
Example 3
Source File: JAXWSBindingExtensionHandler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param context
 * @param jaxwsBinding
 * @param e
 */
private void parseParameter(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding jaxwsBinding, Element e) {
    String part = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.PART_ATTR);
    Element msgPartElm = evaluateXPathNode(e.getOwnerDocument(), part, new NamespaceContextImpl(e));
    Node msgElm = msgPartElm.getParentNode();
    //MessagePart msgPart = new MessagePart();

    String partName = XmlUtil.getAttributeOrNull(msgPartElm, "name");
    String msgName = XmlUtil.getAttributeOrNull((Element)msgElm, "name");
    if ((partName == null) || (msgName == null)) {
        return;
    }

    String element = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.ELEMENT_ATTR);
    String name = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR);

    QName elementName = null;
    if(element != null){
        String uri = e.lookupNamespaceURI(XmlUtil.getPrefix(element));
        elementName = (uri == null)?null:new QName(uri, XmlUtil.getLocalPart(element));
    }

    jaxwsBinding.addParameter(new Parameter(msgName, partName, elementName, name));
}
 
Example 4
Source File: JAXWSBindingExtensionHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param context
 * @param jaxwsBinding
 * @param e
 */
private void parseParameter(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding jaxwsBinding, Element e) {
    String part = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.PART_ATTR);
    Element msgPartElm = evaluateXPathNode(e.getOwnerDocument(), part, new NamespaceContextImpl(e));
    Node msgElm = msgPartElm.getParentNode();
    //MessagePart msgPart = new MessagePart();

    String partName = XmlUtil.getAttributeOrNull(msgPartElm, "name");
    String msgName = XmlUtil.getAttributeOrNull((Element)msgElm, "name");
    if ((partName == null) || (msgName == null)) {
        return;
    }

    String element = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.ELEMENT_ATTR);
    String name = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR);

    QName elementName = null;
    if(element != null){
        String uri = e.lookupNamespaceURI(XmlUtil.getPrefix(element));
        elementName = (uri == null)?null:new QName(uri, XmlUtil.getLocalPart(element));
    }

    jaxwsBinding.addParameter(new Parameter(msgName, partName, elementName, name));
}
 
Example 5
Source File: MIMEExtensionHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected MIMEContent parseMIMEContent(TWSDLParserContext context, Element e) {
        context.push();
        context.registerNamespaces(e);

        MIMEContent content = new MIMEContent(context.getLocation(e));

        String part = XmlUtil.getAttributeOrNull(e, Constants.ATTR_PART);
        if (part != null) {
            content.setPart(part);
        }

        String type = XmlUtil.getAttributeOrNull(e, Constants.ATTR_TYPE);
        if (type != null) {
            content.setType(type);
        }

        context.pop();
//        context.fireDoneParsingEntity(MIMEConstants.QNAME_CONTENT, content);
        return content;
    }
 
Example 6
Source File: WSDLParser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private MessagePart parseMessagePart(TWSDLParserContextImpl context, Element e) {
    context.push();
    context.registerNamespaces(e);
    MessagePart part = new MessagePart(forest.locatorTable.getStartLocation(e));
    String partName = Util.getRequiredAttribute(e, Constants.ATTR_NAME);
    part.setName(partName);

    String elementAttr =
        XmlUtil.getAttributeOrNull(e, Constants.ATTR_ELEMENT);
    String typeAttr = XmlUtil.getAttributeOrNull(e, Constants.ATTR_TYPE);

    if (elementAttr != null) {
        if (typeAttr != null) {
            errReceiver.error(context.getLocation(e), WsdlMessages.PARSING_ONLY_ONE_OF_ELEMENT_OR_TYPE_REQUIRED(partName));

        }

        part.setDescriptor(context.translateQualifiedName(context.getLocation(e), elementAttr));
        part.setDescriptorKind(SchemaKinds.XSD_ELEMENT);
    } else if (typeAttr != null) {
        part.setDescriptor(context.translateQualifiedName(context.getLocation(e), typeAttr));
        part.setDescriptorKind(SchemaKinds.XSD_TYPE);
    } else {
        // XXX-NOTE - this is wrong; for extensibility purposes,
        // any attribute can be specified on a <part> element, so
        // we need to put an extensibility hook here
        errReceiver.warning(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ELEMENT_OR_TYPE_REQUIRED(partName));
    }

    context.pop();
    context.fireDoneParsingEntity(WSDLConstants.QNAME_PART, part);
    return part;
}
 
Example 7
Source File: JAXWSBindingExtensionHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param context
 * @param parent
 * @param e
 */
private void parsePackage(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding parent, Element e) {
    //System.out.println("In handlePackageExtension: " + e.getNodeName());
    String packageName = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR);
    JAXWSBinding binding = (JAXWSBinding)parent;
    binding.setJaxwsPackage(new CustomName(packageName, getJavaDoc(e)));
}
 
Example 8
Source File: WSDLParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private MessagePart parseMessagePart(TWSDLParserContextImpl context, Element e) {
    context.push();
    context.registerNamespaces(e);
    MessagePart part = new MessagePart(forest.locatorTable.getStartLocation(e));
    String partName = Util.getRequiredAttribute(e, Constants.ATTR_NAME);
    part.setName(partName);

    String elementAttr =
        XmlUtil.getAttributeOrNull(e, Constants.ATTR_ELEMENT);
    String typeAttr = XmlUtil.getAttributeOrNull(e, Constants.ATTR_TYPE);

    if (elementAttr != null) {
        if (typeAttr != null) {
            errReceiver.error(context.getLocation(e), WsdlMessages.PARSING_ONLY_ONE_OF_ELEMENT_OR_TYPE_REQUIRED(partName));

        }

        part.setDescriptor(context.translateQualifiedName(context.getLocation(e), elementAttr));
        part.setDescriptorKind(SchemaKinds.XSD_ELEMENT);
    } else if (typeAttr != null) {
        part.setDescriptor(context.translateQualifiedName(context.getLocation(e), typeAttr));
        part.setDescriptorKind(SchemaKinds.XSD_TYPE);
    } else {
        // XXX-NOTE - this is wrong; for extensibility purposes,
        // any attribute can be specified on a <part> element, so
        // we need to put an extensibility hook here
        errReceiver.warning(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_ELEMENT_OR_TYPE_REQUIRED(partName));
    }

    context.pop();
    context.fireDoneParsingEntity(WSDLConstants.QNAME_PART, part);
    return part;
}
 
Example 9
Source File: SOAPExtensionHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public boolean handleFaultExtension(
        TWSDLParserContext context,
        TWSDLExtensible parent,
        Element e) {
        if (XmlUtil.matchesTagNS(e, getFaultQName())) {
            context.push();
            context.registerNamespaces(e);

            SOAPFault fault = new SOAPFault(context.getLocation(e));

            String name = XmlUtil.getAttributeOrNull(e, Constants.ATTR_NAME);
            if (name != null) {
                fault.setName(name);
            }

            String use = XmlUtil.getAttributeOrNull(e, Constants.ATTR_USE);
            if (use != null) {
                if (use.equals(Constants.ATTRVALUE_LITERAL)) {
                    fault.setUse(SOAPUse.LITERAL);
                } else if (use.equals(Constants.ATTRVALUE_ENCODED)) {
                    fault.setUse(SOAPUse.ENCODED);
                } else {
                    Util.fail(
                        "parsing.invalidAttributeValue",
                        Constants.ATTR_USE,
                        use);
                }
            }

            String namespace =
                XmlUtil.getAttributeOrNull(e, Constants.ATTR_NAMESPACE);
            if (namespace != null) {
                fault.setNamespace(namespace);
            }

            String encodingStyle =
                XmlUtil.getAttributeOrNull(e, Constants.ATTR_ENCODING_STYLE);
            if (encodingStyle != null) {
                fault.setEncodingStyle(encodingStyle);
            }

            parent.addExtension(fault);
            context.pop();
//            context.fireDoneParsingEntity(getFaultQName(), fault);
            return true;
        } else if (XmlUtil.matchesTagNS(e, getHeaderQName())) {
            // although SOAP spec doesn't define meaning of this extension; it is allowed
            // to be here, so we have to accept it, not fail (bug 13576977)
            return handleHeaderElement(parent, e, (TWSDLParserContextImpl) context);
        } else {
            Util.fail(
                "parsing.invalidExtensionElement",
                e.getTagName(),
                e.getNamespaceURI());
            return false; // keep compiler happy
        }
    }
 
Example 10
Source File: SOAPExtensionHandler.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private void handleHeaderFaultElement(Element e, TWSDLParserContextImpl context, SOAPHeader header, String use, Element e2) {
    context.push();
    context.registerNamespaces(e);

    SOAPHeaderFault headerfault = new SOAPHeaderFault(context.getLocation(e));

    String use2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_USE);
    if (use2 != null) {
        if (use2.equals(Constants.ATTRVALUE_LITERAL)) {
            headerfault.setUse(SOAPUse.LITERAL);
        } else if (use.equals(Constants.ATTRVALUE_ENCODED)) {
            headerfault.setUse(SOAPUse.ENCODED);
        } else {
            Util.fail("parsing.invalidAttributeValue", Constants.ATTR_USE, use2);
        }
    }

    String namespace2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_NAMESPACE);
    if (namespace2 != null) {
        headerfault.setNamespace(namespace2);
    }

    String encodingStyle2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_ENCODING_STYLE);
    if (encodingStyle2 != null) {
        headerfault.setEncodingStyle(encodingStyle2);
    }

    String part2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_PART);
    if (part2 != null) {
        headerfault.setPart(part2);
    }

    String messageAttr2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_MESSAGE);
    if (messageAttr2 != null) {
        headerfault.setMessage(
            context.translateQualifiedName(context.getLocation(e2), messageAttr2));
    }

    header.add(headerfault);
    context.pop();
}
 
Example 11
Source File: MIMEExtensionHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected boolean handleInputOutputExtension(
        TWSDLParserContext context,
        TWSDLExtensible parent,
        Element e) {
        if (XmlUtil.matchesTagNS(e, MIMEConstants.QNAME_MULTIPART_RELATED)) {
            context.push();
            context.registerNamespaces(e);

            MIMEMultipartRelated mpr = new MIMEMultipartRelated(context.getLocation(e));

            for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
                Element e2 = Util.nextElement(iter);
                if (e2 == null)
                    break;

                if (XmlUtil.matchesTagNS(e2, MIMEConstants.QNAME_PART)) {
                    context.push();
                    context.registerNamespaces(e2);

                    MIMEPart part = new MIMEPart(context.getLocation(e2));

                    String name =
                        XmlUtil.getAttributeOrNull(e2, Constants.ATTR_NAME);
                    if (name != null) {
                        part.setName(name);
                    }

                    for (Iterator iter2 = XmlUtil.getAllChildren(e2);
                         iter2.hasNext();
                        ) {
                        Element e3 = Util.nextElement(iter2);
                        if (e3 == null)
                            break;

                        AbstractExtensionHandler h = getExtensionHandlers().get(e3.getNamespaceURI());
                        boolean handled = false;
                        if (h != null) {
                            handled = h.doHandleExtension(context, part, e3);
                        }

                        if (!handled) {
                            String required =
                                XmlUtil.getAttributeNSOrNull(
                                    e3,
                                    Constants.ATTR_REQUIRED,
                                    Constants.NS_WSDL);
                            if (required != null
                                && required.equals(Constants.TRUE)) {
                                Util.fail(
                                    "parsing.requiredExtensibilityElement",
                                    e3.getTagName(),
                                    e3.getNamespaceURI());
                            } else {
//                                context.fireIgnoringExtension(
//                                    new QName(
//                                        e3.getNamespaceURI(),
//                                        e3.getLocalName()),
//                                    part.getElementName());
                            }
                        }
                    }

                    mpr.add(part);
                    context.pop();
//                    context.fireDoneParsingEntity(
//                        MIMEConstants.QNAME_PART,
//                        part);
                } else {
                    Util.fail(
                        "parsing.invalidElement",
                        e2.getTagName(),
                        e2.getNamespaceURI());
                }
            }

            parent.addExtension(mpr);
            context.pop();
//            context.fireDoneParsingEntity(
//                MIMEConstants.QNAME_MULTIPART_RELATED,
//                mpr);
            return true;
        } else if (XmlUtil.matchesTagNS(e, MIMEConstants.QNAME_CONTENT)) {
            MIMEContent content = parseMIMEContent(context, e);
            parent.addExtension(content);
            return true;
        } else if (XmlUtil.matchesTagNS(e, MIMEConstants.QNAME_MIME_XML)) {
            MIMEXml mimeXml = parseMIMEXml(context, e);
            parent.addExtension(mimeXml);
            return true;
        } else {
            Util.fail(
                "parsing.invalidExtensionElement",
                e.getTagName(),
                e.getNamespaceURI());
            return false; // keep compiler happy
        }
    }
 
Example 12
Source File: WSDLParser.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private Definitions parseDefinitionsNoImport(
    TWSDLParserContextImpl context,
    Document doc) {
    Element e = doc.getDocumentElement();
    //at this poinjt we expect a wsdl or schema document to be fully qualified
    if(e.getNamespaceURI() == null || (!e.getNamespaceURI().equals(WSDLConstants.NS_WSDL) || !e.getLocalName().equals("definitions"))){
        return null;
    }
    context.push();
    context.registerNamespaces(e);

    Definitions definitions = new Definitions(context.getDocument(), forest.locatorTable.getStartLocation(e));
    String name = XmlUtil.getAttributeOrNull(e, Constants.ATTR_NAME);
    definitions.setName(name);

    String targetNamespaceURI =
        XmlUtil.getAttributeOrNull(e, Constants.ATTR_TARGET_NAMESPACE);

    definitions.setTargetNamespaceURI(targetNamespaceURI);

    boolean gotDocumentation = false;
    boolean gotTypes = false;

    for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
        Element e2 = Util.nextElement(iter);
        if (e2 == null)
            break;

        if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) {
            if (gotDocumentation) {
                errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                return null;
            }
            gotDocumentation = true;
            if(definitions.getDocumentation() == null)
                definitions.setDocumentation(getDocumentationFor(e2));
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_TYPES)) {
            if (gotTypes && !options.isExtensionMode()) {
                errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_TYPES_ALLOWED(Constants.TAG_DEFINITIONS));
                return null;
            }
            gotTypes = true;
            //add all the wsdl:type elements to latter make a list of all the schema elements
            // that will be needed to create jaxb model
            if(!options.isExtensionMode())
                validateSchemaImports(e2);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_MESSAGE)) {
            Message message = parseMessage(context, definitions, e2);
            definitions.add(message);
        } else if (
            XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_PORT_TYPE)) {
            PortType portType = parsePortType(context, definitions, e2);
            definitions.add(portType);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_BINDING)) {
            Binding binding = parseBinding(context, definitions, e2);
            definitions.add(binding);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_SERVICE)) {
            Service service = parseService(context, definitions, e2);
            definitions.add(service);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_IMPORT)) {
            definitions.add(parseImport(context, definitions, e2));
        } else if (XmlUtil.matchesTagNS(e2, SchemaConstants.QNAME_IMPORT)) {
            errReceiver.warning(forest.locatorTable.getStartLocation(e2), WsdlMessages.WARNING_WSI_R_2003());
        } else {
            // possible extensibility element -- must live outside the WSDL namespace
            checkNotWsdlElement(e2);
            if (!handleExtension(context, definitions, e2)) {
                checkNotWsdlRequired(e2);
            }
        }
    }

    context.pop();
    context.fireDoneParsingEntity(
        WSDLConstants.QNAME_DEFINITIONS,
        definitions);
    return definitions;
}
 
Example 13
Source File: SOAPExtensionHandler.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private void handleHeaderFaultElement(Element e, TWSDLParserContextImpl context, SOAPHeader header, String use, Element e2) {
    context.push();
    context.registerNamespaces(e);

    SOAPHeaderFault headerfault = new SOAPHeaderFault(context.getLocation(e));

    String use2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_USE);
    if (use2 != null) {
        if (use2.equals(Constants.ATTRVALUE_LITERAL)) {
            headerfault.setUse(SOAPUse.LITERAL);
        } else if (use.equals(Constants.ATTRVALUE_ENCODED)) {
            headerfault.setUse(SOAPUse.ENCODED);
        } else {
            Util.fail("parsing.invalidAttributeValue", Constants.ATTR_USE, use2);
        }
    }

    String namespace2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_NAMESPACE);
    if (namespace2 != null) {
        headerfault.setNamespace(namespace2);
    }

    String encodingStyle2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_ENCODING_STYLE);
    if (encodingStyle2 != null) {
        headerfault.setEncodingStyle(encodingStyle2);
    }

    String part2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_PART);
    if (part2 != null) {
        headerfault.setPart(part2);
    }

    String messageAttr2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_MESSAGE);
    if (messageAttr2 != null) {
        headerfault.setMessage(
            context.translateQualifiedName(context.getLocation(e2), messageAttr2));
    }

    header.add(headerfault);
    context.pop();
}
 
Example 14
Source File: SOAPExtensionHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected boolean handleInputOutputExtension(
        TWSDLParserContext contextif,
        TWSDLExtensible parent,
        Element e) {
        TWSDLParserContextImpl context = (TWSDLParserContextImpl)contextif;
        if (XmlUtil.matchesTagNS(e, getBodyQName())) {
            context.push();
            context.registerNamespaces(e);

            SOAPBody body = new SOAPBody(context.getLocation(e));

            String use = XmlUtil.getAttributeOrNull(e, Constants.ATTR_USE);
            if (use != null) {
                if (use.equals(Constants.ATTRVALUE_LITERAL)) {
                    body.setUse(SOAPUse.LITERAL);
                } else if (use.equals(Constants.ATTRVALUE_ENCODED)) {
                    body.setUse(SOAPUse.ENCODED);
                } else {
                    Util.fail(
                        "parsing.invalidAttributeValue",
                        Constants.ATTR_USE,
                        use);
                }
            }

            String namespace =
                XmlUtil.getAttributeOrNull(e, Constants.ATTR_NAMESPACE);
            if (namespace != null) {
                body.setNamespace(namespace);
            }

            String encodingStyle =
                XmlUtil.getAttributeOrNull(e, Constants.ATTR_ENCODING_STYLE);
            if (encodingStyle != null) {
                body.setEncodingStyle(encodingStyle);
            }

            String parts = XmlUtil.getAttributeOrNull(e, Constants.ATTR_PARTS);
            if (parts != null) {
                body.setParts(parts);
            }

            parent.addExtension(body);
            context.pop();
//            context.fireDoneParsingEntity(getBodyQName(), body);
            return true;
        } else if (XmlUtil.matchesTagNS(e, getHeaderQName())) {
            return handleHeaderElement(parent, e, context);
        } else {
            Util.fail("parsing.invalidExtensionElement", e.getTagName(), e.getNamespaceURI());
            return false; // keep compiler happy
        }
    }
 
Example 15
Source File: SOAPExtensionHandler.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected boolean handleInputOutputExtension(
        TWSDLParserContext contextif,
        TWSDLExtensible parent,
        Element e) {
        TWSDLParserContextImpl context = (TWSDLParserContextImpl)contextif;
        if (XmlUtil.matchesTagNS(e, getBodyQName())) {
            context.push();
            context.registerNamespaces(e);

            SOAPBody body = new SOAPBody(context.getLocation(e));

            String use = XmlUtil.getAttributeOrNull(e, Constants.ATTR_USE);
            if (use != null) {
                if (use.equals(Constants.ATTRVALUE_LITERAL)) {
                    body.setUse(SOAPUse.LITERAL);
                } else if (use.equals(Constants.ATTRVALUE_ENCODED)) {
                    body.setUse(SOAPUse.ENCODED);
                } else {
                    Util.fail(
                        "parsing.invalidAttributeValue",
                        Constants.ATTR_USE,
                        use);
                }
            }

            String namespace =
                XmlUtil.getAttributeOrNull(e, Constants.ATTR_NAMESPACE);
            if (namespace != null) {
                body.setNamespace(namespace);
            }

            String encodingStyle =
                XmlUtil.getAttributeOrNull(e, Constants.ATTR_ENCODING_STYLE);
            if (encodingStyle != null) {
                body.setEncodingStyle(encodingStyle);
            }

            String parts = XmlUtil.getAttributeOrNull(e, Constants.ATTR_PARTS);
            if (parts != null) {
                body.setParts(parts);
            }

            parent.addExtension(body);
            context.pop();
//            context.fireDoneParsingEntity(getBodyQName(), body);
            return true;
        } else if (XmlUtil.matchesTagNS(e, getHeaderQName())) {
            return handleHeaderElement(parent, e, context);
        } else {
            Util.fail("parsing.invalidExtensionElement", e.getTagName(), e.getNamespaceURI());
            return false; // keep compiler happy
        }
    }
 
Example 16
Source File: SOAPExtensionHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public boolean handleOperationExtension(
        TWSDLParserContext context,
        TWSDLExtensible parent,
        Element e) {
        if (XmlUtil.matchesTagNS(e, getOperationQName())) {
            context.push();
            context.registerNamespaces(e);

            SOAPOperation operation = new SOAPOperation(context.getLocation(e));

            String soapAction =
                XmlUtil.getAttributeOrNull(e, Constants.ATTR_SOAP_ACTION);
            if (soapAction != null) {
                operation.setSOAPAction(soapAction);
            }

            String style = XmlUtil.getAttributeOrNull(e, Constants.ATTR_STYLE);
            if (style != null) {
                if (style.equals(Constants.ATTRVALUE_RPC)) {
                    operation.setStyle(SOAPStyle.RPC);
                } else if (style.equals(Constants.ATTRVALUE_DOCUMENT)) {
                    operation.setStyle(SOAPStyle.DOCUMENT);
                } else {
                    Util.fail(
                        "parsing.invalidAttributeValue",
                        Constants.ATTR_STYLE,
                        style);
                }
            }
            parent.addExtension(operation);
            context.pop();
//            context.fireDoneParsingEntity(
//                getOperationQName(),
//                operation);
            return true;
        } else {
            Util.fail(
                "parsing.invalidExtensionElement",
                e.getTagName(),
                e.getNamespaceURI());
            return false; // keep compiler happy
        }
    }
 
Example 17
Source File: WSDLParser.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private Definitions parseDefinitionsNoImport(
    TWSDLParserContextImpl context,
    Document doc) {
    Element e = doc.getDocumentElement();
    //at this poinjt we expect a wsdl or schema document to be fully qualified
    if(e.getNamespaceURI() == null || (!e.getNamespaceURI().equals(WSDLConstants.NS_WSDL) || !e.getLocalName().equals("definitions"))){
        return null;
    }
    context.push();
    context.registerNamespaces(e);

    Definitions definitions = new Definitions(context.getDocument(), forest.locatorTable.getStartLocation(e));
    String name = XmlUtil.getAttributeOrNull(e, Constants.ATTR_NAME);
    definitions.setName(name);

    String targetNamespaceURI =
        XmlUtil.getAttributeOrNull(e, Constants.ATTR_TARGET_NAMESPACE);

    definitions.setTargetNamespaceURI(targetNamespaceURI);

    boolean gotDocumentation = false;
    boolean gotTypes = false;

    for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
        Element e2 = Util.nextElement(iter);
        if (e2 == null)
            break;

        if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) {
            if (gotDocumentation) {
                errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                return null;
            }
            gotDocumentation = true;
            if(definitions.getDocumentation() == null)
                definitions.setDocumentation(getDocumentationFor(e2));
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_TYPES)) {
            if (gotTypes && !options.isExtensionMode()) {
                errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_TYPES_ALLOWED(Constants.TAG_DEFINITIONS));
                return null;
            }
            gotTypes = true;
            //add all the wsdl:type elements to latter make a list of all the schema elements
            // that will be needed to create jaxb model
            if(!options.isExtensionMode())
                validateSchemaImports(e2);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_MESSAGE)) {
            Message message = parseMessage(context, definitions, e2);
            definitions.add(message);
        } else if (
            XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_PORT_TYPE)) {
            PortType portType = parsePortType(context, definitions, e2);
            definitions.add(portType);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_BINDING)) {
            Binding binding = parseBinding(context, definitions, e2);
            definitions.add(binding);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_SERVICE)) {
            Service service = parseService(context, definitions, e2);
            definitions.add(service);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_IMPORT)) {
            definitions.add(parseImport(context, definitions, e2));
        } else if (XmlUtil.matchesTagNS(e2, SchemaConstants.QNAME_IMPORT)) {
            errReceiver.warning(forest.locatorTable.getStartLocation(e2), WsdlMessages.WARNING_WSI_R_2003());
        } else {
            // possible extensibility element -- must live outside the WSDL namespace
            checkNotWsdlElement(e2);
            if (!handleExtension(context, definitions, e2)) {
                checkNotWsdlRequired(e2);
            }
        }
    }

    context.pop();
    context.fireDoneParsingEntity(
        WSDLConstants.QNAME_DEFINITIONS,
        definitions);
    return definitions;
}
 
Example 18
Source File: SOAPExtensionHandler.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public boolean handleOperationExtension(
        TWSDLParserContext context,
        TWSDLExtensible parent,
        Element e) {
        if (XmlUtil.matchesTagNS(e, getOperationQName())) {
            context.push();
            context.registerNamespaces(e);

            SOAPOperation operation = new SOAPOperation(context.getLocation(e));

            String soapAction =
                XmlUtil.getAttributeOrNull(e, Constants.ATTR_SOAP_ACTION);
            if (soapAction != null) {
                operation.setSOAPAction(soapAction);
            }

            String style = XmlUtil.getAttributeOrNull(e, Constants.ATTR_STYLE);
            if (style != null) {
                if (style.equals(Constants.ATTRVALUE_RPC)) {
                    operation.setStyle(SOAPStyle.RPC);
                } else if (style.equals(Constants.ATTRVALUE_DOCUMENT)) {
                    operation.setStyle(SOAPStyle.DOCUMENT);
                } else {
                    Util.fail(
                        "parsing.invalidAttributeValue",
                        Constants.ATTR_STYLE,
                        style);
                }
            }
            parent.addExtension(operation);
            context.pop();
//            context.fireDoneParsingEntity(
//                getOperationQName(),
//                operation);
            return true;
        } else {
            Util.fail(
                "parsing.invalidExtensionElement",
                e.getTagName(),
                e.getNamespaceURI());
            return false; // keep compiler happy
        }
    }
 
Example 19
Source File: WSDLParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private Definitions parseDefinitionsNoImport(
    TWSDLParserContextImpl context,
    Document doc) {
    Element e = doc.getDocumentElement();
    //at this poinjt we expect a wsdl or schema document to be fully qualified
    if(e.getNamespaceURI() == null || (!e.getNamespaceURI().equals(WSDLConstants.NS_WSDL) || !e.getLocalName().equals("definitions"))){
        return null;
    }
    context.push();
    context.registerNamespaces(e);

    Definitions definitions = new Definitions(context.getDocument(), forest.locatorTable.getStartLocation(e));
    String name = XmlUtil.getAttributeOrNull(e, Constants.ATTR_NAME);
    definitions.setName(name);

    String targetNamespaceURI =
        XmlUtil.getAttributeOrNull(e, Constants.ATTR_TARGET_NAMESPACE);

    definitions.setTargetNamespaceURI(targetNamespaceURI);

    boolean gotDocumentation = false;
    boolean gotTypes = false;

    for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
        Element e2 = Util.nextElement(iter);
        if (e2 == null)
            break;

        if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) {
            if (gotDocumentation) {
                errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                return null;
            }
            gotDocumentation = true;
            if(definitions.getDocumentation() == null)
                definitions.setDocumentation(getDocumentationFor(e2));
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_TYPES)) {
            if (gotTypes && !options.isExtensionMode()) {
                errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_TYPES_ALLOWED(Constants.TAG_DEFINITIONS));
                return null;
            }
            gotTypes = true;
            //add all the wsdl:type elements to latter make a list of all the schema elements
            // that will be needed to create jaxb model
            if(!options.isExtensionMode())
                validateSchemaImports(e2);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_MESSAGE)) {
            Message message = parseMessage(context, definitions, e2);
            definitions.add(message);
        } else if (
            XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_PORT_TYPE)) {
            PortType portType = parsePortType(context, definitions, e2);
            definitions.add(portType);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_BINDING)) {
            Binding binding = parseBinding(context, definitions, e2);
            definitions.add(binding);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_SERVICE)) {
            Service service = parseService(context, definitions, e2);
            definitions.add(service);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_IMPORT)) {
            definitions.add(parseImport(context, definitions, e2));
        } else if (XmlUtil.matchesTagNS(e2, SchemaConstants.QNAME_IMPORT)) {
            errReceiver.warning(forest.locatorTable.getStartLocation(e2), WsdlMessages.WARNING_WSI_R_2003());
        } else {
            // possible extensibility element -- must live outside the WSDL namespace
            checkNotWsdlElement(e2);
            if (!handleExtension(context, definitions, e2)) {
                checkNotWsdlRequired(e2);
            }
        }
    }

    context.pop();
    context.fireDoneParsingEntity(
        WSDLConstants.QNAME_DEFINITIONS,
        definitions);
    return definitions;
}
 
Example 20
Source File: JAXWSBindingExtensionHandler.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param context
 * @param jaxwsBinding
 * @param e
 */
private void parseClass(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding jaxwsBinding, Element e) {
    String className = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR);
    String javaDoc = getJavaDoc(e);
    jaxwsBinding.setClassName(new CustomName(className, javaDoc));
}