You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2013/07/10 16:20:27 UTC
svn commit: r1501775 [1/2] - in /cxf/trunk:
api/src/main/java/org/apache/cxf/helpers/
api/src/main/java/org/apache/cxf/interceptor/
api/src/main/java/org/apache/cxf/staxutils/
api/src/main/java/org/apache/cxf/staxutils/transform/
api/src/test/java/org/...
Author: dkulp
Date: Wed Jul 10 14:20:25 2013
New Revision: 1501775
URL: http://svn.apache.org/r1501775
Log:
Start process of completely removing XMLUtils (in favor of either StaxUtils for IO or DOMUtils for DOM related stuff)
Modified:
cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java
cxf/trunk/api/src/main/java/org/apache/cxf/helpers/XMLUtils.java
cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java
cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
cxf/trunk/api/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java
cxf/trunk/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultOutInterceptor.java
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerOutInterceptor.java
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlEnvelopedOutInterceptor.java
cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/xml/XmlSigOutInterceptor.java
cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java
cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java
cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisWSDLNSTest.java
cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/ClientServerSourceTest.java
cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/GreeterImpl.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchXMLClientServerTest.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerGreeterNoWsdlTest.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerRPCLitTest.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerXMLTest.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AbstractSourcePayloadProvider.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentProviderXMLClientServerTest.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderXMLClientServerTest.java
cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/servlet/CXFServletTest.java
cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap12/Soap12ClientServerTest.java
cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/DeliveryAssuranceOnewayTest.java
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java
cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/Server.java
cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaWriterImpl.java
cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParserTest.java
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/helpers/DOMUtils.java Wed Jul 10 14:20:25 2013
@@ -24,8 +24,13 @@ import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
@@ -52,11 +57,48 @@ import org.apache.cxf.common.util.String
* Few simple utils to read DOM. This is originally from the Jakarta Commons Modeler.
*/
public final class DOMUtils {
+ private static final Map<ClassLoader, DocumentBuilder> DOCUMENT_BUILDERS
+ = Collections.synchronizedMap(new WeakHashMap<ClassLoader, DocumentBuilder>());
private static final String XMLNAMESPACE = "xmlns";
private DOMUtils() {
}
+ private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null) {
+ loader = XMLUtils.class.getClassLoader();
+ }
+ if (loader == null) {
+ return DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ }
+ DocumentBuilder factory = DOCUMENT_BUILDERS.get(loader);
+ if (factory == null) {
+ DocumentBuilderFactory f2 = DocumentBuilderFactory.newInstance();
+ f2.setNamespaceAware(true);
+ factory = f2.newDocumentBuilder();
+ DOCUMENT_BUILDERS.put(loader, factory);
+ }
+ return factory;
+ }
+
+ /**
+ * Creates a new Docuement object
+ * @return
+ * @throws ParserConfigurationException
+ */
+ public static Document newDocument() {
+ return createDocument();
+ }
+ public static Document createDocument() {
+ try {
+ return getDocumentBuilder().newDocument();
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
/**
* This function is much like getAttribute, but returns null, not "", for a nonexistent attribute.
*
@@ -162,6 +204,17 @@ public final class DOMUtils {
return null;
}
+
+ public static boolean hasAttribute(Element element, String value) {
+ NamedNodeMap attributes = element.getAttributes();
+ for (int i = 0; i < attributes.getLength(); i++) {
+ Node node = attributes.item(i);
+ if (value.equals(node.getNodeValue())) {
+ return true;
+ }
+ }
+ return false;
+ }
public static String getAttribute(Node element, String attName) {
NamedNodeMap attrs = element.getAttributes();
if (attrs == null) {
@@ -256,6 +309,66 @@ public final class DOMUtils {
public static QName getElementQName(Element el) {
return new QName(el.getNamespaceURI(), el.getLocalName());
}
+
+ /**
+ * Creates a QName object based on the qualified name
+ * and using the Node as a base to lookup the namespace
+ * for the prefix
+ * @param qualifiedName
+ * @param node
+ * @return
+ */
+ public static QName createQName(String qualifiedName, Node node) {
+ if (qualifiedName == null) {
+ return null;
+ }
+
+ int index = qualifiedName.indexOf(":");
+
+ if (index == -1) {
+ return new QName(qualifiedName);
+ }
+
+ String prefix = qualifiedName.substring(0, index);
+ String localName = qualifiedName.substring(index + 1);
+ String ns = node.lookupNamespaceURI(prefix);
+
+ if (ns == null || localName == null) {
+ throw new RuntimeException("Invalid QName in mapping: " + qualifiedName);
+ }
+
+ return new QName(ns, localName, prefix);
+ }
+
+ public static QName convertStringToQName(String expandedQName) {
+ return convertStringToQName(expandedQName, "");
+ }
+
+ public static QName convertStringToQName(String expandedQName, String prefix) {
+ int ind1 = expandedQName.indexOf('{');
+ if (ind1 != 0) {
+ return new QName(expandedQName);
+ }
+
+ int ind2 = expandedQName.indexOf('}');
+ if (ind2 <= ind1 + 1 || ind2 >= expandedQName.length() - 1) {
+ return null;
+ }
+ String ns = expandedQName.substring(ind1 + 1, ind2);
+ String localName = expandedQName.substring(ind2 + 1);
+ return new QName(ns, localName, prefix);
+ }
+ public static Set<QName> convertStringsToQNames(List<String> expandedQNames) {
+ Set<QName> dropElements = Collections.emptySet();
+ if (expandedQNames != null) {
+ dropElements = new LinkedHashSet<QName>(expandedQNames.size());
+ for (String val : expandedQNames) {
+ dropElements.add(convertStringToQName(val));
+ }
+ }
+ return dropElements;
+ }
+
/**
* Get the first direct child with a given type
@@ -480,14 +593,6 @@ public final class DOMUtils {
return db.parse(is2);
}
- public static Document createDocument() {
- try {
- return XMLUtils.newDocument();
- } catch (ParserConfigurationException e) {
- throw new RuntimeException("Couldn't find a DOM parser.", e);
- }
- }
-
public static String getPrefixRecursive(Element el, String ns) {
String prefix = getPrefix(el, ns);
if (prefix == null && el.getParentNode() instanceof Element) {
@@ -590,7 +695,7 @@ public final class DOMUtils {
return null;
}
-
+
public static List<Element> findAllElementsByTagNameNS(Element elem, String nameSpaceURI,
String localName) {
List<Element> ret = new LinkedList<Element>();
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/helpers/XMLUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/helpers/XMLUtils.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/helpers/XMLUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/helpers/XMLUtils.java Wed Jul 10 14:20:25 2013
@@ -19,59 +19,30 @@
package org.apache.cxf.helpers;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
-import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
-import java.util.Collections;
import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.WeakHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMSource;
-import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-import org.xml.sax.InputSource;
-
-import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.staxutils.PrettyPrintXMLStreamWriter;
import org.apache.cxf.staxutils.StaxUtils;
public final class XMLUtils {
-
- private static final Logger LOG = LogUtils.getL7dLogger(XMLUtils.class);
-
- private static final Map<ClassLoader, DocumentBuilder> DOCUMENT_BUILDERS
- = Collections.synchronizedMap(new WeakHashMap<ClassLoader, DocumentBuilder>());
private static final Pattern XML_ESCAPE_CHARS = Pattern.compile("[\"'&<>]");
private static final Map<String, String> XML_ENCODING_TABLE;
@@ -87,68 +58,6 @@ public final class XMLUtils {
private XMLUtils() {
}
- private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if (loader == null) {
- loader = XMLUtils.class.getClassLoader();
- }
- if (loader == null) {
- return DocumentBuilderFactory.newInstance().newDocumentBuilder();
- }
- DocumentBuilder factory = DOCUMENT_BUILDERS.get(loader);
- if (factory == null) {
- DocumentBuilderFactory f2 = DocumentBuilderFactory.newInstance();
- f2.setNamespaceAware(true);
- factory = f2.newDocumentBuilder();
- DOCUMENT_BUILDERS.put(loader, factory);
- }
- return factory;
- }
-
-
- public static Document parse(InputSource is) throws XMLStreamException {
- return StaxUtils.read(is);
- }
-
- public static Document parse(File is) throws XMLStreamException, IOException {
- InputStream fin = new FileInputStream(is);
- try {
- return StaxUtils.read(fin);
- } finally {
- fin.close();
- }
- }
-
- public static Document parse(InputStream in) throws XMLStreamException {
- if (in == null && LOG.isLoggable(Level.FINE)) {
- LOG.fine("XMLUtils trying to parse a null inputstream");
- }
- return StaxUtils.read(in);
- }
-
- public static Document parse(String in) throws XMLStreamException {
- XMLStreamReader reader = StaxUtils.createXMLStreamReader(new StringReader(in));
- try {
- return StaxUtils.read(reader);
- } finally {
- reader.close();
- }
- }
-
- public static Document parse(byte[] in) throws XMLStreamException {
- if (in == null) {
- if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("XMLUtils trying to parse a null bytes");
- }
- return null;
- }
- return StaxUtils.read(new ByteArrayInputStream(in));
- }
-
- public static Document newDocument() throws ParserConfigurationException {
- return getDocumentBuilder().newDocument();
- }
-
public static void writeTo(Node node, OutputStream os) throws XMLStreamException {
writeTo(new DOMSource(node), os);
}
@@ -202,7 +111,7 @@ public final class XMLUtils {
}
XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(os, charset);
if (indent > 0) {
- writer = new PrettyPrintXMLStreamWriter(writer, 0, indent);
+ writer = new PrettyPrintXMLStreamWriter(writer, indent);
}
if (!omitXmlDecl) {
writer.writeStartDocument(charset, "1.0");
@@ -223,7 +132,7 @@ public final class XMLUtils {
}
XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(os);
if (indent > 0) {
- writer = new PrettyPrintXMLStreamWriter(writer, 0, indent);
+ writer = new PrettyPrintXMLStreamWriter(writer, indent);
}
if (!omitXmlDecl) {
writer.writeStartDocument(charset, "1.0");
@@ -265,171 +174,9 @@ public final class XMLUtils {
return out.toString();
}
- public static void printDOM(Node node) {
- printDOM("", node);
- }
-
- public static void printDOM(String words, Node node) {
- System.out.println(words);
- System.out.println(toString(node));
- }
-
- public static Attr getAttribute(Element el, String attrName) {
- return el.getAttributeNode(attrName);
- }
-
- public static void replaceAttribute(Element element, String attr, String value) {
- if (element.hasAttribute(attr)) {
- element.removeAttribute(attr);
- }
- element.setAttribute(attr, value);
- }
-
- public static boolean hasAttribute(Element element, String value) {
- NamedNodeMap attributes = element.getAttributes();
- for (int i = 0; i < attributes.getLength(); i++) {
- Node node = attributes.item(i);
- if (value.equals(node.getNodeValue())) {
- return true;
- }
- }
- return false;
- }
-
- public static void printAttributes(Element element) {
- NamedNodeMap attributes = element.getAttributes();
- for (int i = 0; i < attributes.getLength(); i++) {
- Node node = attributes.item(i);
- System.err.println("## prefix=" + node.getPrefix() + " localname:" + node.getLocalName()
- + " value=" + node.getNodeValue());
- }
- }
-
- public static QName getNamespace(Map<String, String> namespaces, String str, String defaultNamespace) {
- String prefix = null;
- String localName = null;
-
- StringTokenizer tokenizer = new StringTokenizer(str, ":");
- if (tokenizer.countTokens() == 2) {
- prefix = tokenizer.nextToken();
- localName = tokenizer.nextToken();
- } else if (tokenizer.countTokens() == 1) {
- localName = tokenizer.nextToken();
- }
-
- String namespceURI = defaultNamespace;
- if (prefix != null) {
- namespceURI = namespaces.get(prefix);
- }
- return new QName(namespceURI, localName);
- }
-
public static void generateXMLFile(Element element, Writer writer) throws XMLStreamException {
writeTo(new DOMSource(element), writer, 2, "UTF-8", false);
- }
-
- public static Element createElementNS(Node node, QName name) {
- return createElementNS(node.getOwnerDocument(), name.getNamespaceURI(), name.getLocalPart());
- }
-
- public static Element createElementNS(Document root, QName name) {
- return createElementNS(root, name.getNamespaceURI(), name.getLocalPart());
- }
-
- public static Element createElementNS(Document root, String namespaceURI, String qualifiedName) {
- return root.createElementNS(namespaceURI, qualifiedName);
- }
-
- public static Text createTextNode(Document root, String data) {
- return root.createTextNode(data);
- }
-
- public static Text createTextNode(Node node, String data) {
- return createTextNode(node.getOwnerDocument(), data);
- }
-
- public static void removeContents(Node parent) {
- Node node = parent.getFirstChild();
- while (node != null) {
- parent.removeChild(node);
- node = node.getNextSibling();
- }
- }
-
- public static InputStream getInputStream(Document doc) throws Exception {
- LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream();
- XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out, "UTF-8");
- StaxUtils.writeDocument(doc, writer, true);
- writer.close();
- return out.createInputStream();
- }
-
- public static Element fetchElementByNameAttribute(Element parent, String targetName, String nameValue) {
-
- List<Element> elemList = DOMUtils.findAllElementsByTagName(parent, targetName);
- for (Element elem : elemList) {
- if (elem.getAttribute("name").equals(nameValue)) {
- return elem;
- }
- }
- return null;
- }
-
- public static QName getQName(String value, Node node) {
- if (value == null) {
- return null;
- }
-
- int index = value.indexOf(":");
-
- if (index == -1) {
- return new QName(value);
- }
-
- String prefix = value.substring(0, index);
- String localName = value.substring(index + 1);
- String ns = node.lookupNamespaceURI(prefix);
-
- if (ns == null || localName == null) {
- throw new RuntimeException("Invalid QName in mapping: " + value);
- }
-
- return new QName(ns, localName, prefix);
- }
-
- public static Node fromSource(Source src) throws Exception {
- return StaxUtils.read(src);
- }
-
- public static QName convertStringToQName(String expandedQName) {
- return convertStringToQName(expandedQName, "");
- }
-
- public static QName convertStringToQName(String expandedQName, String prefix) {
- int ind1 = expandedQName.indexOf('{');
- if (ind1 != 0) {
- return new QName(expandedQName);
- }
-
- int ind2 = expandedQName.indexOf('}');
- if (ind2 <= ind1 + 1 || ind2 >= expandedQName.length() - 1) {
- return null;
- }
- String ns = expandedQName.substring(ind1 + 1, ind2);
- String localName = expandedQName.substring(ind2 + 1);
- return new QName(ns, localName, prefix);
- }
-
- public static Set<QName> convertStringsToQNames(List<String> expandedQNames) {
- Set<QName> dropElements = Collections.emptySet();
- if (expandedQNames != null) {
- dropElements = new LinkedHashSet<QName>(expandedQNames.size());
- for (String val : expandedQNames) {
- dropElements.add(XMLUtils.convertStringToQName(val));
- }
- }
- return dropElements;
- }
+ }
public static String xmlEncode(String value) {
Matcher m = XML_ESCAPE_CHARS.matcher(value);
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java Wed Jul 10 14:20:25 2013
@@ -153,7 +153,7 @@ public abstract class AbstractLoggingInt
StringWriter swriter = new StringWriter();
XMLStreamWriter xwriter = StaxUtils.createXMLStreamWriter(swriter);
- xwriter = new PrettyPrintXMLStreamWriter(xwriter, 0, 2);
+ xwriter = new PrettyPrintXMLStreamWriter(xwriter, 2);
InputStream in = cos.getInputStream();
StaxUtils.copy(new StreamSource(in), xwriter);
xwriter.close();
@@ -187,7 +187,7 @@ public abstract class AbstractLoggingInt
StringWriter swriter = new StringWriter();
XMLStreamWriter xwriter = StaxUtils.createXMLStreamWriter(swriter);
- xwriter = new PrettyPrintXMLStreamWriter(xwriter, 0, 2);
+ xwriter = new PrettyPrintXMLStreamWriter(xwriter, 2);
StaxUtils.copy(new StreamSource(new StringReader(stringWriter.getBuffer().toString())), xwriter);
xwriter.close();
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/PrettyPrintXMLStreamWriter.java Wed Jul 10 14:20:25 2013
@@ -39,13 +39,12 @@ public class PrettyPrintXMLStreamWriter
boolean nestedStartElement;
public PrettyPrintXMLStreamWriter(XMLStreamWriter writer,
- int initialLevel) {
- baseWriter = writer;
- curIndent = initialLevel;
+ int indentAmount) {
+ this(writer, indentAmount, 0);
}
public PrettyPrintXMLStreamWriter(XMLStreamWriter writer,
- int initialLevel,
- int indentAmount) {
+ int indentAmount,
+ int initialLevel) {
baseWriter = writer;
curIndent = initialLevel;
this.indentAmount = indentAmount;
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Wed Jul 10 14:20:25 2013
@@ -19,6 +19,9 @@
package org.apache.cxf.staxutils;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
@@ -75,6 +78,7 @@ import org.w3c.dom.Node;
import org.w3c.dom.ProcessingInstruction;
import org.w3c.dom.Text;
import org.w3c.dom.UserDataHandler;
+
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
@@ -84,7 +88,6 @@ import org.apache.cxf.common.util.String
import org.apache.cxf.common.util.SystemPropertyAction;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.helpers.XMLUtils;
public final class StaxUtils {
// System properies for defaults, but also contextual properties usable
@@ -1041,6 +1044,26 @@ public final class StaxUtils {
}
}
}
+ public static Document read(Reader s) throws XMLStreamException {
+ XMLStreamReader reader = createXMLStreamReader(s);
+ try {
+ return read(reader);
+ } finally {
+ try {
+ reader.close();
+ } catch (Exception ex) {
+ //ignore
+ }
+ }
+ }
+ public static Document read(File is) throws XMLStreamException, IOException {
+ InputStream fin = new FileInputStream(is);
+ try {
+ return read(fin);
+ } finally {
+ fin.close();
+ }
+ }
public static Document read(InputSource s) throws XMLStreamException {
XMLStreamReader reader = createXMLStreamReader(s);
try {
@@ -1537,7 +1560,16 @@ public final class StaxUtils {
public static void printXmlFragment(XMLStreamReader reader) {
try {
- LOG.info(XMLUtils.toString(StaxUtils.read(reader), 4));
+ StringWriter sw = new StringWriter(1024);
+ XMLStreamWriter writer = null;
+ try {
+ writer = new PrettyPrintXMLStreamWriter(createXMLStreamWriter(sw), 4);
+ copy(reader, writer);
+ writer.flush();
+ } finally {
+ StaxUtils.close(writer);
+ }
+ LOG.info(sw.toString());
} catch (XMLStreamException e) {
LOG.severe(e.getMessage());
}
@@ -1668,18 +1700,23 @@ public final class StaxUtils {
return sw.toString();
}
public static String toString(Element el) throws XMLStreamException {
+ return toString(el, 0);
+ }
+ public static String toString(Element el, int indent) throws XMLStreamException {
StringWriter sw = new StringWriter(1024);
XMLStreamWriter writer = null;
try {
writer = createXMLStreamWriter(sw);
+ if (indent > 0) {
+ writer = new PrettyPrintXMLStreamWriter(writer, indent);
+ }
copy(el, writer);
writer.flush();
} finally {
StaxUtils.close(writer);
}
- return sw.toString();
+ return sw.toString();
}
-
public static void close(XMLStreamReader reader) {
if (reader != null) {
try {
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java Wed Jul 10 14:20:25 2013
@@ -34,8 +34,8 @@ import org.w3c.dom.DocumentFragment;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.helpers.MapNamespaceContext;
-import org.apache.cxf.helpers.XMLUtils;
public class W3CDOMStreamWriter implements XMLStreamWriter {
static final String XML_NS = "http://www.w3.org/2000/xmlns/";
@@ -47,7 +47,7 @@ public class W3CDOMStreamWriter implemen
private Map<String, Object> properties = Collections.emptyMap();
public W3CDOMStreamWriter() throws ParserConfigurationException {
- document = XMLUtils.newDocument();
+ document = DOMUtils.newDocument();
}
public W3CDOMStreamWriter(DocumentBuilder builder) {
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java Wed Jul 10 14:20:25 2013
@@ -34,7 +34,7 @@ import javax.xml.stream.XMLStreamExcepti
import javax.xml.stream.XMLStreamWriter;
import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.staxutils.DelegatingXMLStreamWriter;
public class OutTransformWriter extends DelegatingXMLStreamWriter {
@@ -78,7 +78,7 @@ public class OutTransformWriter extends
TransformUtils.convertToQNamesMap(outAMap, attributesMap, null);
TransformUtils.convertToMapOfElementProperties(append, appendMap);
- dropElements = XMLUtils.convertStringsToQNames(dropEls);
+ dropElements = DOMUtils.convertStringsToQNames(dropEls);
this.attributesToElements = attributesToElements;
namespaceContext = new DelegatingNamespaceContext(
writer.getNamespaceContext(), nsMap);
Modified: cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java Wed Jul 10 14:20:25 2013
@@ -30,7 +30,7 @@ import javax.xml.stream.XMLStreamConstan
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.staxutils.StaxUtils;
public final class TransformUtils {
@@ -94,8 +94,8 @@ public final class TransformUtils {
Map<String, String> nsMap) {
if (map != null) {
for (Map.Entry<String, String> entry : map.entrySet()) {
- QName lname = XMLUtils.convertStringToQName(entry.getKey());
- QName rname = XMLUtils.convertStringToQName(entry.getValue());
+ QName lname = DOMUtils.convertStringToQName(entry.getKey());
+ QName rname = DOMUtils.convertStringToQName(entry.getValue());
elementsMap.put(lname, rname);
if (nsMap != null && !isEmptyQName(rname)
&& ("*".equals(lname.getLocalPart()) && "*".equals(rname.getLocalPart()))) {
@@ -112,8 +112,8 @@ public final class TransformUtils {
Map<QName, QName> elementsMap) {
if (map != null) {
for (Map.Entry<String, String> entry : map.entrySet()) {
- QName lname = XMLUtils.convertStringToQName(entry.getKey());
- QName rname = XMLUtils.convertStringToQName(entry.getValue());
+ QName lname = DOMUtils.convertStringToQName(entry.getKey());
+ QName rname = DOMUtils.convertStringToQName(entry.getValue());
elementsMap.put(lname, rname);
}
}
@@ -141,8 +141,8 @@ public final class TransformUtils {
key = key.substring(0, key.length() - 1);
child = true;
}
- QName lname = XMLUtils.convertStringToQName(key);
- QName rname = XMLUtils.convertStringToQName(value);
+ QName lname = DOMUtils.convertStringToQName(key);
+ QName rname = DOMUtils.convertStringToQName(value);
ElementProperty desc = new ElementProperty(rname, text, child);
elementsMap.put(lname, desc);
@@ -154,7 +154,7 @@ public final class TransformUtils {
Set<QName> elementsSet) {
if (set != null) {
for (String entry : set) {
- QName name = XMLUtils.convertStringToQName(entry);
+ QName name = DOMUtils.convertStringToQName(entry);
elementsSet.add(name);
}
}
Modified: cxf/trunk/api/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/api/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java (original)
+++ cxf/trunk/api/src/test/java/org/apache/cxf/common/xmlschema/ImportRepairTest.java Wed Jul 10 14:20:25 2013
@@ -205,7 +205,7 @@ public class ImportRepairTest extends As
}
XMLStreamWriter xwriter = StaxUtils.createXMLStreamWriter(System.err);
- xwriter = new PrettyPrintXMLStreamWriter(xwriter, 0, 2);
+ xwriter = new PrettyPrintXMLStreamWriter(xwriter, 2);
StaxUtils.copy(new DOMSource(document), xwriter);
xwriter.close();
}
Modified: cxf/trunk/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java (original)
+++ cxf/trunk/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java Wed Jul 10 14:20:25 2013
@@ -41,6 +41,7 @@ import org.w3c.dom.Element;
import org.xml.sax.InputSource;
+import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.helpers.XMLUtils;
import org.junit.Assert;
@@ -131,7 +132,7 @@ public class StaxUtilsTest extends Asser
@Test
public void testCXF2468() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = DOMUtils.newDocument();
doc.appendChild(doc.createElementNS("http://blah.org/", "blah"));
Element foo = doc.createElementNS("http://blah.org/", "foo");
Attr attr = doc.createAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:nil");
Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java (original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java Wed Jul 10 14:20:25 2013
@@ -32,7 +32,7 @@ import org.w3c.dom.Element;
import org.apache.cxf.binding.soap.SoapFault;
import org.apache.cxf.binding.soap.SoapMessage;
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
import org.apache.cxf.message.MessageUtils;
@@ -93,7 +93,7 @@ public abstract class AbstractSoapInterc
Element detail = fault.getDetail();
String soapNamespace = message.getVersion().getNamespace();
if (detail == null) {
- Document doc = XMLUtils.newDocument();
+ Document doc = DOMUtils.newDocument();
Element stackTrace = doc.createElementNS(
Fault.STACKTRACE_NAMESPACE, Fault.STACKTRACE);
stackTrace.setTextContent(sb.toString());
Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java (original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultInInterceptor.java Wed Jul 10 14:20:25 2013
@@ -40,7 +40,7 @@ import org.apache.cxf.binding.soap.SoapF
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.common.i18n.Message;
import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.helpers.XPathUtils;
import org.apache.cxf.interceptor.ClientFaultConverter;
import org.apache.cxf.interceptor.Fault;
@@ -103,7 +103,7 @@ public class Soap12FaultInInterceptor ex
fault,
XPathConstants.NODE);
if (el != null) {
- faultCode = XMLUtils.getQName(el.getTextContent(), el);
+ faultCode = DOMUtils.createQName(el.getTextContent(), el);
}
el = (Element)xu.getValue("//s:Fault/s:Code/s:Subcode",
@@ -114,7 +114,7 @@ public class Soap12FaultInInterceptor ex
NodeList vlist = el.getElementsByTagNameNS(Soap12.SOAP_NAMESPACE, "Value");
for (int i = 0; i < vlist.getLength(); i++) {
Node v = vlist.item(i);
- subCodes.add(XMLUtils.getQName(v.getTextContent(), v));
+ subCodes.add(DOMUtils.createQName(v.getTextContent(), v));
}
}
Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java Wed Jul 10 14:20:25 2013
@@ -46,7 +46,7 @@ import org.apache.cxf.aegis.type.basic.B
import org.apache.cxf.aegis.type.java5.Java5TypeCreator;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.xmlschema.XmlSchemaUtils;
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
@@ -297,7 +297,7 @@ public class AegisContext {
private Document getSchemaDocument(String resourcePath) {
try {
- return XMLUtils.parse(getClass().getResourceAsStream(resourcePath));
+ return StaxUtils.read(getClass().getResourceAsStream(resourcePath));
} catch (XMLStreamException e) {
throw new RuntimeException(e);
}
Modified: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java (original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java Wed Jul 10 14:20:25 2013
@@ -41,17 +41,16 @@ import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
-
import org.apache.cxf.common.WSDLConstants;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.common.xmlschema.SchemaCollection;
import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.helpers.XPathUtils;
import org.apache.cxf.service.ServiceModelVisitor;
import org.apache.cxf.service.model.MessagePartInfo;
import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.XmlSchemaException;
@@ -184,7 +183,7 @@ class XmlBeansSchemaInitializer extends
//temporary marker to make sure recursive imports don't blow up
schemaMap.put(file, null);
- Document doc = XMLUtils.parse(ins);
+ Document doc = StaxUtils.read(ins);
Element elem = doc.getDocumentElement();
doc.removeChild(elem);
Modified: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java (original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java Wed Jul 10 14:20:25 2013
@@ -43,7 +43,7 @@ import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.tools.common.ToolConstants;
import org.apache.cxf.tools.common.ToolContext;
import org.apache.cxf.tools.common.ToolException;
@@ -352,7 +352,7 @@ public class XMLBeansToolingDataBinding
configdoc = loader.parse(new File(uri), null, options);
} else {
InputSource source = new InputSource(configFiles[i]);
- Document doc = XMLUtils.parse(source);
+ Document doc = StaxUtils.read(source);
configdoc = loader.parse(doc, null, options);
}
Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java Wed Jul 10 14:20:25 2013
@@ -1547,7 +1547,7 @@ public class WadlGenerator implements Co
name = type.getAnnotation(XMLName.class);
}
if (name != null) {
- QName qname = XMLUtils.convertStringToQName(name.value(), name.prefix());
+ QName qname = DOMUtils.convertStringToQName(name.value(), name.prefix());
if (qname.getPrefix().length() > 0) {
return qname;
} else {
Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Wed Jul 10 14:20:25 2013
@@ -102,7 +102,7 @@ import org.apache.cxf.common.logging.Log
import org.apache.cxf.common.util.PackageUtils;
import org.apache.cxf.common.util.ReflectionUtil;
import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.jaxrs.JAXRSServiceImpl;
import org.apache.cxf.jaxrs.ext.ContextProvider;
@@ -1689,7 +1689,7 @@ public final class JAXRSUtils {
}
public static QName convertStringToQName(String name) {
- return XMLUtils.convertStringToQName(name, "");
+ return DOMUtils.convertStringToQName(name, "");
}
public static boolean runContainerRequestFilters(ServerProviderFactory pf,
Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java Wed Jul 10 14:20:25 2013
@@ -48,6 +48,7 @@ import org.apache.cxf.common.logging.Log
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.jaxws.javaee.PortComponentHandlerType;
+import org.apache.cxf.staxutils.StaxUtils;
@SuppressWarnings("rawtypes")
public class AnnotationHandlerChainBuilder extends HandlerChainBuilder {
@@ -90,7 +91,7 @@ public class AnnotationHandlerChainBuild
.getFileName()).toString());
}
- Document doc = XMLUtils.parse(handlerFileURL.openStream());
+ Document doc = StaxUtils.read(handlerFileURL.openStream());
Element el = doc.getDocumentElement();
if (!"http://java.sun.com/xml/ns/javaee".equals(el.getNamespaceURI())
|| !"handler-chains".equals(el.getLocalName())) {
Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultOutInterceptor.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultOutInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerFaultOutInterceptor.java Wed Jul 10 14:20:25 2013
@@ -19,7 +19,6 @@
package org.apache.cxf.jaxws.handler.logical;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.soap.SOAPMessage;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
@@ -32,7 +31,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.interceptor.InterceptorChain;
import org.apache.cxf.jaxws.handler.AbstractJAXWSHandlerInterceptor;
@@ -67,26 +66,21 @@ public class LogicalHandlerFaultOutInter
return;
}
+ XMLStreamWriter origWriter = message.getContent(XMLStreamWriter.class);
+ Document doc = DOMUtils.newDocument();
+ message.setContent(Node.class, doc);
+ W3CDOMStreamWriter writer = new W3CDOMStreamWriter(doc);
+ // set up the namespace context
try {
+ writer.setNamespaceContext(origWriter.getNamespaceContext());
+ } catch (XMLStreamException ex) {
+ // don't set the namespaceContext
+ }
+ // Replace stax writer with DomStreamWriter
+ message.setContent(XMLStreamWriter.class, writer);
+ message.put(ORIGINAL_WRITER, origWriter);
- XMLStreamWriter origWriter = message.getContent(XMLStreamWriter.class);
- Document doc = XMLUtils.newDocument();
- message.setContent(Node.class, doc);
- W3CDOMStreamWriter writer = new W3CDOMStreamWriter(doc);
- // set up the namespace context
- try {
- writer.setNamespaceContext(origWriter.getNamespaceContext());
- } catch (XMLStreamException ex) {
- // don't set the namespaceContext
- }
- // Replace stax writer with DomStreamWriter
- message.setContent(XMLStreamWriter.class, writer);
- message.put(ORIGINAL_WRITER, origWriter);
-
- message.getInterceptorChain().add(ending);
- } catch (ParserConfigurationException e) {
- throw new Fault(e);
- }
+ message.getInterceptorChain().add(ending);
}
Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerOutInterceptor.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerOutInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerOutInterceptor.java Wed Jul 10 14:20:25 2013
@@ -19,7 +19,6 @@
package org.apache.cxf.jaxws.handler.logical;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.soap.SOAPMessage;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
@@ -34,7 +33,7 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.jaxws.handler.AbstractJAXWSHandlerInterceptor;
import org.apache.cxf.jaxws.handler.HandlerChainInvoker;
@@ -69,33 +68,28 @@ public class LogicalHandlerOutIntercepto
return;
}
- try {
-
- XMLStreamWriter origWriter = message.getContent(XMLStreamWriter.class);
-
- Node nd = message.getContent(Node.class);
- SOAPMessage m = message.getContent(SOAPMessage.class);
- Document document = null;
-
- if (m != null) {
- document = m.getSOAPPart();
- } else if (nd != null) {
- document = nd.getOwnerDocument();
- } else {
- document = XMLUtils.newDocument();
- message.setContent(Node.class, document);
- }
-
- W3CDOMStreamWriter writer = new W3CDOMStreamWriter(document.createDocumentFragment());
+ XMLStreamWriter origWriter = message.getContent(XMLStreamWriter.class);
- // Replace stax writer with DomStreamWriter
- message.setContent(XMLStreamWriter.class, writer);
- message.put(ORIGINAL_WRITER, origWriter);
-
- message.getInterceptorChain().add(ending);
- } catch (ParserConfigurationException e) {
- throw new Fault(e);
+ Node nd = message.getContent(Node.class);
+ SOAPMessage m = message.getContent(SOAPMessage.class);
+ Document document = null;
+
+ if (m != null) {
+ document = m.getSOAPPart();
+ } else if (nd != null) {
+ document = nd.getOwnerDocument();
+ } else {
+ document = DOMUtils.newDocument();
+ message.setContent(Node.class, document);
}
+
+ W3CDOMStreamWriter writer = new W3CDOMStreamWriter(document.createDocumentFragment());
+
+ // Replace stax writer with DomStreamWriter
+ message.setContent(XMLStreamWriter.class, writer);
+ message.put(ORIGINAL_WRITER, origWriter);
+
+ message.getInterceptorChain().add(ending);
}
@Override
public void handleFault(Message message) {
Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java Wed Jul 10 14:20:25 2013
@@ -30,7 +30,6 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.namespace.QName;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
@@ -50,7 +49,7 @@ import org.apache.cxf.common.WSDLConstan
import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.i18n.Message;
import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.jaxws.EndpointUtils;
import org.apache.cxf.jaxws.ServiceImpl;
@@ -182,7 +181,7 @@ public class ProviderImpl extends javax.
try {
- Document doc = XMLUtils.newDocument();
+ Document doc = DOMUtils.newDocument();
DOMResult result = new DOMResult(doc);
external.writeTo(result);
W3CDOMStreamReader reader = new W3CDOMStreamReader(doc.getDocumentElement());
@@ -199,9 +198,6 @@ public class ProviderImpl extends javax.
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- } catch (ParserConfigurationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
return null;
} else {
Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java Wed Jul 10 14:20:25 2013
@@ -28,9 +28,7 @@ import javax.xml.transform.Result;
import javax.xml.transform.dom.DOMSource;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.EndpointReference;
-
import javax.xml.ws.WebServiceException;
-
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
@@ -38,9 +36,9 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.apache.cxf.BusFactory;
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.jaxws.spi.ProviderImpl;
-
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.hello_world_soap_http.Greeter;
import org.apache.hello_world_soap_http.GreeterImpl;
@@ -130,7 +128,7 @@ public class EndpointReferenceTest exten
.create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = XMLUtils.parse(is);
+ Document doc = StaxUtils.read(is);
DOMSource erXML = new DOMSource(doc);
EndpointReference endpointReference = EndpointReference.readFrom(erXML);
@@ -151,7 +149,7 @@ public class EndpointReferenceTest exten
endpoint.publish("http://localhost:8080/test");
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = XMLUtils.parse(is);
+ Document doc = StaxUtils.read(is);
DOMSource erXML = new DOMSource(doc);
EndpointReference endpointReference = EndpointReference.readFrom(erXML);
@@ -170,10 +168,10 @@ public class EndpointReferenceTest exten
endpoint.publish("http://localhost:8080/test");
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = XMLUtils.parse(is);
- Element referenceParameters = XMLUtils.fetchElementByNameAttribute(doc.getDocumentElement(),
- "wsa:ReferenceParameters",
- "");
+ Document doc = StaxUtils.read(is);
+ Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(),
+ "wsa:ReferenceParameters",
+ "");
EndpointReference endpointReference = endpoint.getEndpointReference(referenceParameters);
assertNotNull(endpointReference);
assertTrue(endpointReference instanceof W3CEndpointReference);
@@ -195,10 +193,10 @@ public class EndpointReferenceTest exten
try {
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = XMLUtils.parse(is);
- Element referenceParameters = XMLUtils.fetchElementByNameAttribute(doc.getDocumentElement(),
- "wsa:ReferenceParameters",
- "");
+ Document doc = StaxUtils.read(is);
+ Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(),
+ "wsa:ReferenceParameters",
+ "");
endpoint.getEndpointReference(referenceParameters);
fail("Did not get expected UnsupportedOperationException");
@@ -217,10 +215,10 @@ public class EndpointReferenceTest exten
endpoint.publish("http://localhost:8080/test");
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = XMLUtils.parse(is);
- Element referenceParameters = XMLUtils.fetchElementByNameAttribute(doc.getDocumentElement(),
- "wsa:ReferenceParameters",
- "");
+ Document doc = StaxUtils.read(is);
+ Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(),
+ "wsa:ReferenceParameters",
+ "");
EndpointReference endpointReference = endpoint.getEndpointReference(W3CEndpointReference.class,
referenceParameters);
assertNotNull(endpointReference);
@@ -243,10 +241,10 @@ public class EndpointReferenceTest exten
try {
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = XMLUtils.parse(is);
- Element referenceParameters = XMLUtils.fetchElementByNameAttribute(doc.getDocumentElement(),
- "wsa:ReferenceParameters",
- "");
+ Document doc = StaxUtils.read(is);
+ Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(),
+ "wsa:ReferenceParameters",
+ "");
endpoint.getEndpointReference(MyEndpointReference.class, referenceParameters);
fail("Did not get expected WebServiceException");
@@ -262,7 +260,7 @@ public class EndpointReferenceTest exten
ProviderImpl provider = new ProviderImpl();
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = XMLUtils.parse(is);
+ Document doc = StaxUtils.read(is);
DOMSource erXML = new DOMSource(doc);
EndpointReference endpointReference = provider.readEndpointReference(erXML);
assertNotNull(endpointReference);
@@ -275,16 +273,16 @@ public class EndpointReferenceTest exten
ProviderImpl provider = new ProviderImpl();
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = XMLUtils.parse(is);
- Element referenceParameter = XMLUtils.fetchElementByNameAttribute(doc.getDocumentElement(),
- "wsa:ReferenceParameters",
- "");
+ Document doc = StaxUtils.read(is);
+ Element referenceParameter = fetchElementByNameAttribute(doc.getDocumentElement(),
+ "wsa:ReferenceParameters",
+ "");
List<Element> referenceParameters = new ArrayList<Element>();
if (referenceParameter != null) {
referenceParameters.add(referenceParameter);
}
- Element metadata = XMLUtils.fetchElementByNameAttribute(doc.getDocumentElement(), "wsa:metadata", "");
+ Element metadata = fetchElementByNameAttribute(doc.getDocumentElement(), "wsa:metadata", "");
List<Element> metadataList = new ArrayList<Element>();
if (metadata != null) {
metadataList.add(metadata);
@@ -306,7 +304,7 @@ public class EndpointReferenceTest exten
ProviderImpl provider = new ProviderImpl();
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = XMLUtils.parse(is);
+ Document doc = StaxUtils.read(is);
DOMSource erXML = new DOMSource(doc);
EndpointReference endpointReference = EndpointReference.readFrom(erXML);
@@ -327,4 +325,21 @@ public class EndpointReferenceTest exten
}
}
+
+
+ public static Element fetchElementByNameAttribute(Element parent, String elementName, String nameValue) {
+ if (elementName.equals(parent.getTagName())
+ && parent.getAttribute("name").equals(nameValue)) {
+ return parent;
+ }
+ Element elem = DOMUtils.getFirstElement(parent);
+ while (elem != null) {
+ Element el = fetchElementByNameAttribute(elem, elementName, nameValue);
+ if (el != null) {
+ return el;
+ }
+ elem = DOMUtils.getNextElement(elem);
+ }
+ return null;
+ }
}
Modified: cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlEnvelopedOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlEnvelopedOutInterceptor.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlEnvelopedOutInterceptor.java (original)
+++ cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/SamlEnvelopedOutInterceptor.java Wed Jul 10 14:20:25 2013
@@ -109,7 +109,7 @@ public class SamlEnvelopedOutInterceptor
public void setEnvelopeName(String expandedName) {
- setEnvelopeQName(XMLUtils.convertStringToQName(expandedName, DEFAULT_ENV_PREFIX));
+ setEnvelopeQName(DOMUtils.convertStringToQName(expandedName, DEFAULT_ENV_PREFIX));
}
public void setEnvelopeQName(QName name) {
Modified: cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/xml/XmlSigOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/xml/XmlSigOutInterceptor.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/xml/XmlSigOutInterceptor.java (original)
+++ cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/xml/XmlSigOutInterceptor.java Wed Jul 10 14:20:25 2013
@@ -34,7 +34,6 @@ import org.w3c.dom.Element;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.message.Message;
import org.apache.cxf.rs.security.common.CryptoLoader;
import org.apache.cxf.rs.security.common.SecurityUtils;
@@ -227,7 +226,7 @@ public class XmlSigOutInterceptor extend
}
public void setEnvelopeName(String expandedName) {
- setEnvelopeQName(XMLUtils.convertStringToQName(expandedName, DEFAULT_ENV_PREFIX));
+ setEnvelopeQName(DOMUtils.convertStringToQName(expandedName, DEFAULT_ENV_PREFIX));
}
public void setEnvelopeQName(QName name) {
Modified: cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java (original)
+++ cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java Wed Jul 10 14:20:25 2013
@@ -298,7 +298,7 @@ public class JAXBExtensionHelper impleme
javax.xml.stream.XMLOutputFactory fact = javax.xml.stream.XMLOutputFactory.newInstance();
XMLStreamWriter writer =
- new PrettyPrintXMLStreamWriter(fact.createXMLStreamWriter(pw), getIndentLevel(parent));
+ new PrettyPrintXMLStreamWriter(fact.createXMLStreamWriter(pw), 2, getIndentLevel(parent));
writer.setNamespaceContext(new javax.xml.namespace.NamespaceContext() {
public String getNamespaceURI(String arg) {
Modified: cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java (original)
+++ cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/SchemaSerializer.java Wed Jul 10 14:20:25 2013
@@ -54,7 +54,7 @@ public class SchemaSerializer implements
private void writeXml(Node n, PrintWriter pw) throws XMLStreamException {
XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(pw);
- writer = new PrettyPrintXMLStreamWriter(writer, 0, 2);
+ writer = new PrettyPrintXMLStreamWriter(writer, 2);
StaxUtils.copy(new DOMSource(n), writer);
writer.close();
}
Modified: cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java (original)
+++ cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java Wed Jul 10 14:20:25 2013
@@ -55,7 +55,6 @@ import javax.wsdl.extensions.schema.Sche
import javax.wsdl.extensions.schema.SchemaImport;
import javax.wsdl.extensions.schema.SchemaReference;
import javax.xml.namespace.QName;
-import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -64,7 +63,6 @@ import org.apache.cxf.Bus;
import org.apache.cxf.common.WSDLConstants;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.service.model.AbstractMessageContainer;
import org.apache.cxf.service.model.AbstractPropertiesHolder;
import org.apache.cxf.service.model.BindingFaultInfo;
@@ -247,11 +245,7 @@ public class ServiceWSDLBuilder {
return;
}
if (docDoc == null) {
- try {
- docDoc = XMLUtils.newDocument();
- } catch (ParserConfigurationException e) {
- //ignore
- }
+ docDoc = DOMUtils.newDocument();
}
Element el = docDoc.createElementNS(WSDLConstants.NS_WSDL11, "wsdl:documentation");
el.setTextContent(text);
@@ -422,8 +416,8 @@ public class ServiceWSDLBuilder {
}
}
- Document doc = createDocument();
- Element nd = XMLUtils.createElementNS(doc, new QName(WSDLConstants.NS_SCHEMA_XSD, "schema"));
+ Document doc = DOMUtils.createDocument();
+ Element nd = doc.createElementNS(WSDLConstants.NS_SCHEMA_XSD, "schema");
nd.setAttribute("xmlns", WSDLConstants.NS_SCHEMA_XSD);
doc.appendChild(nd);
@@ -438,8 +432,7 @@ public class ServiceWSDLBuilder {
// this ensures only the schemas directly referenced by the wsdl are included.
if (defNamespaces.contains(schemaInfo.getNamespaceURI())) {
- Element impElement = XMLUtils.createElementNS(doc, new QName(WSDLConstants.NS_SCHEMA_XSD,
- "import"));
+ Element impElement = doc.createElementNS(WSDLConstants.NS_SCHEMA_XSD, "import");
impElement.setAttribute("schemaLocation", referencedSchema.getDocumentBaseURI());
impElement.setAttribute("namespace", schemaInfo.getNamespaceURI());
@@ -455,16 +448,6 @@ public class ServiceWSDLBuilder {
def.setTypes(types);
}
- private Document createDocument() {
- Document doc = null;
- try {
- doc = XMLUtils.newDocument();
- } catch (ParserConfigurationException e) {
- throw new RuntimeException("DOM configuration problem", e);
- }
- return doc;
- }
-
private void addSchemaImport(Schema schema, SchemaInfo schemaInfo, Schema referencedSchema) {
SchemaImport imp = schema.createImport();
imp.setId(schemaInfo.getSystemId());
Modified: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java (original)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java Wed Jul 10 14:20:25 2013
@@ -37,13 +37,14 @@ import org.apache.cxf.common.logging.Log
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.endpoint.dynamic.DynamicClientFactory;
import org.apache.cxf.frontend.ClientProxyFactoryBean;
-import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.systest.aegis.SportsService.Pair;
import org.apache.cxf.test.TestUtilities;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+
import org.junit.BeforeClass;
import org.junit.Test;
@@ -125,7 +126,7 @@ public class AegisClientServerTest exten
@Test
public void testWSDL() throws Exception {
URL url = new URL("http://localhost:" + PORT + "/jaxwsAndAegis?wsdl");
- Document dom = XMLUtils.parse(url.openStream());
+ Document dom = StaxUtils.read(url.openStream());
TestUtilities util = new TestUtilities(this.getClass());
util.addDefaultNamespaces();
util.assertInvalid("//wsdl:definitions/wsdl:types/xsd:schema/"
@@ -138,7 +139,7 @@ public class AegisClientServerTest exten
dom);
url = new URL("http://localhost:" + PORT + "/serviceWithCustomNS?wsdl");
- dom = XMLUtils.parse(url.openStream());
+ dom = StaxUtils.read(url.openStream());
util.assertValid("//wsdl:definitions[@targetNamespace='http://foo.bar.com']",
dom);
}
Modified: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisWSDLNSTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisWSDLNSTest.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisWSDLNSTest.java (original)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisWSDLNSTest.java Wed Jul 10 14:20:25 2013
@@ -26,8 +26,8 @@ import javax.xml.namespace.QName;
import org.w3c.dom.Document;
import org.apache.cxf.aegis.databinding.AegisDatabinding;
-import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.test.TestUtilities;
import org.apache.cxf.testutil.common.TestUtil;
@@ -82,7 +82,7 @@ public class AegisWSDLNSTest extends Abs
@Test
public void testGeneratedWsdlNs() throws Exception {
URL url = new URL("http://localhost:" + PORT + "/aegisJaxWsWSDLNS?wsdl");
- Document dom = XMLUtils.parse(url.openStream());
+ Document dom = StaxUtils.read(url.openStream());
TestUtilities util = new TestUtilities(this.getClass());
util.addDefaultNamespaces();
util.assertValid(
Modified: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/ClientServerSourceTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/ClientServerSourceTest.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/ClientServerSourceTest.java (original)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/ClientServerSourceTest.java Wed Jul 10 14:20:25 2013
@@ -33,7 +33,6 @@ import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
@@ -82,7 +81,7 @@ public class ClientServerSourceTest exte
ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor());
ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor());
- Document doc = XMLUtils.newDocument();
+ Document doc = DOMUtils.newDocument();
doc.appendChild(doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
"ns1:sayHi"));
DOMSource ds = new DOMSource(doc);
@@ -90,7 +89,7 @@ public class ClientServerSourceTest exte
assertEquals("We should get the right response", "Bonjour",
DOMUtils.getContent(getElement(resp.getNode())));
- doc = XMLUtils.newDocument();
+ doc = DOMUtils.newDocument();
Element el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
"ns1:greetMe");
Element el2 = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
@@ -104,7 +103,7 @@ public class ClientServerSourceTest exte
DOMUtils.getContent(DOMUtils.getFirstElement(getElement(resp.getNode()))));
try {
- doc = XMLUtils.newDocument();
+ doc = DOMUtils.newDocument();
el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
"ns1:greetMe");
el2 = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
Modified: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/GreeterImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/GreeterImpl.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/GreeterImpl.java (original)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/source/GreeterImpl.java Wed Jul 10 14:20:25 2013
@@ -19,7 +19,6 @@
package org.apache.cxf.systest.source;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.Document;
@@ -27,7 +26,6 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.helpers.XMLUtils;
import org.apache.hello_world_soap_http_source.source.GreetMeFault;
import org.apache.hello_world_soap_http_source.source.Greeter;
import org.apache.hello_world_soap_http_source.source.PingMeFault;
@@ -43,17 +41,13 @@ public class GreeterImpl implements Gree
}
public DOMSource sayHi(DOMSource in) {
- try {
- Document doc = XMLUtils.newDocument();
- Element el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
- "ns1:sayHiResponse");
- el.appendChild(doc.createTextNode("Bonjour"));
- doc.appendChild(el);
-
- return new DOMSource(doc);
- } catch (ParserConfigurationException e) {
- throw new RuntimeException(e);
- }
+ Document doc = DOMUtils.newDocument();
+ Element el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
+ "ns1:sayHiResponse");
+ el.appendChild(doc.createTextNode("Bonjour"));
+ doc.appendChild(el);
+
+ return new DOMSource(doc);
}
private Element getElement(Node nd) {
if (nd instanceof Document) {
@@ -66,32 +60,28 @@ public class GreeterImpl implements Gree
Element eval = getElement(in.getNode());
eval = DOMUtils.getFirstElement(eval);
String val = DOMUtils.getContent(eval);
- try {
- if ("fault".equals(val)) {
- Document doc = XMLUtils.newDocument();
- Element el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/"
- + "source/types",
- "ns1:greetMeFaultDetail");
- el.appendChild(doc.createTextNode("Some fault detail"));
- doc.appendChild(el);
-
- throw new GreetMeFault("Fault String", new DOMSource(doc));
- }
-
- Document doc = XMLUtils.newDocument();
- Element el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
- "ns1:greetMeResponse");
- Element el2 = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
- "ns1:responseType");
- el2.appendChild(doc.createTextNode("Hello " + val));
- el.appendChild(el2);
-
+ if ("fault".equals(val)) {
+ Document doc = DOMUtils.newDocument();
+ Element el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/"
+ + "source/types",
+ "ns1:greetMeFaultDetail");
+ el.appendChild(doc.createTextNode("Some fault detail"));
doc.appendChild(el);
- return new DOMSource(doc);
- } catch (ParserConfigurationException e) {
- throw new RuntimeException(e);
+ throw new GreetMeFault("Fault String", new DOMSource(doc));
}
+
+ Document doc = DOMUtils.newDocument();
+ Element el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
+ "ns1:greetMeResponse");
+ Element el2 = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
+ "ns1:responseType");
+ el2.appendChild(doc.createTextNode("Hello " + val));
+ el.appendChild(el2);
+
+ doc.appendChild(el);
+
+ return new DOMSource(doc);
}
public void pingMe() throws PingMeFault {
Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchXMLClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchXMLClientServerTest.java?rev=1501775&r1=1501774&r2=1501775&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchXMLClientServerTest.java (original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchXMLClientServerTest.java Wed Jul 10 14:20:25 2013
@@ -20,6 +20,7 @@
package org.apache.cxf.systest.dispatch;
import java.io.InputStream;
+import java.io.StringReader;
import java.net.URL;
import javax.xml.bind.JAXBContext;
@@ -36,12 +37,14 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.testutil.common.TestUtil;
import org.apache.hello_world_xml_http.wrapped.XMLService;
import org.apache.hello_world_xml_http.wrapped.types.GreetMe;
import org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse;
import org.apache.hello_world_xml_http.wrapped.types.ObjectFactory;
+
import org.junit.BeforeClass;
import org.junit.Test;
@@ -107,7 +110,7 @@ public class DispatchXMLClientServerTest
assertNotNull(source);
String streamString = XMLUtils.toString(source);
- Document doc = XMLUtils.parse(streamString);
+ Document doc = StaxUtils.read(new StringReader(streamString));
assertEquals("greetMeResponse", doc.getFirstChild().getLocalName());
assertEquals("Hello tli", doc.getFirstChild().getTextContent());
}
@@ -121,7 +124,7 @@ public class DispatchXMLClientServerTest
assertNotNull(service);
InputStream is = getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq.xml");
- Document doc = XMLUtils.parse(is);
+ Document doc = StaxUtils.read(is);
DOMSource reqMsg = new DOMSource(doc);
assertNotNull(reqMsg);