< prev index next >
jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/SOAPPartImpl.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -23,33 +23,60 @@
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
-import java.io.*;
-import java.util.Iterator;
-import java.util.logging.Logger;
-import java.util.logging.Level;
-
-import javax.activation.DataHandler;
-import javax.activation.DataSource;
-import javax.xml.soap.*;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-
-import org.w3c.dom.*;
-
-import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeBodyPart;
-
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
+import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeBodyPart;
import com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
-import com.sun.xml.internal.messaging.saaj.util.*;
+import com.sun.xml.internal.messaging.saaj.util.ByteInputStream;
+import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
+import com.sun.xml.internal.messaging.saaj.util.FastInfosetReflection;
+import com.sun.xml.internal.messaging.saaj.util.JAXMStreamSource;
+import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
+import com.sun.xml.internal.messaging.saaj.util.MimeHeadersUtil;
+import com.sun.xml.internal.messaging.saaj.util.SAAJUtil;
+import com.sun.xml.internal.messaging.saaj.util.XMLDeclarationParser;
+import org.w3c.dom.Attr;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Comment;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.w3c.dom.EntityReference;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.ProcessingInstruction;
+import org.w3c.dom.UserDataHandler;
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPPart;
+import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamSource;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.PushbackReader;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* SOAPPartImpl is the first attachment. This contains the XML/SOAP document.
*
* @author Anil Vijendran (anil@sun.com)
@@ -126,24 +153,25 @@
}
} else if (source != null) {
envelope = createEnvelopeFromSource();
} else {
envelope = createEmptyEnvelope(null);
- document.insertBefore(envelope, null);
+ document.insertBefore(((EnvelopeImpl) envelope).getDomElement(), null);
}
return envelope;
}
protected void lookForEnvelope() throws SOAPException {
Element envelopeChildElement = document.doGetDocumentElement();
- if (envelopeChildElement == null || envelopeChildElement instanceof Envelope) {
- envelope = (EnvelopeImpl) envelopeChildElement;
- } else if (!(envelopeChildElement instanceof ElementImpl)) {
+ org.w3c.dom.Node soapEnvelope = document.findIfPresent(envelopeChildElement);
+ if (soapEnvelope == null || soapEnvelope instanceof Envelope) {
+ envelope = (EnvelopeImpl) soapEnvelope;
+ } else if (document.find(envelopeChildElement) == null) {
log.severe("SAAJ0512.soap.incorrect.factory.used");
throw new SOAPExceptionImpl("Unable to create envelope: incorrect factory used during tree construction");
} else {
- ElementImpl soapElement = (ElementImpl) envelopeChildElement;
+ ElementImpl soapElement = (ElementImpl) document.find(envelopeChildElement);
if (soapElement.getLocalName().equalsIgnoreCase("Envelope")) {
String prefix = soapElement.getPrefix();
String uri = (prefix == null) ? soapElement.getNamespaceURI() : soapElement.getNamespaceURI(prefix);
if(!uri.equals(NameImpl.SOAP11_NAMESPACE) && !uri.equals(NameImpl.SOAP12_NAMESPACE)) {
log.severe("SAAJ0513.soap.unknown.ns");
@@ -496,11 +524,11 @@
newSoapPart.source = this.source;
return newSoapPart;
}
public NamedNodeMap getAttributes() {
- return document.getAttributes();
+ return document.getDomDocument().getAttributes();
}
public NodeList getChildNodes() {
handleNewSource();
return document.getChildNodes();
@@ -515,52 +543,52 @@
handleNewSource();
return document.getLastChild();
}
public String getLocalName() {
- return document.getLocalName();
+ return document.getDomDocument().getLocalName();
}
public String getNamespaceURI() {
- return document.getNamespaceURI();
+ return document.getDomDocument().getNamespaceURI();
}
public org.w3c.dom.Node getNextSibling() {
handleNewSource();
return document.getNextSibling();
}
public String getNodeName() {
- return document.getNodeName();
+ return document.getDomDocument().getNodeName();
}
public short getNodeType() {
- return document.getNodeType();
+ return document.getDomDocument().getNodeType();
}
public String getNodeValue() throws DOMException {
return document.getNodeValue();
}
public Document getOwnerDocument() {
- return document.getOwnerDocument();
+ return document.getDomDocument().getOwnerDocument();
}
public org.w3c.dom.Node getParentNode() {
- return document.getParentNode();
+ return document.getDomDocument().getParentNode();
}
public String getPrefix() {
- return document.getPrefix();
+ return document.getDomDocument().getPrefix();
}
public org.w3c.dom.Node getPreviousSibling() {
- return document.getPreviousSibling();
+ return document.getDomDocument().getPreviousSibling();
}
public boolean hasAttributes() {
- return document.hasAttributes();
+ return document.getDomDocument().hasAttributes();
}
public boolean hasChildNodes() {
handleNewSource();
return document.hasChildNodes();
@@ -573,11 +601,11 @@
handleNewSource();
return document.insertBefore(arg0, arg1);
}
public boolean isSupported(String arg0, String arg1) {
- return document.isSupported(arg0, arg1);
+ return document.getDomDocument().isSupported(arg0, arg1);
}
public void normalize() {
handleNewSource();
document.normalize();
@@ -684,11 +712,11 @@
public void normalizeDocument() {
document.normalizeDocument();
}
public DOMConfiguration getDomConfig() {
- return document.getDomConfig();
+ return document.getDomDocument().getDomConfig();
}
public org.w3c.dom.Node adoptNode(org.w3c.dom.Node source) throws DOMException {
handleNewSource();
return document.adoptNode(source);
@@ -697,48 +725,48 @@
public void setDocumentURI(String documentURI) {
document.setDocumentURI(documentURI);
}
public String getDocumentURI() {
- return document.getDocumentURI();
+ return document.getDomDocument().getDocumentURI();
}
public void setStrictErrorChecking(boolean strictErrorChecking) {
document.setStrictErrorChecking(strictErrorChecking);
}
public String getInputEncoding() {
- return document.getInputEncoding();
+ return document.getDomDocument().getInputEncoding();
}
public String getXmlEncoding() {
- return document.getXmlEncoding();
+ return document.getDomDocument().getXmlEncoding();
}
public boolean getXmlStandalone() {
- return document.getXmlStandalone();
+ return document.getDomDocument().getXmlStandalone();
}
public void setXmlStandalone(boolean xmlStandalone) throws DOMException {
document.setXmlStandalone(xmlStandalone);
}
public String getXmlVersion() {
- return document.getXmlVersion();
+ return document.getDomDocument().getXmlVersion();
}
public void setXmlVersion(String xmlVersion) throws DOMException {
document.setXmlVersion(xmlVersion);
}
public boolean getStrictErrorChecking() {
- return document.getStrictErrorChecking();
+ return document.getDomDocument().getStrictErrorChecking();
}
// DOM L3 methods from org.w3c.dom.Node
public String getBaseURI() {
- return document.getBaseURI();
+ return document.getDomDocument().getBaseURI();
}
public short compareDocumentPosition(org.w3c.dom.Node other)
throws DOMException {
return document.compareDocumentPosition(other);
@@ -756,11 +784,11 @@
public boolean isSameNode(org.w3c.dom.Node other) {
return document.isSameNode(other);
}
public String lookupPrefix(String namespaceURI) {
- return document.lookupPrefix(namespaceURI);
+ return document.getDomDocument().lookupPrefix(namespaceURI);
}
public boolean isDefaultNamespace(String namespaceURI) {
return document.isDefaultNamespace(namespaceURI);
}
@@ -768,11 +796,11 @@
public String lookupNamespaceURI(String prefix) {
return document.lookupNamespaceURI(prefix);
}
public boolean isEqualNode(org.w3c.dom.Node arg) {
- return document.isEqualNode(arg);
+ return document.getDomDocument().isEqualNode(arg);
}
public Object getFeature(String feature,
String version) {
return document.getFeature(feature,version);
@@ -783,11 +811,11 @@
UserDataHandler handler) {
return document.setUserData(key, data, handler);
}
public Object getUserData(String key) {
- return document.getUserData(key);
+ return document.getDomDocument().getUserData(key);
}
public void recycleNode() {
// Nothing seems to be required to be done here
}
< prev index next >