com.sun.xml.internal.messaging.saaj.soap.name.NameImpl Java Examples

The following examples show how to use com.sun.xml.internal.messaging.saaj.soap.name.NameImpl. 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: HeaderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public SOAPHeaderElement addUpgradeHeaderElement(String[] supportedSoapUris)
    throws SOAPException {

    if (supportedSoapUris == null) {
        log.severe("SAAJ0411.ver1_2.no.null.supportedURIs");
        throw new SOAPException("Argument cannot be null; array of supportedURIs cannot be null");
    }
    if (supportedSoapUris.length == 0) {
        log.severe("SAAJ0412.ver1_2.no.empty.list.of.supportedURIs");
        throw new SOAPException("List of supported URIs cannot be empty");
    }
    Name upgradeName = getUpgradeName();
    SOAPHeaderElement upgradeHeaderElement =
        (SOAPHeaderElement) addChildElement(upgradeName);
    Name supportedEnvelopeName = getSupportedEnvelopeName();
    for (int i = 0; i < supportedSoapUris.length; i ++) {
        SOAPElement subElement =
            upgradeHeaderElement.addChildElement(supportedEnvelopeName);
        String ns = "ns" + Integer.toString(i);
        subElement.addAttribute(
            NameImpl.createFromUnqualifiedName("qname"),
            ns + ":Envelope");
        subElement.addNamespaceDeclaration(ns, supportedSoapUris[i]);
    }
    return upgradeHeaderElement;
}
 
Example #2
Source File: HeaderImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected SOAPElement convertToSoapElement(Element element) {
    if (element instanceof SOAPHeaderElement) {
        return (SOAPElement) element;
    } else {
        SOAPHeaderElement headerElement;
        try {
            headerElement =
                createHeaderElement(NameImpl.copyElementName(element));
        } catch (SOAPException e) {
            throw new ClassCastException("Could not convert Element to SOAPHeaderElement: " + e.getMessage());
        }
        return replaceElementWithSOAPElement(
            element,
            (ElementImpl) headerElement);
    }
}
 
Example #3
Source File: HeaderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected SOAPElement convertToSoapElement(Element element) {
    if (element instanceof SOAPHeaderElement) {
        return (SOAPElement) element;
    } else {
        SOAPHeaderElement headerElement;
        try {
            headerElement =
                createHeaderElement(NameImpl.copyElementName(element));
        } catch (SOAPException e) {
            throw new ClassCastException("Could not convert Element to SOAPHeaderElement: " + e.getMessage());
        }
        return replaceElementWithSOAPElement(
            element,
            (ElementImpl) headerElement);
    }
}
 
Example #4
Source File: HeaderImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public SOAPHeaderElement addUpgradeHeaderElement(String[] supportedSoapUris)
    throws SOAPException {

    if (supportedSoapUris == null) {
        log.severe("SAAJ0411.ver1_2.no.null.supportedURIs");
        throw new SOAPException("Argument cannot be null; array of supportedURIs cannot be null");
    }
    if (supportedSoapUris.length == 0) {
        log.severe("SAAJ0412.ver1_2.no.empty.list.of.supportedURIs");
        throw new SOAPException("List of supported URIs cannot be empty");
    }
    Name upgradeName = getUpgradeName();
    SOAPHeaderElement upgradeHeaderElement =
        (SOAPHeaderElement) addChildElement(upgradeName);
    Name supportedEnvelopeName = getSupportedEnvelopeName();
    for (int i = 0; i < supportedSoapUris.length; i ++) {
        SOAPElement subElement =
            upgradeHeaderElement.addChildElement(supportedEnvelopeName);
        String ns = "ns" + Integer.toString(i);
        subElement.addAttribute(
            NameImpl.createFromUnqualifiedName("qname"),
            ns + ":Envelope");
        subElement.addNamespaceDeclaration(ns, supportedSoapUris[i]);
    }
    return upgradeHeaderElement;
}
 
Example #5
Source File: EnvelopeImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Name createName(String localName, String prefix, String uri)
    throws SOAPException {

    // validating parameters before passing them on
    // to make sure that the namespace specification rules are followed

    // reserved xmlns prefix cannot be used.
    if ("xmlns".equals(prefix)) {
        log.severe("SAAJ0123.impl.no.reserved.xmlns");
        throw new SOAPExceptionImpl("Cannot declare reserved xmlns prefix");
    }
    // Qualified name cannot be xmlns.
    if ((prefix == null) && ("xmlns".equals(localName))) {
        log.severe("SAAJ0124.impl.qualified.name.cannot.be.xmlns");
        throw new SOAPExceptionImpl("Qualified name cannot be xmlns");
    }

    return NameImpl.create(localName, prefix, uri);
}
 
Example #6
Source File: Fault1_1Impl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public Name getFaultCodeAsName() {

        String faultcodeString = getFaultCode();
        if (faultcodeString == null) {
            return null;
        }
        int prefixIndex = faultcodeString.indexOf(':');
        if (prefixIndex == -1) {
            // Not a valid SOAP message, but we return the unqualified name
            // anyway since some apps do not strictly conform to SOAP
            // specs.  A message that does not contain a <faultcode>
            // element itself is also not valid in which case we return
            // null instead of throwing an exception so this is consistent.
            return NameImpl.createFromUnqualifiedName(faultcodeString);
        }

        // Get the prefix and map it to a namespace name (AKA namespace URI)
        String prefix = faultcodeString.substring(0, prefixIndex);
        if (this.faultCodeElement == null)
            findFaultCodeElement();
        String nsName = this.faultCodeElement.getNamespaceURI(prefix);
        return NameImpl.createFromQualifiedName(faultcodeString, nsName);
    }
 
Example #7
Source File: Body1_2Impl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPElement addAttribute(Name name, String value)
    throws SOAPException {
    if (name.getLocalName().equals("encodingStyle")
        && name.getURI().equals(NameImpl.SOAP12_NAMESPACE)) {

        setEncodingStyle(value);
    }
    return super.addAttribute(name, value);
}
 
Example #8
Source File: Header1_2Impl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public SOAPElement addAttribute(QName name, String value)
    throws SOAPException {
    if (name.getLocalPart().equals("encodingStyle")
        && name.getNamespaceURI().equals(NameImpl.SOAP12_NAMESPACE)) {

        setEncodingStyle(value);
    }
    return super.addAttribute(name, value);
}
 
Example #9
Source File: EnvelopeImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPHeader addHeader(String prefix) throws SOAPException {

        if (prefix == null || prefix.equals("")) {
            prefix = getPrefix();
        }

        NameImpl headerName = getHeaderName(prefix);
        NameImpl bodyName = getBodyName(prefix);

        HeaderImpl header = null;
        SOAPElement firstChild = (SOAPElement) getFirstChildElement();

        if (firstChild != null) {
            if (firstChild.getElementName().equals(headerName)) {
                log.severe("SAAJ0120.impl.header.already.exists");
                throw new SOAPExceptionImpl("Can't add a header when one is already present.");
            } else if (!firstChild.getElementName().equals(bodyName)) {
                log.severe("SAAJ0121.impl.invalid.first.child.of.envelope");
                throw new SOAPExceptionImpl("First child of Envelope must be either a Header or Body");
            }
        }

        header = (HeaderImpl) createElement(headerName);
        insertBefore(header.getDomElement(), firstChild);
        header.ensureNamespaceIsDeclared(headerName.getPrefix(), headerName.getURI());

        return header;
    }
 
Example #10
Source File: ElementImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected SOAPElement convertToSoapElement(Element element) {
    if (element instanceof SOAPElement) {
        return (SOAPElement) element;
    } else {
        return replaceElementWithSOAPElement(
            element,
            (ElementImpl) createElement(NameImpl.copyElementName(element)));
    }
}
 
Example #11
Source File: BodyImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected SOAPElement convertToSoapElement(Element element) {
    if ((element instanceof SOAPBodyElement) &&
        //this check is required because ElementImpl currently
        // implements SOAPBodyElement
        !(element.getClass().equals(ElementImpl.class))) {
        return (SOAPElement) element;
    } else {
        return replaceElementWithSOAPElement(
            element,
            (ElementImpl) createBodyElement(NameImpl
                .copyElementName(element)));
    }
}
 
Example #12
Source File: Fault1_2Impl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public SOAPElement addAttribute(Name name, String value)
    throws SOAPException {
    if (name.getLocalName().equals("encodingStyle")
        && name.getURI().equals(NameImpl.SOAP12_NAMESPACE)) {
        setEncodingStyle(value);
    }
    return super.addAttribute(name, value);
}
 
Example #13
Source File: Fault1_2Impl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Name getFaultCodeAsName() {
    String faultcode = getFaultCode();
    if (faultcode == null) {
        return null;
    }
    if (this.faultCodeElement == null)
        findFaultCodeElement();
    Iterator valueElements =
        this.faultCodeElement.getChildElements(valueName);
    return NameImpl.convertToName(
        convertCodeToQName(
            faultcode,
            (SOAPElement) valueElements.next()));
}
 
Example #14
Source File: SOAPDocumentImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Element createElement(String tagName) throws DOMException {
    return ElementFactory.createElement(
        this,
        NameImpl.getLocalNameFromTagName(tagName),
        NameImpl.getPrefixFromTagName(tagName),
        null);
}
 
Example #15
Source File: SOAPFactoryImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Name createName(String localName) throws SOAPException {
    // @since SAAJ 1.3
    // if localName==null, earlier impl would create Name with localName=null
    // which is absurd.
    if (localName == null) {
        log.log(
            Level.SEVERE,"SAAJ0567.soap.null.input",
            new Object[] {"localName","SOAPFactory.createName"});
        throw new SOAPException("Null localName argument passed to createName");
    }
    return NameImpl.createFromUnqualifiedName(localName);
}
 
Example #16
Source File: Envelope1_1Impl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Envelope1_1Impl(
    SOAPDocumentImpl ownerDoc,
    String prefix,
    boolean createHeader,
    boolean createBody)
    throws SOAPException {
    super(
        ownerDoc,
        NameImpl.createEnvelope1_1Name(prefix),
        createHeader,
        createBody);
}
 
Example #17
Source File: Body1_2Impl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public SOAPElement addAttribute(QName name, String value)
    throws SOAPException {
    if (name.getLocalPart().equals("encodingStyle")
        && name.getNamespaceURI().equals(NameImpl.SOAP12_NAMESPACE)) {

        setEncodingStyle(value);
    }
    return super.addAttribute(name, value);
}
 
Example #18
Source File: Detail1_2Impl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPElement addAttribute(QName name, String value)
    throws SOAPException {
    if (name.getLocalPart().equals("encodingStyle")
        && name.getNamespaceURI().equals(NameImpl.SOAP12_NAMESPACE)) {
        setEncodingStyle(value);
    }
    return super.addAttribute(name, value);
}
 
Example #19
Source File: Detail1_2Impl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SOAPElement addAttribute(Name name, String value)
    throws SOAPException {
    if (name.getLocalName().equals("encodingStyle")
        && name.getURI().equals(NameImpl.SOAP12_NAMESPACE)) {
        setEncodingStyle(value);
    }
    return super.addAttribute(name, value);
}
 
Example #20
Source File: Fault1_1Impl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Locale getFaultStringLocale() {
    if (this.faultStringElement == null)
        findFaultStringElement();
    if (this.faultStringElement != null) {
        String xmlLangAttr =
            this.faultStringElement.getAttributeValue(
                NameImpl.createFromUnqualifiedName("xml:lang"));
        if (xmlLangAttr != null)
            return xmlLangToLocale(xmlLangAttr);
    }
    return null;
}
 
Example #21
Source File: Detail1_2Impl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPElement addAttribute(Name name, String value)
    throws SOAPException {
    if (name.getLocalName().equals("encodingStyle")
        && name.getURI().equals(NameImpl.SOAP12_NAMESPACE)) {
        setEncodingStyle(value);
    }
    return super.addAttribute(name, value);
}
 
Example #22
Source File: Body1_2Impl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public SOAPElement addAttribute(Name name, String value)
    throws SOAPException {
    if (name.getLocalName().equals("encodingStyle")
        && name.getURI().equals(NameImpl.SOAP12_NAMESPACE)) {

        setEncodingStyle(value);
    }
    return super.addAttribute(name, value);
}
 
Example #23
Source File: ElementImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected SOAPElement convertToSoapElement(Element element) {
    if (element instanceof SOAPElement) {
        return (SOAPElement) element;
    } else {
        return replaceElementWithSOAPElement(
            element,
            (ElementImpl) createElement(NameImpl.copyElementName(element)));
    }
}
 
Example #24
Source File: Envelope1_2Impl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Envelope1_2Impl(
    SOAPDocumentImpl ownerDoc,
    String prefix,
    boolean createHeader,
    boolean createBody)
    throws SOAPException {
    super(
        ownerDoc,
        NameImpl.createEnvelope1_2Name(prefix),
        createHeader,
        createBody);
}
 
Example #25
Source File: ElementImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected SOAPElement findChild(NameImpl name) {
    Iterator eachChild = getChildElementNodes();
    while (eachChild.hasNext()) {
        SOAPElement child = (SOAPElement) eachChild.next();
        if (child.getElementName().equals(name)) {
            return child;
        }
    }

    return null;
}
 
Example #26
Source File: Header1_2Impl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public SOAPElement addAttribute(QName name, String value)
    throws SOAPException {
    if (name.getLocalPart().equals("encodingStyle")
        && name.getNamespaceURI().equals(NameImpl.SOAP12_NAMESPACE)) {

        setEncodingStyle(value);
    }
    return super.addAttribute(name, value);
}
 
Example #27
Source File: ElementImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Iterator getAllAttributesAsQNames() {
    Iterator i = getAllAttributesFrom(this);
    ArrayList list = new ArrayList();
    while (i.hasNext()) {
        Name name = (Name) i.next();
        if (!"xmlns".equalsIgnoreCase(name.getPrefix())) {
            list.add(NameImpl.convertToQName(name));
        }
    }
    return list.iterator();
}
 
Example #28
Source File: ElementImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected SOAPElement convertToSoapElement(Element element) {
    if (element instanceof SOAPElement) {
        return (SOAPElement) element;
    } else {
        return replaceElementWithSOAPElement(
            element,
            (ElementImpl) createElement(NameImpl.copyElementName(element)));
    }
}
 
Example #29
Source File: HeaderImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public SOAPHeaderElement addUpgradeHeaderElement(Iterator supportedSoapUris)
    throws SOAPException {
    if (supportedSoapUris == null) {
        log.severe("SAAJ0411.ver1_2.no.null.supportedURIs");
        throw new SOAPException("Argument cannot be null; iterator of supportedURIs cannot be null");
    }
    if (!supportedSoapUris.hasNext()) {
        log.severe("SAAJ0412.ver1_2.no.empty.list.of.supportedURIs");
        throw new SOAPException("List of supported URIs cannot be empty");
    }
    Name upgradeName = getUpgradeName();
    SOAPHeaderElement upgradeHeaderElement =
        (SOAPHeaderElement) addChildElement(upgradeName);
    Name supportedEnvelopeName = getSupportedEnvelopeName();
    int i = 0;
    while (supportedSoapUris.hasNext()) {
        SOAPElement subElement =
            upgradeHeaderElement.addChildElement(supportedEnvelopeName);
        String ns = "ns" + Integer.toString(i);
        subElement.addAttribute(
            NameImpl.createFromUnqualifiedName("qname"),
            ns + ":Envelope");
        subElement.addNamespaceDeclaration(
            ns,
            (String) supportedSoapUris.next());
        i ++;
    }
    return upgradeHeaderElement;
}
 
Example #30
Source File: EnvelopeImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPHeader addHeader(String prefix) throws SOAPException {

        if (prefix == null || prefix.equals("")) {
            prefix = getPrefix();
        }

        NameImpl headerName = getHeaderName(prefix);
        NameImpl bodyName = getBodyName(prefix);

        HeaderImpl header = null;
        SOAPElement firstChild = null;

        Iterator eachChild = getChildElementNodes();
        if (eachChild.hasNext()) {
            firstChild = (SOAPElement) eachChild.next();
            if (firstChild.getElementName().equals(headerName)) {
                log.severe("SAAJ0120.impl.header.already.exists");
                throw new SOAPExceptionImpl("Can't add a header when one is already present.");
            } else if (!firstChild.getElementName().equals(bodyName)) {
                log.severe("SAAJ0121.impl.invalid.first.child.of.envelope");
                throw new SOAPExceptionImpl("First child of Envelope must be either a Header or Body");
            }
        }

        header = (HeaderImpl) createElement(headerName);
        insertBefore(header, firstChild);
        header.ensureNamespaceIsDeclared(headerName.getPrefix(), headerName.getURI());

        return header;
    }