feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,607 @@
/*
* Copyright (c) 1997, 2013, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.packaging.mime.util.ASCIIUtility;
import com.sun.xml.internal.messaging.saaj.packaging.mime.Header;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimePartDataSource;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.InternetHeaders;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeBodyPart;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeUtility;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
import java.io.IOException;
import java.io.InputStream;
import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.activation.*;
import javax.xml.soap.*;
import com.sun.xml.internal.org.jvnet.mimepull.MIMEPart;
/**
* Implementation of attachments.
*
* @author Anil Vijendran (akv@eng.sun.com)
*/
public class AttachmentPartImpl extends AttachmentPart {
protected static final Logger log =
Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
private final MimeHeaders headers;
private MimeBodyPart rawContent = null;
private DataHandler dataHandler = null;
//alternate impl that uses a MIMEPart
private MIMEPart mimePart = null;
public AttachmentPartImpl() {
headers = new MimeHeaders();
// initialization from here should cover most of cases;
// if not, it would be necessary to call
// AttachmentPartImpl.initializeJavaActivationHandlers()
// explicitly by programmer
initializeJavaActivationHandlers();
}
public AttachmentPartImpl(MIMEPart part) {
headers = new MimeHeaders();
mimePart = part;
List<? extends com.sun.xml.internal.org.jvnet.mimepull.Header> hdrs = part.getAllHeaders();
for (com.sun.xml.internal.org.jvnet.mimepull.Header hd : hdrs) {
headers.addHeader(hd.getName(), hd.getValue());
}
}
public int getSize() throws SOAPException {
byte[] bytes;
if (mimePart != null) {
try {
return mimePart.read().available();
} catch (IOException e) {
return -1;
}
}
if ((rawContent == null) && (dataHandler == null))
return 0;
if (rawContent != null) {
try {
return rawContent.getSize();
} catch (Exception ex) {
log.log(
Level.SEVERE,
"SAAJ0573.soap.attachment.getrawbytes.ioexception",
new String[] { ex.getLocalizedMessage()});
throw new SOAPExceptionImpl("Raw InputStream Error: " + ex);
}
} else {
ByteOutputStream bout = new ByteOutputStream();
try {
dataHandler.writeTo(bout);
} catch (IOException ex) {
log.log(
Level.SEVERE,
"SAAJ0501.soap.data.handler.err",
new String[] { ex.getLocalizedMessage()});
throw new SOAPExceptionImpl("Data handler error: " + ex);
}
return bout.size();
}
}
public void clearContent() {
if (mimePart != null) {
mimePart.close();
mimePart = null;
}
dataHandler = null;
rawContent = null;
}
public Object getContent() throws SOAPException {
try {
if (mimePart != null) {
//return an inputstream
return mimePart.read();
}
if (dataHandler != null) {
return getDataHandler().getContent();
} else if (rawContent != null) {
return rawContent.getContent();
} else {
log.severe("SAAJ0572.soap.no.content.for.attachment");
throw new SOAPExceptionImpl("No data handler/content associated with this attachment");
}
} catch (Exception ex) {
log.log(Level.SEVERE, "SAAJ0575.soap.attachment.getcontent.exception", ex);
throw new SOAPExceptionImpl(ex.getLocalizedMessage());
}
}
public void setContent(Object object, String contentType)
throws IllegalArgumentException {
if (mimePart != null) {
mimePart.close();
mimePart = null;
}
DataHandler dh = new DataHandler(object, contentType);
setDataHandler(dh);
}
public DataHandler getDataHandler() throws SOAPException {
if (mimePart != null) {
//return an inputstream
return new DataHandler(new DataSource() {
public InputStream getInputStream() throws IOException {
return mimePart.read();
}
public OutputStream getOutputStream() throws IOException {
throw new UnsupportedOperationException("getOutputStream cannot be supported : You have enabled LazyAttachments Option");
}
public String getContentType() {
return mimePart.getContentType();
}
public String getName() {
return "MIMEPart Wrapper DataSource";
}
});
}
if (dataHandler == null) {
if (rawContent != null) {
return new DataHandler(new MimePartDataSource(rawContent));
}
log.severe("SAAJ0502.soap.no.handler.for.attachment");
throw new SOAPExceptionImpl("No data handler associated with this attachment");
}
return dataHandler;
}
public void setDataHandler(DataHandler dataHandler)
throws IllegalArgumentException {
if (mimePart != null) {
mimePart.close();
mimePart = null;
}
if (dataHandler == null) {
log.severe("SAAJ0503.soap.no.null.to.dataHandler");
throw new IllegalArgumentException("Null dataHandler argument to setDataHandler");
}
this.dataHandler = dataHandler;
rawContent = null;
if (log.isLoggable(Level.FINE))
log.log(Level.FINE, "SAAJ0580.soap.set.Content-Type",
new String[] { dataHandler.getContentType() });
setMimeHeader("Content-Type", dataHandler.getContentType());
}
public void removeAllMimeHeaders() {
headers.removeAllHeaders();
}
public void removeMimeHeader(String header) {
headers.removeHeader(header);
}
public String[] getMimeHeader(String name) {
return headers.getHeader(name);
}
public void setMimeHeader(String name, String value) {
headers.setHeader(name, value);
}
public void addMimeHeader(String name, String value) {
headers.addHeader(name, value);
}
public Iterator getAllMimeHeaders() {
return headers.getAllHeaders();
}
public Iterator getMatchingMimeHeaders(String[] names) {
return headers.getMatchingHeaders(names);
}
public Iterator getNonMatchingMimeHeaders(String[] names) {
return headers.getNonMatchingHeaders(names);
}
boolean hasAllHeaders(MimeHeaders hdrs) {
if (hdrs != null) {
Iterator i = hdrs.getAllHeaders();
while (i.hasNext()) {
MimeHeader hdr = (MimeHeader) i.next();
String[] values = headers.getHeader(hdr.getName());
boolean found = false;
if (values != null) {
for (int j = 0; j < values.length; j++)
if (hdr.getValue().equalsIgnoreCase(values[j])) {
found = true;
break;
}
}
if (!found) {
return false;
}
}
}
return true;
}
MimeBodyPart getMimePart() throws SOAPException {
try {
if (this.mimePart != null) {
return new MimeBodyPart(mimePart);
}
if (rawContent != null) {
copyMimeHeaders(headers, rawContent);
return rawContent;
}
MimeBodyPart envelope = new MimeBodyPart();
envelope.setDataHandler(dataHandler);
copyMimeHeaders(headers, envelope);
return envelope;
} catch (Exception ex) {
log.severe("SAAJ0504.soap.cannot.externalize.attachment");
throw new SOAPExceptionImpl("Unable to externalize attachment", ex);
}
}
public static void copyMimeHeaders(MimeHeaders headers, MimeBodyPart mbp)
throws SOAPException {
Iterator i = headers.getAllHeaders();
while (i.hasNext())
try {
MimeHeader mh = (MimeHeader) i.next();
mbp.setHeader(mh.getName(), mh.getValue());
} catch (Exception ex) {
log.severe("SAAJ0505.soap.cannot.copy.mime.hdr");
throw new SOAPExceptionImpl("Unable to copy MIME header", ex);
}
}
public static void copyMimeHeaders(MimeBodyPart mbp, AttachmentPartImpl ap)
throws SOAPException {
try {
List hdr = mbp.getAllHeaders();
int sz = hdr.size();
for( int i=0; i<sz; i++ ) {
Header h = (Header)hdr.get(i);
if(h.getName().equalsIgnoreCase("Content-Type"))
continue; // skip
ap.addMimeHeader(h.getName(), h.getValue());
}
} catch (Exception ex) {
log.severe("SAAJ0506.soap.cannot.copy.mime.hdrs.into.attachment");
throw new SOAPExceptionImpl(
"Unable to copy MIME headers into attachment",
ex);
}
}
public void setBase64Content(InputStream content, String contentType)
throws SOAPException {
if (mimePart != null) {
mimePart.close();
mimePart = null;
}
dataHandler = null;
InputStream decoded = null;
try {
decoded = MimeUtility.decode(content, "base64");
InternetHeaders hdrs = new InternetHeaders();
hdrs.setHeader("Content-Type", contentType);
//TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
// Ctor with inputStream causes problems based on the InputStream
// has markSupported()==true
ByteOutputStream bos = new ByteOutputStream();
bos.write(decoded);
rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
setMimeHeader("Content-Type", contentType);
} catch (Exception e) {
log.log(Level.SEVERE, "SAAJ0578.soap.attachment.setbase64content.exception", e);
throw new SOAPExceptionImpl(e.getLocalizedMessage());
} finally {
try {
decoded.close();
} catch (IOException ex) {
throw new SOAPException(ex);
}
}
}
public InputStream getBase64Content() throws SOAPException {
InputStream stream;
if (mimePart != null) {
stream = mimePart.read();
} else if (rawContent != null) {
try {
stream = rawContent.getInputStream();
} catch (Exception e) {
log.log(Level.SEVERE,"SAAJ0579.soap.attachment.getbase64content.exception", e);
throw new SOAPExceptionImpl(e.getLocalizedMessage());
}
} else if (dataHandler != null) {
try {
stream = dataHandler.getInputStream();
} catch (IOException e) {
log.severe("SAAJ0574.soap.attachment.datahandler.ioexception");
throw new SOAPExceptionImpl("DataHandler error" + e);
}
} else {
log.severe("SAAJ0572.soap.no.content.for.attachment");
throw new SOAPExceptionImpl("No data handler/content associated with this attachment");
}
//TODO: Write a BASE64EncoderInputStream instead,
// this code below is inefficient
// where we are trying to read the whole attachment first
int len;
int size = 1024;
byte [] buf;
if (stream != null) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream(size);
//TODO: try and optimize this on the same lines as
// ByteOutputStream : to eliminate the temp buffer here
OutputStream ret = MimeUtility.encode(bos, "base64");
buf = new byte[size];
while ((len = stream.read(buf, 0, size)) != -1) {
ret.write(buf, 0, len);
}
ret.flush();
buf = bos.toByteArray();
return new ByteArrayInputStream(buf);
} catch (Exception e) {
// throw new SOAPException
log.log(Level.SEVERE,"SAAJ0579.soap.attachment.getbase64content.exception", e);
throw new SOAPExceptionImpl(e.getLocalizedMessage());
} finally {
try {
stream.close();
} catch (IOException ex) {
//close the stream
}
}
} else {
//throw new SOAPException
log.log(Level.SEVERE,"SAAJ0572.soap.no.content.for.attachment");
throw new SOAPExceptionImpl("No data handler/content associated with this attachment");
}
}
public void setRawContent(InputStream content, String contentType)
throws SOAPException {
if (mimePart != null) {
mimePart.close();
mimePart = null;
}
dataHandler = null;
try {
InternetHeaders hdrs = new InternetHeaders();
hdrs.setHeader("Content-Type", contentType);
//TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
// Ctor with inputStream causes problems based on whether the InputStream has
// markSupported()==true or false
ByteOutputStream bos = new ByteOutputStream();
bos.write(content);
rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
setMimeHeader("Content-Type", contentType);
} catch (Exception e) {
log.log(Level.SEVERE, "SAAJ0576.soap.attachment.setrawcontent.exception", e);
throw new SOAPExceptionImpl(e.getLocalizedMessage());
} finally {
try {
content.close();
} catch (IOException ex) {
throw new SOAPException(ex);
}
}
}
/*
public void setRawContentBytes(byte[] content, String contentType)
throws SOAPException {
if (content == null) {
throw new SOAPExceptionImpl("Null content passed to setRawContentBytes");
}
dataHandler = null;
try {
InternetHeaders hdrs = new InternetHeaders();
hdrs.setHeader("Content-Type", contentType);
rawContent = new MimeBodyPart(hdrs, content, content.length);
setMimeHeader("Content-Type", contentType);
} catch (Exception e) {
log.log(Level.SEVERE, "SAAJ0576.soap.attachment.setrawcontent.exception", e);
throw new SOAPExceptionImpl(e.getLocalizedMessage());
}
} */
public void setRawContentBytes(
byte[] content, int off, int len, String contentType)
throws SOAPException {
if (mimePart != null) {
mimePart.close();
mimePart = null;
}
if (content == null) {
throw new SOAPExceptionImpl("Null content passed to setRawContentBytes");
}
dataHandler = null;
try {
InternetHeaders hdrs = new InternetHeaders();
hdrs.setHeader("Content-Type", contentType);
rawContent = new MimeBodyPart(hdrs, content, off, len);
setMimeHeader("Content-Type", contentType);
} catch (Exception e) {
log.log(Level.SEVERE,
"SAAJ0576.soap.attachment.setrawcontent.exception", e);
throw new SOAPExceptionImpl(e.getLocalizedMessage());
}
}
public InputStream getRawContent() throws SOAPException {
if (mimePart != null) {
return mimePart.read();
}
if (rawContent != null) {
try {
return rawContent.getInputStream();
} catch (Exception e) {
log.log(Level.SEVERE,"SAAJ0577.soap.attachment.getrawcontent.exception", e);
throw new SOAPExceptionImpl(e.getLocalizedMessage());
}
} else if (dataHandler != null) {
try {
return dataHandler.getInputStream();
} catch (IOException e) {
log.severe("SAAJ0574.soap.attachment.datahandler.ioexception");
throw new SOAPExceptionImpl("DataHandler error" + e);
}
} else {
log.severe("SAAJ0572.soap.no.content.for.attachment");
throw new SOAPExceptionImpl("No data handler/content associated with this attachment");
}
}
public byte[] getRawContentBytes() throws SOAPException {
InputStream ret;
if (mimePart != null) {
try {
ret = mimePart.read();
return ASCIIUtility.getBytes(ret);
} catch (IOException ex) {
log.log(Level.SEVERE,"SAAJ0577.soap.attachment.getrawcontent.exception", ex);
throw new SOAPExceptionImpl(ex);
}
}
if (rawContent != null) {
try {
ret = rawContent.getInputStream();
return ASCIIUtility.getBytes(ret);
} catch (Exception e) {
log.log(Level.SEVERE,"SAAJ0577.soap.attachment.getrawcontent.exception", e);
throw new SOAPExceptionImpl(e);
}
} else if (dataHandler != null) {
try {
ret = dataHandler.getInputStream();
return ASCIIUtility.getBytes(ret);
} catch (IOException e) {
log.severe("SAAJ0574.soap.attachment.datahandler.ioexception");
throw new SOAPExceptionImpl("DataHandler error" + e);
}
} else {
log.severe("SAAJ0572.soap.no.content.for.attachment");
throw new SOAPExceptionImpl("No data handler/content associated with this attachment");
}
}
// attachments are equal if they are the same reference
public boolean equals(Object o) {
return (this == o);
}
// In JDK 8 we get a warning if we implement equals() but not hashCode().
// There is no intuitive value for this, the default one in Object is fine.
public int hashCode() {
return super.hashCode();
}
public MimeHeaders getMimeHeaders() {
return headers;
}
public static void initializeJavaActivationHandlers() {
// DataHandler.writeTo() may search for DCH. So adding some default ones.
try {
CommandMap map = CommandMap.getDefaultCommandMap();
if (map instanceof MailcapCommandMap) {
MailcapCommandMap mailMap = (MailcapCommandMap) map;
// registering our DCH since javamail's DCH doesn't handle
if (!cmdMapInitialized(mailMap)) {
mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler");
mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler");
mailMap.addMailcap("application/fastinfoset;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.FastInfosetDataContentHandler");
// this handler seems to be not used according VCS history ...
// mailMap.addMailcap("multipart/*;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.MultipartDataContentHandler");
mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.ImageDataContentHandler");
mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.StringDataContentHandler");
}
}
} catch (Throwable t) {
// ignore the exception.
}
}
private static boolean cmdMapInitialized(MailcapCommandMap mailMap) {
// checking fastinfoset handler, since this one is specific to SAAJ
CommandInfo[] commands = mailMap.getAllCommands("application/fastinfoset");
if (commands == null || commands.length == 0) {
return false;
}
String saajClassName = "com.sun.xml.internal.ws.binding.FastInfosetDataContentHandler";
for (CommandInfo command : commands) {
String commandClass = command.getCommandClass();
if (saajClassName.equals(commandClass)) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2014, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.MessageFormat;
import java.util.ResourceBundle;
import java.util.WeakHashMap;
/**
* Simple utility ensuring that the value is cached only in case it is non-internal implementation
*/
abstract class ContextClassloaderLocal<V> {
private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
public V get() throws Error {
ClassLoader tccl = getContextClassLoader();
V instance = CACHE.get(tccl);
if (instance == null) {
instance = createNewInstance();
CACHE.put(tccl, instance);
}
return instance;
}
public void set(V instance) {
CACHE.put(getContextClassLoader(), instance);
}
protected abstract V initialValue() throws Exception;
private V createNewInstance() {
try {
return initialValue();
} catch (Exception e) {
throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
}
}
private static String format(String property, Object... args) {
String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
return MessageFormat.format(text, args);
}
private static ClassLoader getContextClassLoader() {
return (ClassLoader)
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
ClassLoader cl = null;
try {
cl = Thread.currentThread().getContextClassLoader();
} catch (SecurityException ex) {
}
return cl;
}
});
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import java.io.IOException;
import java.io.OutputStream;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.transform.Source;
/**
* Different implementations for SOAP Envelope must all implement this
* interface.
*
* @author Anil Vijendran (akv@eng.sun.com)
*/
public interface Envelope extends SOAPEnvelope {
/**
* Get the content as a JAXP Source.
*/
Source getContent();
/**
* Output the content.
*/
void output(OutputStream out) throws IOException;
/**
* Output the content.
*/
void output(OutputStream out, boolean isFastInfoset) throws IOException;
}

View File

@@ -0,0 +1,126 @@
/*
* Copyright (c) 1997, 2014, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
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.ParserPool;
import com.sun.xml.internal.messaging.saaj.util.RejectDoctypeSaxFilter;
import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import javax.xml.parsers.SAXParser;
import javax.xml.soap.SOAPException;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
import java.util.logging.Logger;
/**
* EnvelopeFactory creates SOAP Envelope objects using different
* underlying implementations.
*/
public class EnvelopeFactory {
protected static final Logger
log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
private static ContextClassloaderLocal<ParserPool> parserPool =
new ContextClassloaderLocal<ParserPool>() {
@Override
protected ParserPool initialValue() throws Exception {
return new ParserPool(5);
}
};
public static Envelope createEnvelope(Source src, SOAPPartImpl soapPart)
throws SOAPException {
// Insert SAX filter to disallow Document Type Declarations since
// they are not legal in SOAP
SAXParser saxParser = null;
if (src instanceof StreamSource) {
if (src instanceof JAXMStreamSource) {
try {
if (!SOAPPartImpl.lazyContentLength) {
((JAXMStreamSource) src).reset();
}
} catch (java.io.IOException ioe) {
log.severe("SAAJ0515.source.reset.exception");
throw new SOAPExceptionImpl(ioe);
}
}
try {
saxParser = parserPool.get().get();
} catch (Exception e) {
log.severe("SAAJ0601.util.newSAXParser.exception");
throw new SOAPExceptionImpl(
"Couldn't get a SAX parser while constructing a envelope",
e);
}
InputSource is = SAXSource.sourceToInputSource(src);
if (is.getEncoding() == null && soapPart.getSourceCharsetEncoding() != null) {
is.setEncoding(soapPart.getSourceCharsetEncoding());
}
XMLReader rejectFilter;
try {
rejectFilter = new RejectDoctypeSaxFilter(saxParser);
} catch (Exception ex) {
log.severe("SAAJ0510.soap.cannot.create.envelope");
throw new SOAPExceptionImpl(
"Unable to create envelope from given source: ",
ex);
}
src = new SAXSource(rejectFilter, is);
}
try {
Transformer transformer =
EfficientStreamingTransformer.newTransformer();
DOMResult result = new DOMResult(soapPart);
transformer.transform(src, result);
Envelope env = (Envelope) soapPart.getEnvelope();
return env;
} catch (Exception ex) {
if (ex instanceof SOAPVersionMismatchException) {
throw (SOAPVersionMismatchException) ex;
}
log.severe("SAAJ0511.soap.cannot.create.envelope");
throw new SOAPExceptionImpl(
"Unable to create envelope from given source: ",
ex);
} finally {
if (saxParser != null) {
parserPool.get().returnParser(saxParser);
}
}
}
}

View File

@@ -0,0 +1,121 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import java.awt.datatransfer.DataFlavor;
import java.io.IOException;
import java.io.OutputStream;
import java.io.InputStream;
import javax.activation.*;
import javax.xml.transform.Source;
import com.sun.xml.internal.messaging.saaj.util.FastInfosetReflection;
/**
* JAF data handler for Fast Infoset content
*
* @author Santiago Pericas-Geertsen
*/
public class FastInfosetDataContentHandler implements DataContentHandler {
public static final String STR_SRC = "com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetSource";
public FastInfosetDataContentHandler() {
}
/**
* return the DataFlavors for this <code>DataContentHandler</code>
* @return The DataFlavors.
*/
public DataFlavor[] getTransferDataFlavors() { // throws Exception;
DataFlavor flavors[] = new DataFlavor[1];
flavors[0] = new ActivationDataFlavor(
FastInfosetReflection.getFastInfosetSource_class(),
"application/fastinfoset", "Fast Infoset");
return flavors;
}
/**
* return the Transfer Data of type DataFlavor from InputStream
* @param df The DataFlavor.
* @param ins The InputStream corresponding to the data.
* @return The constructed Object.
*/
public Object getTransferData(DataFlavor flavor, DataSource dataSource)
throws IOException
{
if (flavor.getMimeType().startsWith("application/fastinfoset")) {
try {
if (flavor.getRepresentationClass().getName().equals(STR_SRC)) {
return FastInfosetReflection.FastInfosetSource_new(
dataSource.getInputStream());
}
}
catch (Exception e) {
throw new IOException(e.getMessage());
}
}
return null;
}
public Object getContent(DataSource dataSource) throws IOException {
try {
return FastInfosetReflection.FastInfosetSource_new(
dataSource.getInputStream());
}
catch (Exception e) {
throw new IOException(e.getMessage());
}
}
/**
* construct an object from a byte stream
* (similar semantically to previous method, we are deciding
* which one to support)
*/
public void writeTo(Object obj, String mimeType, OutputStream os)
throws IOException
{
if (!mimeType.equals("application/fastinfoset")) {
throw new IOException("Invalid content type \"" + mimeType
+ "\" for FastInfosetDCH");
}
try {
InputStream is = FastInfosetReflection.FastInfosetSource_getInputStream(
(Source) obj);
int n; byte[] buffer = new byte[4096];
while ((n = is.read(buffer)) != -1) {
os.write(buffer, 0, n);
}
}
catch (Exception ex) {
throw new IOException(
"Error copying FI source to output stream " + ex.getMessage());
}
}
}

View File

@@ -0,0 +1,113 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import java.awt.datatransfer.DataFlavor;
import java.io.*;
import java.awt.*;
import javax.activation.*;
/**
* DataContentHandler for image/gif.
*
* @author Ana Lindstrom-Tamer
*/
public class GifDataContentHandler extends Component implements DataContentHandler {
private static ActivationDataFlavor myDF =
new ActivationDataFlavor(
java.awt.Image.class,
"image/gif",
"GIF Image");
protected ActivationDataFlavor getDF() {
return myDF;
}
/**
* Return the DataFlavors for this <code>DataContentHandler</code>.
*
* @return The DataFlavors
*/
public DataFlavor[] getTransferDataFlavors() { // throws Exception;
return new DataFlavor[] { getDF()};
}
/**
* Return the Transfer Data of type DataFlavor from InputStream.
*
* @param df The DataFlavor
* @param ins The InputStream corresponding to the data
* @return String object
*/
public Object getTransferData(DataFlavor df, DataSource ds)
throws IOException {
// use myDF.equals to be sure to get ActivationDataFlavor.equals,
// which properly ignores Content-Type parameters in comparison
if (getDF().equals(df))
return getContent(ds);
else
return null;
}
public Object getContent(DataSource ds) throws IOException {
InputStream is = ds.getInputStream();
int pos = 0;
int count;
byte buf[] = new byte[1024];
while ((count = is.read(buf, pos, buf.length - pos)) != -1) {
pos += count;
if (pos >= buf.length) {
int size = buf.length;
if (size < 256*1024)
size += size;
else
size += 256*1024;
byte tbuf[] = new byte[size];
System.arraycopy(buf, 0, tbuf, 0, pos);
buf = tbuf;
}
}
Toolkit tk = Toolkit.getDefaultToolkit();
return tk.createImage(buf, 0, pos);
}
/**
* Write the object to the output stream, using the specified MIME type.
*/
public void writeTo(Object obj, String type, OutputStream os)
throws IOException {
if (obj != null && !(obj instanceof Image))
throw new IOException("\"" + getDF().getMimeType() +
"\" DataContentHandler requires Image object, " +
"was given object of type " + obj.getClass().toString());
throw new IOException(getDF().getMimeType() + " encoding not supported");
}
}

View File

@@ -0,0 +1,171 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.Arrays;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.activation.*;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
public class ImageDataContentHandler extends Component
implements DataContentHandler {
protected static final Logger log =
Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
private DataFlavor[] flavor;
public ImageDataContentHandler() {
String[] mimeTypes = ImageIO.getReaderMIMETypes();
flavor = new DataFlavor[mimeTypes.length];
for(int i=0; i < mimeTypes.length; i++) {
flavor[i] = new ActivationDataFlavor(
java.awt.Image.class, mimeTypes[i], "Image");
}
}
/**
* Returns an array of DataFlavor objects indicating the flavors the
* data can be provided in. The array should be ordered according to
* preference for providing the data (from most richly descriptive to
* least descriptive).
*
* @return The DataFlavors.
*/
public DataFlavor[] getTransferDataFlavors() {
return (DataFlavor[]) Arrays.copyOf(flavor, flavor.length);
}
/**
* Returns an object which represents the data to be transferred.
* The class of the object returned is defined by the representation class
* of the flavor.
*
* @param df The DataFlavor representing the requested type.
* @param ds The DataSource representing the data to be converted.
* @return The constructed Object.
*/
public Object getTransferData(DataFlavor df, DataSource ds)
throws IOException {
for (int i=0; i < flavor.length; i++) {
if (flavor[i].equals(df)) {
return getContent(ds);
}
}
return null;
}
/**
* Return an object representing the data in its most preferred form.
* Generally this will be the form described by the first DataFlavor
* returned by the <code>getTransferDataFlavors</code> method.
*
* @param ds The DataSource representing the data to be converted.
* @return The constructed Object.
*/
public Object getContent(DataSource ds) throws IOException {
return ImageIO.read(new BufferedInputStream(ds.getInputStream()));
}
/**
* Convert the object to a byte stream of the specified MIME type
* and write it to the output stream.
*
* @param obj The object to be converted.
* @param mimeType The requested MIME type of the resulting byte stream.
* @param os The output stream into which to write the converted
* byte stream.
*/
public void writeTo(Object obj, String type, OutputStream os)
throws IOException {
try {
BufferedImage bufImage = null;
if (obj instanceof BufferedImage) {
bufImage = (BufferedImage)obj;
} else if (obj instanceof Image) {
bufImage = render((Image)obj);
} else {
log.log(Level.SEVERE,
"SAAJ0520.soap.invalid.obj.type",
new String[] { obj.getClass().toString() });
throw new IOException(
"ImageDataContentHandler requires Image object, "
+ "was given object of type "
+ obj.getClass().toString());
}
ImageWriter writer = null;
Iterator i = ImageIO.getImageWritersByMIMEType(type);
if (i.hasNext()) {
writer = (ImageWriter)i.next();
}
if (writer != null) {
ImageOutputStream stream = null;
stream = ImageIO.createImageOutputStream(os);
writer.setOutput(stream);
writer.write(bufImage);
writer.dispose();
stream.close();
} else {
log.log(Level.SEVERE, "SAAJ0526.soap.unsupported.mime.type",
new String[] { type });
throw new IOException("Unsupported mime type:"+ type);
}
} catch (Exception e) {
log.severe("SAAJ0525.soap.cannot.encode.img");
throw new IOException("Unable to encode the image to a stream "
+ e.getMessage());
}
}
private BufferedImage render(Image img) throws InterruptedException {
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(img, 0);
tracker.waitForAll();
BufferedImage bufImage = new BufferedImage(img.getWidth(null),
img.getHeight(null), BufferedImage.TYPE_INT_RGB);
Graphics g = bufImage.createGraphics();
g.drawImage(img, 0, 0, null);
g.dispose();
return bufImage;
}
}

View File

@@ -0,0 +1,162 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.activation.*;
//import com.sun.image.codec.jpeg.*;
import javax.imageio.ImageIO;
/**
* JAF data handler for Jpeg content
*
* @author Ana Lindstrom-Tamer
*/
public class JpegDataContentHandler
extends Component
implements DataContentHandler {
public static final String STR_SRC = "java.awt.Image";
/**
* return the DataFlavors for this <code>DataContentHandler</code>
* @return The DataFlavors.
*/
public DataFlavor[] getTransferDataFlavors() { // throws Exception;
DataFlavor flavors[] = new DataFlavor[1];
try {
flavors[0] =
new ActivationDataFlavor(
Class.forName(STR_SRC),
"image/jpeg",
"JPEG");
} catch (Exception e) {
System.out.println(e);
}
return flavors;
}
/**
* return the Transfer Data of type DataFlavor from InputStream
* @param df The DataFlavor.
* @param ins The InputStream corresponding to the data.
* @return The constructed Object.
*/
public Object getTransferData(DataFlavor df, DataSource ds) {
// this is sort of hacky, but will work for the
// sake of testing...
if (df.getMimeType().startsWith("image/jpeg")) {
if (df.getRepresentationClass().getName().equals(STR_SRC)) {
InputStream inputStream = null;
BufferedImage jpegLoadImage = null;
try {
inputStream = ds.getInputStream();
jpegLoadImage = ImageIO.read(inputStream);
} catch (Exception e) {
System.out.println(e);
}
return jpegLoadImage;
}
}
return null;
}
/**
*
*/
public Object getContent(DataSource ds) { // throws Exception;
InputStream inputStream = null;
BufferedImage jpegLoadImage = null;
try {
inputStream = ds.getInputStream();
jpegLoadImage = ImageIO.read(inputStream);
} catch (Exception e) {
}
return (Image) jpegLoadImage;
}
/**
* construct an object from a byte stream
* (similar semantically to previous method, we are deciding
* which one to support)
*/
public void writeTo(Object obj, String mimeType, OutputStream os)
throws IOException {
if (!mimeType.equals("image/jpeg"))
throw new IOException(
"Invalid content type \""
+ mimeType
+ "\" for ImageContentHandler");
if (obj == null) {
throw new IOException("Null object for ImageContentHandler");
}
try {
BufferedImage bufImage = null;
if (obj instanceof BufferedImage) {
bufImage = (BufferedImage) obj;
} else {
Image img = (Image) obj;
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(img, 0);
tracker.waitForAll();
if (tracker.isErrorAny()) {
throw new IOException("Error while loading image");
}
bufImage =
new BufferedImage(
img.getWidth(null),
img.getHeight(null),
BufferedImage.TYPE_INT_RGB);
Graphics g = bufImage.createGraphics();
g.drawImage(img, 0, 0, null);
}
ImageIO.write(bufImage, "jpeg", os);
} catch (Exception ex) {
throw new IOException(
"Unable to run the JPEG Encoder on a stream "
+ ex.getMessage());
}
}
}

View File

@@ -0,0 +1,114 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import java.io.*;
import java.util.logging.Logger;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.ContentType;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.ParseException;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl;
import com.sun.xml.internal.messaging.saaj.soap.ver1_2.Message1_2Impl;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
import com.sun.xml.internal.messaging.saaj.util.TeeInputStream;
/**
* A factory for creating SOAP messages.
*
* Converted to a placeholder for common functionality between SOAP
* implementations.
*
* @author Phil Goodwin (phil.goodwin@sun.com)
*/
public class MessageFactoryImpl extends MessageFactory {
protected static final Logger log =
Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
protected OutputStream listener;
protected boolean lazyAttachments = false;
public OutputStream listen(OutputStream newListener) {
OutputStream oldListener = listener;
listener = newListener;
return oldListener;
}
public SOAPMessage createMessage() throws SOAPException {
throw new UnsupportedOperationException();
}
public SOAPMessage createMessage(boolean isFastInfoset,
boolean acceptFastInfoset) throws SOAPException
{
throw new UnsupportedOperationException();
}
public SOAPMessage createMessage(MimeHeaders headers, InputStream in)
throws SOAPException, IOException {
String contentTypeString = MessageImpl.getContentType(headers);
if (listener != null) {
in = new TeeInputStream(in, listener);
}
try {
ContentType contentType = new ContentType(contentTypeString);
int stat = MessageImpl.identifyContentType(contentType);
if (MessageImpl.isSoap1_1Content(stat)) {
return new Message1_1Impl(headers,contentType,stat,in);
} else if (MessageImpl.isSoap1_2Content(stat)) {
return new Message1_2Impl(headers,contentType,stat,in);
} else {
log.severe("SAAJ0530.soap.unknown.Content-Type");
throw new SOAPExceptionImpl("Unrecognized Content-Type");
}
} catch (ParseException e) {
log.severe("SAAJ0531.soap.cannot.parse.Content-Type");
throw new SOAPExceptionImpl(
"Unable to parse content type: " + e.getMessage());
}
}
protected static final String getContentType(MimeHeaders headers) {
String[] values = headers.getHeader("Content-Type");
if (values == null)
return null;
else
return values[0];
}
public void setLazyAttachmentOptimization(boolean flag) {
lazyAttachments = flag;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,100 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import java.io.*;
import java.awt.datatransfer.DataFlavor;
import javax.activation.*;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeMultipart;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.ContentType;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
public class MultipartDataContentHandler implements DataContentHandler {
private ActivationDataFlavor myDF = new ActivationDataFlavor(
com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeMultipart.class,
"multipart/mixed",
"Multipart");
/**
* Return the DataFlavors for this <code>DataContentHandler</code>.
*
* @return The DataFlavors
*/
public DataFlavor[] getTransferDataFlavors() { // throws Exception;
return new DataFlavor[] { myDF };
}
/**
* Return the Transfer Data of type DataFlavor from InputStream.
*
* @param df The DataFlavor
* @param ins The InputStream corresponding to the data
* @return String object
*/
public Object getTransferData(DataFlavor df, DataSource ds) {
// use myDF.equals to be sure to get ActivationDataFlavor.equals,
// which properly ignores Content-Type parameters in comparison
if (myDF.equals(df))
return getContent(ds);
else
return null;
}
/**
* Return the content.
*/
public Object getContent(DataSource ds) {
try {
return new MimeMultipart(
ds, new ContentType(ds.getContentType()));
} catch (Exception e) {
return null;
}
}
/**
* Write the object to the output stream, using the specific MIME type.
*/
public void writeTo(Object obj, String mimeType, OutputStream os)
throws IOException {
if (obj instanceof MimeMultipart) {
try {
//TODO: temporarily allow only ByteOutputStream
// Need to add writeTo(OutputStream) on MimeMultipart
ByteOutputStream baos = null;
if (os instanceof ByteOutputStream) {
baos = (ByteOutputStream)os;
} else {
throw new IOException("Input Stream expected to be a com.sun.xml.internal.messaging.saaj.util.ByteOutputStream, but found " +
os.getClass().getName());
}
((MimeMultipart)obj).writeTo(baos);
} catch (Exception e) {
throw new IOException(e.toString());
}
}
}
}

View File

@@ -0,0 +1,81 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import javax.xml.soap.SAAJMetaFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPException;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
public class SAAJMetaFactoryImpl extends SAAJMetaFactory {
protected static final Logger log =
Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
protected MessageFactory newMessageFactory(String protocol)
throws SOAPException {
if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl();
} else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl();
} else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl();
} else {
log.log(
Level.SEVERE,
"SAAJ0569.soap.unknown.protocol",
new Object[] {protocol, "MessageFactory"});
throw new SOAPException("Unknown Protocol: " + protocol +
" specified for creating MessageFactory");
}
}
protected SOAPFactory newSOAPFactory(String protocol)
throws SOAPException {
if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl();
} else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPFactory1_2Impl();
} else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPFactoryDynamicImpl();
} else {
log.log(
Level.SEVERE,
"SAAJ0569.soap.unknown.protocol",
new Object[] {protocol, "SOAPFactory"});
throw new SOAPException("Unknown Protocol: " + protocol +
" specified for creating SOAPFactory");
}
}
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap;
public interface SOAPDocument {
SOAPPartImpl getSOAPPart();
SOAPDocumentImpl getDocument();
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap;
import com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl;
import com.sun.org.apache.xerces.internal.dom.DocumentFragmentImpl;
public class SOAPDocumentFragment extends DocumentFragmentImpl {
public SOAPDocumentFragment(CoreDocumentImpl ownerDoc) {
super(ownerDoc);
}
public SOAPDocumentFragment() {
super();
}
}

View File

@@ -0,0 +1,193 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap;
import java.util.logging.Logger;
import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
import org.w3c.dom.*;
import com.sun.xml.internal.messaging.saaj.soap.impl.*;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
public class SOAPDocumentImpl extends DocumentImpl implements SOAPDocument {
private static final String XMLNS = "xmlns".intern();
protected static final Logger log =
Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
SOAPPartImpl enclosingSOAPPart;
public SOAPDocumentImpl(SOAPPartImpl enclosingDocument) {
this.enclosingSOAPPart = enclosingDocument;
}
// public SOAPDocumentImpl(boolean grammarAccess) {
// super(grammarAccess);
// }
//
// public SOAPDocumentImpl(DocumentType doctype) {
// super(doctype);
// }
//
// public SOAPDocumentImpl(DocumentType doctype, boolean grammarAccess) {
// super(doctype, grammarAccess);
// }
public SOAPPartImpl getSOAPPart() {
if (enclosingSOAPPart == null) {
log.severe("SAAJ0541.soap.fragment.not.bound.to.part");
throw new RuntimeException("Could not complete operation. Fragment not bound to SOAP part.");
}
return enclosingSOAPPart;
}
public SOAPDocumentImpl getDocument() {
return this;
}
public DocumentType getDoctype() {
// SOAP means no DTD, No DTD means no doctype (SOAP 1.2 only?)
return null;
}
public DOMImplementation getImplementation() {
return super.getImplementation();
}
public Element getDocumentElement() {
// This had better be an Envelope!
getSOAPPart().doGetDocumentElement();
return doGetDocumentElement();
}
protected Element doGetDocumentElement() {
return super.getDocumentElement();
}
public Element createElement(String tagName) throws DOMException {
return ElementFactory.createElement(
this,
NameImpl.getLocalNameFromTagName(tagName),
NameImpl.getPrefixFromTagName(tagName),
null);
}
public DocumentFragment createDocumentFragment() {
return new SOAPDocumentFragment(this);
}
public org.w3c.dom.Text createTextNode(String data) {
return new TextImpl(this, data);
}
public Comment createComment(String data) {
return new CommentImpl(this, data);
}
public CDATASection createCDATASection(String data) throws DOMException {
return new CDATAImpl(this, data);
}
public ProcessingInstruction createProcessingInstruction(
String target,
String data)
throws DOMException {
log.severe("SAAJ0542.soap.proc.instructions.not.allowed.in.docs");
throw new UnsupportedOperationException("Processing Instructions are not allowed in SOAP documents");
}
public Attr createAttribute(String name) throws DOMException {
boolean isQualifiedName = (name.indexOf(":") > 0);
if (isQualifiedName) {
String nsUri = null;
String prefix = name.substring(0, name.indexOf(":"));
//cannot do anything to resolve the URI if prefix is not
//XMLNS.
if (XMLNS.equals(prefix)) {
nsUri = ElementImpl.XMLNS_URI;
return createAttributeNS(nsUri, name);
}
}
return super.createAttribute(name);
}
public EntityReference createEntityReference(String name)
throws DOMException {
log.severe("SAAJ0543.soap.entity.refs.not.allowed.in.docs");
throw new UnsupportedOperationException("Entity References are not allowed in SOAP documents");
}
public NodeList getElementsByTagName(String tagname) {
return super.getElementsByTagName(tagname);
}
public org.w3c.dom.Node importNode(Node importedNode, boolean deep)
throws DOMException {
return super.importNode(importedNode, deep);
}
public Element createElementNS(String namespaceURI, String qualifiedName)
throws DOMException {
return ElementFactory.createElement(
this,
NameImpl.getLocalNameFromTagName(qualifiedName),
NameImpl.getPrefixFromTagName(qualifiedName),
namespaceURI);
}
public Attr createAttributeNS(String namespaceURI, String qualifiedName)
throws DOMException {
return super.createAttributeNS(namespaceURI, qualifiedName);
}
public NodeList getElementsByTagNameNS(
String namespaceURI,
String localName) {
return super.getElementsByTagNameNS(namespaceURI, localName);
}
public Element getElementById(String elementId) {
return super.getElementById(elementId);
}
public Node cloneNode(boolean deep) {
SOAPPartImpl newSoapPart = getSOAPPart().doCloneNode();
super.cloneNode(newSoapPart.getDocument(), deep);
return newSoapPart;
}
public void cloneNode(SOAPDocumentImpl newdoc, boolean deep) {
super.cloneNode(newdoc, deep);
}
}

View File

@@ -0,0 +1,179 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import java.util.logging.Logger;
import java.util.logging.Level;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.soap.impl.ElementFactory;
import com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
import com.sun.xml.internal.messaging.saaj.util.*;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Attr;
public abstract class SOAPFactoryImpl extends SOAPFactory {
protected static final Logger
log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
protected abstract SOAPDocumentImpl createDocument();
public SOAPElement createElement(String tagName) throws SOAPException {
if (tagName == null) {
log.log(
Level.SEVERE,"SAAJ0567.soap.null.input",
new Object[] {"tagName","SOAPFactory.createElement"});
throw new SOAPException("Null tagName argument passed to createElement");
}
return ElementFactory.createElement(createDocument(),
NameImpl.createFromTagName(tagName));
}
public SOAPElement createElement(Name name) throws SOAPException {
// @since SAAJ 1.3
// If the Name was null it would cause a NullPointerException in earlier release
if (name == null) {
log.log(Level.SEVERE,"SAAJ0567.soap.null.input",
new Object[] {"name","SOAPFactory.createElement"});
throw new SOAPException("Null name argument passed to createElement");
}
return ElementFactory.createElement(createDocument(), name);
}
public SOAPElement createElement(QName qname) throws SOAPException {
if (qname == null) {
log.log(Level.SEVERE,"SAAJ0567.soap.null.input",
new Object[] {"qname","SOAPFactory.createElement"});
throw new SOAPException("Null qname argument passed to createElement");
}
return ElementFactory.createElement(createDocument(),qname);
}
public SOAPElement createElement(
String localName,
String prefix,
String uri) throws SOAPException {
// @since SAAJ 1.3
// if prefix !=null but localName== null then in earlier releases it would create
// a Qualified Name <prefix>:null which is not meaningful
if (localName == null) {
log.log(Level.SEVERE,"SAAJ0567.soap.null.input",
new Object[] {"localName","SOAPFactory.createElement"});
throw new SOAPException("Null localName argument passed to createElement");
}
return ElementFactory.createElement(createDocument(), localName, prefix, uri);
}
public Name createName(String localName, String prefix, String uri)
throws SOAPException {
// @since SAAJ 1.3
// if localName==null, earlier impl would create Name with localName=""
// 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.create(localName, prefix, uri);
}
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);
}
// Note: the child elements might still be org.w3c.dom.Element's, but the
// getChildElements will do the conversion to SOAPElement when called.
public SOAPElement createElement(Element domElement) throws SOAPException {
if (domElement == null) {
return null;
}
return convertToSoapElement(domElement);
}
private SOAPElement convertToSoapElement(Element element) throws SOAPException {
if (element instanceof SOAPElement) {
return (SOAPElement) element;
}
SOAPElement copy = createElement(
element.getLocalName(),
element.getPrefix(),
element.getNamespaceURI());
Document ownerDoc = copy.getOwnerDocument();
NamedNodeMap attrMap = element.getAttributes();
for (int i=0; i < attrMap.getLength(); i++) {
Attr nextAttr = (Attr)attrMap.item(i);
Attr importedAttr = (Attr)ownerDoc.importNode(nextAttr, true);
copy.setAttributeNodeNS(importedAttr);
}
NodeList nl = element.getChildNodes();
for (int i=0; i < nl.getLength(); i++) {
org.w3c.dom.Node next = nl.item(i);
org.w3c.dom.Node imported = ownerDoc.importNode(next, true);
copy.appendChild(imported);
}
return copy;
}
public Detail createDetail() throws SOAPException {
throw new UnsupportedOperationException();
}
public SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException {
throw new UnsupportedOperationException();
}
public SOAPFault createFault() throws SOAPException {
throw new UnsupportedOperationException();
}
}

View File

@@ -0,0 +1,98 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Created on Nov 19, 2002
*
* To change this generated comment edit the template variable "filecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of file comments go to
* Window>Preferences>Java>Code Generation.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import java.io.*;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
public class SOAPIOException extends IOException {
SOAPExceptionImpl soapException;
public SOAPIOException() {
super();
soapException = new SOAPExceptionImpl();
soapException.fillInStackTrace();
}
public SOAPIOException(String s) {
super();
soapException = new SOAPExceptionImpl(s);
soapException.fillInStackTrace();
}
public SOAPIOException(String reason, Throwable cause) {
super();
soapException = new SOAPExceptionImpl(reason, cause);
soapException.fillInStackTrace();
}
public SOAPIOException(Throwable cause) {
super(cause.toString());
soapException = new SOAPExceptionImpl(cause);
soapException.fillInStackTrace();
}
public Throwable fillInStackTrace() {
if (soapException != null) {
soapException.fillInStackTrace();
}
return this;
}
public String getLocalizedMessage() {
return soapException.getLocalizedMessage();
}
public String getMessage() {
return soapException.getMessage();
}
public void printStackTrace() {
soapException.printStackTrace();
}
public void printStackTrace(PrintStream s) {
soapException.printStackTrace(s);
}
public void printStackTrace(PrintWriter s) {
soapException.printStackTrace(s);
}
public String toString() {
return soapException.toString();
}
}

View File

@@ -0,0 +1,814 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* 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.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 javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
/**
* SOAPPartImpl is the first attachment. This contains the XML/SOAP document.
*
* @author Anil Vijendran (anil@sun.com)
*/
public abstract class SOAPPartImpl extends SOAPPart implements SOAPDocument {
protected static final Logger log =
Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
protected MimeHeaders headers;
protected Envelope envelope;
protected Source source;
protected SOAPDocumentImpl document;
//flag to indicate if a setContent happened.
private boolean sourceWasSet = false;
// Records whether the input source had an xml decl or not.
protected boolean omitXmlDecl = true;
// Records the charset encoding of the input stream source if provided.
protected String sourceCharsetEncoding = null;
/**
* Reference to containing message (may be null)
*/
protected MessageImpl message;
static final boolean lazyContentLength;
static {
lazyContentLength = SAAJUtil.getSystemBoolean("saaj.lazy.contentlength");
}
protected SOAPPartImpl() {
this(null);
}
protected SOAPPartImpl(MessageImpl message) {
document = new SOAPDocumentImpl(this);
headers = new MimeHeaders();
this.message = message;
headers.setHeader("Content-Type", getContentType());
}
protected abstract String getContentType();
protected abstract Envelope createEnvelopeFromSource()
throws SOAPException;
protected abstract Envelope createEmptyEnvelope(String prefix)
throws SOAPException;
protected abstract SOAPPartImpl duplicateType();
protected String getContentTypeString() {
return getContentType();
}
public boolean isFastInfoset() {
return (message != null) ? message.isFastInfoset() : false;
}
public SOAPEnvelope getEnvelope() throws SOAPException {
// If there is no SOAP envelope already created, then create
// one from a source if one exists. If there is a newer source
// then use that source.
if (sourceWasSet)
sourceWasSet = false;
lookForEnvelope();
if (envelope != null) {
if (source != null) { // there's a newer source, use it
document.removeChild(envelope);
envelope = createEnvelopeFromSource();
}
} else if (source != null) {
envelope = createEnvelopeFromSource();
} else {
envelope = createEmptyEnvelope(null);
document.insertBefore(envelope, 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)) {
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;
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");
throw new SOAPVersionMismatchException("Unable to create envelope from given source because the namespace was not recognized");
}
} else {
log.severe("SAAJ0514.soap.root.elem.not.named.envelope");
throw new SOAPExceptionImpl(
"Unable to create envelope from given source because the root element is not named \"Envelope\"");
}
}
}
public void removeAllMimeHeaders() {
headers.removeAllHeaders();
}
public void removeMimeHeader(String header) {
headers.removeHeader(header);
}
public String[] getMimeHeader(String name) {
return headers.getHeader(name);
}
public void setMimeHeader(String name, String value) {
headers.setHeader(name, value);
}
public void addMimeHeader(String name, String value) {
headers.addHeader(name, value);
}
public Iterator getAllMimeHeaders() {
return headers.getAllHeaders();
}
public Iterator getMatchingMimeHeaders(String[] names) {
return headers.getMatchingHeaders(names);
}
public Iterator getNonMatchingMimeHeaders(String[] names) {
return headers.getNonMatchingHeaders(names);
}
public Source getContent() throws SOAPException {
if (source != null) {
InputStream bis = null;
if (source instanceof JAXMStreamSource) {
StreamSource streamSource = (StreamSource)source;
bis = streamSource.getInputStream();
} else if (FastInfosetReflection.isFastInfosetSource(source)) {
// FastInfosetSource inherits from SAXSource
SAXSource saxSource = (SAXSource)source;
bis = saxSource.getInputSource().getByteStream();
}
if (bis != null) {
try {
bis.reset();
} catch (IOException e) {
/* This exception will never be thrown.
*
* The setContent method will modify the source
* if StreamSource to JAXMStreamSource, that uses
* a ByteInputStream, and for a FastInfosetSource will
* replace the InputStream with a ByteInputStream.
*/
}
}
return source;
}
return ((Envelope) getEnvelope()).getContent();
}
public void setContent(Source source) throws SOAPException {
try {
if (source instanceof StreamSource) {
InputStream is = ((StreamSource) source).getInputStream();
Reader rdr = ((StreamSource) source).getReader();
if (is != null) {
this.source = new JAXMStreamSource(is);
} else if (rdr != null) {
this.source = new JAXMStreamSource(rdr);
} else {
log.severe("SAAJ0544.soap.no.valid.reader.for.src");
throw new SOAPExceptionImpl("Source does not have a valid Reader or InputStream");
}
}
else if (FastInfosetReflection.isFastInfosetSource(source)) {
// InputStream is = source.getInputStream()
InputStream is = FastInfosetReflection.FastInfosetSource_getInputStream(source);
/*
* Underlying stream must be ByteInputStream for getContentAsStream(). We pay the
* cost of copying the underlying bytes here to avoid multiple copies every time
* getBytes() is called on a ByteInputStream.
*/
if (!(is instanceof ByteInputStream)) {
ByteOutputStream bout = new ByteOutputStream();
bout.write(is);
// source.setInputStream(new ByteInputStream(...))
FastInfosetReflection.FastInfosetSource_setInputStream(
source, bout.newInputStream());
}
this.source = source;
}
else {
this.source = source;
}
sourceWasSet = true;
}
catch (Exception ex) {
ex.printStackTrace();
log.severe("SAAJ0545.soap.cannot.set.src.for.part");
throw new SOAPExceptionImpl(
"Error setting the source for SOAPPart: " + ex.getMessage());
}
}
public InputStream getContentAsStream() throws IOException {
if (source != null) {
InputStream is = null;
// Allow message to be transcode if so requested
if (source instanceof StreamSource && !isFastInfoset()) {
is = ((StreamSource) source).getInputStream();
}
else if (FastInfosetReflection.isFastInfosetSource(source) &&
isFastInfoset())
{
try {
// InputStream is = source.getInputStream()
is = FastInfosetReflection.FastInfosetSource_getInputStream(source);
}
catch (Exception e) {
throw new IOException(e.toString());
}
}
if (is != null) {
if (lazyContentLength) {
return is;
}
if (!(is instanceof ByteInputStream)) {
log.severe("SAAJ0546.soap.stream.incorrect.type");
throw new IOException("Internal error: stream not of the right type");
}
return (ByteInputStream) is;
}
// need to do something here for reader...
// for now we'll see if we can fallback...
}
ByteOutputStream b = new ByteOutputStream();
Envelope env = null;
try {
env = (Envelope) getEnvelope();
env.output(b, isFastInfoset());
}
catch (SOAPException soapException) {
log.severe("SAAJ0547.soap.cannot.externalize");
throw new SOAPIOException(
"SOAP exception while trying to externalize: ",
soapException);
}
return b.newInputStream();
}
MimeBodyPart getMimePart() throws SOAPException {
try {
MimeBodyPart headerEnvelope = new MimeBodyPart();
headerEnvelope.setDataHandler(getDataHandler());
AttachmentPartImpl.copyMimeHeaders(headers, headerEnvelope);
return headerEnvelope;
} catch (SOAPException ex) {
throw ex;
} catch (Exception ex) {
log.severe("SAAJ0548.soap.cannot.externalize.hdr");
throw new SOAPExceptionImpl("Unable to externalize header", ex);
}
}
MimeHeaders getMimeHeaders() {
return headers;
}
DataHandler getDataHandler() {
DataSource ds = new DataSource() {
public OutputStream getOutputStream() throws IOException {
throw new IOException("Illegal Operation");
}
public String getContentType() {
return getContentTypeString();
}
public String getName() {
return getContentId();
}
public InputStream getInputStream() throws IOException {
return getContentAsStream();
}
};
return new DataHandler(ds);
}
public SOAPDocumentImpl getDocument() {
handleNewSource();
return document;
}
public SOAPPartImpl getSOAPPart() {
return this;
}
public DocumentType getDoctype() {
return document.getDoctype();
}
// Forward all of these calls to the document to ensure that they work the
// same way whether they are called from here or directly from the document.
// If the document needs any help from this SOAPPart then
// Make it use a call-back as in doGetDocumentElement() below
public DOMImplementation getImplementation() {
return document.getImplementation();
}
public Element getDocumentElement() {
// If there is no SOAP envelope already created, then create
// one from a source if one exists. If there is a newer source
// then use that source.
try {
getEnvelope();
} catch (SOAPException e) {
}
return document.getDocumentElement();
}
protected void doGetDocumentElement() {
handleNewSource();
try {
lookForEnvelope();
} catch (SOAPException e) {
}
}
public Element createElement(String tagName) throws DOMException {
return document.createElement(tagName);
}
public DocumentFragment createDocumentFragment() {
return document.createDocumentFragment();
}
public org.w3c.dom.Text createTextNode(String data) {
return document.createTextNode(data);
}
public Comment createComment(String data) {
return document.createComment(data);
}
public CDATASection createCDATASection(String data) throws DOMException {
return document.createCDATASection(data);
}
public ProcessingInstruction createProcessingInstruction(
String target,
String data)
throws DOMException {
return document.createProcessingInstruction(target, data);
}
public Attr createAttribute(String name) throws DOMException {
return document.createAttribute(name);
}
public EntityReference createEntityReference(String name)
throws DOMException {
return document.createEntityReference(name);
}
public NodeList getElementsByTagName(String tagname) {
handleNewSource();
return document.getElementsByTagName(tagname);
}
public org.w3c.dom.Node importNode(
org.w3c.dom.Node importedNode,
boolean deep)
throws DOMException {
handleNewSource();
return document.importNode(importedNode, deep);
}
public Element createElementNS(String namespaceURI, String qualifiedName)
throws DOMException {
return document.createElementNS(namespaceURI, qualifiedName);
}
public Attr createAttributeNS(String namespaceURI, String qualifiedName)
throws DOMException {
return document.createAttributeNS(namespaceURI, qualifiedName);
}
public NodeList getElementsByTagNameNS(
String namespaceURI,
String localName) {
handleNewSource();
return document.getElementsByTagNameNS(namespaceURI, localName);
}
public Element getElementById(String elementId) {
handleNewSource();
return document.getElementById(elementId);
}
public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
throws DOMException {
handleNewSource();
return document.appendChild(newChild);
}
public org.w3c.dom.Node cloneNode(boolean deep) {
handleNewSource();
return document.cloneNode(deep);
}
protected SOAPPartImpl doCloneNode() {
handleNewSource();
SOAPPartImpl newSoapPart = duplicateType();
newSoapPart.headers = MimeHeadersUtil.copy(this.headers);
newSoapPart.source = this.source;
return newSoapPart;
}
public NamedNodeMap getAttributes() {
return document.getAttributes();
}
public NodeList getChildNodes() {
handleNewSource();
return document.getChildNodes();
}
public org.w3c.dom.Node getFirstChild() {
handleNewSource();
return document.getFirstChild();
}
public org.w3c.dom.Node getLastChild() {
handleNewSource();
return document.getLastChild();
}
public String getLocalName() {
return document.getLocalName();
}
public String getNamespaceURI() {
return document.getNamespaceURI();
}
public org.w3c.dom.Node getNextSibling() {
handleNewSource();
return document.getNextSibling();
}
public String getNodeName() {
return document.getNodeName();
}
public short getNodeType() {
return document.getNodeType();
}
public String getNodeValue() throws DOMException {
return document.getNodeValue();
}
public Document getOwnerDocument() {
return document.getOwnerDocument();
}
public org.w3c.dom.Node getParentNode() {
return document.getParentNode();
}
public String getPrefix() {
return document.getPrefix();
}
public org.w3c.dom.Node getPreviousSibling() {
return document.getPreviousSibling();
}
public boolean hasAttributes() {
return document.hasAttributes();
}
public boolean hasChildNodes() {
handleNewSource();
return document.hasChildNodes();
}
public org.w3c.dom.Node insertBefore(
org.w3c.dom.Node arg0,
org.w3c.dom.Node arg1)
throws DOMException {
handleNewSource();
return document.insertBefore(arg0, arg1);
}
public boolean isSupported(String arg0, String arg1) {
return document.isSupported(arg0, arg1);
}
public void normalize() {
handleNewSource();
document.normalize();
}
public org.w3c.dom.Node removeChild(org.w3c.dom.Node arg0)
throws DOMException {
handleNewSource();
return document.removeChild(arg0);
}
public org.w3c.dom.Node replaceChild(
org.w3c.dom.Node arg0,
org.w3c.dom.Node arg1)
throws DOMException {
handleNewSource();
return document.replaceChild(arg0, arg1);
}
public void setNodeValue(String arg0) throws DOMException {
document.setNodeValue(arg0);
}
public void setPrefix(String arg0) throws DOMException {
document.setPrefix(arg0);
}
private void handleNewSource() {
if (sourceWasSet) {
// There is a newer source use that source.
try {
getEnvelope();
} catch (SOAPException e) {
}
}
}
protected XMLDeclarationParser lookForXmlDecl() throws SOAPException {
if ((source != null) && (source instanceof StreamSource)) {
Reader reader = null;
InputStream inputStream = ((StreamSource) source).getInputStream();
if (inputStream != null) {
if (getSourceCharsetEncoding() == null) {
reader = new InputStreamReader(inputStream);
} else {
try {
reader =
new InputStreamReader(
inputStream, getSourceCharsetEncoding());
} catch (UnsupportedEncodingException uee) {
log.log(
Level.SEVERE,
"SAAJ0551.soap.unsupported.encoding",
new Object[] {getSourceCharsetEncoding()});
throw new SOAPExceptionImpl(
"Unsupported encoding " + getSourceCharsetEncoding(),
uee);
}
}
} else {
reader = ((StreamSource) source).getReader();
}
if (reader != null) {
PushbackReader pushbackReader =
new PushbackReader(reader, 4096); //some size to unread <?xml ....?>
XMLDeclarationParser ev =
new XMLDeclarationParser(pushbackReader);
try {
ev.parse();
} catch (Exception e) {
log.log(
Level.SEVERE,
"SAAJ0552.soap.xml.decl.parsing.failed");
throw new SOAPExceptionImpl(
"XML declaration parsing failed", e);
}
String xmlDecl = ev.getXmlDeclaration();
if ((xmlDecl != null) && (xmlDecl.length() > 0)) {
this.omitXmlDecl = false;
}
if (lazyContentLength) {
source = new StreamSource(pushbackReader);
}
return ev;
}
} else if ((source != null) && (source instanceof DOMSource)) {
//TODO: A Domsource maynot contain XMLDecl ?.
}
return null;
}
public void setSourceCharsetEncoding(String charset) {
this.sourceCharsetEncoding = charset;
}
public org.w3c.dom.Node renameNode(org.w3c.dom.Node n, String namespaceURI, String qualifiedName)
throws DOMException {
handleNewSource();
return document.renameNode(n, namespaceURI, qualifiedName);
}
public void normalizeDocument() {
document.normalizeDocument();
}
public DOMConfiguration getDomConfig() {
return document.getDomConfig();
}
public org.w3c.dom.Node adoptNode(org.w3c.dom.Node source) throws DOMException {
handleNewSource();
return document.adoptNode(source);
}
public void setDocumentURI(String documentURI) {
document.setDocumentURI(documentURI);
}
public String getDocumentURI() {
return document.getDocumentURI();
}
public void setStrictErrorChecking(boolean strictErrorChecking) {
document.setStrictErrorChecking(strictErrorChecking);
}
public String getInputEncoding() {
return document.getInputEncoding();
}
public String getXmlEncoding() {
return document.getXmlEncoding();
}
public boolean getXmlStandalone() {
return document.getXmlStandalone();
}
public void setXmlStandalone(boolean xmlStandalone) throws DOMException {
document.setXmlStandalone(xmlStandalone);
}
public String getXmlVersion() {
return document.getXmlVersion();
}
public void setXmlVersion(String xmlVersion) throws DOMException {
document.setXmlVersion(xmlVersion);
}
public boolean getStrictErrorChecking() {
return document.getStrictErrorChecking();
}
// DOM L3 methods from org.w3c.dom.Node
public String getBaseURI() {
return document.getBaseURI();
}
public short compareDocumentPosition(org.w3c.dom.Node other)
throws DOMException {
return document.compareDocumentPosition(other);
}
public String getTextContent()
throws DOMException {
return document.getTextContent();
}
public void setTextContent(String textContent) throws DOMException {
document.setTextContent(textContent);
}
public boolean isSameNode(org.w3c.dom.Node other) {
return document.isSameNode(other);
}
public String lookupPrefix(String namespaceURI) {
return document.lookupPrefix(namespaceURI);
}
public boolean isDefaultNamespace(String namespaceURI) {
return document.isDefaultNamespace(namespaceURI);
}
public String lookupNamespaceURI(String prefix) {
return document.lookupNamespaceURI(prefix);
}
public boolean isEqualNode(org.w3c.dom.Node arg) {
return document.isEqualNode(arg);
}
public Object getFeature(String feature,
String version) {
return document.getFeature(feature,version);
}
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
return document.setUserData(key, data, handler);
}
public Object getUserData(String key) {
return document.getUserData(key);
}
public void recycleNode() {
// Nothing seems to be required to be done here
}
public String getValue() {
return null;
}
public void setValue(String value) {
log.severe("SAAJ0571.soappart.setValue.not.defined");
throw new IllegalStateException("Setting value of a soap part is not defined");
}
public void setParentElement(SOAPElement parent) throws SOAPException {
log.severe("SAAJ0570.soappart.parent.element.not.defined");
throw new SOAPExceptionImpl("The parent element of a soap part is not defined");
}
public SOAPElement getParentElement() {
return null;
}
public void detachNode() {
// Nothing seems to be required to be done here
}
public String getSourceCharsetEncoding() {
return sourceCharsetEncoding;
}
}

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
public class SOAPVersionMismatchException extends SOAPExceptionImpl {
/**
* Constructs a <code>SOAPExceptionImpl</code> object with no
* reason or embedded <code>Throwable</code> object.
*/
public SOAPVersionMismatchException() {
super();
}
/**
* Constructs a <code>SOAPExceptionImpl</code> object with the given
* <code>String</code> as the reason for the exception being thrown.
*
* @param reason a description of what caused the exception
*/
public SOAPVersionMismatchException(String reason) {
super(reason);
}
/**
* Constructs a <code>SOAPExceptionImpl</code> object with the given
* <code>String</code> as the reason for the exception being thrown
* and the given <code>Throwable</code> object as an embedded
* exception.
*
* @param reason a description of what caused the exception
* @param cause a <code>Throwable</code> object that is to
* be embedded in this <code>SOAPExceptionImpl</code> object
*/
public SOAPVersionMismatchException(String reason, Throwable cause) {
super(reason, cause);
}
/**
* Constructs a <code>SOAPExceptionImpl</code> object initialized
* with the given <code>Throwable</code> object.
*/
public SOAPVersionMismatchException(Throwable cause) {
super(cause);
}
}

View File

@@ -0,0 +1,167 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import java.awt.datatransfer.DataFlavor;
import java.io.*;
import javax.activation.*;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeUtility;
import com.sun.xml.internal.messaging.saaj.packaging.mime.util.ASCIIUtility;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.ContentType;
/**
* JAF data content handler for text/plain --> String
*
*/
public class StringDataContentHandler implements DataContentHandler {
private static ActivationDataFlavor myDF = new ActivationDataFlavor(
java.lang.String.class,
"text/plain",
"Text String");
protected ActivationDataFlavor getDF() {
return myDF;
}
/**
* Return the DataFlavors for this <code>DataContentHandler</code>.
*
* @return The DataFlavors
*/
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[] { getDF() };
}
/**
* Return the Transfer Data of type DataFlavor from InputStream.
*
* @param df The DataFlavor
* @param ds The DataSource corresponding to the data
* @return String object
*/
public Object getTransferData(DataFlavor df, DataSource ds)
throws IOException {
// use myDF.equals to be sure to get ActivationDataFlavor.equals,
// which properly ignores Content-Type parameters in comparison
if (getDF().equals(df))
return getContent(ds);
else
return null;
}
public Object getContent(DataSource ds) throws IOException {
String enc = null;
InputStreamReader is = null;
try {
enc = getCharset(ds.getContentType());
is = new InputStreamReader(ds.getInputStream(), enc);
} catch (IllegalArgumentException iex) {
/*
* An unknown charset of the form ISO-XXX-XXX will cause
* the JDK to throw an IllegalArgumentException. The
* JDK will attempt to create a classname using this string,
* but valid classnames must not contain the character '-',
* and this results in an IllegalArgumentException, rather than
* the expected UnsupportedEncodingException. Yikes.
*/
throw new UnsupportedEncodingException(enc);
}
try {
int pos = 0;
int count;
char buf[] = new char[1024];
while ((count = is.read(buf, pos, buf.length - pos)) != -1) {
pos += count;
if (pos >= buf.length) {
int size = buf.length;
if (size < 256*1024)
size += size;
else
size += 256*1024;
char tbuf[] = new char[size];
System.arraycopy(buf, 0, tbuf, 0, pos);
buf = tbuf;
}
}
return new String(buf, 0, pos);
} finally {
try {
is.close();
} catch (IOException ex) { }
}
}
/**
* Write the object to the output stream, using the specified MIME type.
*/
public void writeTo(Object obj, String type, OutputStream os)
throws IOException {
if (!(obj instanceof String))
throw new IOException("\"" + getDF().getMimeType() +
"\" DataContentHandler requires String object, " +
"was given object of type " + obj.getClass().toString());
String enc = null;
OutputStreamWriter osw = null;
try {
enc = getCharset(type);
osw = new OutputStreamWriter(os, enc);
} catch (IllegalArgumentException iex) {
/*
* An unknown charset of the form ISO-XXX-XXX will cause
* the JDK to throw an IllegalArgumentException. The
* JDK will attempt to create a classname using this string,
* but valid classnames must not contain the character '-',
* and this results in an IllegalArgumentException, rather than
* the expected UnsupportedEncodingException. Yikes.
*/
throw new UnsupportedEncodingException(enc);
}
String s = (String)obj;
osw.write(s, 0, s.length());
osw.flush();
}
private String getCharset(String type) {
try {
ContentType ct = new ContentType(type);
String charset = ct.getParameter("charset");
if (charset == null)
// If the charset parameter is absent, use US-ASCII.
charset = "us-ascii";
return MimeUtility.javaCharset(charset);
} catch (Exception ex) {
return null;
}
}
}

View File

@@ -0,0 +1,127 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap;
import java.awt.datatransfer.DataFlavor;
import java.io.IOException;
import java.io.OutputStream;
import javax.activation.*;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer;
/**
* JAF data handler for XML content
*
* @author Anil Vijendran
*/
public class XmlDataContentHandler implements DataContentHandler {
public static final String STR_SRC = "javax.xml.transform.stream.StreamSource";
private static Class streamSourceClass = null;
public XmlDataContentHandler() throws ClassNotFoundException {
if (streamSourceClass == null) {
streamSourceClass = Class.forName(STR_SRC);
}
}
/**
* return the DataFlavors for this <code>DataContentHandler</code>
* @return The DataFlavors.
*/
public DataFlavor[] getTransferDataFlavors() { // throws Exception;
DataFlavor flavors[] = new DataFlavor[2];
flavors[0] =
new ActivationDataFlavor(streamSourceClass, "text/xml", "XML");
flavors[1] =
new ActivationDataFlavor(streamSourceClass, "application/xml", "XML");
return flavors;
}
/**
* return the Transfer Data of type DataFlavor from InputStream
* @param df The DataFlavor.
* @param ins The InputStream corresponding to the data.
* @return The constructed Object.
*/
public Object getTransferData(DataFlavor flavor, DataSource dataSource)
throws IOException {
if (flavor.getMimeType().startsWith("text/xml") ||
flavor.getMimeType().startsWith("application/xml")) {
if (flavor.getRepresentationClass().getName().equals(STR_SRC)) {
return new StreamSource(dataSource.getInputStream());
}
}
return null;
}
/**
*
*/
public Object getContent(DataSource dataSource) throws IOException {
return new StreamSource(dataSource.getInputStream());
}
/**
* construct an object from a byte stream
* (similar semantically to previous method, we are deciding
* which one to support)
*/
public void writeTo(Object obj, String mimeType, OutputStream os)
throws IOException {
if (!mimeType.startsWith("text/xml") && !mimeType.startsWith("application/xml"))
throw new IOException(
"Invalid content type \"" + mimeType + "\" for XmlDCH");
try {
Transformer transformer = EfficientStreamingTransformer.newTransformer();
StreamResult result = new StreamResult(os);
if (obj instanceof DataSource) {
// Streaming transform applies only to javax.xml.transform.StreamSource
transformer.transform((Source) getContent((DataSource)obj), result);
} else {
Source src=null;
if (obj instanceof String) {
src= new StreamSource(new java.io.StringReader((String) obj));
} else {
src=(Source) obj;
}
transformer.transform(src, result);
}
} catch (Exception ex) {
throw new IOException(
"Unable to run the JAXP transformer on a stream "
+ ex.getMessage());
}
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.dynamic;
import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPFactoryImpl;
public class SOAPFactoryDynamicImpl extends SOAPFactoryImpl {
protected SOAPDocumentImpl createDocument() {
return null;
}
public Detail createDetail() throws SOAPException {
throw new UnsupportedOperationException(
"createDetail() not supported for Dynamic Protocol");
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.dynamic;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.MessageFactoryImpl;
public class SOAPMessageFactoryDynamicImpl extends MessageFactoryImpl {
public SOAPMessage createMessage() throws SOAPException {
throw new UnsupportedOperationException(
"createMessage() not supported for Dynamic Protocol");
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
/**
* All elements of the SOAP-ENV:BODY.
*
* @author Anil Vijendran (akv@eng.sun.com)
*/
public abstract class BodyElementImpl
extends ElementImpl
implements SOAPBodyElement {
public BodyElementImpl(SOAPDocumentImpl ownerDoc, Name qname) {
super(ownerDoc, qname);
}
public BodyElementImpl(SOAPDocumentImpl ownerDoc, QName qname) {
super(ownerDoc, qname);
}
public void setParentElement(SOAPElement element) throws SOAPException {
if (! (element instanceof SOAPBody)) {
log.severe("SAAJ0101.impl.parent.of.body.elem.mustbe.body");
throw new SOAPException("Parent of a SOAPBodyElement has to be a SOAPBody");
}
super.setParentElement(element);
}
}

View File

@@ -0,0 +1,325 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
import java.util.Iterator;
import java.util.Locale;
import java.util.logging.Level;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.*;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
/**
* The implementation of SOAP-ENV:BODY or the SOAPBody abstraction.
*
* @author Anil Vijendran (anil@sun.com)
*/
public abstract class BodyImpl extends ElementImpl implements SOAPBody {
private SOAPFault fault;
protected BodyImpl(SOAPDocumentImpl ownerDoc, NameImpl bodyName) {
super(ownerDoc, bodyName);
}
protected abstract NameImpl getFaultName(String name);
protected abstract boolean isFault(SOAPElement child);
protected abstract SOAPBodyElement createBodyElement(Name name);
protected abstract SOAPBodyElement createBodyElement(QName name);
protected abstract SOAPFault createFaultElement();
protected abstract QName getDefaultFaultCode();
public SOAPFault addFault() throws SOAPException {
if (hasFault()) {
log.severe("SAAJ0110.impl.fault.already.exists");
throw new SOAPExceptionImpl("Error: Fault already exists");
}
fault = createFaultElement();
addNode(fault);
fault.setFaultCode(getDefaultFaultCode());
fault.setFaultString("Fault string, and possibly fault code, not set");
return fault;
}
public SOAPFault addFault(
Name faultCode,
String faultString,
Locale locale)
throws SOAPException {
SOAPFault fault = addFault();
fault.setFaultCode(faultCode);
fault.setFaultString(faultString, locale);
return fault;
}
public SOAPFault addFault(
QName faultCode,
String faultString,
Locale locale)
throws SOAPException {
SOAPFault fault = addFault();
fault.setFaultCode(faultCode);
fault.setFaultString(faultString, locale);
return fault;
}
public SOAPFault addFault(Name faultCode, String faultString)
throws SOAPException {
SOAPFault fault = addFault();
fault.setFaultCode(faultCode);
fault.setFaultString(faultString);
return fault;
}
public SOAPFault addFault(QName faultCode, String faultString)
throws SOAPException {
SOAPFault fault = addFault();
fault.setFaultCode(faultCode);
fault.setFaultString(faultString);
return fault;
}
void initializeFault() {
FaultImpl flt = (FaultImpl) findFault();
fault = flt;
}
protected SOAPElement findFault() {
Iterator eachChild = getChildElementNodes();
while (eachChild.hasNext()) {
SOAPElement child = (SOAPElement) eachChild.next();
if (isFault(child)) {
return child;
}
}
return null;
}
public boolean hasFault() {
initializeFault();
return fault != null;
}
public SOAPFault getFault() {
if (hasFault())
return fault;
return null;
}
public SOAPBodyElement addBodyElement(Name name) throws SOAPException {
SOAPBodyElement newBodyElement =
(SOAPBodyElement) ElementFactory.createNamedElement(
((SOAPDocument) getOwnerDocument()).getDocument(),
name.getLocalName(),
name.getPrefix(),
name.getURI());
if (newBodyElement == null) {
newBodyElement = createBodyElement(name);
}
addNode(newBodyElement);
return newBodyElement;
}
public SOAPBodyElement addBodyElement(QName qname) throws SOAPException {
SOAPBodyElement newBodyElement =
(SOAPBodyElement) ElementFactory.createNamedElement(
((SOAPDocument) getOwnerDocument()).getDocument(),
qname.getLocalPart(),
qname.getPrefix(),
qname.getNamespaceURI());
if (newBodyElement == null) {
newBodyElement = createBodyElement(qname);
}
addNode(newBodyElement);
return newBodyElement;
}
public void setParentElement(SOAPElement element) throws SOAPException {
if (!(element instanceof SOAPEnvelope)) {
log.severe("SAAJ0111.impl.body.parent.must.be.envelope");
throw new SOAPException("Parent of SOAPBody has to be a SOAPEnvelope");
}
super.setParentElement(element);
}
protected SOAPElement addElement(Name name) throws SOAPException {
return addBodyElement(name);
}
protected SOAPElement addElement(QName name) throws SOAPException {
return addBodyElement(name);
}
// public Node insertBefore(Node newElement, Node ref) throws DOMException {
// if (!(newElement instanceof SOAPBodyElement) && (newElement instanceof SOAPElement)) {
// newElement = new ElementWrapper((ElementImpl) newElement);
// }
// return super.insertBefore(newElement, ref);
// }
//
// public Node replaceChild(Node newElement, Node ref) throws DOMException {
// if (!(newElement instanceof SOAPBodyElement) && (newElement instanceof SOAPElement)) {
// newElement = new ElementWrapper((ElementImpl) newElement);
// }
// return super.replaceChild(newElement, ref);
// }
public SOAPBodyElement addDocument(Document document)
throws SOAPException {
/*
Element rootNode =
document.getDocumentElement();
// Causes all deferred nodes to be inflated
rootNode.normalize();
adoptElement(rootNode);
SOAPBodyElement bodyElement = (SOAPBodyElement) convertToSoapElement(rootNode);
addNode(bodyElement);
return bodyElement;
*/
///*
SOAPBodyElement newBodyElement = null;
DocumentFragment docFrag = document.createDocumentFragment();
Element rootElement = document.getDocumentElement();
if(rootElement != null) {
docFrag.appendChild(rootElement);
Document ownerDoc = getOwnerDocument();
// This copies the whole tree which could be very big so it's slow.
// However, it does have the advantage of actually working.
org.w3c.dom.Node replacingNode = ownerDoc.importNode(docFrag, true);
// Adding replacingNode at the last of the children list of body
addNode(replacingNode);
Iterator i =
getChildElements(NameImpl.copyElementName(rootElement));
// Return the child element with the required name which is at the
// end of the list
while(i.hasNext())
newBodyElement = (SOAPBodyElement) i.next();
}
return newBodyElement;
//*/
}
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)));
}
}
public SOAPElement setElementQName(QName newName) throws SOAPException {
log.log(Level.SEVERE,
"SAAJ0146.impl.invalid.name.change.requested",
new Object[] {elementQName.getLocalPart(),
newName.getLocalPart()});
throw new SOAPException("Cannot change name for "
+ elementQName.getLocalPart() + " to "
+ newName.getLocalPart());
}
public Document extractContentAsDocument() throws SOAPException {
Iterator eachChild = getChildElements();
javax.xml.soap.Node firstBodyElement = null;
while (eachChild.hasNext() &&
!(firstBodyElement instanceof SOAPElement))
firstBodyElement = (javax.xml.soap.Node) eachChild.next();
boolean exactlyOneChildElement = true;
if (firstBodyElement == null)
exactlyOneChildElement = false;
else {
for (org.w3c.dom.Node node = firstBodyElement.getNextSibling();
node != null;
node = node.getNextSibling()) {
if (node instanceof Element) {
exactlyOneChildElement = false;
break;
}
}
}
if(!exactlyOneChildElement) {
log.log(Level.SEVERE,
"SAAJ0250.impl.body.should.have.exactly.one.child");
throw new SOAPException("Cannot extract Document from body");
}
Document document = null;
try {
DocumentBuilderFactory factory =
new com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.newDocument();
Element rootElement = (Element) document.importNode(
firstBodyElement,
true);
document.appendChild(rootElement);
} catch(Exception e) {
log.log(Level.SEVERE,
"SAAJ0251.impl.cannot.extract.document.from.body");
throw new SOAPExceptionImpl(
"Unable to extract Document from body", e);
}
firstBodyElement.detachNode();
return document;
}
}

View File

@@ -0,0 +1,90 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
import java.util.logging.Logger;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
public class CDATAImpl
extends com.sun.org.apache.xerces.internal.dom.CDATASectionImpl
implements javax.xml.soap.Text {
protected static final Logger log =
Logger.getLogger(LogDomainConstants.SOAP_IMPL_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.impl.LocalStrings");
static final String cdataUC = "<![CDATA[";
static final String cdataLC = "<![cdata[";
public CDATAImpl(SOAPDocumentImpl ownerDoc, String text) {
super(ownerDoc, text);
}
public String getValue() {
String nodeValue = getNodeValue();
return (nodeValue.equals("") ? null : nodeValue);
}
public void setValue(String text) {
setNodeValue(text);
}
public void setParentElement(SOAPElement parent) throws SOAPException {
if (parent == null) {
log.severe("SAAJ0145.impl.no.null.to.parent.elem");
throw new SOAPException("Cannot pass NULL to setParentElement");
}
((ElementImpl) parent).addNode(this);
}
public SOAPElement getParentElement() {
return (SOAPElement) getParentNode();
}
public void detachNode() {
org.w3c.dom.Node parent = getParentNode();
if (parent != null) {
parent.removeChild(this);
}
}
public void recycleNode() {
detachNode();
// TBD
// - add this to the factory so subsequent
// creations can reuse this object.
}
public boolean isComment() {
return false;
}
}

View File

@@ -0,0 +1,114 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
import java.util.ResourceBundle;
import java.util.logging.Logger;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import org.w3c.dom.DOMException;
import org.w3c.dom.Text;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
public class CommentImpl
extends com.sun.org.apache.xerces.internal.dom.CommentImpl
implements javax.xml.soap.Text, org.w3c.dom.Comment {
protected static final Logger log =
Logger.getLogger(LogDomainConstants.SOAP_IMPL_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.impl.LocalStrings");
protected static ResourceBundle rb =
log.getResourceBundle();
public CommentImpl(SOAPDocumentImpl ownerDoc, String text) {
super(ownerDoc, text);
}
public String getValue() {
String nodeValue = getNodeValue();
return (nodeValue.equals("") ? null : nodeValue);
}
public void setValue(String text) {
setNodeValue(text);
}
public void setParentElement(SOAPElement element) throws SOAPException {
if (element == null) {
log.severe("SAAJ0112.impl.no.null.to.parent.elem");
throw new SOAPException("Cannot pass NULL to setParentElement");
}
((ElementImpl) element).addNode(this);
}
public SOAPElement getParentElement() {
return (SOAPElement) getParentNode();
}
public void detachNode() {
org.w3c.dom.Node parent = getParentNode();
if (parent != null) {
parent.removeChild(this);
}
}
public void recycleNode() {
detachNode();
// TBD
// - add this to the factory so subsequent
// creations can reuse this object.
}
public boolean isComment() {
return true;
}
public Text splitText(int offset) throws DOMException {
log.severe("SAAJ0113.impl.cannot.split.text.from.comment");
throw new UnsupportedOperationException("Cannot split text from a Comment Node.");
}
public Text replaceWholeText(String content) throws DOMException {
log.severe("SAAJ0114.impl.cannot.replace.wholetext.from.comment");
throw new UnsupportedOperationException("Cannot replace Whole Text from a Comment Node.");
}
public String getWholeText() {
//TODO: maybe we have to implement this in future.
throw new UnsupportedOperationException("Not Supported");
}
public boolean isElementContentWhitespace() {
//TODO: maybe we have to implement this in future.
throw new UnsupportedOperationException("Not Supported");
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
import javax.xml.namespace.QName;
import javax.xml.soap.DetailEntry;
import javax.xml.soap.Name;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
public abstract class DetailEntryImpl
extends ElementImpl
implements DetailEntry {
public DetailEntryImpl(SOAPDocumentImpl ownerDoc, Name qname) {
super(ownerDoc, qname);
}
public DetailEntryImpl(SOAPDocumentImpl ownerDoc, QName qname) {
super(ownerDoc, qname);
}
}

View File

@@ -0,0 +1,122 @@
/*
* 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
import java.util.Iterator;
import java.util.NoSuchElementException;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import org.w3c.dom.Element;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
public abstract class DetailImpl extends FaultElementImpl implements Detail {
public DetailImpl(SOAPDocumentImpl ownerDoc, NameImpl detailName) {
super(ownerDoc, detailName);
}
protected abstract DetailEntry createDetailEntry(Name name);
protected abstract DetailEntry createDetailEntry(QName name);
public DetailEntry addDetailEntry(Name name) throws SOAPException {
DetailEntry entry = createDetailEntry(name);
addNode(entry);
return entry;
}
public DetailEntry addDetailEntry(QName qname) throws SOAPException {
DetailEntry entry = createDetailEntry(qname);
addNode(entry);
return entry;
}
protected SOAPElement addElement(Name name) throws SOAPException {
return addDetailEntry(name);
}
protected SOAPElement addElement(QName name) throws SOAPException {
return addDetailEntry(name);
}
protected SOAPElement convertToSoapElement(Element element) {
if (element instanceof DetailEntry) {
return (SOAPElement) element;
} else {
DetailEntry detailEntry =
createDetailEntry(NameImpl.copyElementName(element));
return replaceElementWithSOAPElement(
element,
(ElementImpl) detailEntry);
}
}
public Iterator getDetailEntries() {
return new Iterator() {
Iterator eachNode = getChildElementNodes();
SOAPElement next = null;
SOAPElement last = null;
public boolean hasNext() {
if (next == null) {
while (eachNode.hasNext()) {
next = (SOAPElement) eachNode.next();
if (next instanceof DetailEntry) {
break;
}
next = null;
}
}
return next != null;
}
public Object next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
last = next;
next = null;
return last;
}
public void remove() {
if (last == null) {
throw new IllegalStateException();
}
SOAPElement target = last;
removeChild(target);
last = null;
}
};
}
protected boolean isStandardFaultElement() {
return true;
}
}

View File

@@ -0,0 +1,167 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
import com.sun.xml.internal.messaging.saaj.soap.ver1_1.*;
import com.sun.xml.internal.messaging.saaj.soap.ver1_2.*;
public class ElementFactory {
public static SOAPElement createElement(
SOAPDocumentImpl ownerDocument,
Name name) {
return createElement(
ownerDocument,
name.getLocalName(),
name.getPrefix(),
name.getURI());
}
public static SOAPElement createElement(
SOAPDocumentImpl ownerDocument,
QName name) {
return createElement(
ownerDocument,
name.getLocalPart(),
name.getPrefix(),
name.getNamespaceURI());
}
public static SOAPElement createElement(
SOAPDocumentImpl ownerDocument,
String localName,
String prefix,
String namespaceUri) {
if (ownerDocument == null) {
if (NameImpl.SOAP11_NAMESPACE.equals(namespaceUri)) {
ownerDocument = new SOAPPart1_1Impl().getDocument();
} else if (NameImpl.SOAP12_NAMESPACE.equals(namespaceUri)) {
ownerDocument = new SOAPPart1_2Impl().getDocument();
} else {
ownerDocument = new SOAPDocumentImpl(null);
}
}
SOAPElement newElement =
createNamedElement(ownerDocument, localName, prefix, namespaceUri);
return newElement != null
? newElement
: new ElementImpl(
ownerDocument,
namespaceUri,
NameImpl.createQName(prefix, localName));
}
public static SOAPElement createNamedElement(
SOAPDocumentImpl ownerDocument,
String localName,
String prefix,
String namespaceUri) {
if (prefix == null) {
prefix = NameImpl.SOAP_ENVELOPE_PREFIX;
}
if (localName.equalsIgnoreCase("Envelope")) {
if (NameImpl.SOAP11_NAMESPACE.equals(namespaceUri)) {
return new Envelope1_1Impl(ownerDocument, prefix);
} else if (NameImpl.SOAP12_NAMESPACE.equals(namespaceUri)) {
return new Envelope1_2Impl(ownerDocument, prefix);
}
}
if (localName.equalsIgnoreCase("Body")) {
if (NameImpl.SOAP11_NAMESPACE.equals(namespaceUri)) {
return new Body1_1Impl(ownerDocument, prefix);
} else if (NameImpl.SOAP12_NAMESPACE.equals(namespaceUri)) {
return new Body1_2Impl(ownerDocument, prefix);
}
}
if (localName.equalsIgnoreCase("Header")) {
if (NameImpl.SOAP11_NAMESPACE.equals(namespaceUri)) {
return new Header1_1Impl(ownerDocument, prefix);
} else if (NameImpl.SOAP12_NAMESPACE.equals(namespaceUri)) {
return new Header1_2Impl(ownerDocument, prefix);
}
}
if (localName.equalsIgnoreCase("Fault")) {
SOAPFault fault = null;
if (NameImpl.SOAP11_NAMESPACE.equals(namespaceUri)) {
fault = new Fault1_1Impl(ownerDocument, prefix);
} else if (NameImpl.SOAP12_NAMESPACE.equals(namespaceUri)) {
fault = new Fault1_2Impl(ownerDocument, prefix);
}
if (fault != null) {
// try {
// fault.addNamespaceDeclaration(
// NameImpl.SOAP_ENVELOPE_PREFIX,
// SOAPConstants.URI_NS_SOAP_ENVELOPE);
// fault.setFaultCode(
// NameImpl.create(
// "Server",
// NameImpl.SOAP_ENVELOPE_PREFIX,
// SOAPConstants.URI_NS_SOAP_ENVELOPE));
// fault.setFaultString(
// "Fault string, and possibly fault code, not set");
// } catch (SOAPException e) {
// }
return fault;
}
}
if (localName.equalsIgnoreCase("Detail")) {
if (NameImpl.SOAP11_NAMESPACE.equals(namespaceUri)) {
return new Detail1_1Impl(ownerDocument, prefix);
} else if (NameImpl.SOAP12_NAMESPACE.equals(namespaceUri)) {
return new Detail1_2Impl(ownerDocument, prefix);
}
}
if (localName.equalsIgnoreCase("faultcode")
|| localName.equalsIgnoreCase("faultstring")
|| localName.equalsIgnoreCase("faultactor")) {
// SOAP 1.2 does not have fault(code/string/actor)
// So there is no else case required
if (NameImpl.SOAP11_NAMESPACE.equals(namespaceUri)) {
return new FaultElement1_1Impl(ownerDocument,
localName,
prefix);
}
}
return null;
}
protected static void invalidCreate(String msg) {
throw new TreeException(msg);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,360 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Iterator;
import java.util.logging.Level;
import org.w3c.dom.Document;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.sax.*;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.Envelope;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
import com.sun.xml.internal.messaging.saaj.util.FastInfosetReflection;
import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer;
/**
* Our implementation of the SOAP envelope.
*
* @author Anil Vijendran (anil@sun.com)
*/
public abstract class EnvelopeImpl extends ElementImpl implements Envelope {
protected HeaderImpl header;
protected BodyImpl body;
String omitXmlDecl = "yes";
String charset = "utf-8";
String xmlDecl = null;
protected EnvelopeImpl(SOAPDocumentImpl ownerDoc, Name name) {
super(ownerDoc, name);
}
protected EnvelopeImpl(SOAPDocumentImpl ownerDoc, QName name) {
super(ownerDoc, name);
}
protected EnvelopeImpl(
SOAPDocumentImpl ownerDoc,
NameImpl name,
boolean createHeader,
boolean createBody)
throws SOAPException {
this(ownerDoc, name);
ensureNamespaceIsDeclared(
getElementQName().getPrefix(), getElementQName().getNamespaceURI());
// XXX
if (createHeader)
addHeader();
if (createBody)
addBody();
}
protected abstract NameImpl getHeaderName(String prefix);
protected abstract NameImpl getBodyName(String prefix);
public SOAPHeader addHeader() throws SOAPException {
return addHeader(null);
}
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;
}
protected void lookForHeader() throws SOAPException {
NameImpl headerName = getHeaderName(null);
HeaderImpl hdr = (HeaderImpl) findChild(headerName);
header = hdr;
}
public SOAPHeader getHeader() throws SOAPException {
lookForHeader();
return header;
}
protected void lookForBody() throws SOAPException {
NameImpl bodyName = getBodyName(null);
BodyImpl bodyChildElement = (BodyImpl) findChild(bodyName);
body = bodyChildElement;
}
public SOAPBody addBody() throws SOAPException {
return addBody(null);
}
public SOAPBody addBody(String prefix) throws SOAPException {
lookForBody();
if (prefix == null || prefix.equals("")) {
prefix = getPrefix();
}
if (body == null) {
NameImpl bodyName = getBodyName(prefix);
body = (BodyImpl) createElement(bodyName);
insertBefore(body, null);
body.ensureNamespaceIsDeclared(bodyName.getPrefix(), bodyName.getURI());
} else {
log.severe("SAAJ0122.impl.body.already.exists");
throw new SOAPExceptionImpl("Can't add a body when one is already present.");
}
return body;
}
protected SOAPElement addElement(Name name) throws SOAPException {
if (getBodyName(null).equals(name)) {
return addBody(name.getPrefix());
}
if (getHeaderName(null).equals(name)) {
return addHeader(name.getPrefix());
}
return super.addElement(name);
}
protected SOAPElement addElement(QName name) throws SOAPException {
if (getBodyName(null).equals(NameImpl.convertToName(name))) {
return addBody(name.getPrefix());
}
if (getHeaderName(null).equals(NameImpl.convertToName(name))) {
return addHeader(name.getPrefix());
}
return super.addElement(name);
}
public SOAPBody getBody() throws SOAPException {
lookForBody();
return body;
}
public Source getContent() {
return new DOMSource(getOwnerDocument());
}
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);
}
public Name createName(String localName, String prefix)
throws SOAPException {
String namespace = getNamespaceURI(prefix);
if (namespace == null) {
log.log(
Level.SEVERE,
"SAAJ0126.impl.cannot.locate.ns",
new String[] { prefix });
throw new SOAPExceptionImpl(
"Unable to locate namespace for prefix " + prefix);
}
return NameImpl.create(localName, prefix, namespace);
}
public Name createName(String localName) throws SOAPException {
return NameImpl.createFromUnqualifiedName(localName);
}
public void setOmitXmlDecl(String value) {
this.omitXmlDecl = value;
}
public void setXmlDecl(String value) {
this.xmlDecl = value;
}
private String getOmitXmlDecl() {
return this.omitXmlDecl;
}
public void setCharsetEncoding(String value) {
charset = value;
}
public void output(OutputStream out) throws IOException {
try {
Transformer transformer =
EfficientStreamingTransformer.newTransformer();
transformer.setOutputProperty(
OutputKeys.OMIT_XML_DECLARATION, "yes");
/*omitXmlDecl);*/
// no equivalent for "setExpandEmptyElements"
transformer.setOutputProperty(
OutputKeys.ENCODING,
charset);
if (omitXmlDecl.equals("no") && xmlDecl == null) {
xmlDecl = "<?xml version=\"" + getOwnerDocument().getXmlVersion() + "\" encoding=\"" +
charset + "\" ?>";
}
StreamResult result = new StreamResult(out);
if (xmlDecl != null) {
OutputStreamWriter writer = new OutputStreamWriter(out, charset);
writer.write(xmlDecl);
writer.flush();
result = new StreamResult(writer);
}
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "SAAJ0190.impl.set.xml.declaration",
new String[] { omitXmlDecl });
log.log(Level.FINE, "SAAJ0191.impl.set.encoding",
new String[] { charset });
}
//StreamResult result = new StreamResult(out);
transformer.transform(getContent(), result);
} catch (Exception ex) {
throw new IOException(ex.getMessage());
}
}
/**
* Serialize to FI if boolean parameter set.
*/
public void output(OutputStream out, boolean isFastInfoset)
throws IOException
{
if (!isFastInfoset) {
output(out);
}
else {
try {
// Run transform and generate FI output from content
Source source = getContent();
Transformer transformer = EfficientStreamingTransformer.newTransformer();
transformer.transform(getContent(),
FastInfosetReflection.FastInfosetResult_new(out));
}
catch (Exception ex) {
throw new IOException(ex.getMessage());
}
}
}
// public void prettyPrint(OutputStream out) throws IOException {
// if (getDocument() == null)
// initDocument();
//
// OutputFormat format = OutputFormat.createPrettyPrint();
//
// format.setIndentSize(2);
// format.setNewlines(true);
// format.setTrimText(true);
// format.setPadText(true);
// format.setExpandEmptyElements(false);
//
// XMLWriter writer = new XMLWriter(out, format);
// writer.write(getDocument());
// }
//
// public void prettyPrint(Writer out) throws IOException {
// if (getDocument() == null)
// initDocument();
//
// OutputFormat format = OutputFormat.createPrettyPrint();
//
// format.setIndentSize(2);
// format.setNewlines(true);
// format.setTrimText(true);
// format.setPadText(true);
// format.setExpandEmptyElements(false);
//
// XMLWriter writer = new XMLWriter(out, format);
// writer.write(getDocument());
// }
public SOAPElement setElementQName(QName newName) throws SOAPException {
log.log(Level.SEVERE,
"SAAJ0146.impl.invalid.name.change.requested",
new Object[] {elementQName.getLocalPart(),
newName.getLocalPart()});
throw new SOAPException("Cannot change name for "
+ elementQName.getLocalPart() + " to "
+ newName.getLocalPart());
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
import java.util.logging.Level;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPFaultElement;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
public abstract class FaultElementImpl
extends ElementImpl
implements SOAPFaultElement {
protected FaultElementImpl(SOAPDocumentImpl ownerDoc, NameImpl qname) {
super(ownerDoc, qname);
}
protected FaultElementImpl(SOAPDocumentImpl ownerDoc, QName qname) {
super(ownerDoc, qname);
}
protected abstract boolean isStandardFaultElement();
public SOAPElement setElementQName(QName newName) throws SOAPException {
log.log(Level.SEVERE,
"SAAJ0146.impl.invalid.name.change.requested",
new Object[] {elementQName.getLocalPart(),
newName.getLocalPart()});
throw new SOAPException("Cannot change name for "
+ elementQName.getLocalPart() + " to "
+ newName.getLocalPart());
}
}

View File

@@ -0,0 +1,346 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
import java.util.Locale;
import java.util.logging.Level;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import org.w3c.dom.Element;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
public abstract class FaultImpl extends ElementImpl implements SOAPFault {
/* This can also represent a fault reason element */
protected SOAPFaultElement faultStringElement;
/* This can also represent a fault role element */
protected SOAPFaultElement faultActorElement;
protected SOAPFaultElement faultCodeElement;
protected Detail detail;
protected FaultImpl(SOAPDocumentImpl ownerDoc, NameImpl name) {
super(ownerDoc, name);
}
protected abstract NameImpl getDetailName();
protected abstract NameImpl getFaultCodeName();
protected abstract NameImpl getFaultStringName();
protected abstract NameImpl getFaultActorName();
protected abstract DetailImpl createDetail();
protected abstract FaultElementImpl createSOAPFaultElement(String localName);
protected abstract FaultElementImpl createSOAPFaultElement(QName qname);
protected abstract FaultElementImpl createSOAPFaultElement(Name qname);
protected abstract void checkIfStandardFaultCode(String faultCode, String uri) throws SOAPException;
protected abstract void finallySetFaultCode(String faultcode) throws SOAPException;
protected abstract boolean isStandardFaultElement(String localName);
protected abstract QName getDefaultFaultCode();
protected void findFaultCodeElement() {
this.faultCodeElement =
(SOAPFaultElement) findChild(getFaultCodeName());
}
protected void findFaultActorElement() {
this.faultActorElement =
(SOAPFaultElement) findChild(getFaultActorName());
}
protected void findFaultStringElement() {
this.faultStringElement =
(SOAPFaultElement) findChild(getFaultStringName());
}
public void setFaultCode(String faultCode) throws SOAPException {
setFaultCode(
NameImpl.getLocalNameFromTagName(faultCode),
NameImpl.getPrefixFromTagName(faultCode),
null);
}
public void setFaultCode(String faultCode, String prefix, String uri)
throws SOAPException {
if (prefix == null || "".equals(prefix)) {
if (uri != null && !"".equals(uri)) {
prefix = getNamespacePrefix(uri);
if (prefix == null || "".equals(prefix)) {
prefix = "ns0";
}
}
}
if (this.faultCodeElement == null)
findFaultCodeElement();
if (this.faultCodeElement == null)
this.faultCodeElement = addFaultCodeElement();
else
this.faultCodeElement.removeContents();
if (uri == null || "".equals(uri)) {
uri = this.faultCodeElement.getNamespaceURI(prefix);
}
if (uri == null || "".equals(uri)) {
if (prefix != null && !"".equals(prefix)) {
//cannot allow an empty URI for a non-Empty prefix
log.log(Level.SEVERE, "SAAJ0140.impl.no.ns.URI", new Object[]{prefix + ":" + faultCode});
throw new SOAPExceptionImpl("Empty/Null NamespaceURI specified for faultCode \"" + prefix + ":" + faultCode + "\"");
} else {
uri = "";
}
}
checkIfStandardFaultCode(faultCode, uri);
((FaultElementImpl) this.faultCodeElement).ensureNamespaceIsDeclared(prefix, uri);
if (prefix == null || "".equals(prefix)) {
finallySetFaultCode(faultCode);
} else {
finallySetFaultCode(prefix + ":" + faultCode);
}
}
public void setFaultCode(Name faultCodeQName) throws SOAPException {
setFaultCode(
faultCodeQName.getLocalName(),
faultCodeQName.getPrefix(),
faultCodeQName.getURI());
}
public void setFaultCode(QName faultCodeQName) throws SOAPException {
setFaultCode(
faultCodeQName.getLocalPart(),
faultCodeQName.getPrefix(),
faultCodeQName.getNamespaceURI());
}
protected static QName convertCodeToQName(
String code,
SOAPElement codeContainingElement) {
int prefixIndex = code.indexOf(':');
if (prefixIndex == -1) {
return new QName(code);
}
String prefix = code.substring(0, prefixIndex);
String nsName =((ElementImpl) codeContainingElement).lookupNamespaceURI(prefix);
//((ElementImpl) codeContainingElement).getNamespaceURI(prefix);
return new QName(nsName, getLocalPart(code), prefix);
}
protected void initializeDetail() {
NameImpl detailName = getDetailName();
detail = (Detail) findChild(detailName);
}
public Detail getDetail() {
if (detail == null)
initializeDetail();
if ((detail != null) && (detail.getParentNode() == null)) {
// a detach node was called on it
detail = null;
}
return detail;
}
public Detail addDetail() throws SOAPException {
if (detail == null)
initializeDetail();
if (detail == null) {
detail = createDetail();
addNode(detail);
return detail;
} else {
// Log
throw new SOAPExceptionImpl("Error: Detail already exists");
}
}
public boolean hasDetail() {
return (getDetail() != null);
}
public abstract void setFaultActor(String faultActor) throws SOAPException;
public String getFaultActor() {
if (this.faultActorElement == null)
findFaultActorElement();
if (this.faultActorElement != null) {
return this.faultActorElement.getValue();
}
return null;
}
public SOAPElement setElementQName(QName newName) throws SOAPException {
log.log(
Level.SEVERE,
"SAAJ0146.impl.invalid.name.change.requested",
new Object[] {elementQName.getLocalPart(), newName.getLocalPart()});
throw new SOAPException(
"Cannot change name for " + elementQName.getLocalPart() + " to " + newName.getLocalPart());
}
protected SOAPElement convertToSoapElement(Element element) {
if (element instanceof SOAPFaultElement) {
return (SOAPElement) element;
} else if (element instanceof SOAPElement) {
SOAPElement soapElement = (SOAPElement) element;
if (getDetailName().equals(soapElement.getElementName())) {
return replaceElementWithSOAPElement(element, createDetail());
} else {
String localName =
soapElement.getElementName().getLocalName();
if (isStandardFaultElement(localName))
return replaceElementWithSOAPElement(
element,
createSOAPFaultElement(soapElement.getElementQName()));
return soapElement;
}
} else {
Name elementName = NameImpl.copyElementName(element);
ElementImpl newElement;
if (getDetailName().equals(elementName)) {
newElement = (ElementImpl) createDetail();
} else {
String localName = elementName.getLocalName();
if (isStandardFaultElement(localName))
newElement =
(ElementImpl) createSOAPFaultElement(elementName);
else
newElement = (ElementImpl) createElement(elementName);
}
return replaceElementWithSOAPElement(element, newElement);
}
}
protected SOAPFaultElement addFaultCodeElement() throws SOAPException {
if (this.faultCodeElement == null)
findFaultCodeElement();
if (this.faultCodeElement == null) {
this.faultCodeElement =
addSOAPFaultElement(getFaultCodeName().getLocalName());
return this.faultCodeElement;
} else {
throw new SOAPExceptionImpl("Error: Faultcode already exists");
}
}
private SOAPFaultElement addFaultStringElement() throws SOAPException {
if (this.faultStringElement == null)
findFaultStringElement();
if (this.faultStringElement == null) {
this.faultStringElement =
addSOAPFaultElement(getFaultStringName().getLocalName());
return this.faultStringElement;
} else {
// Log
throw new SOAPExceptionImpl("Error: Faultstring already exists");
}
}
private SOAPFaultElement addFaultActorElement() throws SOAPException {
if (this.faultActorElement == null)
findFaultActorElement();
if (this.faultActorElement == null) {
this.faultActorElement =
addSOAPFaultElement(getFaultActorName().getLocalName());
return this.faultActorElement;
} else {
// Log
throw new SOAPExceptionImpl("Error: Faultactor already exists");
}
}
protected SOAPElement addElement(Name name) throws SOAPException {
if (getDetailName().equals(name)) {
return addDetail();
} else if(getFaultCodeName().equals(name)) {
return addFaultCodeElement();
} else if(getFaultStringName().equals(name)) {
return addFaultStringElement();
} else if(getFaultActorName().equals(name)) {
return addFaultActorElement();
}
return super.addElement(name);
}
protected SOAPElement addElement(QName name) throws SOAPException {
return addElement(NameImpl.convertToName(name));
}
protected FaultElementImpl addSOAPFaultElement(String localName)
throws SOAPException {
FaultElementImpl faultElem = createSOAPFaultElement(localName);
addNode(faultElem);
return faultElem;
}
/**
* Convert an xml:lang attribute value into a Locale object
*/
protected static Locale xmlLangToLocale(String xmlLang) {
if (xmlLang == null) {
return null;
}
// Spec uses hyphen as separator
int index = xmlLang.indexOf("-");
// Accept underscore as separator as well
if (index == -1) {
index = xmlLang.indexOf("_");
}
if (index == -1) {
// No separator so assume only a language component
return new Locale(xmlLang, "");
}
String language = xmlLang.substring(0, index);
String country = xmlLang.substring(index + 1);
return new Locale(language, country);
}
protected static String localeToXmlLang(Locale locale) {
String xmlLang = locale.getLanguage();
String country = locale.getCountry();
if (!"".equals(country)) {
xmlLang += "-" + country;
}
return xmlLang;
}
}

View File

@@ -0,0 +1,135 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
public abstract class HeaderElementImpl
extends ElementImpl
implements SOAPHeaderElement {
protected static Name RELAY_ATTRIBUTE_LOCAL_NAME =
NameImpl.createFromTagName("relay");
protected static Name MUST_UNDERSTAND_ATTRIBUTE_LOCAL_NAME =
NameImpl.createFromTagName("mustUnderstand");
public HeaderElementImpl(SOAPDocumentImpl ownerDoc, Name qname) {
super(ownerDoc, qname);
}
public HeaderElementImpl(SOAPDocumentImpl ownerDoc, QName qname) {
super(ownerDoc, qname);
}
protected abstract NameImpl getActorAttributeName();
protected abstract NameImpl getRoleAttributeName();
protected abstract NameImpl getMustunderstandAttributeName();
protected abstract boolean getMustunderstandAttributeValue(String str);
protected abstract String getMustunderstandLiteralValue(boolean mu);
protected abstract NameImpl getRelayAttributeName();
protected abstract boolean getRelayAttributeValue(String str);
protected abstract String getRelayLiteralValue(boolean mu);
protected abstract String getActorOrRole();
public void setParentElement(SOAPElement element) throws SOAPException {
if (!(element instanceof SOAPHeader)) {
log.severe("SAAJ0130.impl.header.elem.parent.mustbe.header");
throw new SOAPException("Parent of a SOAPHeaderElement has to be a SOAPHeader");
}
super.setParentElement(element);
}
public void setActor(String actorUri) {
try {
removeAttribute(getActorAttributeName());
addAttribute((Name) getActorAttributeName(), actorUri);
} catch (SOAPException ex) {
}
}
//SOAP 1.2 supports Role
public void setRole(String roleUri) throws SOAPException {
// runtime exception thrown if called for SOAP 1.1
removeAttribute(getRoleAttributeName());
addAttribute((Name) getRoleAttributeName(), roleUri);
}
Name actorAttNameWithoutNS = NameImpl.createFromTagName("actor");
public String getActor() {
String actor = getAttributeValue(getActorAttributeName());
return actor;
}
Name roleAttNameWithoutNS = NameImpl.createFromTagName("role");
public String getRole() {
// runtime exception thrown for 1.1
String role = getAttributeValue(getRoleAttributeName());
return role;
}
public void setMustUnderstand(boolean mustUnderstand) {
try {
removeAttribute(getMustunderstandAttributeName());
addAttribute(
(Name) getMustunderstandAttributeName(),
getMustunderstandLiteralValue(mustUnderstand));
} catch (SOAPException ex) {
}
}
public boolean getMustUnderstand() {
String mu = getAttributeValue(getMustunderstandAttributeName());
if (mu != null)
return getMustunderstandAttributeValue(mu);
return false;
}
public void setRelay(boolean relay) throws SOAPException {
// runtime exception thrown for 1.1
removeAttribute(getRelayAttributeName());
addAttribute(
(Name) getRelayAttributeName(),
getRelayLiteralValue(relay));
}
public boolean getRelay() {
String mu = getAttributeValue(getRelayAttributeName());
if (mu != null)
return getRelayAttributeValue(mu);
return false;
}
}

View File

@@ -0,0 +1,305 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
import java.util.*;
import java.util.logging.Level;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import org.w3c.dom.Element;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
public abstract class HeaderImpl extends ElementImpl implements SOAPHeader {
protected static final boolean MUST_UNDERSTAND_ONLY = false;
protected HeaderImpl(SOAPDocumentImpl ownerDoc, NameImpl name) {
super(ownerDoc, name);
}
protected abstract SOAPHeaderElement createHeaderElement(Name name)
throws SOAPException;
protected abstract SOAPHeaderElement createHeaderElement(QName name)
throws SOAPException;
protected abstract NameImpl getNotUnderstoodName();
protected abstract NameImpl getUpgradeName();
protected abstract NameImpl getSupportedEnvelopeName();
public SOAPHeaderElement addHeaderElement(Name name) throws SOAPException {
SOAPElement newHeaderElement =
ElementFactory.createNamedElement(
((SOAPDocument) getOwnerDocument()).getDocument(),
name.getLocalName(),
name.getPrefix(),
name.getURI());
if (newHeaderElement == null
|| !(newHeaderElement instanceof SOAPHeaderElement)) {
newHeaderElement = createHeaderElement(name);
}
// header elements must be namespace qualified
// check that URI is not empty, ensuring that the element is NS qualified.
String uri = newHeaderElement.getElementQName().getNamespaceURI();
if ((uri == null) || ("").equals(uri)) {
log.severe("SAAJ0131.impl.header.elems.ns.qualified");
throw new SOAPExceptionImpl("HeaderElements must be namespace qualified");
}
addNode(newHeaderElement);
return (SOAPHeaderElement) newHeaderElement;
}
public SOAPHeaderElement addHeaderElement(QName name) throws SOAPException {
SOAPElement newHeaderElement =
ElementFactory.createNamedElement(
((SOAPDocument) getOwnerDocument()).getDocument(),
name.getLocalPart(),
name.getPrefix(),
name.getNamespaceURI());
if (newHeaderElement == null
|| !(newHeaderElement instanceof SOAPHeaderElement)) {
newHeaderElement = createHeaderElement(name);
}
// header elements must be namespace qualified
// check that URI is not empty, ensuring that the element is NS qualified.
String uri = newHeaderElement.getElementQName().getNamespaceURI();
if ((uri == null) || ("").equals(uri)) {
log.severe("SAAJ0131.impl.header.elems.ns.qualified");
throw new SOAPExceptionImpl("HeaderElements must be namespace qualified");
}
addNode(newHeaderElement);
return (SOAPHeaderElement) newHeaderElement;
}
protected SOAPElement addElement(Name name) throws SOAPException {
return addHeaderElement(name);
}
protected SOAPElement addElement(QName name) throws SOAPException {
return addHeaderElement(name);
}
public Iterator examineHeaderElements(String actor) {
return getHeaderElementsForActor(actor, false, false);
}
public Iterator extractHeaderElements(String actor) {
return getHeaderElementsForActor(actor, true, false);
}
protected Iterator getHeaderElementsForActor(
String actor,
boolean detach,
boolean mustUnderstand) {
if (actor == null || actor.equals("")) {
log.severe("SAAJ0132.impl.invalid.value.for.actor.or.role");
throw new IllegalArgumentException("Invalid value for actor or role");
}
return getHeaderElements(actor, detach, mustUnderstand);
}
protected Iterator getHeaderElements(
String actor,
boolean detach,
boolean mustUnderstand) {
List elementList = new ArrayList();
Iterator eachChild = getChildElements();
Object currentChild = iterate(eachChild);
while (currentChild != null) {
if (!(currentChild instanceof SOAPHeaderElement)) {
currentChild = iterate(eachChild);
} else {
HeaderElementImpl currentElement =
(HeaderElementImpl) currentChild;
currentChild = iterate(eachChild);
boolean isMustUnderstandMatching =
(!mustUnderstand || currentElement.getMustUnderstand());
boolean doAdd = false;
if (actor == null && isMustUnderstandMatching) {
doAdd = true;
} else {
String currentActor = currentElement.getActorOrRole();
if (currentActor == null) {
currentActor = "";
}
if (currentActor.equalsIgnoreCase(actor)
&& isMustUnderstandMatching) {
doAdd = true;
}
}
if (doAdd) {
elementList.add(currentElement);
if (detach) {
currentElement.detachNode();
}
}
}
}
return elementList.listIterator();
}
private Object iterate(Iterator each) {
return each.hasNext() ? each.next() : null;
}
public void setParentElement(SOAPElement element) throws SOAPException {
if (!(element instanceof SOAPEnvelope)) {
log.severe("SAAJ0133.impl.header.parent.mustbe.envelope");
throw new SOAPException("Parent of SOAPHeader has to be a SOAPEnvelope");
}
super.setParentElement(element);
}
// overriding ElementImpl's method to ensure that HeaderElements are
// namespace qualified. Holds for both SOAP versions.
// TODO - This check needs to be made for other addChildElement() methods
// as well.
public SOAPElement addChildElement(String localName) throws SOAPException {
SOAPElement element = super.addChildElement(localName);
// check that URI is not empty, ensuring that the element is NS qualified.
String uri = element.getElementName().getURI();
if ((uri == null) || ("").equals(uri)) {
log.severe("SAAJ0134.impl.header.elems.ns.qualified");
throw new SOAPExceptionImpl("HeaderElements must be namespace qualified");
}
return element;
}
public Iterator examineAllHeaderElements() {
return getHeaderElements(null, false, MUST_UNDERSTAND_ONLY);
}
public Iterator examineMustUnderstandHeaderElements(String actor) {
return getHeaderElements(actor, false, true);
}
public Iterator extractAllHeaderElements() {
return getHeaderElements(null, true, false);
}
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;
}
public SOAPHeaderElement addUpgradeHeaderElement(String supportedSoapUri)
throws SOAPException {
return addUpgradeHeaderElement(new String[] {supportedSoapUri});
}
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;
}
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);
}
}
public SOAPElement setElementQName(QName newName) throws SOAPException {
log.log(Level.SEVERE,
"SAAJ0146.impl.invalid.name.change.requested",
new Object[] {elementQName.getLocalPart(),
newName.getLocalPart()});
throw new SOAPException("Cannot change name for "
+ elementQName.getLocalPart() + " to "
+ newName.getLocalPart());
}
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
import java.util.logging.Logger;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
public class TextImpl
extends com.sun.org.apache.xerces.internal.dom.TextImpl
implements javax.xml.soap.Text, org.w3c.dom.Text {
protected static final Logger log =
Logger.getLogger(LogDomainConstants.SOAP_IMPL_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.impl.LocalStrings");
public TextImpl(SOAPDocumentImpl ownerDoc, String text) {
super(ownerDoc, text);
}
public String getValue() {
String nodeValue = getNodeValue();
return (nodeValue.equals("") ? null : nodeValue);
}
public void setValue(String text) {
setNodeValue(text);
}
public void setParentElement(SOAPElement parent) throws SOAPException {
if (parent == null) {
log.severe("SAAJ0126.impl.cannot.locate.ns");
throw new SOAPException("Cannot pass NULL to setParentElement");
}
((ElementImpl) parent).addNode(this);
}
public SOAPElement getParentElement() {
return (SOAPElement) getParentNode();
}
public void detachNode() {
org.w3c.dom.Node parent = getParentNode();
if (parent != null) {
parent.removeChild(this);
}
}
public void recycleNode() {
detachNode();
// TBD
// - add this to the factory so subsequent
// creations can reuse this object.
}
public boolean isComment() {
String txt = getNodeValue();
if (txt == null) {
return false;
}
return txt.startsWith("<!--") && txt.endsWith("-->");
}
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.impl;
public class TreeException extends RuntimeException {
public TreeException(String reason) {
super(reason);
}
}

View File

@@ -0,0 +1,561 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.messaging.saaj.soap.name;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPConstants;
//import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
import org.w3c.dom.Element;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
public class NameImpl implements Name {
public static final String XML_NAMESPACE_PREFIX = "xml";
public static final String XML_SCHEMA_NAMESPACE_PREFIX = "xs";
public static final String SOAP_ENVELOPE_PREFIX = "SOAP-ENV";
public static final String XML_NAMESPACE =
"http://www.w3.org/XML/1998/namespace";
public static final String SOAP11_NAMESPACE =
SOAPConstants.URI_NS_SOAP_ENVELOPE;
public static final String SOAP12_NAMESPACE =
SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE;
public static final String XML_SCHEMA_NAMESPACE =
"http://www.w3.org/2001/XMLSchema";
protected String uri = "";
protected String localName = "";
protected String prefix = "";
private String qualifiedName = null;
protected static final Logger log =
Logger.getLogger(LogDomainConstants.NAMING_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.name.LocalStrings");
/**
* XML Information Set REC
* all namespace attributes (including those named xmlns,
* whose [prefix] property has no value) have a namespace URI of http://www.w3.org/2000/xmlns/
*/
public final static String XMLNS_URI = "http://www.w3.org/2000/xmlns/".intern();
protected NameImpl(String name) {
this.localName = name == null ? "" : name;
}
protected NameImpl(String name, String prefix, String uri) {
this.uri = uri == null ? "" : uri;
this.localName = name == null ? "" : name;
this.prefix = prefix == null ? "" : prefix;
if (this.prefix.equals("xmlns") && this.uri.equals("")) {
this.uri = XMLNS_URI;
}
if (this.uri.equals(XMLNS_URI) && this.prefix.equals("")) {
this.prefix = "xmlns";
}
}
public static Name convertToName(QName qname) {
return new NameImpl(qname.getLocalPart(),
qname.getPrefix(),
qname.getNamespaceURI());
}
public static QName convertToQName(Name name) {
return new QName(name.getURI(),
name.getLocalName(),
name.getPrefix());
}
public static NameImpl createFromUnqualifiedName(String name) {
return new NameImpl(name);
}
public static Name createFromTagName(String tagName) {
return createFromTagAndUri(tagName, "");
}
public static Name createFromQualifiedName(
String qualifiedName,
String uri) {
return createFromTagAndUri(qualifiedName, uri);
}
protected static Name createFromTagAndUri(String tagName, String uri) {
if (tagName == null) {
log.severe("SAAJ0201.name.not.created.from.null.tag");
throw new IllegalArgumentException("Cannot create a name from a null tag.");
}
int index = tagName.indexOf(':');
if (index < 0) {
return new NameImpl(tagName, "", uri);
} else {
return new NameImpl(
tagName.substring(index + 1),
tagName.substring(0, index),
uri);
}
}
protected static int getPrefixSeparatorIndex(String qualifiedName) {
int index = qualifiedName.indexOf(':');
if (index < 0) {
log.log(
Level.SEVERE,
"SAAJ0202.name.invalid.arg.format",
new String[] { qualifiedName });
throw new IllegalArgumentException(
"Argument \""
+ qualifiedName
+ "\" must be of the form: \"prefix:localName\"");
}
return index;
}
public static String getPrefixFromQualifiedName(String qualifiedName) {
return qualifiedName.substring(
0,
getPrefixSeparatorIndex(qualifiedName));
}
public static String getLocalNameFromQualifiedName(String qualifiedName) {
return qualifiedName.substring(
getPrefixSeparatorIndex(qualifiedName) + 1);
}
public static String getPrefixFromTagName(String tagName) {
if (isQualified(tagName)) {
return getPrefixFromQualifiedName(tagName);
}
return "";
}
public static String getLocalNameFromTagName(String tagName) {
if (isQualified(tagName)) {
return getLocalNameFromQualifiedName(tagName);
}
return tagName;
}
public static boolean isQualified(String tagName) {
return tagName.indexOf(':') >= 0;
}
public static NameImpl create(String name, String prefix, String uri) {
if (prefix == null)
prefix = "";
if (uri == null)
uri = "";
if (name == null)
name = "";
if (!uri.equals("") && !name.equals("")) {
if (uri.equals(NameImpl.SOAP11_NAMESPACE)) {
if (name.equalsIgnoreCase("Envelope"))
return createEnvelope1_1Name(prefix);
else if (name.equalsIgnoreCase("Header"))
return createHeader1_1Name(prefix);
else if (name.equalsIgnoreCase("Body"))
return createBody1_1Name(prefix);
else if (name.equalsIgnoreCase("Fault"))
return createFault1_1Name(prefix);
else
return new SOAP1_1Name(name, prefix);
} else if (uri.equals(SOAP12_NAMESPACE)) {
if (name.equalsIgnoreCase("Envelope"))
return createEnvelope1_2Name(prefix);
else if (name.equalsIgnoreCase("Header"))
return createHeader1_2Name(prefix);
else if (name.equalsIgnoreCase("Body"))
return createBody1_2Name(prefix);
else if (
name.equals("Fault")
|| name.equals("Reason")
|| name.equals("Detail"))
return createFault1_2Name(name, prefix);
else if (name.equals("Code") || name.equals("Subcode"))
return createCodeSubcode1_2Name(prefix, name);
else
return new SOAP1_2Name(name, prefix);
}
}
return new NameImpl(name, prefix, uri);
}
public static String createQName(String prefix, String localName) {
if (prefix == null || prefix.equals("")) {
return localName;
}
return prefix + ":" + localName;
}
public boolean equals(Object obj) {
if (!(obj instanceof Name)) {
return false;
}
Name otherName = (Name) obj;
if (!uri.equals(otherName.getURI())) {
return false;
}
if (!localName.equals(otherName.getLocalName())) {
return false;
}
return true;
}
public int hashCode() {
return localName.hashCode();
}
/**
* Get the local name part of this XML Name.
*
* @return a string for the local name.
*/
public String getLocalName() {
return localName;
}
/* getQualifiedName is inherited from QName */
/**
* Returns the prefix associated with the namespace of the name.
*
* @return the prefix as a string.
*/
public String getPrefix() {
return prefix;
}
/**
* Returns the URI associated of the namespace.
*
* @return the uri as a string.
*/
public String getURI() {
return uri;
}
/**
* Returns a String version of the name suitable for use in an XML document.
*/
public String getQualifiedName() {
if (qualifiedName == null) {
if (prefix != null && prefix.length() > 0) {
qualifiedName = prefix + ":" + localName;
} else {
qualifiedName = localName;
}
}
return qualifiedName;
}
/**
* Create a name object for a SOAP1.1 Envelope.
*/
public static NameImpl createEnvelope1_1Name(String prefix) {
return new Envelope1_1Name(prefix);
}
/**
* Create a name object for a SOAP1.2 Envelope.
*/
public static NameImpl createEnvelope1_2Name(String prefix) {
return new Envelope1_2Name(prefix);
}
/**
* Create a name object for a SOAP1.1 Header.
*/
public static NameImpl createHeader1_1Name(String prefix) {
return new Header1_1Name(prefix);
}
/**
* Create a name object for a SOAP1.2 Header.
*/
public static NameImpl createHeader1_2Name(String prefix) {
return new Header1_2Name(prefix);
}
/**
* Create a name object for a SOAP1.1 Body.
*/
public static NameImpl createBody1_1Name(String prefix) {
return new Body1_1Name(prefix);
}
/**
* Create a name object for a SOAP1.2 Body.
*/
public static NameImpl createBody1_2Name(String prefix) {
return new Body1_2Name(prefix);
}
/**
* Create a name object for a SOAP1.1 Fault.
*/
public static NameImpl createFault1_1Name(String prefix) {
return new Fault1_1Name(prefix);
}
/**
* Create a name object for a SOAP1.2 NotUnderstood element.
*/
public static NameImpl createNotUnderstood1_2Name(String prefix) {
return new NotUnderstood1_2Name(prefix);
}
/**
* Create a name object for a SOAP1.2 Upgrade element.
*/
public static NameImpl createUpgrade1_2Name(String prefix) {
return new Upgrade1_2Name(prefix);
}
/**
* Create a name object for a SOAP1.2 SupportedEnvelope Upgrade element.
*/
public static NameImpl createSupportedEnvelope1_2Name(String prefix) {
return new SupportedEnvelope1_2Name(prefix);
}
/**
* Create a name object for a SOAP1.2
* Fault, Reason or Detail.
*
* @param localName Local Name of element
*/
public static NameImpl createFault1_2Name(
String localName,
String prefix) {
return new Fault1_2Name(localName, prefix);
}
/**
* Create a name object for a SOAP1.2 Fault/Code or Subcode.
*
* @param localName Either "Code" or "Subcode"
*/
public static NameImpl createCodeSubcode1_2Name(
String prefix,
String localName) {
return new CodeSubcode1_2Name(localName, prefix);
}
/**
* Create a name object for a SOAP1.1 Fault Detail.
*/
public static NameImpl createDetail1_1Name() {
return new Detail1_1Name();
}
public static NameImpl createDetail1_1Name(String prefix) {
return new Detail1_1Name(prefix);
}
public static NameImpl createFaultElement1_1Name(String localName) {
return new FaultElement1_1Name(localName);
}
public static NameImpl createFaultElement1_1Name(String localName,
String prefix) {
return new FaultElement1_1Name(localName, prefix);
}
public static NameImpl createSOAP11Name(String string) {
return new SOAP1_1Name(string, null);
}
public static NameImpl createSOAP12Name(String string) {
return new SOAP1_2Name(string, null);
}
public static NameImpl createSOAP12Name(String localName, String prefix) {
return new SOAP1_2Name(localName, prefix);
}
public static NameImpl createXmlName(String localName) {
return new NameImpl(localName, XML_NAMESPACE_PREFIX, XML_NAMESPACE);
}
public static Name copyElementName(Element element) {
String localName = element.getLocalName();
String prefix = element.getPrefix();
String uri = element.getNamespaceURI();
return create(localName, prefix, uri);
}
static class SOAP1_1Name extends NameImpl {
SOAP1_1Name(String name, String prefix) {
super(
name,
(prefix == null || prefix.equals(""))
? NameImpl.SOAP_ENVELOPE_PREFIX
: prefix,
NameImpl.SOAP11_NAMESPACE);
}
}
static class Envelope1_1Name extends SOAP1_1Name {
Envelope1_1Name(String prefix) {
super("Envelope", prefix);
}
}
static class Header1_1Name extends SOAP1_1Name {
Header1_1Name(String prefix) {
super("Header", prefix);
}
}
static class Body1_1Name extends SOAP1_1Name {
Body1_1Name(String prefix) {
super("Body", prefix);
}
}
static class Fault1_1Name extends NameImpl {
Fault1_1Name(String prefix) {
super(
"Fault",
(prefix == null || prefix.equals(""))
? SOAP_ENVELOPE_PREFIX
: prefix,
SOAP11_NAMESPACE);
}
}
static class Detail1_1Name extends NameImpl {
Detail1_1Name() {
super("detail");
}
Detail1_1Name(String prefix) {
super("detail", prefix, "");
}
}
static class FaultElement1_1Name extends NameImpl {
FaultElement1_1Name(String localName) {
super(localName);
}
FaultElement1_1Name(String localName, String prefix) {
super(localName, prefix, "");
}
}
static class SOAP1_2Name extends NameImpl {
SOAP1_2Name(String name, String prefix) {
super(
name,
(prefix == null || prefix.equals(""))
? SOAPConstants.SOAP_ENV_PREFIX
: prefix,
SOAP12_NAMESPACE);
}
}
static class Envelope1_2Name extends SOAP1_2Name {
Envelope1_2Name(String prefix) {
super("Envelope", prefix);
}
}
static class Header1_2Name extends SOAP1_2Name {
Header1_2Name(String prefix) {
super("Header", prefix);
}
}
static class Body1_2Name extends SOAP1_2Name {
Body1_2Name(String prefix) {
super("Body", prefix);
}
}
static class Fault1_2Name extends NameImpl {
Fault1_2Name(String name, String prefix) {
super(
(name == null || name.equals("")) ? "Fault" : name,
(prefix == null || prefix.equals(""))
? SOAPConstants.SOAP_ENV_PREFIX
: prefix,
SOAP12_NAMESPACE);
}
}
static class NotUnderstood1_2Name extends NameImpl {
NotUnderstood1_2Name(String prefix) {
super(
"NotUnderstood",
(prefix == null || prefix.equals(""))
? SOAPConstants.SOAP_ENV_PREFIX
: prefix,
SOAP12_NAMESPACE);
}
}
static class Upgrade1_2Name extends NameImpl {
Upgrade1_2Name(String prefix) {
super(
"Upgrade",
(prefix == null || prefix.equals(""))
? SOAPConstants.SOAP_ENV_PREFIX
: prefix,
SOAP12_NAMESPACE);
}
}
static class SupportedEnvelope1_2Name extends NameImpl {
SupportedEnvelope1_2Name(String prefix) {
super(
"SupportedEnvelope",
(prefix == null || prefix.equals(""))
? SOAPConstants.SOAP_ENV_PREFIX
: prefix,
SOAP12_NAMESPACE);
}
}
static class CodeSubcode1_2Name extends SOAP1_2Name {
CodeSubcode1_2Name(String prefix, String localName) {
super(prefix, localName);
}
}
}

View File

@@ -0,0 +1,83 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.BodyImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
public class Body1_1Impl extends BodyImpl {
public Body1_1Impl(SOAPDocumentImpl ownerDocument, String prefix) {
super(ownerDocument, NameImpl.createBody1_1Name(prefix));
}
public SOAPFault addSOAP12Fault(QName faultCode, String faultReason, Locale locale) {
// log message here
throw new UnsupportedOperationException("Not supported in SOAP 1.1");
}
protected NameImpl getFaultName(String name) {
// Ignore name
return NameImpl.createFault1_1Name(null);
}
protected SOAPBodyElement createBodyElement(Name name) {
return new BodyElement1_1Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
name);
}
protected SOAPBodyElement createBodyElement(QName name) {
return new BodyElement1_1Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
name);
}
protected QName getDefaultFaultCode() {
return new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "Server");
}
protected boolean isFault(SOAPElement child) {
// SOAP 1.1 faults always use the default name
return child.getElementName().equals(getFaultName(null));
}
protected SOAPFault createFaultElement() {
return new Fault1_1Impl(
((SOAPDocument) getOwnerDocument()).getDocument(), getPrefix());
}
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.BodyElementImpl;
public class BodyElement1_1Impl extends BodyElementImpl {
public BodyElement1_1Impl(SOAPDocumentImpl ownerDoc, Name qname) {
super(ownerDoc, qname);
}
public BodyElement1_1Impl(SOAPDocumentImpl ownerDoc, QName qname) {
super(ownerDoc, qname);
}
public SOAPElement setElementQName(QName newName) throws SOAPException {
BodyElementImpl copy =
new BodyElement1_1Impl((SOAPDocumentImpl) getOwnerDocument(), newName);
return replaceElementWithSOAPElement(this,copy);
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
import javax.xml.namespace.QName;
import javax.xml.soap.DetailEntry;
import javax.xml.soap.Name;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.DetailImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
public class Detail1_1Impl extends DetailImpl {
public Detail1_1Impl(SOAPDocumentImpl ownerDoc, String prefix) {
super(ownerDoc, NameImpl.createDetail1_1Name(prefix));
}
public Detail1_1Impl(SOAPDocumentImpl ownerDoc) {
super(ownerDoc, NameImpl.createDetail1_1Name());
}
protected DetailEntry createDetailEntry(Name name) {
return new DetailEntry1_1Impl(
(SOAPDocumentImpl) getOwnerDocument(),
name);
}
protected DetailEntry createDetailEntry(QName name) {
return new DetailEntry1_1Impl(
(SOAPDocumentImpl) getOwnerDocument(),
name);
}
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.DetailEntryImpl;
public class DetailEntry1_1Impl extends DetailEntryImpl {
public DetailEntry1_1Impl(SOAPDocumentImpl ownerDoc, Name qname) {
super(ownerDoc, qname);
}
public DetailEntry1_1Impl(SOAPDocumentImpl ownerDoc, QName qname) {
super(ownerDoc, qname);
}
public SOAPElement setElementQName(QName newName) throws SOAPException {
DetailEntryImpl copy =
new DetailEntry1_1Impl((SOAPDocumentImpl) getOwnerDocument(), newName);
return replaceElementWithSOAPElement(this,copy);
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
import javax.xml.soap.SOAPException;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
public class Envelope1_1Impl extends EnvelopeImpl {
public Envelope1_1Impl(SOAPDocumentImpl ownerDoc, String prefix){
super(ownerDoc, NameImpl.createEnvelope1_1Name(prefix));
}
Envelope1_1Impl(
SOAPDocumentImpl ownerDoc,
String prefix,
boolean createHeader,
boolean createBody)
throws SOAPException {
super(
ownerDoc,
NameImpl.createEnvelope1_1Name(prefix),
createHeader,
createBody);
}
protected NameImpl getBodyName(String prefix) {
return NameImpl.createBody1_1Name(prefix);
}
protected NameImpl getHeaderName(String prefix) {
return NameImpl.createHeader1_1Name(prefix);
}
}

View File

@@ -0,0 +1,387 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
import java.util.Iterator;
import java.util.Locale;
import java.util.logging.Logger;
import java.util.logging.Level;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPFaultElement;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.Name;
import javax.xml.soap.Name;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.*;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
public class Fault1_1Impl extends FaultImpl {
protected static final Logger log =
Logger.getLogger(
LogDomainConstants.SOAP_VER1_1_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.ver1_1.LocalStrings");
public Fault1_1Impl(SOAPDocumentImpl ownerDocument, String prefix) {
super(ownerDocument, NameImpl.createFault1_1Name(prefix));
}
protected NameImpl getDetailName() {
return NameImpl.createDetail1_1Name();
}
protected NameImpl getFaultCodeName() {
return NameImpl.createFromUnqualifiedName("faultcode");
}
protected NameImpl getFaultStringName() {
return NameImpl.createFromUnqualifiedName("faultstring");
}
protected NameImpl getFaultActorName() {
return NameImpl.createFromUnqualifiedName("faultactor");
}
protected DetailImpl createDetail() {
return new Detail1_1Impl(
((SOAPDocument) getOwnerDocument()).getDocument());
}
protected FaultElementImpl createSOAPFaultElement(String localName) {
return new FaultElement1_1Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
localName);
}
protected void checkIfStandardFaultCode(String faultCode, String uri)
throws SOAPException {
// SOAP 1.1 doesn't seem to mandate using faultcode from a particular
// set of values.
// Also need to be backward compatible.
}
protected void finallySetFaultCode(String faultcode) throws SOAPException {
this.faultCodeElement.addTextNode(faultcode);
}
public String getFaultCode() {
if (this.faultCodeElement == null)
findFaultCodeElement();
return this.faultCodeElement.getValue();
}
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);
}
public QName getFaultCodeAsQName() {
String faultcodeString = getFaultCode();
if (faultcodeString == null) {
return null;
}
if (this.faultCodeElement == null)
findFaultCodeElement();
return convertCodeToQName(faultcodeString, this.faultCodeElement);
}
public void setFaultString(String faultString) throws SOAPException {
if (this.faultStringElement == null)
findFaultStringElement();
if (this.faultStringElement == null)
this.faultStringElement = addSOAPFaultElement("faultstring");
else {
this.faultStringElement.removeContents();
//this.faultStringElement.removeAttributeNS("http://www.w3.org/XML/1998/namespace", "lang");
this.faultStringElement.removeAttribute("xml:lang");
}
this.faultStringElement.addTextNode(faultString);
}
public String getFaultString() {
if (this.faultStringElement == null)
findFaultStringElement();
return this.faultStringElement.getValue();
}
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;
}
public void setFaultString(String faultString, Locale locale)
throws SOAPException {
setFaultString(faultString);
this.faultStringElement.addAttribute(
NameImpl.createFromTagName("xml:lang"),
localeToXmlLang(locale));
}
protected boolean isStandardFaultElement(String localName) {
if (localName.equalsIgnoreCase("detail") ||
localName.equalsIgnoreCase("faultcode") ||
localName.equalsIgnoreCase("faultstring") ||
localName.equalsIgnoreCase("faultactor")) {
return true;
}
return false;
}
public void appendFaultSubcode(QName subcode) {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
"appendFaultSubcode");
throw new UnsupportedOperationException("Not supported in SOAP 1.1");
}
public void removeAllFaultSubcodes() {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
"removeAllFaultSubcodes");
throw new UnsupportedOperationException("Not supported in SOAP 1.1");
}
public Iterator getFaultSubcodes() {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
"getFaultSubcodes");
throw new UnsupportedOperationException("Not supported in SOAP 1.1");
}
public String getFaultReasonText(Locale locale) {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
"getFaultReasonText");
throw new UnsupportedOperationException("Not supported in SOAP 1.1");
}
public Iterator getFaultReasonTexts() {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
"getFaultReasonTexts");
throw new UnsupportedOperationException("Not supported in SOAP 1.1");
}
public Iterator getFaultReasonLocales() {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
"getFaultReasonLocales");
throw new UnsupportedOperationException("Not supported in SOAP 1.1");
}
public void addFaultReasonText(String text, java.util.Locale locale)
throws SOAPException {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
"addFaultReasonText");
throw new UnsupportedOperationException("Not supported in SOAP 1.1");
}
public String getFaultRole() {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
"getFaultRole");
throw new UnsupportedOperationException("Not supported in SOAP 1.1");
}
public void setFaultRole(String uri) {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
"setFaultRole");
throw new UnsupportedOperationException("Not supported in SOAP 1.1");
}
public String getFaultNode() {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
"getFaultNode");
throw new UnsupportedOperationException("Not supported in SOAP 1.1");
}
public void setFaultNode(String uri) {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
"setFaultNode");
throw new UnsupportedOperationException("Not supported in SOAP 1.1");
}
protected QName getDefaultFaultCode() {
return new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "Server");
}
public SOAPElement addChildElement(SOAPElement element)
throws SOAPException {
String localName = element.getLocalName();
if ("Detail".equalsIgnoreCase(localName)) {
if (hasDetail()) {
log.severe("SAAJ0305.ver1_2.detail.exists.error");
throw new SOAPExceptionImpl("Cannot add Detail, Detail already exists");
}
}
return super.addChildElement(element);
}
protected FaultElementImpl createSOAPFaultElement(QName qname) {
return new FaultElement1_1Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
qname);
}
protected FaultElementImpl createSOAPFaultElement(Name qname) {
return new FaultElement1_1Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
(NameImpl)qname);
}
public void setFaultCode(String faultCode, String prefix, String uri)
throws SOAPException {
if (prefix == null || "".equals(prefix)) {
if (uri != null && !"".equals(uri)) {
prefix = getNamespacePrefix(uri);
if (prefix == null || "".equals(prefix)) {
prefix = "ns0";
}
}
}
if (this.faultCodeElement == null)
findFaultCodeElement();
if (this.faultCodeElement == null)
this.faultCodeElement = addFaultCodeElement();
else
this.faultCodeElement.removeContents();
if (uri == null || "".equals(uri)) {
if (prefix != null && !"".equals("prefix")) {
uri = this.faultCodeElement.getNamespaceURI(prefix);
}
}
if (uri == null || "".equals(uri)) {
if (prefix != null && !"".equals(prefix)) {
//cannot allow an empty URI for a non-Empty prefix
log.log(Level.SEVERE, "SAAJ0307.impl.no.ns.URI", new Object[]{prefix + ":" + faultCode});
throw new SOAPExceptionImpl("Empty/Null NamespaceURI specified for faultCode \"" + prefix + ":" + faultCode + "\"");
} else {
uri = "";
}
}
checkIfStandardFaultCode(faultCode, uri);
((FaultElementImpl) this.faultCodeElement).ensureNamespaceIsDeclared(prefix, uri);
if (prefix == null || "".equals(prefix)) {
finallySetFaultCode(faultCode);
} else {
finallySetFaultCode(prefix + ":" + faultCode);
}
}
private boolean standardFaultCode(String faultCode) {
if (faultCode.equals("VersionMismatch") || faultCode.equals("MustUnderstand")
|| faultCode.equals("Client") || faultCode.equals("Server")) {
return true;
}
if (faultCode.startsWith("VersionMismatch.") || faultCode.startsWith("MustUnderstand.")
|| faultCode.startsWith("Client.") || faultCode.startsWith("Server.")) {
return true;
}
return false;
}
public void setFaultActor(String faultActor) throws SOAPException {
if (this.faultActorElement == null)
findFaultActorElement();
if (this.faultActorElement != null)
this.faultActorElement.detachNode();
if (faultActor == null)
return;
this.faultActorElement =
createSOAPFaultElement(getFaultActorName());
this.faultActorElement.addTextNode(faultActor);
if (hasDetail()) {
insertBefore(this.faultActorElement, this.detail);
return;
}
addNode(this.faultActorElement);
}
}

View File

@@ -0,0 +1,81 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.FaultElementImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
public class FaultElement1_1Impl extends FaultElementImpl {
public FaultElement1_1Impl(SOAPDocumentImpl ownerDoc, NameImpl qname) {
super(ownerDoc, qname);
}
public FaultElement1_1Impl(SOAPDocumentImpl ownerDoc, QName qname) {
super(ownerDoc, qname);
}
public FaultElement1_1Impl(SOAPDocumentImpl ownerDoc,
String localName) {
super(ownerDoc, NameImpl.createFaultElement1_1Name(localName));
}
public FaultElement1_1Impl(SOAPDocumentImpl ownerDoc,
String localName,
String prefix) {
super(ownerDoc,
NameImpl.createFaultElement1_1Name(localName, prefix));
}
protected boolean isStandardFaultElement() {
String localName = elementQName.getLocalPart();
if (localName.equalsIgnoreCase("faultcode") ||
localName.equalsIgnoreCase("faultstring") ||
localName.equalsIgnoreCase("faultactor")) {
return true;
}
return false;
}
public SOAPElement setElementQName(QName newName) throws SOAPException {
if (!isStandardFaultElement()) {
FaultElement1_1Impl copy =
new FaultElement1_1Impl((SOAPDocumentImpl) getOwnerDocument(), newName);
return replaceElementWithSOAPElement(this,copy);
} else {
return super.setElementQName(newName);
}
}
}

View File

@@ -0,0 +1,97 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
import java.util.List;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.HeaderImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
public class Header1_1Impl extends HeaderImpl {
protected static final Logger log =
Logger.getLogger(LogDomainConstants.SOAP_VER1_1_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.ver1_1.LocalStrings");
public Header1_1Impl(SOAPDocumentImpl ownerDocument, String prefix) {
super(ownerDocument, NameImpl.createHeader1_1Name(prefix));
}
protected NameImpl getNotUnderstoodName() {
log.log(
Level.SEVERE,
"SAAJ0301.ver1_1.hdr.op.unsupported.in.SOAP1.1",
new String[] { "getNotUnderstoodName" });
throw new UnsupportedOperationException("Not supported by SOAP 1.1");
}
protected NameImpl getUpgradeName() {
return NameImpl.create(
"Upgrade",
getPrefix(),
SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE);
}
protected NameImpl getSupportedEnvelopeName() {
return NameImpl.create(
"SupportedEnvelope",
getPrefix(),
SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE);
}
public SOAPHeaderElement addNotUnderstoodHeaderElement(QName name)
throws SOAPException {
log.log(
Level.SEVERE,
"SAAJ0301.ver1_1.hdr.op.unsupported.in.SOAP1.1",
new String[] { "addNotUnderstoodHeaderElement" });
throw new UnsupportedOperationException("Not supported by SOAP 1.1");
}
protected SOAPHeaderElement createHeaderElement(Name name) {
return new HeaderElement1_1Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
name);
}
protected SOAPHeaderElement createHeaderElement(QName name) {
return new HeaderElement1_1Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
name);
}
}

View File

@@ -0,0 +1,121 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPElement;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.HeaderElementImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
public class HeaderElement1_1Impl extends HeaderElementImpl {
protected static final Logger log =
Logger.getLogger(LogDomainConstants.SOAP_VER1_1_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.ver1_1.LocalStrings");
public HeaderElement1_1Impl(SOAPDocumentImpl ownerDoc, Name qname) {
super(ownerDoc, qname);
}
public HeaderElement1_1Impl(SOAPDocumentImpl ownerDoc, QName qname) {
super(ownerDoc, qname);
}
public SOAPElement setElementQName(QName newName) throws SOAPException {
HeaderElementImpl copy =
new HeaderElement1_1Impl((SOAPDocumentImpl) getOwnerDocument(), newName);
return replaceElementWithSOAPElement(this,copy);
}
protected NameImpl getActorAttributeName() {
return NameImpl.create("actor", null, NameImpl.SOAP11_NAMESPACE);
}
// role not supported by SOAP 1.1
protected NameImpl getRoleAttributeName() {
log.log(
Level.SEVERE,
"SAAJ0302.ver1_1.hdr.attr.unsupported.in.SOAP1.1",
new String[] { "Role" });
throw new UnsupportedOperationException("Role not supported by SOAP 1.1");
}
protected NameImpl getMustunderstandAttributeName() {
return NameImpl.create("mustUnderstand", null, NameImpl.SOAP11_NAMESPACE);
}
// mustUnderstand attribute has literal value "1" or "0"
protected String getMustunderstandLiteralValue(boolean mustUnderstand) {
return (mustUnderstand == true ? "1" : "0");
}
protected boolean getMustunderstandAttributeValue(String mu) {
if ("1".equals(mu) || "true".equalsIgnoreCase(mu))
return true;
return false;
}
// relay not supported by SOAP 1.1
protected NameImpl getRelayAttributeName() {
log.log(
Level.SEVERE,
"SAAJ0302.ver1_1.hdr.attr.unsupported.in.SOAP1.1",
new String[] { "Relay" });
throw new UnsupportedOperationException("Relay not supported by SOAP 1.1");
}
protected String getRelayLiteralValue(boolean relayAttr) {
log.log(
Level.SEVERE,
"SAAJ0302.ver1_1.hdr.attr.unsupported.in.SOAP1.1",
new String[] { "Relay" });
throw new UnsupportedOperationException("Relay not supported by SOAP 1.1");
}
protected boolean getRelayAttributeValue(String mu) {
log.log(
Level.SEVERE,
"SAAJ0302.ver1_1.hdr.attr.unsupported.in.SOAP1.1",
new String[] { "Relay" });
throw new UnsupportedOperationException("Relay not supported by SOAP 1.1");
}
protected String getActorOrRole() {
return getActor();
}
}

View File

@@ -0,0 +1,125 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.ContentType;
import com.sun.xml.internal.messaging.saaj.soap.MessageImpl;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
public class Message1_1Impl extends MessageImpl implements SOAPConstants {
protected static final Logger log =
Logger.getLogger(LogDomainConstants.SOAP_VER1_1_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.ver1_1.LocalStrings");
public Message1_1Impl() {
super();
}
public Message1_1Impl(boolean isFastInfoset, boolean acceptFastInfoset) {
super(isFastInfoset, acceptFastInfoset);
}
public Message1_1Impl(SOAPMessage msg) {
super(msg);
}
// unused. can we delete this? - Kohsuke
public Message1_1Impl(MimeHeaders headers, InputStream in)
throws IOException, SOAPExceptionImpl {
super(headers, in);
}
public Message1_1Impl(MimeHeaders headers, ContentType ct, int stat, InputStream in)
throws SOAPExceptionImpl {
super(headers,ct,stat,in);
}
public SOAPPart getSOAPPart() {
if (soapPartImpl == null) {
soapPartImpl = new SOAPPart1_1Impl(this);
}
return soapPartImpl;
}
protected boolean isCorrectSoapVersion(int contentTypeId) {
return (contentTypeId & SOAP1_1_FLAG) != 0;
}
public String getAction() {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
new String[] { "Action" });
throw new UnsupportedOperationException("Operation not supported by SOAP 1.1");
}
public void setAction(String type) {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
new String[] { "Action" });
throw new UnsupportedOperationException("Operation not supported by SOAP 1.1");
}
public String getCharset() {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
new String[] { "Charset" });
throw new UnsupportedOperationException("Operation not supported by SOAP 1.1");
}
public void setCharset(String charset) {
log.log(
Level.SEVERE,
"SAAJ0303.ver1_1.msg.op.unsupported.in.SOAP1.1",
new String[] { "Charset" });
throw new UnsupportedOperationException("Operation not supported by SOAP 1.1");
}
protected String getExpectedContentType() {
return isFastInfoset ? "application/fastinfoset" : "text/xml";
}
protected String getExpectedAcceptHeader() {
String accept = "text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2";
return acceptFastInfoset ? ("application/fastinfoset, " + accept) : accept;
}
}

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import javax.xml.namespace.QName;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPFactoryImpl;
public class SOAPFactory1_1Impl extends SOAPFactoryImpl {
protected SOAPDocumentImpl createDocument() {
return (new SOAPPart1_1Impl()).getDocument();
}
public Detail createDetail() throws SOAPException {
return new Detail1_1Impl(createDocument());
}
public SOAPFault createFault(String reasonText, QName faultCode)
throws SOAPException {
if (faultCode == null) {
throw new IllegalArgumentException("faultCode argument for createFault was passed NULL");
}
if (reasonText == null) {
throw new IllegalArgumentException("reasonText argument for createFault was passed NULL");
}
Fault1_1Impl fault = new Fault1_1Impl(createDocument(), null);
fault.setFaultCode(faultCode);
fault.setFaultString(reasonText);
return fault;
}
public SOAPFault createFault() throws SOAPException {
Fault1_1Impl fault = new Fault1_1Impl(createDocument(), null);
fault.setFaultCode(fault.getDefaultFaultCode());
fault.setFaultString("Fault string, and possibly fault code, not set");
return fault;
}
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.MessageFactoryImpl;
import com.sun.xml.internal.messaging.saaj.soap.MessageImpl;
public class SOAPMessageFactory1_1Impl extends MessageFactoryImpl {
public SOAPMessage createMessage() throws SOAPException {
return new Message1_1Impl();
}
public SOAPMessage createMessage(boolean isFastInfoset,
boolean acceptFastInfoset) throws SOAPException
{
return new Message1_1Impl(isFastInfoset, acceptFastInfoset);
}
public SOAPMessage createMessage(MimeHeaders headers, InputStream in) throws IOException, SOAPExceptionImpl {
if (headers == null) {
headers = new MimeHeaders();
}
if (getContentType(headers) == null) {
headers.setHeader("Content-Type", SOAPConstants.SOAP_1_1_CONTENT_TYPE);
}
MessageImpl msg = new Message1_1Impl(headers, in);
msg.setLazyAttachments(lazyAttachments);
return msg;
}
}

View File

@@ -0,0 +1,93 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import javax.xml.transform.Source;
import com.sun.xml.internal.messaging.saaj.soap.*;
import com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
import com.sun.xml.internal.messaging.saaj.util.XMLDeclarationParser;
public class SOAPPart1_1Impl extends SOAPPartImpl implements SOAPConstants {
protected static final Logger log =
Logger.getLogger(LogDomainConstants.SOAP_VER1_1_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.ver1_1.LocalStrings");
public SOAPPart1_1Impl() {
super();
}
public SOAPPart1_1Impl(MessageImpl message) {
super(message);
}
protected String getContentType() {
return isFastInfoset() ? "application/fastinfoset" : "text/xml";
}
protected Envelope createEnvelopeFromSource() throws SOAPException {
// Record the presence of xml declaration before the envelope gets
// created.
XMLDeclarationParser parser = lookForXmlDecl();
Source tmp = source;
source = null;
EnvelopeImpl envelope =
(EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);
if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
}
if (parser != null && !omitXmlDecl) {
envelope.setOmitXmlDecl("no");
envelope.setXmlDecl(parser.getXmlDeclaration());
envelope.setCharsetEncoding(parser.getEncoding());
}
return envelope;
}
protected Envelope createEmptyEnvelope(String prefix)
throws SOAPException {
return new Envelope1_1Impl(getDocument(), prefix, true, true);
}
protected SOAPPartImpl duplicateType() {
return new SOAPPart1_1Impl();
}
}

View File

@@ -0,0 +1,197 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
import java.util.logging.Logger;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import org.w3c.dom.Node;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.BodyImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
public class Body1_2Impl extends BodyImpl {
protected static final Logger log =
Logger.getLogger(Body1_2Impl.class.getName(),
"com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
public Body1_2Impl(SOAPDocumentImpl ownerDocument, String prefix) {
super(ownerDocument, NameImpl.createBody1_2Name(prefix));
}
protected NameImpl getFaultName(String name) {
return NameImpl.createFault1_2Name(name, null);
}
protected SOAPBodyElement createBodyElement(Name name) {
return new BodyElement1_2Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
name);
}
protected SOAPBodyElement createBodyElement(QName name) {
return new BodyElement1_2Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
name);
}
protected QName getDefaultFaultCode() {
return SOAPConstants.SOAP_RECEIVER_FAULT;
}
public SOAPFault addFault() throws SOAPException {
if (hasAnyChildElement()) {
log.severe("SAAJ0402.ver1_2.only.fault.allowed.in.body");
throw new SOAPExceptionImpl(
"No other element except Fault allowed in SOAPBody");
}
return super.addFault();
}
/*
* Override setEncodingStyle of ElementImpl to restrict adding encodingStyle
* attribute to SOAP Body (SOAP 1.2 spec, part 1, section 5.1.1)
*/
public void setEncodingStyle(String encodingStyle) throws SOAPException {
log.severe("SAAJ0401.ver1_2.no.encodingstyle.in.body");
throw new SOAPExceptionImpl("encodingStyle attribute cannot appear on Body");
}
/*
* Override addAttribute of ElementImpl to restrict adding encodingStyle
* attribute to SOAP Body (SOAP 1.2 spec, part 1, section 5.1.1)
*/
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);
}
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);
}
protected boolean isFault(SOAPElement child) {
return (child.getElementName().getURI().equals(
SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE) &&
child.getElementName().getLocalName().equals(
"Fault"));
}
protected SOAPFault createFaultElement() {
return new Fault1_2Impl(
((SOAPDocument) getOwnerDocument()).getDocument(), getPrefix());
}
/*
* section 5.4 of SOAP1.2 candidate recommendation says that a
* SOAP message MUST contain a single Fault element as the only
* child element of the SOAP Body.
*/
public SOAPBodyElement addBodyElement(Name name) throws SOAPException {
if (hasFault()) {
log.severe("SAAJ0402.ver1_2.only.fault.allowed.in.body");
throw new SOAPExceptionImpl(
"No other element except Fault allowed in SOAPBody");
}
return super.addBodyElement(name);
}
public SOAPBodyElement addBodyElement(QName name) throws SOAPException {
if (hasFault()) {
log.severe("SAAJ0402.ver1_2.only.fault.allowed.in.body");
throw new SOAPExceptionImpl(
"No other element except Fault allowed in SOAPBody");
}
return super.addBodyElement(name);
}
protected SOAPElement addElement(Name name) throws SOAPException {
if (hasFault()) {
log.severe("SAAJ0402.ver1_2.only.fault.allowed.in.body");
throw new SOAPExceptionImpl(
"No other element except Fault allowed in SOAPBody");
}
return super.addElement(name);
}
protected SOAPElement addElement(QName name) throws SOAPException {
if (hasFault()) {
log.severe("SAAJ0402.ver1_2.only.fault.allowed.in.body");
throw new SOAPExceptionImpl(
"No other element except Fault allowed in SOAPBody");
}
return super.addElement(name);
}
public SOAPElement addChildElement(Name name) throws SOAPException {
if (hasFault()) {
log.severe("SAAJ0402.ver1_2.only.fault.allowed.in.body");
throw new SOAPExceptionImpl(
"No other element except Fault allowed in SOAPBody");
}
return super.addChildElement(name);
}
public SOAPElement addChildElement(QName name) throws SOAPException {
if (hasFault()) {
log.severe("SAAJ0402.ver1_2.only.fault.allowed.in.body");
throw new SOAPExceptionImpl(
"No other element except Fault allowed in SOAPBody");
}
return super.addChildElement(name);
}
private boolean hasAnyChildElement() {
Node currentNode = getFirstChild();
while (currentNode != null) {
if (currentNode.getNodeType() == Node.ELEMENT_NODE)
return true;
currentNode = currentNode.getNextSibling();
}
return false;
}
}

View File

@@ -0,0 +1,56 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPElement;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.BodyElementImpl;
public class BodyElement1_2Impl extends BodyElementImpl {
public BodyElement1_2Impl(SOAPDocumentImpl ownerDoc, Name qname) {
super(ownerDoc, qname);
}
public BodyElement1_2Impl(SOAPDocumentImpl ownerDoc, QName qname) {
super(ownerDoc, qname);
}
public SOAPElement setElementQName(QName newName) throws SOAPException {
BodyElementImpl copy =
new BodyElement1_2Impl((SOAPDocumentImpl) getOwnerDocument(), newName);
return replaceElementWithSOAPElement(this,copy);
}
}

View File

@@ -0,0 +1,95 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.DetailImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
public class Detail1_2Impl extends DetailImpl {
protected static final Logger log =
Logger.getLogger(Detail1_2Impl.class.getName(),
"com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
public Detail1_2Impl(SOAPDocumentImpl ownerDocument, String prefix) {
super(ownerDocument, NameImpl.createSOAP12Name("Detail", prefix));
}
public Detail1_2Impl(SOAPDocumentImpl ownerDocument) {
super(ownerDocument, NameImpl.createSOAP12Name("Detail"));
}
protected DetailEntry createDetailEntry(Name name) {
return new DetailEntry1_2Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
name);
}
protected DetailEntry createDetailEntry(QName name) {
return new DetailEntry1_2Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
name);
}
/*
* Override setEncodingStyle of ElementImpl to restrict adding encodingStyle
* attribute to SOAP Detail (SOAP 1.2 spec, part 1, section 5.1.1)
*/
public void setEncodingStyle(String encodingStyle) throws SOAPException {
log.severe("SAAJ0403.ver1_2.no.encodingStyle.in.detail");
throw new SOAPExceptionImpl("EncodingStyle attribute cannot appear in Detail");
}
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);
}
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);
}
}

View File

@@ -0,0 +1,56 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPElement;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.DetailEntryImpl;
public class DetailEntry1_2Impl extends DetailEntryImpl {
public DetailEntry1_2Impl(SOAPDocumentImpl ownerDoc, Name qname) {
super(ownerDoc, qname);
}
public DetailEntry1_2Impl(SOAPDocumentImpl ownerDoc, QName qname) {
super(ownerDoc, qname);
}
public SOAPElement setElementQName(QName newName) throws SOAPException {
DetailEntryImpl copy =
new DetailEntry1_2Impl((SOAPDocumentImpl) getOwnerDocument(), newName);
return replaceElementWithSOAPElement(this,copy);
}
}

View File

@@ -0,0 +1,147 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
import java.util.logging.Logger;
import java.util.logging.Level;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
public class Envelope1_2Impl extends EnvelopeImpl {
protected static final Logger log =
Logger.getLogger(Envelope1_2Impl.class.getName(),
"com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
public Envelope1_2Impl(SOAPDocumentImpl ownerDoc, String prefix) {
super(ownerDoc, NameImpl.createEnvelope1_2Name(prefix));
}
public Envelope1_2Impl(
SOAPDocumentImpl ownerDoc,
String prefix,
boolean createHeader,
boolean createBody)
throws SOAPException {
super(
ownerDoc,
NameImpl.createEnvelope1_2Name(prefix),
createHeader,
createBody);
}
protected NameImpl getBodyName(String prefix) {
return NameImpl.createBody1_2Name(prefix);
}
protected NameImpl getHeaderName(String prefix) {
return NameImpl.createHeader1_2Name(prefix);
}
/*
* Override setEncodingStyle of ElementImpl to restrict adding encodingStyle
* attribute to SOAP Envelope (SOAP 1.2 spec, part 1, section 5.1.1)
*/
public void setEncodingStyle(String encodingStyle) throws SOAPException {
log.severe("SAAJ0404.ver1_2.no.encodingStyle.in.envelope");
throw new SOAPExceptionImpl("encodingStyle attribute cannot appear on Envelope");
}
/*
* Override addAttribute of ElementImpl to restrict adding encodingStyle
* attribute to SOAP Envelope (SOAP 1.2 spec, part 1, section 5.1.1)
*/
public SOAPElement addAttribute(Name name, String value)
throws SOAPException {
if (name.getLocalName().equals("encodingStyle")
&& name.getURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
setEncodingStyle(value);
}
return super.addAttribute(name, value);
}
public SOAPElement addAttribute(QName name, String value)
throws SOAPException {
if (name.getLocalPart().equals("encodingStyle")
&& name.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
setEncodingStyle(value);
}
return super.addAttribute(name, value);
}
/*
* Override addChildElement method to ensure that no element
* is added after body in SOAP 1.2.
*/
public SOAPElement addChildElement(Name name) throws SOAPException {
// check if body already exists
if (getBody() != null) {
log.severe("SAAJ0405.ver1_2.body.must.last.in.envelope");
throw new SOAPExceptionImpl(
"Body must be the last element in" + " SOAP Envelope");
}
return super.addChildElement(name);
}
public SOAPElement addChildElement(QName name) throws SOAPException {
// check if body already exists
if (getBody() != null) {
log.severe("SAAJ0405.ver1_2.body.must.last.in.envelope");
throw new SOAPExceptionImpl(
"Body must be the last element in" + " SOAP Envelope");
}
return super.addChildElement(name);
}
/*
* Ideally we should be overriding other addChildElement() methods as well
* but we are not adding them here since internally all those call the
* method addChildElement(Name name).
* In future, if this behaviour changes, then we would need to override
* all the rest of them as well.
*
*/
public SOAPElement addTextNode(String text) throws SOAPException {
log.log(
Level.SEVERE,
"SAAJ0416.ver1_2.adding.text.not.legal",
getElementQName());
throw new SOAPExceptionImpl("Adding text to SOAP 1.2 Envelope is not legal");
}
}

View File

@@ -0,0 +1,562 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
import java.util.*;
import java.util.logging.Logger;
import java.util.logging.Level;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.*;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
public class Fault1_2Impl extends FaultImpl {
protected static final Logger log =
Logger.getLogger(
LogDomainConstants.SOAP_VER1_2_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
private static final QName textName =
new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Text");
private final QName valueName =
new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Value", getPrefix());
private final QName subcodeName =
new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Subcode", getPrefix());
private SOAPElement innermostSubCodeElement = null;
public Fault1_2Impl(SOAPDocumentImpl ownerDoc, String name, String prefix) {
super(ownerDoc, NameImpl.createFault1_2Name(name, prefix));
}
public Fault1_2Impl(SOAPDocumentImpl ownerDocument, String prefix) {
super(ownerDocument, NameImpl.createFault1_2Name(null, prefix));
}
protected NameImpl getDetailName() {
return NameImpl.createSOAP12Name("Detail", getPrefix());
}
protected NameImpl getFaultCodeName() {
return NameImpl.createSOAP12Name("Code", getPrefix());
}
protected NameImpl getFaultStringName() {
return getFaultReasonName();
}
protected NameImpl getFaultActorName() {
return getFaultRoleName();
}
private NameImpl getFaultRoleName() {
return NameImpl.createSOAP12Name("Role", getPrefix());
}
private NameImpl getFaultReasonName() {
return NameImpl.createSOAP12Name("Reason", getPrefix());
}
private NameImpl getFaultReasonTextName() {
return NameImpl.createSOAP12Name("Text", getPrefix());
}
private NameImpl getFaultNodeName() {
return NameImpl.createSOAP12Name("Node", getPrefix());
}
private static NameImpl getXmlLangName() {
return NameImpl.createXmlName("lang");
}
protected DetailImpl createDetail() {
return new Detail1_2Impl(
((SOAPDocument) getOwnerDocument()).getDocument());
}
protected FaultElementImpl createSOAPFaultElement(String localName) {
return new FaultElement1_2Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
localName);
}
protected void checkIfStandardFaultCode(String faultCode, String uri)
throws SOAPException {
QName qname = new QName(uri, faultCode);
if (SOAPConstants.SOAP_DATAENCODINGUNKNOWN_FAULT.equals(qname) ||
SOAPConstants.SOAP_MUSTUNDERSTAND_FAULT.equals(qname) ||
SOAPConstants.SOAP_RECEIVER_FAULT.equals(qname) ||
SOAPConstants.SOAP_SENDER_FAULT.equals(qname) ||
SOAPConstants.SOAP_VERSIONMISMATCH_FAULT.equals(qname))
return;
log.log(
Level.SEVERE,
"SAAJ0435.ver1_2.code.not.standard",
qname);
throw new SOAPExceptionImpl(qname + " is not a standard Code value");
}
protected void finallySetFaultCode(String faultcode) throws SOAPException {
SOAPElement value = this.faultCodeElement.addChildElement(valueName);
value.addTextNode(faultcode);
}
private void findReasonElement() {
findFaultStringElement();
}
public Iterator getFaultReasonTexts() throws SOAPException {
// Fault Reason has similar semantics as faultstring
if (this.faultStringElement == null)
findReasonElement();
Iterator eachTextElement =
this.faultStringElement.getChildElements(textName);
List texts = new ArrayList();
while (eachTextElement.hasNext()) {
SOAPElement textElement = (SOAPElement) eachTextElement.next();
Locale thisLocale = getLocale(textElement);
if (thisLocale == null) {
log.severe("SAAJ0431.ver1_2.xml.lang.missing");
throw new SOAPExceptionImpl("\"xml:lang\" attribute is not present on the Text element");
}
texts.add(textElement.getValue());
}
if (texts.isEmpty()) {
log.severe("SAAJ0434.ver1_2.text.element.not.present");
throw new SOAPExceptionImpl("env:Text must be present inside env:Reason");
}
return texts.iterator();
}
public void addFaultReasonText(String text, java.util.Locale locale)
throws SOAPException {
if (locale == null) {
log.severe("SAAJ0430.ver1_2.locale.required");
throw new SOAPException("locale is required and must not be null");
}
// Fault Reason has similar semantics as faultstring
if (this.faultStringElement == null)
findReasonElement();
SOAPElement reasonText;
if (this.faultStringElement == null) {
this.faultStringElement = addSOAPFaultElement("Reason");
reasonText =
this.faultStringElement.addChildElement(
getFaultReasonTextName());
} else {
removeDefaultFaultString();
reasonText = getFaultReasonTextElement(locale);
if (reasonText != null) {
reasonText.removeContents();
} else {
reasonText =
this.faultStringElement.addChildElement(
getFaultReasonTextName());
}
}
String xmlLang = localeToXmlLang(locale);
reasonText.addAttribute(getXmlLangName(), xmlLang);
reasonText.addTextNode(text);
}
private void removeDefaultFaultString() throws SOAPException {
SOAPElement reasonText = getFaultReasonTextElement(Locale.getDefault());
if (reasonText != null) {
String defaultFaultString =
"Fault string, and possibly fault code, not set";
if (defaultFaultString.equals(reasonText.getValue())) {
reasonText.detachNode();
}
}
}
public String getFaultReasonText(Locale locale) throws SOAPException {
if (locale == null)
return null;
// Fault Reason has similar semantics as faultstring
if (this.faultStringElement == null)
findReasonElement();
if (this.faultStringElement != null) {
SOAPElement textElement = getFaultReasonTextElement(locale);
if (textElement != null) {
textElement.normalize();
return textElement.getFirstChild().getNodeValue();
}
}
return null;
}
public Iterator getFaultReasonLocales() throws SOAPException {
// Fault Reason has similar semantics as faultstring
if (this.faultStringElement == null)
findReasonElement();
Iterator eachTextElement =
this.faultStringElement.getChildElements(textName);
List localeSet = new ArrayList();
while (eachTextElement.hasNext()) {
SOAPElement textElement = (SOAPElement) eachTextElement.next();
Locale thisLocale = getLocale(textElement);
if (thisLocale == null) {
log.severe("SAAJ0431.ver1_2.xml.lang.missing");
throw new SOAPExceptionImpl("\"xml:lang\" attribute is not present on the Text element");
}
localeSet.add(thisLocale);
}
if (localeSet.isEmpty()) {
log.severe("SAAJ0434.ver1_2.text.element.not.present");
throw new SOAPExceptionImpl("env:Text elements with mandatory xml:lang attributes must be present inside env:Reason");
}
return localeSet.iterator();
}
public Locale getFaultStringLocale() {
Locale locale = null;
try {
locale = (Locale) getFaultReasonLocales().next();
} catch (SOAPException e) {}
return locale;
}
/*
* This method assumes that locale and faultStringElement are non-null
*/
private SOAPElement getFaultReasonTextElement(Locale locale)
throws SOAPException {
// Fault Reason has similar semantics as faultstring
Iterator eachTextElement =
this.faultStringElement.getChildElements(textName);
while (eachTextElement.hasNext()) {
SOAPElement textElement = (SOAPElement) eachTextElement.next();
Locale thisLocale = getLocale(textElement);
if (thisLocale == null) {
log.severe("SAAJ0431.ver1_2.xml.lang.missing");
throw new SOAPExceptionImpl("\"xml:lang\" attribute is not present on the Text element");
}
if (thisLocale.equals(locale)) {
return textElement;
}
}
return null;
}
public String getFaultNode() {
SOAPElement faultNode = findChild(getFaultNodeName());
if (faultNode == null) {
return null;
}
return faultNode.getValue();
}
public void setFaultNode(String uri) throws SOAPException {
SOAPElement faultNode = findChild(getFaultNodeName());
if (faultNode != null) {
faultNode.detachNode();
}
faultNode = createSOAPFaultElement(getFaultNodeName());
faultNode = faultNode.addTextNode(uri);
if (getFaultRole() != null) {
insertBefore(faultNode, this.faultActorElement);
return;
}
if (hasDetail()) {
insertBefore(faultNode, this.detail);
return;
}
addNode(faultNode);
}
public String getFaultRole() {
return getFaultActor();
}
public void setFaultRole(String uri) throws SOAPException {
if (this.faultActorElement == null)
findFaultActorElement();
if (this.faultActorElement != null)
this.faultActorElement.detachNode();
this.faultActorElement =
createSOAPFaultElement(getFaultActorName());
this.faultActorElement.addTextNode(uri);
if (hasDetail()) {
insertBefore(this.faultActorElement, this.detail);
return;
}
addNode(this.faultActorElement);
}
public String getFaultCode() {
if (this.faultCodeElement == null)
findFaultCodeElement();
Iterator codeValues =
this.faultCodeElement.getChildElements(valueName);
return ((SOAPElement) codeValues.next()).getValue();
}
public QName getFaultCodeAsQName() {
String faultcode = getFaultCode();
if (faultcode == null) {
return null;
}
if (this.faultCodeElement == null)
findFaultCodeElement();
Iterator valueElements =
this.faultCodeElement.getChildElements(valueName);
return convertCodeToQName(
faultcode,
(SOAPElement) valueElements.next());
}
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()));
}
public String getFaultString() {
String reason = null;
try {
//reason = getFaultReasonText(Locale.getDefault());
//if (reason == null)
reason = (String) getFaultReasonTexts().next();
} catch (SOAPException e) {}
return reason;
}
public void setFaultString(String faultString) throws SOAPException {
addFaultReasonText(faultString, Locale.getDefault());
}
public void setFaultString(
String faultString,
Locale locale)
throws SOAPException {
addFaultReasonText(faultString, locale);
}
public void appendFaultSubcode(QName subcode) throws SOAPException {
if (subcode == null) {
return;
}
if (subcode.getNamespaceURI() == null ||
"".equals(subcode.getNamespaceURI())) {
log.severe("SAAJ0432.ver1_2.subcode.not.ns.qualified");
throw new SOAPExceptionImpl("A Subcode must be namespace-qualified");
}
if (innermostSubCodeElement == null) {
if (faultCodeElement == null)
findFaultCodeElement();
innermostSubCodeElement = faultCodeElement;
}
String prefix = null;
if (subcode.getPrefix() == null || "".equals(subcode.getPrefix())) {
prefix =
((ElementImpl) innermostSubCodeElement).getNamespacePrefix(
subcode.getNamespaceURI());
} else
prefix = subcode.getPrefix();
if (prefix == null || "".equals(prefix)) {
prefix = "ns1";
}
innermostSubCodeElement =
innermostSubCodeElement.addChildElement(subcodeName);
SOAPElement subcodeValueElement =
innermostSubCodeElement.addChildElement(valueName);
((ElementImpl) subcodeValueElement).ensureNamespaceIsDeclared(
prefix,
subcode.getNamespaceURI());
subcodeValueElement.addTextNode(prefix + ":" + subcode.getLocalPart());
}
public void removeAllFaultSubcodes() {
if (this.faultCodeElement == null)
findFaultCodeElement();
Iterator subcodeElements =
this.faultCodeElement.getChildElements(subcodeName);
if (subcodeElements.hasNext()) {
SOAPElement subcode = (SOAPElement) subcodeElements.next();
subcode.detachNode();
}
}
public Iterator getFaultSubcodes() {
if (this.faultCodeElement == null)
findFaultCodeElement();
final List subcodeList = new ArrayList();
SOAPElement currentCodeElement = this.faultCodeElement;
Iterator subcodeElements =
currentCodeElement.getChildElements(subcodeName);
while (subcodeElements.hasNext()) {
currentCodeElement = (ElementImpl) subcodeElements.next();
Iterator valueElements =
currentCodeElement.getChildElements(valueName);
SOAPElement valueElement = (SOAPElement) valueElements.next();
String code = valueElement.getValue();
subcodeList.add(convertCodeToQName(code, valueElement));
subcodeElements = currentCodeElement.getChildElements(subcodeName);
}
//return subcodeList.iterator();
return new Iterator() {
Iterator subCodeIter = subcodeList.iterator();
public boolean hasNext() {
return subCodeIter.hasNext();
}
public Object next() {
return subCodeIter.next();
}
public void remove() {
throw new UnsupportedOperationException(
"Method remove() not supported on SubCodes Iterator");
}
};
}
private static Locale getLocale(SOAPElement reasonText) {
return xmlLangToLocale(reasonText.getAttributeValue(getXmlLangName()));
}
/*
* Override setEncodingStyle of ElementImpl to restrict adding encodingStyle
* attribute to SOAP Fault (SOAP 1.2 spec, part 1, section 5.1.1)
*/
public void setEncodingStyle(String encodingStyle) throws SOAPException {
log.severe("SAAJ0407.ver1_2.no.encodingStyle.in.fault");
throw new SOAPExceptionImpl("encodingStyle attribute cannot appear on Fault");
}
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);
}
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);
}
public SOAPElement addTextNode(String text) throws SOAPException {
log.log(
Level.SEVERE,
"SAAJ0416.ver1_2.adding.text.not.legal",
getElementQName());
throw new SOAPExceptionImpl("Adding text to SOAP 1.2 Fault is not legal");
}
public SOAPElement addChildElement(SOAPElement element)
throws SOAPException {
String localName = element.getLocalName();
if ("Detail".equalsIgnoreCase(localName)) {
if (hasDetail()) {
log.severe("SAAJ0436.ver1_2.detail.exists.error");
throw new SOAPExceptionImpl("Cannot add Detail, Detail already exists");
}
String uri = element.getElementQName().getNamespaceURI();
if (!uri.equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
log.severe("SAAJ0437.ver1_2.version.mismatch.error");
throw new SOAPExceptionImpl("Cannot add Detail, Incorrect SOAP version specified for Detail element");
}
}
if (element instanceof Detail1_2Impl) {
ElementImpl importedElement = (ElementImpl) importElement(element);
addNode(importedElement);
return convertToSoapElement(importedElement);
} else
return super.addChildElement(element);
}
protected boolean isStandardFaultElement(String localName) {
if (localName.equalsIgnoreCase("code") ||
localName.equalsIgnoreCase("reason") ||
localName.equalsIgnoreCase("node") ||
localName.equalsIgnoreCase("role") ||
localName.equalsIgnoreCase("detail")) {
return true;
}
return false;
}
protected QName getDefaultFaultCode() {
return SOAPConstants.SOAP_SENDER_FAULT;
}
protected FaultElementImpl createSOAPFaultElement(QName qname) {
return new FaultElement1_2Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
qname);
}
protected FaultElementImpl createSOAPFaultElement(Name qname) {
return new FaultElement1_2Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
(NameImpl)qname);
}
public void setFaultActor(String faultActor) throws SOAPException {
this.setFaultRole(faultActor);
}
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.Name;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.FaultElementImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
public class FaultElement1_2Impl extends FaultElementImpl {
public FaultElement1_2Impl(SOAPDocumentImpl ownerDoc, NameImpl qname) {
super(ownerDoc, qname);
}
public FaultElement1_2Impl(SOAPDocumentImpl ownerDoc, QName qname) {
super(ownerDoc, qname);
}
public FaultElement1_2Impl(SOAPDocumentImpl ownerDoc, String localName) {
super(ownerDoc, NameImpl.createSOAP12Name(localName));
}
protected boolean isStandardFaultElement() {
String localName = elementQName.getLocalPart();
if (localName.equalsIgnoreCase("code") ||
localName.equalsIgnoreCase("reason") ||
localName.equalsIgnoreCase("node") ||
localName.equalsIgnoreCase("role")) {
return true;
}
return false;
}
public SOAPElement setElementQName(QName newName) throws SOAPException {
if (!isStandardFaultElement()) {
FaultElement1_2Impl copy =
new FaultElement1_2Impl((SOAPDocumentImpl) getOwnerDocument(), newName);
return replaceElementWithSOAPElement(this,copy);
} else {
return super.setElementQName(newName);
}
}
public void setEncodingStyle(String encodingStyle) throws SOAPException {
log.severe("SAAJ0408.ver1_2.no.encodingStyle.in.fault.child");
throw new SOAPExceptionImpl("encodingStyle attribute cannot appear on a Fault child element");
}
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);
}
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);
}
}

View File

@@ -0,0 +1,159 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
import java.util.List;
import java.util.Iterator;
import java.util.logging.Logger;
import java.util.logging.Level;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.HeaderElementImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.HeaderImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
public class Header1_2Impl extends HeaderImpl {
protected static final Logger log =
Logger.getLogger(
LogDomainConstants.SOAP_VER1_2_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
public Header1_2Impl(SOAPDocumentImpl ownerDocument, String prefix) {
super(ownerDocument, NameImpl.createHeader1_2Name(prefix));
}
protected NameImpl getNotUnderstoodName() {
return NameImpl.createNotUnderstood1_2Name(null);
}
protected NameImpl getUpgradeName() {
return NameImpl.createUpgrade1_2Name(null);
}
protected NameImpl getSupportedEnvelopeName() {
return NameImpl.createSupportedEnvelope1_2Name(null);
}
public SOAPHeaderElement addNotUnderstoodHeaderElement(final QName sourceName)
throws SOAPException {
if (sourceName == null) {
log.severe("SAAJ0410.ver1_2.no.null.to.addNotUnderstoodHeader");
throw new SOAPException("Cannot pass NULL to addNotUnderstoodHeaderElement");
}
if ("".equals(sourceName.getNamespaceURI())) {
log.severe("SAAJ0417.ver1_2.qname.not.ns.qualified");
throw new SOAPException("The qname passed to addNotUnderstoodHeaderElement must be namespace-qualified");
}
String prefix = sourceName.getPrefix();
if ("".equals(prefix)) {
prefix = "ns1";
}
Name notunderstoodName = getNotUnderstoodName();
SOAPHeaderElement notunderstoodHeaderElement =
(SOAPHeaderElement) addChildElement(notunderstoodName);
notunderstoodHeaderElement.addAttribute(
NameImpl.createFromUnqualifiedName("qname"),
getQualifiedName(
new QName(
sourceName.getNamespaceURI(),
sourceName.getLocalPart(),
prefix)));
notunderstoodHeaderElement.addNamespaceDeclaration(
prefix,
sourceName.getNamespaceURI());
return notunderstoodHeaderElement;
}
public SOAPElement addTextNode(String text) throws SOAPException {
log.log(
Level.SEVERE,
"SAAJ0416.ver1_2.adding.text.not.legal",
getElementQName());
throw new SOAPExceptionImpl("Adding text to SOAP 1.2 Header is not legal");
}
protected SOAPHeaderElement createHeaderElement(Name name)
throws SOAPException {
String uri = name.getURI();
if (uri == null || uri.equals("")) {
log.severe("SAAJ0413.ver1_2.header.elems.must.be.ns.qualified");
throw new SOAPExceptionImpl("SOAP 1.2 header elements must be namespace qualified");
}
return new HeaderElement1_2Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
name);
}
protected SOAPHeaderElement createHeaderElement(QName name)
throws SOAPException {
String uri = name.getNamespaceURI();
if (uri == null || uri.equals("")) {
log.severe("SAAJ0413.ver1_2.header.elems.must.be.ns.qualified");
throw new SOAPExceptionImpl("SOAP 1.2 header elements must be namespace qualified");
}
return new HeaderElement1_2Impl(
((SOAPDocument) getOwnerDocument()).getDocument(),
name);
}
public void setEncodingStyle(String encodingStyle) throws SOAPException {
log.severe("SAAJ0409.ver1_2.no.encodingstyle.in.header");
throw new SOAPExceptionImpl("encodingStyle attribute cannot appear on Header");
}
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);
}
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);
}
}

View File

@@ -0,0 +1,104 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.impl.HeaderElementImpl;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
public class HeaderElement1_2Impl extends HeaderElementImpl {
private static final Logger log =
Logger.getLogger(HeaderElement1_2Impl.class.getName(),
"com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
public HeaderElement1_2Impl(SOAPDocumentImpl ownerDoc, Name qname) {
super(ownerDoc, qname);
}
public HeaderElement1_2Impl(SOAPDocumentImpl ownerDoc, QName qname) {
super(ownerDoc, qname);
}
public SOAPElement setElementQName(QName newName) throws SOAPException {
HeaderElementImpl copy =
new HeaderElement1_2Impl((SOAPDocumentImpl)getOwnerDocument(), newName);
return replaceElementWithSOAPElement(this,copy);
}
protected NameImpl getRoleAttributeName() {
return NameImpl.create("role", null, NameImpl.SOAP12_NAMESPACE);
}
// Actor equivalent to Role in SOAP 1.2
protected NameImpl getActorAttributeName() {
return getRoleAttributeName();
}
protected NameImpl getMustunderstandAttributeName() {
return NameImpl.create("mustUnderstand", null, NameImpl.SOAP12_NAMESPACE);
}
// mustUnderstand attribute has literal value "true" or "false"
protected String getMustunderstandLiteralValue(boolean mustUnderstand) {
return (mustUnderstand == true ? "true" : "false");
}
protected boolean getMustunderstandAttributeValue(String mu) {
if (mu.equals("true") || mu.equals("1"))
return true;
return false;
}
protected NameImpl getRelayAttributeName() {
return NameImpl.create("relay", null, NameImpl.SOAP12_NAMESPACE);
}
//relay attribute has literal value "true" or "false"
protected String getRelayLiteralValue(boolean relay) {
return (relay == true ? "true" : "false");
}
protected boolean getRelayAttributeValue(String relay) {
if (relay.equals("true") || relay.equals("1"))
return true;
return false;
}
protected String getActorOrRole() {
return getRole();
}
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.ContentType;
import com.sun.xml.internal.messaging.saaj.soap.MessageImpl;
public class Message1_2Impl extends MessageImpl implements SOAPConstants{
public Message1_2Impl() {
super();
}
public Message1_2Impl(SOAPMessage msg) {
super(msg);
}
public Message1_2Impl(boolean isFastInfoset, boolean acceptFastInfoset) {
super(isFastInfoset, acceptFastInfoset);
}
// unused. can we delete this? - Kohsuke
public Message1_2Impl(MimeHeaders headers, InputStream in)
throws IOException, SOAPExceptionImpl {
super(headers, in);
}
public Message1_2Impl(MimeHeaders headers, ContentType ct, int stat, InputStream in)
throws SOAPExceptionImpl {
super(headers,ct,stat,in);
}
public SOAPPart getSOAPPart() {
if (soapPartImpl == null)
soapPartImpl = new SOAPPart1_2Impl(this);
return soapPartImpl;
}
protected boolean isCorrectSoapVersion(int contentTypeId) {
return (contentTypeId & SOAP1_2_FLAG) != 0;
}
protected String getExpectedContentType() {
return isFastInfoset ? "application/soap+fastinfoset" : "application/soap+xml";
}
protected String getExpectedAcceptHeader() {
String accept = "application/soap+xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2";
return acceptFastInfoset ? ("application/soap+fastinfoset, " + accept) : accept;
}
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import javax.xml.namespace.QName;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPFactoryImpl;
public class SOAPFactory1_2Impl extends SOAPFactoryImpl {
protected SOAPDocumentImpl createDocument() {
return (new SOAPPart1_2Impl()).getDocument();
}
public Detail createDetail() throws SOAPException {
return new Detail1_2Impl(createDocument());
}
public SOAPFault createFault(String reasonText, QName faultCode)
throws SOAPException {
if (faultCode == null) {
throw new IllegalArgumentException("faultCode argument for createFault was passed NULL");
}
if (reasonText == null) {
throw new IllegalArgumentException("reasonText argument for createFault was passed NULL");
}
Fault1_2Impl fault = new Fault1_2Impl(createDocument(), null);
fault.setFaultCode(faultCode);
fault.setFaultString(reasonText);
return fault;
}
public SOAPFault createFault() throws SOAPException {
Fault1_2Impl fault = new Fault1_2Impl(createDocument(), null);
fault.setFaultCode(fault.getDefaultFaultCode());
fault.setFaultString("Fault string, and possibly fault code, not set");
return fault;
}
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author JAX-RPC RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.soap.*;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.MessageFactoryImpl;
import com.sun.xml.internal.messaging.saaj.soap.MessageImpl;
public class SOAPMessageFactory1_2Impl extends MessageFactoryImpl {
public SOAPMessage createMessage() throws SOAPException {
return new Message1_2Impl();
}
public SOAPMessage createMessage(boolean isFastInfoset,
boolean acceptFastInfoset) throws SOAPException
{
return new Message1_2Impl(isFastInfoset, acceptFastInfoset);
}
public SOAPMessage createMessage(MimeHeaders headers, InputStream in) throws IOException, SOAPExceptionImpl {
if (headers == null) {
headers = new MimeHeaders();
}
if (getContentType(headers) == null) {
headers.setHeader("Content-Type", SOAPConstants.SOAP_1_2_CONTENT_TYPE);
}
MessageImpl msg = new Message1_2Impl(headers, in);
msg.setLazyAttachments(lazyAttachments);
return msg;
}
}

View File

@@ -0,0 +1,90 @@
/*
* Copyright (c) 1997, 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author SAAJ RI Development Team
*/
package com.sun.xml.internal.messaging.saaj.soap.ver1_2;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import javax.xml.transform.Source;
import com.sun.xml.internal.messaging.saaj.soap.*;
import com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl;
import com.sun.xml.internal.messaging.saaj.util.XMLDeclarationParser;
public class SOAPPart1_2Impl extends SOAPPartImpl implements SOAPConstants{
protected static final Logger log =
Logger.getLogger(SOAPPart1_2Impl.class.getName(),
"com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
public SOAPPart1_2Impl() {
super();
}
public SOAPPart1_2Impl(MessageImpl message) {
super(message);
}
protected String getContentType() {
return "application/soap+xml";
}
protected Envelope createEmptyEnvelope(String prefix) throws SOAPException {
return new Envelope1_2Impl(getDocument(), prefix, true, true);
}
protected Envelope createEnvelopeFromSource() throws SOAPException {
XMLDeclarationParser parser = lookForXmlDecl();
Source tmp = source;
source = null;
EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
}
if (parser != null) { //can be null if source was a DomSource and not StreamSource
if (!omitXmlDecl) {
envelope.setOmitXmlDecl("no");
envelope.setXmlDecl(parser.getXmlDeclaration());
envelope.setCharsetEncoding(parser.getEncoding());
}
}
return envelope;
}
protected SOAPPartImpl duplicateType() {
return new SOAPPart1_2Impl();
}
}