1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/SOAPPartImpl.java Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,799 @@ 1.4 +/* 1.5 + * $Id: SOAPPartImpl.java,v 1.1.1.1 2006/01/27 13:10:55 kumarjayanti Exp $ 1.6 + * $Revision: 1.1.1.1 $ 1.7 + * $Date: 2006/01/27 13:10:55 $ 1.8 + */ 1.9 + 1.10 +/* 1.11 + * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. 1.12 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.13 + * 1.14 + * This code is free software; you can redistribute it and/or modify it 1.15 + * under the terms of the GNU General Public License version 2 only, as 1.16 + * published by the Free Software Foundation. Sun designates this 1.17 + * particular file as subject to the "Classpath" exception as provided 1.18 + * by Sun in the LICENSE file that accompanied this code. 1.19 + * 1.20 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.21 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.22 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.23 + * version 2 for more details (a copy is included in the LICENSE file that 1.24 + * accompanied this code). 1.25 + * 1.26 + * You should have received a copy of the GNU General Public License version 1.27 + * 2 along with this work; if not, write to the Free Software Foundation, 1.28 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.29 + * 1.30 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.31 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.32 + * have any questions. 1.33 + */ 1.34 +package com.sun.xml.internal.messaging.saaj.soap; 1.35 + 1.36 +import java.io.*; 1.37 +import java.util.Iterator; 1.38 +import java.util.logging.Logger; 1.39 +import java.util.logging.Level; 1.40 + 1.41 +import javax.activation.DataHandler; 1.42 +import javax.activation.DataSource; 1.43 +import javax.xml.soap.*; 1.44 +import javax.xml.transform.Source; 1.45 +import javax.xml.transform.stream.StreamSource; 1.46 + 1.47 +import org.w3c.dom.*; 1.48 + 1.49 +import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeBodyPart; 1.50 + 1.51 +import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl; 1.52 +import com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl; 1.53 +import com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl; 1.54 +import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl; 1.55 +import com.sun.xml.internal.messaging.saaj.util.*; 1.56 +import javax.xml.transform.sax.SAXSource; 1.57 + 1.58 +/** 1.59 + * SOAPPartImpl is the first attachment. This contains the XML/SOAP document. 1.60 + * 1.61 + * @author Anil Vijendran (anil@sun.com) 1.62 + */ 1.63 +public abstract class SOAPPartImpl extends SOAPPart implements SOAPDocument { 1.64 + protected static Logger log = 1.65 + Logger.getLogger(LogDomainConstants.SOAP_DOMAIN, 1.66 + "com.sun.xml.internal.messaging.saaj.soap.LocalStrings"); 1.67 + 1.68 + protected MimeHeaders headers; 1.69 + protected Envelope envelope; 1.70 + protected Source source; 1.71 + protected SOAPDocumentImpl document; 1.72 + 1.73 + //flag to indicate if a setContent happened. 1.74 + private boolean sourceWasSet = false; 1.75 + 1.76 + // Records whether the input source had an xml decl or not. 1.77 + protected boolean omitXmlDecl = true; 1.78 + 1.79 + // Records the charset encoding of the input stream source if provided. 1.80 + protected String sourceCharsetEncoding = null; 1.81 + 1.82 + /** 1.83 + * Reference to containing message (may be null) 1.84 + */ 1.85 + protected MessageImpl message; 1.86 + 1.87 + protected SOAPPartImpl() { 1.88 + this(null); 1.89 + } 1.90 + 1.91 + protected SOAPPartImpl(MessageImpl message) { 1.92 + document = new SOAPDocumentImpl(this); 1.93 + headers = new MimeHeaders(); 1.94 + this.message = message; 1.95 + headers.setHeader("Content-Type", getContentType()); 1.96 + } 1.97 + 1.98 + protected abstract String getContentType(); 1.99 + protected abstract Envelope createEnvelopeFromSource() 1.100 + throws SOAPException; 1.101 + protected abstract Envelope createEmptyEnvelope(String prefix) 1.102 + throws SOAPException; 1.103 + protected abstract SOAPPartImpl duplicateType(); 1.104 + 1.105 + protected String getContentTypeString() { 1.106 + return getContentType(); 1.107 + } 1.108 + 1.109 + public boolean isFastInfoset() { 1.110 + return (message != null) ? message.isFastInfoset() : false; 1.111 + } 1.112 + 1.113 + public SOAPEnvelope getEnvelope() throws SOAPException { 1.114 + 1.115 + // If there is no SOAP envelope already created, then create 1.116 + // one from a source if one exists. If there is a newer source 1.117 + // then use that source. 1.118 + 1.119 + if (sourceWasSet) 1.120 + sourceWasSet = false; 1.121 + 1.122 + lookForEnvelope(); 1.123 + if (envelope != null) { 1.124 + if (source != null) { // there's a newer source, use it 1.125 + document.removeChild(envelope); 1.126 + envelope = createEnvelopeFromSource(); 1.127 + } 1.128 + } else if (source != null) { 1.129 + envelope = createEnvelopeFromSource(); 1.130 + } else { 1.131 + envelope = createEmptyEnvelope(null); 1.132 + document.insertBefore(envelope, null); 1.133 + } 1.134 + return envelope; 1.135 + } 1.136 + 1.137 + protected void lookForEnvelope() throws SOAPException { 1.138 + Element envelopeChildElement = document.doGetDocumentElement(); 1.139 + if (envelopeChildElement == null || envelopeChildElement instanceof Envelope) { 1.140 + envelope = (EnvelopeImpl) envelopeChildElement; 1.141 + } else if (!(envelopeChildElement instanceof ElementImpl)) { 1.142 + log.severe("SAAJ0512.soap.incorrect.factory.used"); 1.143 + throw new SOAPExceptionImpl("Unable to create envelope: incorrect factory used during tree construction"); 1.144 + } else { 1.145 + ElementImpl soapElement = (ElementImpl) envelopeChildElement; 1.146 + if (soapElement.getLocalName().equalsIgnoreCase("Envelope")) { 1.147 + String prefix = soapElement.getPrefix(); 1.148 + String uri = (prefix == null) ? soapElement.getNamespaceURI() : soapElement.getNamespaceURI(prefix); 1.149 + if(!uri.equals(NameImpl.SOAP11_NAMESPACE) && !uri.equals(NameImpl.SOAP12_NAMESPACE)) { 1.150 + log.severe("SAAJ0513.soap.unknown.ns"); 1.151 + throw new SOAPVersionMismatchException("Unable to create envelope from given source because the namespace was not recognized"); 1.152 + } 1.153 + } else { 1.154 + log.severe("SAAJ0514.soap.root.elem.not.named.envelope"); 1.155 + throw new SOAPExceptionImpl( 1.156 + "Unable to create envelope from given source because the root element is not named \"Envelope\""); 1.157 + } 1.158 + } 1.159 + } 1.160 + 1.161 + public void removeAllMimeHeaders() { 1.162 + headers.removeAllHeaders(); 1.163 + } 1.164 + 1.165 + public void removeMimeHeader(String header) { 1.166 + headers.removeHeader(header); 1.167 + } 1.168 + 1.169 + public String[] getMimeHeader(String name) { 1.170 + return headers.getHeader(name); 1.171 + } 1.172 + 1.173 + public void setMimeHeader(String name, String value) { 1.174 + headers.setHeader(name, value); 1.175 + } 1.176 + 1.177 + public void addMimeHeader(String name, String value) { 1.178 + headers.addHeader(name, value); 1.179 + } 1.180 + 1.181 + public Iterator getAllMimeHeaders() { 1.182 + return headers.getAllHeaders(); 1.183 + } 1.184 + 1.185 + public Iterator getMatchingMimeHeaders(String[] names) { 1.186 + return headers.getMatchingHeaders(names); 1.187 + } 1.188 + 1.189 + public Iterator getNonMatchingMimeHeaders(String[] names) { 1.190 + return headers.getNonMatchingHeaders(names); 1.191 + } 1.192 + 1.193 + public Source getContent() throws SOAPException { 1.194 + if (source != null) { 1.195 + InputStream bis = null; 1.196 + if (source instanceof JAXMStreamSource) { 1.197 + StreamSource streamSource = (StreamSource)source; 1.198 + bis = streamSource.getInputStream(); 1.199 + } else if (FastInfosetReflection.isFastInfosetSource(source)) { 1.200 + // FastInfosetSource inherits from SAXSource 1.201 + SAXSource saxSource = (SAXSource)source; 1.202 + bis = saxSource.getInputSource().getByteStream(); 1.203 + } 1.204 + 1.205 + if (bis != null) { 1.206 + try { 1.207 + bis.reset(); 1.208 + } catch (IOException e) { 1.209 + /* This exception will never be thrown. 1.210 + * 1.211 + * The setContent method will modify the source 1.212 + * if StreamSource to JAXMStreamSource, that uses 1.213 + * a ByteInputStream, and for a FastInfosetSource will 1.214 + * replace the InputStream with a ByteInputStream. 1.215 + */ 1.216 + } 1.217 + } 1.218 + return source; 1.219 + } 1.220 + 1.221 + return ((Envelope) getEnvelope()).getContent(); 1.222 + } 1.223 + 1.224 + public void setContent(Source source) throws SOAPException { 1.225 + try { 1.226 + if (source instanceof StreamSource) { 1.227 + InputStream is = ((StreamSource) source).getInputStream(); 1.228 + Reader rdr = ((StreamSource) source).getReader(); 1.229 + 1.230 + if (is != null) { 1.231 + this.source = new JAXMStreamSource(is); 1.232 + } else if (rdr != null) { 1.233 + this.source = new JAXMStreamSource(rdr); 1.234 + } else { 1.235 + log.severe("SAAJ0544.soap.no.valid.reader.for.src"); 1.236 + throw new SOAPExceptionImpl("Source does not have a valid Reader or InputStream"); 1.237 + } 1.238 + } 1.239 + else if (FastInfosetReflection.isFastInfosetSource(source)) { 1.240 + // InputStream is = source.getInputStream() 1.241 + InputStream is = FastInfosetReflection.FastInfosetSource_getInputStream(source); 1.242 + 1.243 + /* 1.244 + * Underlying stream must be ByteInputStream for getContentAsStream(). We pay the 1.245 + * cost of copying the underlying bytes here to avoid multiple copies every time 1.246 + * getBytes() is called on a ByteInputStream. 1.247 + */ 1.248 + if (!(is instanceof ByteInputStream)) { 1.249 + ByteOutputStream bout = new ByteOutputStream(); 1.250 + bout.write(is); 1.251 + 1.252 + // source.setInputStream(new ByteInputStream(...)) 1.253 + FastInfosetReflection.FastInfosetSource_setInputStream( 1.254 + source, bout.newInputStream()); 1.255 + } 1.256 + this.source = source; 1.257 + } 1.258 + else { 1.259 + this.source = source; 1.260 + } 1.261 + sourceWasSet = true; 1.262 + } 1.263 + catch (Exception ex) { 1.264 + ex.printStackTrace(); 1.265 + 1.266 + log.severe("SAAJ0545.soap.cannot.set.src.for.part"); 1.267 + throw new SOAPExceptionImpl( 1.268 + "Error setting the source for SOAPPart: " + ex.getMessage()); 1.269 + } 1.270 + } 1.271 + 1.272 + public ByteInputStream getContentAsStream() throws IOException { 1.273 + if (source != null) { 1.274 + InputStream is = null; 1.275 + 1.276 + // Allow message to be transcode if so requested 1.277 + if (source instanceof StreamSource && !isFastInfoset()) { 1.278 + is = ((StreamSource) source).getInputStream(); 1.279 + } 1.280 + else if (FastInfosetReflection.isFastInfosetSource(source) && 1.281 + isFastInfoset()) 1.282 + { 1.283 + try { 1.284 + // InputStream is = source.getInputStream() 1.285 + is = FastInfosetReflection.FastInfosetSource_getInputStream(source); 1.286 + } 1.287 + catch (Exception e) { 1.288 + throw new IOException(e.toString()); 1.289 + } 1.290 + } 1.291 + 1.292 + if (is != null) { 1.293 + if (!(is instanceof ByteInputStream)) { 1.294 + log.severe("SAAJ0546.soap.stream.incorrect.type"); 1.295 + throw new IOException("Internal error: stream not of the right type"); 1.296 + } 1.297 + return (ByteInputStream) is; 1.298 + } 1.299 + // need to do something here for reader... 1.300 + // for now we'll see if we can fallback... 1.301 + } 1.302 + 1.303 + ByteOutputStream b = new ByteOutputStream(); 1.304 + 1.305 + Envelope env = null; 1.306 + 1.307 + try { 1.308 + env = (Envelope) getEnvelope(); 1.309 + env.output(b, isFastInfoset()); 1.310 + } 1.311 + catch (SOAPException soapException) { 1.312 + log.severe("SAAJ0547.soap.cannot.externalize"); 1.313 + throw new SOAPIOException( 1.314 + "SOAP exception while trying to externalize: ", 1.315 + soapException); 1.316 + } 1.317 + 1.318 + return b.newInputStream(); 1.319 + } 1.320 + 1.321 + MimeBodyPart getMimePart() throws SOAPException { 1.322 + try { 1.323 + MimeBodyPart headerEnvelope = new MimeBodyPart(); 1.324 + 1.325 + headerEnvelope.setDataHandler(getDataHandler()); 1.326 + AttachmentPartImpl.copyMimeHeaders(headers, headerEnvelope); 1.327 + 1.328 + return headerEnvelope; 1.329 + } catch (SOAPException ex) { 1.330 + throw ex; 1.331 + } catch (Exception ex) { 1.332 + log.severe("SAAJ0548.soap.cannot.externalize.hdr"); 1.333 + throw new SOAPExceptionImpl("Unable to externalize header", ex); 1.334 + } 1.335 + } 1.336 + 1.337 + MimeHeaders getMimeHeaders() { 1.338 + return headers; 1.339 + } 1.340 + 1.341 + DataHandler getDataHandler() { 1.342 + DataSource ds = new DataSource() { 1.343 + public OutputStream getOutputStream() throws IOException { 1.344 + throw new IOException("Illegal Operation"); 1.345 + } 1.346 + 1.347 + public String getContentType() { 1.348 + return getContentTypeString(); 1.349 + } 1.350 + 1.351 + public String getName() { 1.352 + return getContentId(); 1.353 + } 1.354 + 1.355 + public InputStream getInputStream() throws IOException { 1.356 + return getContentAsStream(); 1.357 + } 1.358 + }; 1.359 + return new DataHandler(ds); 1.360 + } 1.361 + 1.362 + public SOAPDocumentImpl getDocument() { 1.363 + handleNewSource(); 1.364 + return document; 1.365 + } 1.366 + 1.367 + public SOAPPartImpl getSOAPPart() { 1.368 + return this; 1.369 + } 1.370 + 1.371 + public DocumentType getDoctype() { 1.372 + return document.getDoctype(); 1.373 + } 1.374 + 1.375 + // Forward all of these calls to the document to ensure that they work the 1.376 + // same way whether they are called from here or directly from the document. 1.377 + // If the document needs any help from this SOAPPart then 1.378 + // Make it use a call-back as in doGetDocumentElement() below 1.379 + public DOMImplementation getImplementation() { 1.380 + return document.getImplementation(); 1.381 + } 1.382 + 1.383 + public Element getDocumentElement() { 1.384 + // If there is no SOAP envelope already created, then create 1.385 + // one from a source if one exists. If there is a newer source 1.386 + // then use that source. 1.387 + try { 1.388 + getEnvelope(); 1.389 + } catch (SOAPException e) { 1.390 + } 1.391 + return document.getDocumentElement(); 1.392 + } 1.393 + 1.394 + protected void doGetDocumentElement() { 1.395 + handleNewSource(); 1.396 + try { 1.397 + lookForEnvelope(); 1.398 + } catch (SOAPException e) { 1.399 + } 1.400 + } 1.401 + 1.402 + public Element createElement(String tagName) throws DOMException { 1.403 + return document.createElement(tagName); 1.404 + } 1.405 + 1.406 + public DocumentFragment createDocumentFragment() { 1.407 + return document.createDocumentFragment(); 1.408 + } 1.409 + 1.410 + public org.w3c.dom.Text createTextNode(String data) { 1.411 + return document.createTextNode(data); 1.412 + } 1.413 + 1.414 + public Comment createComment(String data) { 1.415 + return document.createComment(data); 1.416 + } 1.417 + 1.418 + public CDATASection createCDATASection(String data) throws DOMException { 1.419 + return document.createCDATASection(data); 1.420 + } 1.421 + 1.422 + public ProcessingInstruction createProcessingInstruction( 1.423 + String target, 1.424 + String data) 1.425 + throws DOMException { 1.426 + return document.createProcessingInstruction(target, data); 1.427 + } 1.428 + 1.429 + public Attr createAttribute(String name) throws DOMException { 1.430 + return document.createAttribute(name); 1.431 + } 1.432 + 1.433 + public EntityReference createEntityReference(String name) 1.434 + throws DOMException { 1.435 + return document.createEntityReference(name); 1.436 + } 1.437 + 1.438 + public NodeList getElementsByTagName(String tagname) { 1.439 + handleNewSource(); 1.440 + return document.getElementsByTagName(tagname); 1.441 + } 1.442 + 1.443 + public org.w3c.dom.Node importNode( 1.444 + org.w3c.dom.Node importedNode, 1.445 + boolean deep) 1.446 + throws DOMException { 1.447 + handleNewSource(); 1.448 + return document.importNode(importedNode, deep); 1.449 + } 1.450 + 1.451 + public Element createElementNS(String namespaceURI, String qualifiedName) 1.452 + throws DOMException { 1.453 + return document.createElementNS(namespaceURI, qualifiedName); 1.454 + } 1.455 + 1.456 + public Attr createAttributeNS(String namespaceURI, String qualifiedName) 1.457 + throws DOMException { 1.458 + return document.createAttributeNS(namespaceURI, qualifiedName); 1.459 + } 1.460 + 1.461 + public NodeList getElementsByTagNameNS( 1.462 + String namespaceURI, 1.463 + String localName) { 1.464 + handleNewSource(); 1.465 + return document.getElementsByTagNameNS(namespaceURI, localName); 1.466 + } 1.467 + 1.468 + public Element getElementById(String elementId) { 1.469 + handleNewSource(); 1.470 + return document.getElementById(elementId); 1.471 + } 1.472 + public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) 1.473 + throws DOMException { 1.474 + handleNewSource(); 1.475 + return document.appendChild(newChild); 1.476 + } 1.477 + 1.478 + public org.w3c.dom.Node cloneNode(boolean deep) { 1.479 + handleNewSource(); 1.480 + return document.cloneNode(deep); 1.481 + } 1.482 + 1.483 + protected SOAPPartImpl doCloneNode() { 1.484 + handleNewSource(); 1.485 + SOAPPartImpl newSoapPart = duplicateType(); 1.486 + 1.487 + newSoapPart.headers = MimeHeadersUtil.copy(this.headers); 1.488 + newSoapPart.source = this.source; 1.489 + return newSoapPart; 1.490 + } 1.491 + 1.492 + public NamedNodeMap getAttributes() { 1.493 + return document.getAttributes(); 1.494 + } 1.495 + 1.496 + public NodeList getChildNodes() { 1.497 + handleNewSource(); 1.498 + return document.getChildNodes(); 1.499 + } 1.500 + 1.501 + public org.w3c.dom.Node getFirstChild() { 1.502 + handleNewSource(); 1.503 + return document.getFirstChild(); 1.504 + } 1.505 + 1.506 + public org.w3c.dom.Node getLastChild() { 1.507 + handleNewSource(); 1.508 + return document.getLastChild(); 1.509 + } 1.510 + 1.511 + public String getLocalName() { 1.512 + return document.getLocalName(); 1.513 + } 1.514 + 1.515 + public String getNamespaceURI() { 1.516 + return document.getNamespaceURI(); 1.517 + } 1.518 + 1.519 + public org.w3c.dom.Node getNextSibling() { 1.520 + handleNewSource(); 1.521 + return document.getNextSibling(); 1.522 + } 1.523 + 1.524 + public String getNodeName() { 1.525 + return document.getNodeName(); 1.526 + } 1.527 + 1.528 + public short getNodeType() { 1.529 + return document.getNodeType(); 1.530 + } 1.531 + 1.532 + public String getNodeValue() throws DOMException { 1.533 + return document.getNodeValue(); 1.534 + } 1.535 + 1.536 + public Document getOwnerDocument() { 1.537 + return document.getOwnerDocument(); 1.538 + } 1.539 + 1.540 + public org.w3c.dom.Node getParentNode() { 1.541 + return document.getParentNode(); 1.542 + } 1.543 + 1.544 + public String getPrefix() { 1.545 + return document.getPrefix(); 1.546 + } 1.547 + 1.548 + public org.w3c.dom.Node getPreviousSibling() { 1.549 + return document.getPreviousSibling(); 1.550 + } 1.551 + 1.552 + public boolean hasAttributes() { 1.553 + return document.hasAttributes(); 1.554 + } 1.555 + 1.556 + public boolean hasChildNodes() { 1.557 + handleNewSource(); 1.558 + return document.hasChildNodes(); 1.559 + } 1.560 + 1.561 + public org.w3c.dom.Node insertBefore( 1.562 + org.w3c.dom.Node arg0, 1.563 + org.w3c.dom.Node arg1) 1.564 + throws DOMException { 1.565 + handleNewSource(); 1.566 + return document.insertBefore(arg0, arg1); 1.567 + } 1.568 + 1.569 + public boolean isSupported(String arg0, String arg1) { 1.570 + return document.isSupported(arg0, arg1); 1.571 + } 1.572 + 1.573 + public void normalize() { 1.574 + handleNewSource(); 1.575 + document.normalize(); 1.576 + } 1.577 + 1.578 + public org.w3c.dom.Node removeChild(org.w3c.dom.Node arg0) 1.579 + throws DOMException { 1.580 + handleNewSource(); 1.581 + return document.removeChild(arg0); 1.582 + } 1.583 + 1.584 + public org.w3c.dom.Node replaceChild( 1.585 + org.w3c.dom.Node arg0, 1.586 + org.w3c.dom.Node arg1) 1.587 + throws DOMException { 1.588 + handleNewSource(); 1.589 + return document.replaceChild(arg0, arg1); 1.590 + } 1.591 + 1.592 + public void setNodeValue(String arg0) throws DOMException { 1.593 + document.setNodeValue(arg0); 1.594 + } 1.595 + 1.596 + public void setPrefix(String arg0) throws DOMException { 1.597 + document.setPrefix(arg0); 1.598 + } 1.599 + 1.600 + private void handleNewSource() { 1.601 + if (sourceWasSet) { 1.602 + // There is a newer source use that source. 1.603 + try { 1.604 + getEnvelope(); 1.605 + } catch (SOAPException e) { 1.606 + } 1.607 + } 1.608 + } 1.609 + 1.610 + protected XMLDeclarationParser lookForXmlDecl() throws SOAPException { 1.611 + if ((source != null) && (source instanceof StreamSource)) { 1.612 + 1.613 + Reader reader = null; 1.614 + 1.615 + InputStream inputStream = ((StreamSource) source).getInputStream(); 1.616 + if (inputStream != null) { 1.617 + if (sourceCharsetEncoding == null) { 1.618 + reader = new InputStreamReader(inputStream); 1.619 + } else { 1.620 + try { 1.621 + reader = 1.622 + new InputStreamReader( 1.623 + inputStream, sourceCharsetEncoding); 1.624 + } catch (UnsupportedEncodingException uee) { 1.625 + log.log( 1.626 + Level.SEVERE, 1.627 + "SAAJ0551.soap.unsupported.encoding", 1.628 + new Object[] {sourceCharsetEncoding}); 1.629 + throw new SOAPExceptionImpl( 1.630 + "Unsupported encoding " + sourceCharsetEncoding, 1.631 + uee); 1.632 + } 1.633 + } 1.634 + } else { 1.635 + reader = ((StreamSource) source).getReader(); 1.636 + } 1.637 + if (reader != null) { 1.638 + PushbackReader pushbackReader = 1.639 + new PushbackReader(reader, 4096); //some size to unread <?xml ....?> 1.640 + XMLDeclarationParser ev = 1.641 + new XMLDeclarationParser(pushbackReader); 1.642 + try { 1.643 + ev.parse(); 1.644 + } catch (Exception e) { 1.645 + log.log( 1.646 + Level.SEVERE, 1.647 + "SAAJ0552.soap.xml.decl.parsing.failed"); 1.648 + throw new SOAPExceptionImpl( 1.649 + "XML declaration parsing failed", e); 1.650 + } 1.651 + String xmlDecl = ev.getXmlDeclaration(); 1.652 + if ((xmlDecl != null) && (xmlDecl.length() > 0)) 1.653 + this.omitXmlDecl = false; 1.654 + return ev; 1.655 + } 1.656 + } 1.657 + return null; 1.658 + } 1.659 + 1.660 + public void setSourceCharsetEncoding(String charset) { 1.661 + this.sourceCharsetEncoding = charset; 1.662 + } 1.663 + 1.664 + public org.w3c.dom.Node renameNode(org.w3c.dom.Node n, String namespaceURI, String qualifiedName) 1.665 + throws DOMException { 1.666 + handleNewSource(); 1.667 + return document.renameNode(n, namespaceURI, qualifiedName); 1.668 + } 1.669 + 1.670 + public void normalizeDocument() { 1.671 + document.normalizeDocument(); 1.672 + } 1.673 + 1.674 + public DOMConfiguration getDomConfig() { 1.675 + return document.getDomConfig(); 1.676 + } 1.677 + 1.678 + public org.w3c.dom.Node adoptNode(org.w3c.dom.Node source) throws DOMException { 1.679 + handleNewSource(); 1.680 + return document.adoptNode(source); 1.681 + } 1.682 + 1.683 + public void setDocumentURI(String documentURI) { 1.684 + document.setDocumentURI(documentURI); 1.685 + } 1.686 + 1.687 + public String getDocumentURI() { 1.688 + return document.getDocumentURI(); 1.689 + } 1.690 + 1.691 + public void setStrictErrorChecking(boolean strictErrorChecking) { 1.692 + document.setStrictErrorChecking(strictErrorChecking); 1.693 + } 1.694 + 1.695 + public String getInputEncoding() { 1.696 + return document.getInputEncoding(); 1.697 + } 1.698 + 1.699 + public String getXmlEncoding() { 1.700 + return document.getXmlEncoding(); 1.701 + } 1.702 + 1.703 + public boolean getXmlStandalone() { 1.704 + return document.getXmlStandalone(); 1.705 + } 1.706 + 1.707 + public void setXmlStandalone(boolean xmlStandalone) throws DOMException { 1.708 + document.setXmlStandalone(xmlStandalone); 1.709 + } 1.710 + 1.711 + public String getXmlVersion() { 1.712 + return document.getXmlVersion(); 1.713 + } 1.714 + 1.715 + public void setXmlVersion(String xmlVersion) throws DOMException { 1.716 + document.setXmlVersion(xmlVersion); 1.717 + } 1.718 + 1.719 + public boolean getStrictErrorChecking() { 1.720 + return document.getStrictErrorChecking(); 1.721 + } 1.722 + 1.723 + // DOM L3 methods from org.w3c.dom.Node 1.724 + public String getBaseURI() { 1.725 + return document.getBaseURI(); 1.726 + } 1.727 + 1.728 + public short compareDocumentPosition(org.w3c.dom.Node other) 1.729 + throws DOMException { 1.730 + return document.compareDocumentPosition(other); 1.731 + } 1.732 + 1.733 + public String getTextContent() 1.734 + throws DOMException { 1.735 + return document.getTextContent(); 1.736 + } 1.737 + 1.738 + public void setTextContent(String textContent) throws DOMException { 1.739 + document.setTextContent(textContent); 1.740 + } 1.741 + 1.742 + public boolean isSameNode(org.w3c.dom.Node other) { 1.743 + return document.isSameNode(other); 1.744 + } 1.745 + 1.746 + public String lookupPrefix(String namespaceURI) { 1.747 + return document.lookupPrefix(namespaceURI); 1.748 + } 1.749 + 1.750 + public boolean isDefaultNamespace(String namespaceURI) { 1.751 + return document.isDefaultNamespace(namespaceURI); 1.752 + } 1.753 + 1.754 + public String lookupNamespaceURI(String prefix) { 1.755 + return document.lookupNamespaceURI(prefix); 1.756 + } 1.757 + 1.758 + public boolean isEqualNode(org.w3c.dom.Node arg) { 1.759 + return document.isEqualNode(arg); 1.760 + } 1.761 + 1.762 + public Object getFeature(String feature, 1.763 + String version) { 1.764 + return document.getFeature(feature,version); 1.765 + } 1.766 + 1.767 + public Object setUserData(String key, 1.768 + Object data, 1.769 + UserDataHandler handler) { 1.770 + return document.setUserData(key, data, handler); 1.771 + } 1.772 + 1.773 + public Object getUserData(String key) { 1.774 + return document.getUserData(key); 1.775 + } 1.776 + 1.777 + public void recycleNode() { 1.778 + // Nothing seems to be required to be done here 1.779 + } 1.780 + 1.781 + public String getValue() { 1.782 + return null; 1.783 + } 1.784 + 1.785 + public void setValue(String value) { 1.786 + log.severe("SAAJ0571.soappart.setValue.not.defined"); 1.787 + throw new IllegalStateException("Setting value of a soap part is not defined"); 1.788 + } 1.789 + 1.790 + public void setParentElement(SOAPElement parent) throws SOAPException { 1.791 + log.severe("SAAJ0570.soappart.parent.element.not.defined"); 1.792 + throw new SOAPExceptionImpl("The parent element of a soap part is not defined"); 1.793 + } 1.794 + 1.795 + public SOAPElement getParentElement() { 1.796 + return null; 1.797 + } 1.798 + 1.799 + public void detachNode() { 1.800 + // Nothing seems to be required to be done here 1.801 + } 1.802 +}