You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ru...@apache.org on 2006/10/11 01:45:46 UTC
svn commit: r462640 - in /webservices/axis2/branches/java/1_1/modules:
kernel/src/org/apache/axis2/util/XMLUtils.java
security/src/org/apache/rampart/MessageBuilder.java
security/src/org/apache/rampart/util/Axis2Util.java
Author: ruchithf
Date: Tue Oct 10 16:45:45 2006
New Revision: 462640
URL: http://svn.apache.org/viewvc?view=rev&rev=462640
Log:
Pushing toOM and toDOM methods into XMLUtils
Modified:
webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/util/XMLUtils.java
webservices/axis2/branches/java/1_1/modules/security/src/org/apache/rampart/MessageBuilder.java
webservices/axis2/branches/java/1_1/modules/security/src/org/apache/rampart/util/Axis2Util.java
Modified: webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/util/XMLUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/util/XMLUtils.java?view=diff&rev=462640&r1=462639&r2=462640
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/util/XMLUtils.java (original)
+++ webservices/axis2/branches/java/1_1/modules/kernel/src/org/apache/axis2/util/XMLUtils.java Tue Oct 10 16:45:45 2006
@@ -17,6 +17,10 @@
package org.apache.axis2.util;
import com.ibm.wsdl.Constants;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.util.StAXUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Document;
@@ -36,7 +40,16 @@
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
@@ -475,5 +488,48 @@
return ret;
}
return null;
+ }
+
+ /**
+ * Converts a given DOM Element to an OMElement.
+ * @param element
+ * @return Returns OMElement.
+ * @throws Exception
+ */
+ public static OMElement toOM(Element element) throws Exception {
+
+ Source source = new DOMSource(element);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Result result = new StreamResult(baos);
+
+ Transformer xformer = TransformerFactory.newInstance().newTransformer();
+ xformer.transform(source, result);
+
+ ByteArrayInputStream is = new ByteArrayInputStream(baos.toByteArray());
+ XMLStreamReader reader = StAXUtils
+ .createXMLStreamReader(is);
+
+ StAXOMBuilder builder = new StAXOMBuilder(reader);
+ builder.setCache(true);
+
+ return builder.getDocumentElement();
+ }
+
+
+ /**
+ * Converts a given OMElement to a DOM Element.
+ * @param element
+ * @return Returns Element.
+ * @throws Exception
+ */
+ public static Element toDOM(OMElement element) throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ element.serialize(baos);
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ return factory.newDocumentBuilder().parse(bais).getDocumentElement();
}
}
Modified: webservices/axis2/branches/java/1_1/modules/security/src/org/apache/rampart/MessageBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/security/src/org/apache/rampart/MessageBuilder.java?view=diff&rev=462640&r1=462639&r2=462640
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/security/src/org/apache/rampart/MessageBuilder.java (original)
+++ webservices/axis2/branches/java/1_1/modules/security/src/org/apache/rampart/MessageBuilder.java Tue Oct 10 16:45:45 2006
@@ -24,6 +24,7 @@
import org.apache.axis2.addressing.AddressingConstants.Submission;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.util.XMLUtils;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -102,7 +103,7 @@
OMElement bodyElem = msgCtx.getEnvelope().getBody();
OMElement child = bodyElem.getFirstElement();
OMElement newChild = TrustUtil.createCancelRequest(tokenId, rmd.getWstVersion());
- Element newDomChild = Axis2Util.toDOM(newChild);
+ Element newDomChild = XMLUtils.toDOM(newChild);
Node importedNode = rmd.getDocument().importNode((Element) newDomChild, true);
((Element) bodyElem).replaceChild(importedNode, (Element) child);
} else {
Modified: webservices/axis2/branches/java/1_1/modules/security/src/org/apache/rampart/util/Axis2Util.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/security/src/org/apache/rampart/util/Axis2Util.java?view=diff&rev=462640&r1=462639&r2=462640
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/security/src/org/apache/rampart/util/Axis2Util.java (original)
+++ webservices/axis2/branches/java/1_1/modules/security/src/org/apache/rampart/util/Axis2Util.java Tue Oct 10 16:45:45 2006
@@ -21,7 +21,6 @@
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
-import org.apache.axiom.om.util.StAXUtils;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAPEnvelope;
@@ -35,12 +34,6 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.stream.FactoryConfigurationError;
import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -170,49 +163,6 @@
return originalKey;
}
- /**
- * Converts a given DOM Element to an OMElement.
- * @param element
- * @return Returns OMElement.
- * @throws Exception
- */
- public static OMElement toOM(Element element) throws Exception {
-
- Source source = new DOMSource(element);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Result result = new StreamResult(baos);
-
- Transformer xformer = TransformerFactory.newInstance().newTransformer();
- xformer.transform(source, result);
-
- ByteArrayInputStream is = new ByteArrayInputStream(baos.toByteArray());
- XMLStreamReader reader = StAXUtils
- .createXMLStreamReader(is);
-
- StAXOMBuilder builder = new StAXOMBuilder(reader);
- builder.setCache(true);
-
- return builder.getDocumentElement();
- }
-
-
- /**
- * Converts a given OMElement to a DOM Element.
- * @param element
- * @return Returns Element.
- * @throws Exception
- */
- public static Element toDOM(OMElement element) throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- element.serialize(baos);
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- return factory.newDocumentBuilder().parse(bais).getDocumentElement();
- }
-
/**
* This will build a DOOM Element that is of the same <code>Document</code>
* @param factory
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org