You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/09/15 21:07:03 UTC
svn commit: r289289 [88/134] - in /webservices/axis2/trunk/java: ./ etc/
modules/addressing/ modules/addressing/src/META-INF/
modules/addressing/src/org/apache/axis2/handlers/addressing/
modules/addressing/test-resources/ modules/addressing/test/org/ap...
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/NodeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/NodeImpl.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/NodeImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/NodeImpl.java Thu Sep 15 11:52:11 2005
@@ -1,537 +1,537 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.saaj;
-
-import org.apache.axis2.om.*;
-import org.apache.axis2.util.Dom2OmUtils;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.NodeList;
-
-import javax.xml.soap.Node;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import java.util.Iterator;
-
-/**
- * Class NodeImpl
- *
- * @author Ashutosh Shahi
- * ashutosh.shahi@gmail.com
- */
-public class NodeImpl implements Node {
-
- /**
- * Field omNode
- */
- protected org.apache.axis2.om.OMNode omNode;
- /**
- * field document
- */
- protected org.w3c.dom.Document document;
-
- //protected CharacterData textRep = null;
-
- /**
- * Constructor NodeImpl
- */
- public NodeImpl() {
-
- }
-
- /**
- * Constructor NodeImpl
- *
- * @param node
- */
- public NodeImpl(OMNode node) {
- this.omNode = node;
- }
-
- /**
- * Constructor NodeImpl
- *
- * @param attrib
- */
- public NodeImpl(OMAttribute attrib) {
- //TODO
- // To be implemented
- // Find out a way to construct OMNode from a OMAttribute
- // as OMAttributes are immutable
- }
-
- /**
- * Constructor NodeImpl
- *
- * @param ns
- */
- public NodeImpl(OMNamespace ns) {
- //TODO
- // To be implemented
- // Find out a way to construct OMNode from OMNamespace
- // OMNamespace is immutable
- }
-
- /**
- * constructor which adopts the name and NS of the char data, and its text
- *
- * @param text
- */
-/* public NodeImpl(CharacterData text) {
-
- }
-*/
-
- public OMNode getOMNode() {
- return omNode;
- }
-
- /**
- * Method getValue
- *
- * @see javax.xml.soap.Node#getValue()
- */
- public String getValue() {
-
- if (omNode.getType() == OMNode.TEXT_NODE)
- return ((OMText) omNode).getText();
- else if (omNode.getType() == OMNode.ELEMENT_NODE)
- return new NodeImpl(((OMElement) omNode).getFirstChild()).getValue();
- return null;
- }
-
- /**
- * Method setParentElement
- *
- * @param parent
- * @see javax.xml.soap.Node#setParentElement(javax.xml.soap.SOAPElement)
- */
- public void setParentElement(SOAPElement parent) throws SOAPException {
-
- OMElement omParent = ((SOAPElementImpl) parent).getOMElement();
- omNode.setParent(omParent);
- }
-
- /**
- * Method getParentElement
- *
- * @see javax.xml.soap.Node#getParentElement()
- */
- public SOAPElement getParentElement() {
-
- OMElement omParent = (OMElement) omNode.getParent();
- return new SOAPElementImpl(omParent);
- }
-
- /**
- * Method detachNode
- *
- * @see javax.xml.soap.Node#detachNode()
- */
- public void detachNode() {
-
- omNode.detach();
- }
-
- /**
- * Method recycleNode
- *
- * @see javax.xml.soap.Node#recycleNode()
- */
- public void recycleNode() {
- // No corresponding implementation in OM
- // There is no implementation in Axis 1.2 also
-
- }
-
- /**
- * Method setValue
- *
- * @param value
- * @see javax.xml.soap.Node#setValue(java.lang.String)
- */
- public void setValue(String value) {
-
- if (omNode.getType() == OMNode.TEXT_NODE) {
- OMElement parent = (OMElement) omNode.getParent();
- omNode.discard();
- omNode =
- org.apache.axis2.om.OMAbstractFactory.getOMFactory()
- .createText(parent, value);
- } else if (omNode.getType() == OMNode.ELEMENT_NODE) {
- OMNode firstChild = ((OMElement) omNode).getFirstChild();
- if (firstChild == null) {
- firstChild =
- org.apache.axis2.om.OMAbstractFactory.getOMFactory()
- .createText((OMElement) omNode, value);
- } else if (firstChild.getType() == OMNode.TEXT_NODE) {
- firstChild.discard();
- firstChild =
- org.apache.axis2.om.OMAbstractFactory.getOMFactory()
- .createText((OMElement) omNode, value);
- }
- } else {
- throw new IllegalStateException();
- }
- }
-
- /**
- * Method getNodeType
- *
- * @see org.w3c.dom.Node#getNodeType()
- */
- public short getNodeType() {
-
- return (short) omNode.getType();
- }
-
- /**
- * Method normalize
- *
- * @see org.w3c.dom.Node#normalize()
- */
- public void normalize() {
- // No corresponding function in OM
- //Axis 1.2 also doesn't have any implementation for this
-
- }
-
- /**
- * Method hasAttributes
- *
- * @see org.w3c.dom.Node#hasAttributes()
- */
- public boolean hasAttributes() {
- if (omNode instanceof OMElement) {
- Iterator iter = ((OMElement) omNode).getAttributes();
- return (iter.hasNext());
- }
- return false;
- }
-
- /**
- * Method hasChildNodes
- *
- * @see org.w3c.dom.Node#hasChildNodes()
- */
- public boolean hasChildNodes() {
- if (omNode instanceof OMElement) {
- Iterator iter = ((OMElement) omNode).getChildren();
- return (iter.hasNext());
- }
- return false;
- }
-
- /**
- * Method getLocalName
- *
- * @see org.w3c.dom.Node#getLocalName()
- */
- public String getLocalName() {
- if (omNode.getType() == ELEMENT_NODE || omNode.getType()
- == ATTRIBUTE_NODE)
- return ((OMElement) omNode).getLocalName();
- // TODO: else if(omNode.getType() == ATTRIBUTE_NODE)
- // return some
- return null;
- }
-
- /**
- * Method getNamespaceURI
- *
- * @see org.w3c.dom.Node#getNamespaceURI()
- */
- public String getNamespaceURI() {
-
- return ((OMElement) omNode).getNamespace().getName();
- }
-
- /**
- * Method getNodeName
- *
- * @see org.w3c.dom.Node#getNodeName()
- */
- public String getNodeName() {
-
- if (omNode.getType() == OMNode.ELEMENT_NODE)
- return ((OMElement) omNode).getLocalName();
- else if (omNode.getType() == OMNode.COMMENT_NODE)
- return "#comment";
- else if (omNode.getType() == OMNode.CDATA_SECTION_NODE)
- return "#cdata-section";
- else if (omNode.getType() == OMNode.TEXT_NODE)
- return "#text";
- //TODO else if Attribute Node so something
- // return attribute name
- return null;
- }
-
- /**
- * Method getNodeValue
- *
- * @see org.w3c.dom.Node#getNodeValue()
- */
- public String getNodeValue() throws DOMException {
- // Returns text for a TEXT_NODE, null otherwise
- if (omNode.getType() == OMNode.TEXT_NODE)
- return ((OMText) omNode).getText();
- //TODO else if(omNode.getType() == Attribute)
- else
- return null;
- }
-
- /**
- * Method getPrefix
- *
- * @see org.w3c.dom.Node#getPrefix()
- */
- public String getPrefix() {
- if (omNode.getType() == OMNode.ELEMENT_NODE)
- return ((OMElement) omNode).getNamespace().getPrefix();
- return null;
- }
-
- /**
- * Method setNodeValue
- *
- * @see org.w3c.dom.Node#setNodeValue(java.lang.String)
- */
- public void setNodeValue(String value) throws DOMException {
-
- if (omNode.getType() == OMNode.TEXT_NODE) {
- OMElement parent = (OMElement) omNode.getParent();
- omNode.discard();
- omNode =
- org.apache.axis2.om.OMAbstractFactory.getOMFactory()
- .createText(parent, value);
- }
- }
-
- /**
- * Method setPrefix
- *
- * @see org.w3c.dom.Node#setPrefix(java.lang.String)
- */
- public void setPrefix(String prefix) throws DOMException {
- //TODO - Do for attribute Node
- if (omNode.getType() == OMNode.ELEMENT_NODE /*|| Attribute Node*/) {
- OMNamespace ns = ((OMElement) omNode).getNamespace();
- String uri = ns.getName();
- OMNamespace newNs = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
- .createOMNamespace(uri, prefix);
- ((OMElement) omNode).setNamespace(newNs);
- }
-
- }
-
- /**
- * Method setOwnerDocument
- *
- * @param doc
- */
- public void setOwnerDocument(Document doc) {
- // method not part of org.w3c.dom.Node, created to set the document
- this.document = doc;
- }
-
- /**
- * Method getOwnerDocument
- *
- * @see org.w3c.dom.Node#getOwnerDocument()
- */
- public Document getOwnerDocument() {
- // return the set document
- return document;
- }
-
- /**
- * Method getAttributes
- *
- * @see org.w3c.dom.Node#getAttributes()
- */
- public NamedNodeMap getAttributes() {
- // Will have to provide an implementation of NamedNodeMap
- // Dropping for now
- // TODO
- Iterator iter = ((OMElement) omNode).getAttributes();
-
- return null;
- }
-
- /**
- * Method getFirstChild
- *
- * @see org.w3c.dom.Node#getFirstChild()
- */
- public org.w3c.dom.Node getFirstChild() {
- //
- OMNode child = ((OMElement) omNode).getFirstChild();
- return new NodeImpl(child);
- }
-
- /**
- * Method getLastChild
- *
- * @see org.w3c.dom.Node#getLastChild()
- */
- public org.w3c.dom.Node getLastChild() {
-
- Iterator children = ((OMElement) omNode).getChildren();
- Object child = null;
- while (children.hasNext()) {
- child = children.next();
- }
- if (child instanceof OMNode) {
- return new NodeImpl((OMNode) child);
- }
- return null;
- }
-
- /**
- * dom Node method
- */
- public org.w3c.dom.Node getNextSibling() {
-
- OMNode sibling = omNode.getNextSibling();
- return new NodeImpl(sibling);
- }
-
-
- public org.w3c.dom.Node getParentNode() {
-
- OMElement parent = (OMElement) omNode.getParent();
- return new NodeImpl(parent);
- }
-
- /**
- * dom Node method
- */
- public org.w3c.dom.Node getPreviousSibling() {
-
- OMNode prevSibling = omNode.getPreviousSibling();
- return new NodeImpl(prevSibling);
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#cloneNode(boolean)
- */
- public org.w3c.dom.Node cloneNode(boolean deep) {
- //TODO
- return null;
- }
-
- /**
- * DOM Node method
- */
- public NodeList getChildNodes() {
- Iterator iter = ((OMElement) omNode).getChildren();
- NodeListImpl list = new NodeListImpl();
- while (iter.hasNext()) {
- Object omChild = iter.next();
- if(omChild instanceof OMText){
- OMText omTextChild = (OMText)omChild;
- TextImpl textChild = new TextImpl(omTextChild);
- list.addNode(textChild);
- }else{
- OMNode omNodeChild = (OMNode)omChild;
- Node nodeChild = new NodeImpl(omNodeChild);
- list.addNode(nodeChild);
- }
-
- }
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#isSupported(java.lang.String, java.lang.String)
- */
- public boolean isSupported(String arg0, String arg1) {
- //TODO: Not implemented in 1.2 as well
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#appendChild(org.w3c.dom.Node)
- */
- public org.w3c.dom.Node appendChild(org.w3c.dom.Node node)
- throws DOMException {
-
- OMNode child = Dom2OmUtils.toOM(node);
- if (omNode.getType() == OMNode.ELEMENT_NODE)
- ((OMElement) omNode).addChild(child);
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#removeChild(org.w3c.dom.Node)
- */
- public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
- throws DOMException {
- //Check if equals method has been removed from OMNode
- OMNode child = Dom2OmUtils.toOM(oldChild);
- if (omNode.getType() == OMNode.ELEMENT_NODE) {
- Iterator iter = ((OMElement) omNode).getChildren();
- while (iter.hasNext()) {
- Object nextChild = iter.next();
- if (nextChild instanceof OMNode && nextChild.equals(child)) {
- ((OMElement) nextChild).discard();
- return oldChild;
- }
- }
- }
-
- return null;
- }
-
- /**
- * @see org.w3c.dom.Node#insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)
- */
- public org.w3c.dom.Node insertBefore(org.w3c.dom.Node arg0,
- org.w3c.dom.Node arg1) throws DOMException {
-
- return null;
- }
-
- /**
- * @see org.w3c.dom.Node#replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)
- */
- public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
- org.w3c.dom.Node refChild) throws DOMException {
- OMNode newOmChild = Dom2OmUtils.toOM(newChild);
- OMNode refOmChild = Dom2OmUtils.toOM(refChild);
- if (omNode.getType() == OMNode.ELEMENT_NODE) {
- Iterator iter = ((OMElement) omNode).getChildren();
- while (iter.hasNext()) {
- Object nextChild = iter.next();
- if (nextChild instanceof OMNode &&
- nextChild.equals(refOmChild)) {
-
- }
- }
- }
- return null;
- }
-
- public boolean equals(Object o) {
- if (o instanceof NodeImpl) {
- if (this.omNode.equals(((NodeImpl) o).omNode))
- return true;
- }
- return false;
- }
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.saaj;
+
+import org.apache.axis2.om.*;
+import org.apache.axis2.util.Dom2OmUtils;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.NodeList;
+
+import javax.xml.soap.Node;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import java.util.Iterator;
+
+/**
+ * Class NodeImpl
+ *
+ * @author Ashutosh Shahi
+ * ashutosh.shahi@gmail.com
+ */
+public class NodeImpl implements Node {
+
+ /**
+ * Field omNode
+ */
+ protected org.apache.axis2.om.OMNode omNode;
+ /**
+ * field document
+ */
+ protected org.w3c.dom.Document document;
+
+ //protected CharacterData textRep = null;
+
+ /**
+ * Constructor NodeImpl
+ */
+ public NodeImpl() {
+
+ }
+
+ /**
+ * Constructor NodeImpl
+ *
+ * @param node
+ */
+ public NodeImpl(OMNode node) {
+ this.omNode = node;
+ }
+
+ /**
+ * Constructor NodeImpl
+ *
+ * @param attrib
+ */
+ public NodeImpl(OMAttribute attrib) {
+ //TODO
+ // To be implemented
+ // Find out a way to construct OMNode from a OMAttribute
+ // as OMAttributes are immutable
+ }
+
+ /**
+ * Constructor NodeImpl
+ *
+ * @param ns
+ */
+ public NodeImpl(OMNamespace ns) {
+ //TODO
+ // To be implemented
+ // Find out a way to construct OMNode from OMNamespace
+ // OMNamespace is immutable
+ }
+
+ /**
+ * constructor which adopts the name and NS of the char data, and its text
+ *
+ * @param text
+ */
+/* public NodeImpl(CharacterData text) {
+
+ }
+*/
+
+ public OMNode getOMNode() {
+ return omNode;
+ }
+
+ /**
+ * Method getValue
+ *
+ * @see javax.xml.soap.Node#getValue()
+ */
+ public String getValue() {
+
+ if (omNode.getType() == OMNode.TEXT_NODE)
+ return ((OMText) omNode).getText();
+ else if (omNode.getType() == OMNode.ELEMENT_NODE)
+ return new NodeImpl(((OMElement) omNode).getFirstChild()).getValue();
+ return null;
+ }
+
+ /**
+ * Method setParentElement
+ *
+ * @param parent
+ * @see javax.xml.soap.Node#setParentElement(javax.xml.soap.SOAPElement)
+ */
+ public void setParentElement(SOAPElement parent) throws SOAPException {
+
+ OMElement omParent = ((SOAPElementImpl) parent).getOMElement();
+ omNode.setParent(omParent);
+ }
+
+ /**
+ * Method getParentElement
+ *
+ * @see javax.xml.soap.Node#getParentElement()
+ */
+ public SOAPElement getParentElement() {
+
+ OMElement omParent = (OMElement) omNode.getParent();
+ return new SOAPElementImpl(omParent);
+ }
+
+ /**
+ * Method detachNode
+ *
+ * @see javax.xml.soap.Node#detachNode()
+ */
+ public void detachNode() {
+
+ omNode.detach();
+ }
+
+ /**
+ * Method recycleNode
+ *
+ * @see javax.xml.soap.Node#recycleNode()
+ */
+ public void recycleNode() {
+ // No corresponding implementation in OM
+ // There is no implementation in Axis 1.2 also
+
+ }
+
+ /**
+ * Method setValue
+ *
+ * @param value
+ * @see javax.xml.soap.Node#setValue(java.lang.String)
+ */
+ public void setValue(String value) {
+
+ if (omNode.getType() == OMNode.TEXT_NODE) {
+ OMElement parent = (OMElement) omNode.getParent();
+ omNode.discard();
+ omNode =
+ org.apache.axis2.om.OMAbstractFactory.getOMFactory()
+ .createText(parent, value);
+ } else if (omNode.getType() == OMNode.ELEMENT_NODE) {
+ OMNode firstChild = ((OMElement) omNode).getFirstChild();
+ if (firstChild == null) {
+ firstChild =
+ org.apache.axis2.om.OMAbstractFactory.getOMFactory()
+ .createText((OMElement) omNode, value);
+ } else if (firstChild.getType() == OMNode.TEXT_NODE) {
+ firstChild.discard();
+ firstChild =
+ org.apache.axis2.om.OMAbstractFactory.getOMFactory()
+ .createText((OMElement) omNode, value);
+ }
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ /**
+ * Method getNodeType
+ *
+ * @see org.w3c.dom.Node#getNodeType()
+ */
+ public short getNodeType() {
+
+ return (short) omNode.getType();
+ }
+
+ /**
+ * Method normalize
+ *
+ * @see org.w3c.dom.Node#normalize()
+ */
+ public void normalize() {
+ // No corresponding function in OM
+ //Axis 1.2 also doesn't have any implementation for this
+
+ }
+
+ /**
+ * Method hasAttributes
+ *
+ * @see org.w3c.dom.Node#hasAttributes()
+ */
+ public boolean hasAttributes() {
+ if (omNode instanceof OMElement) {
+ Iterator iter = ((OMElement) omNode).getAttributes();
+ return (iter.hasNext());
+ }
+ return false;
+ }
+
+ /**
+ * Method hasChildNodes
+ *
+ * @see org.w3c.dom.Node#hasChildNodes()
+ */
+ public boolean hasChildNodes() {
+ if (omNode instanceof OMElement) {
+ Iterator iter = ((OMElement) omNode).getChildren();
+ return (iter.hasNext());
+ }
+ return false;
+ }
+
+ /**
+ * Method getLocalName
+ *
+ * @see org.w3c.dom.Node#getLocalName()
+ */
+ public String getLocalName() {
+ if (omNode.getType() == ELEMENT_NODE || omNode.getType()
+ == ATTRIBUTE_NODE)
+ return ((OMElement) omNode).getLocalName();
+ // TODO: else if(omNode.getType() == ATTRIBUTE_NODE)
+ // return some
+ return null;
+ }
+
+ /**
+ * Method getNamespaceURI
+ *
+ * @see org.w3c.dom.Node#getNamespaceURI()
+ */
+ public String getNamespaceURI() {
+
+ return ((OMElement) omNode).getNamespace().getName();
+ }
+
+ /**
+ * Method getNodeName
+ *
+ * @see org.w3c.dom.Node#getNodeName()
+ */
+ public String getNodeName() {
+
+ if (omNode.getType() == OMNode.ELEMENT_NODE)
+ return ((OMElement) omNode).getLocalName();
+ else if (omNode.getType() == OMNode.COMMENT_NODE)
+ return "#comment";
+ else if (omNode.getType() == OMNode.CDATA_SECTION_NODE)
+ return "#cdata-section";
+ else if (omNode.getType() == OMNode.TEXT_NODE)
+ return "#text";
+ //TODO else if Attribute Node so something
+ // return attribute name
+ return null;
+ }
+
+ /**
+ * Method getNodeValue
+ *
+ * @see org.w3c.dom.Node#getNodeValue()
+ */
+ public String getNodeValue() throws DOMException {
+ // Returns text for a TEXT_NODE, null otherwise
+ if (omNode.getType() == OMNode.TEXT_NODE)
+ return ((OMText) omNode).getText();
+ //TODO else if(omNode.getType() == Attribute)
+ else
+ return null;
+ }
+
+ /**
+ * Method getPrefix
+ *
+ * @see org.w3c.dom.Node#getPrefix()
+ */
+ public String getPrefix() {
+ if (omNode.getType() == OMNode.ELEMENT_NODE)
+ return ((OMElement) omNode).getNamespace().getPrefix();
+ return null;
+ }
+
+ /**
+ * Method setNodeValue
+ *
+ * @see org.w3c.dom.Node#setNodeValue(java.lang.String)
+ */
+ public void setNodeValue(String value) throws DOMException {
+
+ if (omNode.getType() == OMNode.TEXT_NODE) {
+ OMElement parent = (OMElement) omNode.getParent();
+ omNode.discard();
+ omNode =
+ org.apache.axis2.om.OMAbstractFactory.getOMFactory()
+ .createText(parent, value);
+ }
+ }
+
+ /**
+ * Method setPrefix
+ *
+ * @see org.w3c.dom.Node#setPrefix(java.lang.String)
+ */
+ public void setPrefix(String prefix) throws DOMException {
+ //TODO - Do for attribute Node
+ if (omNode.getType() == OMNode.ELEMENT_NODE /*|| Attribute Node*/) {
+ OMNamespace ns = ((OMElement) omNode).getNamespace();
+ String uri = ns.getName();
+ OMNamespace newNs = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
+ .createOMNamespace(uri, prefix);
+ ((OMElement) omNode).setNamespace(newNs);
+ }
+
+ }
+
+ /**
+ * Method setOwnerDocument
+ *
+ * @param doc
+ */
+ public void setOwnerDocument(Document doc) {
+ // method not part of org.w3c.dom.Node, created to set the document
+ this.document = doc;
+ }
+
+ /**
+ * Method getOwnerDocument
+ *
+ * @see org.w3c.dom.Node#getOwnerDocument()
+ */
+ public Document getOwnerDocument() {
+ // return the set document
+ return document;
+ }
+
+ /**
+ * Method getAttributes
+ *
+ * @see org.w3c.dom.Node#getAttributes()
+ */
+ public NamedNodeMap getAttributes() {
+ // Will have to provide an implementation of NamedNodeMap
+ // Dropping for now
+ // TODO
+ Iterator iter = ((OMElement) omNode).getAttributes();
+
+ return null;
+ }
+
+ /**
+ * Method getFirstChild
+ *
+ * @see org.w3c.dom.Node#getFirstChild()
+ */
+ public org.w3c.dom.Node getFirstChild() {
+ //
+ OMNode child = ((OMElement) omNode).getFirstChild();
+ return new NodeImpl(child);
+ }
+
+ /**
+ * Method getLastChild
+ *
+ * @see org.w3c.dom.Node#getLastChild()
+ */
+ public org.w3c.dom.Node getLastChild() {
+
+ Iterator children = ((OMElement) omNode).getChildren();
+ Object child = null;
+ while (children.hasNext()) {
+ child = children.next();
+ }
+ if (child instanceof OMNode) {
+ return new NodeImpl((OMNode) child);
+ }
+ return null;
+ }
+
+ /**
+ * dom Node method
+ */
+ public org.w3c.dom.Node getNextSibling() {
+
+ OMNode sibling = omNode.getNextSibling();
+ return new NodeImpl(sibling);
+ }
+
+
+ public org.w3c.dom.Node getParentNode() {
+
+ OMElement parent = (OMElement) omNode.getParent();
+ return new NodeImpl(parent);
+ }
+
+ /**
+ * dom Node method
+ */
+ public org.w3c.dom.Node getPreviousSibling() {
+
+ OMNode prevSibling = omNode.getPreviousSibling();
+ return new NodeImpl(prevSibling);
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Node#cloneNode(boolean)
+ */
+ public org.w3c.dom.Node cloneNode(boolean deep) {
+ //TODO
+ return null;
+ }
+
+ /**
+ * DOM Node method
+ */
+ public NodeList getChildNodes() {
+ Iterator iter = ((OMElement) omNode).getChildren();
+ NodeListImpl list = new NodeListImpl();
+ while (iter.hasNext()) {
+ Object omChild = iter.next();
+ if(omChild instanceof OMText){
+ OMText omTextChild = (OMText)omChild;
+ TextImpl textChild = new TextImpl(omTextChild);
+ list.addNode(textChild);
+ }else{
+ OMNode omNodeChild = (OMNode)omChild;
+ Node nodeChild = new NodeImpl(omNodeChild);
+ list.addNode(nodeChild);
+ }
+
+ }
+ return list;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Node#isSupported(java.lang.String, java.lang.String)
+ */
+ public boolean isSupported(String arg0, String arg1) {
+ //TODO: Not implemented in 1.2 as well
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Node#appendChild(org.w3c.dom.Node)
+ */
+ public org.w3c.dom.Node appendChild(org.w3c.dom.Node node)
+ throws DOMException {
+
+ OMNode child = Dom2OmUtils.toOM(node);
+ if (omNode.getType() == OMNode.ELEMENT_NODE)
+ ((OMElement) omNode).addChild(child);
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Node#removeChild(org.w3c.dom.Node)
+ */
+ public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
+ throws DOMException {
+ //Check if equals method has been removed from OMNode
+ OMNode child = Dom2OmUtils.toOM(oldChild);
+ if (omNode.getType() == OMNode.ELEMENT_NODE) {
+ Iterator iter = ((OMElement) omNode).getChildren();
+ while (iter.hasNext()) {
+ Object nextChild = iter.next();
+ if (nextChild instanceof OMNode && nextChild.equals(child)) {
+ ((OMElement) nextChild).discard();
+ return oldChild;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @see org.w3c.dom.Node#insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)
+ */
+ public org.w3c.dom.Node insertBefore(org.w3c.dom.Node arg0,
+ org.w3c.dom.Node arg1) throws DOMException {
+
+ return null;
+ }
+
+ /**
+ * @see org.w3c.dom.Node#replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)
+ */
+ public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
+ org.w3c.dom.Node refChild) throws DOMException {
+ OMNode newOmChild = Dom2OmUtils.toOM(newChild);
+ OMNode refOmChild = Dom2OmUtils.toOM(refChild);
+ if (omNode.getType() == OMNode.ELEMENT_NODE) {
+ Iterator iter = ((OMElement) omNode).getChildren();
+ while (iter.hasNext()) {
+ Object nextChild = iter.next();
+ if (nextChild instanceof OMNode &&
+ nextChild.equals(refOmChild)) {
+
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean equals(Object o) {
+ if (o instanceof NodeImpl) {
+ if (this.omNode.equals(((NodeImpl) o).omNode))
+ return true;
+ }
+ return false;
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/NodeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/NodeListImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/NodeListImpl.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/NodeListImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/NodeListImpl.java Thu Sep 15 11:52:11 2005
@@ -1,78 +1,78 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.saaj;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author Ashutosh Shahi
- * <p/>
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class NodeListImpl implements NodeList {
-
- List mNodes;
-
- public static final NodeList EMPTY_NODELIST = new NodeListImpl(
- Collections.EMPTY_LIST);
-
- /**
- * Constructor and Setter is intensionally made package access only.
- */
- NodeListImpl() {
- mNodes = new ArrayList();
- }
-
- NodeListImpl(List nodes) {
- this();
- mNodes.addAll(nodes);
- }
-
- void addNode(org.w3c.dom.Node node) {
- mNodes.add(node);
- }
-
- void addNodeList(org.w3c.dom.NodeList nodes) {
- for (int i = 0; i < nodes.getLength(); i++) {
- mNodes.add(nodes.item(i));
- }
- }
-
- /**
- * Interface Implemented
- *
- * @param index
- * @return
- */
- public Node item(int index) {
- if (mNodes != null && mNodes.size() > index) {
- return (Node) mNodes.get(index);
- } else {
- return null;
- }
- }
-
- public int getLength() {
- return mNodes.size();
- }
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.saaj;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Ashutosh Shahi
+ * <p/>
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class NodeListImpl implements NodeList {
+
+ List mNodes;
+
+ public static final NodeList EMPTY_NODELIST = new NodeListImpl(
+ Collections.EMPTY_LIST);
+
+ /**
+ * Constructor and Setter is intensionally made package access only.
+ */
+ NodeListImpl() {
+ mNodes = new ArrayList();
+ }
+
+ NodeListImpl(List nodes) {
+ this();
+ mNodes.addAll(nodes);
+ }
+
+ void addNode(org.w3c.dom.Node node) {
+ mNodes.add(node);
+ }
+
+ void addNodeList(org.w3c.dom.NodeList nodes) {
+ for (int i = 0; i < nodes.getLength(); i++) {
+ mNodes.add(nodes.item(i));
+ }
+ }
+
+ /**
+ * Interface Implemented
+ *
+ * @param index
+ * @return
+ */
+ public Node item(int index) {
+ if (mNodes != null && mNodes.size() > index) {
+ return (Node) mNodes.get(index);
+ } else {
+ return null;
+ }
+ }
+
+ public int getLength() {
+ return mNodes.size();
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/NodeListImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/PrefixedQName.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/PrefixedQName.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/PrefixedQName.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/PrefixedQName.java Thu Sep 15 11:52:11 2005
@@ -1,142 +1,142 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.saaj;
-
-import javax.xml.namespace.QName;
-import javax.xml.soap.Name;
-
-/**
- * Class Prefixed QName
- * <p/>
- * Took this implementation from Axis 1.2 code
- */
-public class PrefixedQName implements Name {
- /**
- * comment/shared empty string
- */
- private static final String emptyString = "".intern();
-
- /**
- * Field prefix
- */
- private String prefix;
- /**
- * Field qName
- */
- private QName qName;
-
- /**
- * Constructor PrefixedQName
- *
- * @param uri
- * @param localName
- * @param pre
- */
- public PrefixedQName(String uri, String localName, String pre) {
- qName = new QName(uri, localName);
- prefix = (pre == null)
- ? emptyString
- : pre.intern();
- }
-
- /**
- * Constructor qname
- *
- * @param qname
- * @return
- */
- public PrefixedQName(QName qname) {
- this.qName = qname;
- prefix = emptyString;
- }
-
- /**
- * Method getLocalName
- *
- * @return
- */
- public String getLocalName() {
- return qName.getLocalPart();
- }
-
- /**
- * Method getQualifiedName
- *
- * @return
- */
- public String getQualifiedName() {
- StringBuffer buf = new StringBuffer(prefix);
- if (!prefix.equals(emptyString))
- buf.append(':');
- buf.append(qName.getLocalPart());
- return buf.toString();
- }
-
- /**
- * Method getURI
- *
- * @return
- */
- public String getURI() {
- return qName.getNamespaceURI();
- }
-
- /**
- * Method getPrefix
- *
- * @return
- */
- public String getPrefix() {
- return prefix;
- }
-
- /**
- * Method equals
- *
- * @param obj
- * @return
- */
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof PrefixedQName)) {
- return false;
- }
- if (!qName.equals(((PrefixedQName) obj).qName)) {
- return false;
- }
- return prefix.equals(((PrefixedQName) obj).prefix);
- }
-
- /**
- * Method hasCode
- *
- * @return
- */
- public int hashCode() {
- return prefix.hashCode() + qName.hashCode();
- }
-
- /**
- * Method toString
- *
- * @return
- */
- public String toString() {
- return qName.toString();
- }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.saaj;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.Name;
+
+/**
+ * Class Prefixed QName
+ * <p/>
+ * Took this implementation from Axis 1.2 code
+ */
+public class PrefixedQName implements Name {
+ /**
+ * comment/shared empty string
+ */
+ private static final String emptyString = "".intern();
+
+ /**
+ * Field prefix
+ */
+ private String prefix;
+ /**
+ * Field qName
+ */
+ private QName qName;
+
+ /**
+ * Constructor PrefixedQName
+ *
+ * @param uri
+ * @param localName
+ * @param pre
+ */
+ public PrefixedQName(String uri, String localName, String pre) {
+ qName = new QName(uri, localName);
+ prefix = (pre == null)
+ ? emptyString
+ : pre.intern();
+ }
+
+ /**
+ * Constructor qname
+ *
+ * @param qname
+ * @return
+ */
+ public PrefixedQName(QName qname) {
+ this.qName = qname;
+ prefix = emptyString;
+ }
+
+ /**
+ * Method getLocalName
+ *
+ * @return
+ */
+ public String getLocalName() {
+ return qName.getLocalPart();
+ }
+
+ /**
+ * Method getQualifiedName
+ *
+ * @return
+ */
+ public String getQualifiedName() {
+ StringBuffer buf = new StringBuffer(prefix);
+ if (!prefix.equals(emptyString))
+ buf.append(':');
+ buf.append(qName.getLocalPart());
+ return buf.toString();
+ }
+
+ /**
+ * Method getURI
+ *
+ * @return
+ */
+ public String getURI() {
+ return qName.getNamespaceURI();
+ }
+
+ /**
+ * Method getPrefix
+ *
+ * @return
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+
+ /**
+ * Method equals
+ *
+ * @param obj
+ * @return
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof PrefixedQName)) {
+ return false;
+ }
+ if (!qName.equals(((PrefixedQName) obj).qName)) {
+ return false;
+ }
+ return prefix.equals(((PrefixedQName) obj).prefix);
+ }
+
+ /**
+ * Method hasCode
+ *
+ * @return
+ */
+ public int hashCode() {
+ return prefix.hashCode() + qName.hashCode();
+ }
+
+ /**
+ * Method toString
+ *
+ * @return
+ */
+ public String toString() {
+ return qName.toString();
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/PrefixedQName.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyElementImpl.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyElementImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyElementImpl.java Thu Sep 15 11:52:11 2005
@@ -1,47 +1,47 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.saaj;
-
-import org.apache.axis2.om.OMElement;
-
-import javax.xml.soap.SOAPBodyElement;
-
-/**
- * Class SOAPBodeElementImpl
- *
- * @author Ashutosh Shahi
- * ashutosh.shahi@gmail.com
- */
-public class SOAPBodyElementImpl extends SOAPElementImpl implements
- SOAPBodyElement {
-
- /**
- * Constructor SOAPBodeElementImpl
- */
- public SOAPBodyElementImpl() {
- super();
- }
-
- /**
- * Constructor SOAPBodeElementImpl
- *
- * @param bodyElement
- */
- public SOAPBodyElementImpl(OMElement bodyElement) {
- super(bodyElement);
- }
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.saaj;
+
+import org.apache.axis2.om.OMElement;
+
+import javax.xml.soap.SOAPBodyElement;
+
+/**
+ * Class SOAPBodeElementImpl
+ *
+ * @author Ashutosh Shahi
+ * ashutosh.shahi@gmail.com
+ */
+public class SOAPBodyElementImpl extends SOAPElementImpl implements
+ SOAPBodyElement {
+
+ /**
+ * Constructor SOAPBodeElementImpl
+ */
+ public SOAPBodyElementImpl() {
+ super();
+ }
+
+ /**
+ * Constructor SOAPBodeElementImpl
+ *
+ * @param bodyElement
+ */
+ public SOAPBodyElementImpl(OMElement bodyElement) {
+ super(bodyElement);
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyElementImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java Thu Sep 15 11:52:11 2005
@@ -1,186 +1,186 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.saaj;
-
-import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMFactory;
-import org.apache.axis2.soap.SOAPFactory;
-import org.w3c.dom.Document;
-
-import javax.xml.namespace.QName;
-import javax.xml.soap.*;
-import java.util.Locale;
-
-/**
- * Class SOAPBodeImpl
- *
- * @author Jayachandra
- * jayachandra@gmail.com
- */
-public class SOAPBodyImpl extends SOAPElementImpl implements SOAPBody {
- /**
- * Field omSOAPBody
- * omSOAPBody is the OM's SOAPBody object that is used for delegation purpose
- */
- private org.apache.axis2.soap.SOAPBody omSOAPBody;
-
- /**
- * Constructor SOAPBodeImpl
- * The constructor to facilitate conversion of SAAJ SOAPBody out of OM SOAPBody
- *
- * @param omSoapBody
- */
- public SOAPBodyImpl(org.apache.axis2.soap.SOAPBody omSoapBody) {
- super(omSoapBody);
- this.omSOAPBody = omSoapBody;
- }
-
- /**
- * Method addFault
- *
- * @return
- * @throws SOAPException
- * @see javax.xml.soap.SOAPBody#addFault()
- */
- public SOAPFault addFault() throws SOAPException {
- try {
- //OM SOAPFaultImpl has SOAPFaultImpl(OMElement parent, Exception e) constructor, will use that
- SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
- org.apache.axis2.soap.SOAPFault omSoapFault = soapFactory.createSOAPFault(
- omSOAPBody);
- omSOAPBody.addFault(omSoapFault);
- return (new SOAPFaultImpl(omSoapFault));
- } catch (Exception e) {
- throw new SOAPException(e);
- }
- }
-
- /**
- * Method hasFault
- *
- * @return
- * @see javax.xml.soap.SOAPBody#hasFault()
- */
- public boolean hasFault() {
- return omSOAPBody.hasFault();
- }
-
- /**
- * Method getFault
- *
- * @return
- * @see javax.xml.soap.SOAPBody#getFault()
- */
- public SOAPFault getFault() {
- return (new SOAPFaultImpl(omSOAPBody.getFault()));
- }
-
- /**
- * Method addBodyElement
- *
- * @param name
- * @return
- * @throws SOAPException
- * @see javax.xml.soap.SOAPBody#addBodyElement(javax.xml.soap.Name)
- */
- public SOAPBodyElement addBodyElement(Name name) throws SOAPException {
-
- try {
- OMFactory omFactory = OMAbstractFactory.getOMFactory();
- QName qname = new QName(name.getURI(),
- name.getLocalName(),
- name.getPrefix());
- OMElement bodyElement = omFactory.createOMElement(qname,
- omSOAPBody);
- omSOAPBody.addChild(bodyElement);
- return (new SOAPBodyElementImpl(bodyElement));
- } catch (Exception e) {
- throw new SOAPException(e);
- }
- }
-
- /**
- * Method addFault
- *
- * @param faultCode
- * @param faultString
- * @param
- * @throws SOAPException
- * @see javax.xml.soap.SOAPBody#addFault(javax.xml.soap.Name, java.lang.String, java.util.Locale)
- */
- public SOAPFault addFault(Name faultCode,
- String faultString,
- Locale locale)
- throws SOAPException {
- try {
- //OM SOAPFaultImpl has SOAPFaultImpl(OMElement parent, Exception e) constructor, will use that
- //actually soap fault is created with the OM's default SOAPFAULT_LOCALNAME and PREFIX, b'coz I've droppe the name param
- //a work around can be possible but would be confusing as there is no straight forward soapfault constructor in om.
- //So am deferring it.
- //even locale param is dropped, don't know how to handle it at the moment. so dropped it.
- SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
- org.apache.axis2.soap.SOAPFault omSoapFault = soapFactory.createSOAPFault(
- omSOAPBody, new Exception(faultString));
- omSOAPBody.addFault(omSoapFault);
- return (new SOAPFaultImpl(omSoapFault));
- } catch (Exception e) {
- throw new SOAPException(e);
- }
- }
-
- /**
- * Method addFault
- *
- * @param faultCode
- * @param faultString
- * @return
- * @throws SOAPException
- * @see javax.xml.soap.SOAPBody#addFault(javax.xml.soap.Name, java.lang.String)
- */
- public SOAPFault addFault(Name faultCode, String faultString)
- throws SOAPException {
- try {
- //OM SOAPFaultImpl has SOAPFaultImpl(OMElement parent, Exception e) constructor, will use that
- //actually soap fault is created with the OM's default SOAPFAULT_LOCALNAME and PREFIX, b'coz I've droppe the name param
- //a work around can be possible but would be confusing as there is no straight forward soapfault constructor in om.
- //So am deferring it.
- SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
- org.apache.axis2.soap.SOAPFault omSoapFault = soapFactory.createSOAPFault(
- omSOAPBody, new Exception(faultString));
- omSOAPBody.addFault(omSoapFault);
- return (new SOAPFaultImpl(omSoapFault));
- } catch (Exception e) {
- throw new SOAPException(e);
- }
- }
-
- /**
- * Method addDocument
- *
- * @param document
- * @return
- * @throws SOAPException
- * @see javax.xml.soap.SOAPBody#addDocument(org.w3c.dom.Document)
- */
- public SOAPBodyElement addDocument(Document document) throws SOAPException {
- /*
- * Don't know how to resolve this as yet. So deferring it.
- */
- return null;
- }
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.saaj;
+
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.soap.SOAPFactory;
+import org.w3c.dom.Document;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.*;
+import java.util.Locale;
+
+/**
+ * Class SOAPBodeImpl
+ *
+ * @author Jayachandra
+ * jayachandra@gmail.com
+ */
+public class SOAPBodyImpl extends SOAPElementImpl implements SOAPBody {
+ /**
+ * Field omSOAPBody
+ * omSOAPBody is the OM's SOAPBody object that is used for delegation purpose
+ */
+ private org.apache.axis2.soap.SOAPBody omSOAPBody;
+
+ /**
+ * Constructor SOAPBodeImpl
+ * The constructor to facilitate conversion of SAAJ SOAPBody out of OM SOAPBody
+ *
+ * @param omSoapBody
+ */
+ public SOAPBodyImpl(org.apache.axis2.soap.SOAPBody omSoapBody) {
+ super(omSoapBody);
+ this.omSOAPBody = omSoapBody;
+ }
+
+ /**
+ * Method addFault
+ *
+ * @return
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPBody#addFault()
+ */
+ public SOAPFault addFault() throws SOAPException {
+ try {
+ //OM SOAPFaultImpl has SOAPFaultImpl(OMElement parent, Exception e) constructor, will use that
+ SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
+ org.apache.axis2.soap.SOAPFault omSoapFault = soapFactory.createSOAPFault(
+ omSOAPBody);
+ omSOAPBody.addFault(omSoapFault);
+ return (new SOAPFaultImpl(omSoapFault));
+ } catch (Exception e) {
+ throw new SOAPException(e);
+ }
+ }
+
+ /**
+ * Method hasFault
+ *
+ * @return
+ * @see javax.xml.soap.SOAPBody#hasFault()
+ */
+ public boolean hasFault() {
+ return omSOAPBody.hasFault();
+ }
+
+ /**
+ * Method getFault
+ *
+ * @return
+ * @see javax.xml.soap.SOAPBody#getFault()
+ */
+ public SOAPFault getFault() {
+ return (new SOAPFaultImpl(omSOAPBody.getFault()));
+ }
+
+ /**
+ * Method addBodyElement
+ *
+ * @param name
+ * @return
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPBody#addBodyElement(javax.xml.soap.Name)
+ */
+ public SOAPBodyElement addBodyElement(Name name) throws SOAPException {
+
+ try {
+ OMFactory omFactory = OMAbstractFactory.getOMFactory();
+ QName qname = new QName(name.getURI(),
+ name.getLocalName(),
+ name.getPrefix());
+ OMElement bodyElement = omFactory.createOMElement(qname,
+ omSOAPBody);
+ omSOAPBody.addChild(bodyElement);
+ return (new SOAPBodyElementImpl(bodyElement));
+ } catch (Exception e) {
+ throw new SOAPException(e);
+ }
+ }
+
+ /**
+ * Method addFault
+ *
+ * @param faultCode
+ * @param faultString
+ * @param
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPBody#addFault(javax.xml.soap.Name, java.lang.String, java.util.Locale)
+ */
+ public SOAPFault addFault(Name faultCode,
+ String faultString,
+ Locale locale)
+ throws SOAPException {
+ try {
+ //OM SOAPFaultImpl has SOAPFaultImpl(OMElement parent, Exception e) constructor, will use that
+ //actually soap fault is created with the OM's default SOAPFAULT_LOCALNAME and PREFIX, b'coz I've droppe the name param
+ //a work around can be possible but would be confusing as there is no straight forward soapfault constructor in om.
+ //So am deferring it.
+ //even locale param is dropped, don't know how to handle it at the moment. so dropped it.
+ SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
+ org.apache.axis2.soap.SOAPFault omSoapFault = soapFactory.createSOAPFault(
+ omSOAPBody, new Exception(faultString));
+ omSOAPBody.addFault(omSoapFault);
+ return (new SOAPFaultImpl(omSoapFault));
+ } catch (Exception e) {
+ throw new SOAPException(e);
+ }
+ }
+
+ /**
+ * Method addFault
+ *
+ * @param faultCode
+ * @param faultString
+ * @return
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPBody#addFault(javax.xml.soap.Name, java.lang.String)
+ */
+ public SOAPFault addFault(Name faultCode, String faultString)
+ throws SOAPException {
+ try {
+ //OM SOAPFaultImpl has SOAPFaultImpl(OMElement parent, Exception e) constructor, will use that
+ //actually soap fault is created with the OM's default SOAPFAULT_LOCALNAME and PREFIX, b'coz I've droppe the name param
+ //a work around can be possible but would be confusing as there is no straight forward soapfault constructor in om.
+ //So am deferring it.
+ SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
+ org.apache.axis2.soap.SOAPFault omSoapFault = soapFactory.createSOAPFault(
+ omSOAPBody, new Exception(faultString));
+ omSOAPBody.addFault(omSoapFault);
+ return (new SOAPFaultImpl(omSoapFault));
+ } catch (Exception e) {
+ throw new SOAPException(e);
+ }
+ }
+
+ /**
+ * Method addDocument
+ *
+ * @param document
+ * @return
+ * @throws SOAPException
+ * @see javax.xml.soap.SOAPBody#addDocument(org.w3c.dom.Document)
+ */
+ public SOAPBodyElement addDocument(Document document) throws SOAPException {
+ /*
+ * Don't know how to resolve this as yet. So deferring it.
+ */
+ return null;
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionFactoryImpl.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionFactoryImpl.java Thu Sep 15 11:52:11 2005
@@ -1,42 +1,42 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.saaj;
-
-import javax.xml.soap.SOAPConnection;
-import javax.xml.soap.SOAPConnectionFactory;
-import javax.xml.soap.SOAPException;
-
-/**
- * Class SOAPConnectionFactoryImpl
- *
- * @author Ashutosh Shahi
- * ashutosh.shahi@gmail.com
- */
-public class SOAPConnectionFactoryImpl extends SOAPConnectionFactory {
-
- /**
- * Create a new <CODE>SOAPConnection</CODE>.
- *
- * @return the new <CODE>SOAPConnection</CODE> object.
- * @throws SOAPException if there was an exception
- * creating the <CODE>SOAPConnection</CODE> object.
- */
- public SOAPConnection createConnection() throws SOAPException {
-
- return new SOAPConnectionImpl();
- }
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.saaj;
+
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPException;
+
+/**
+ * Class SOAPConnectionFactoryImpl
+ *
+ * @author Ashutosh Shahi
+ * ashutosh.shahi@gmail.com
+ */
+public class SOAPConnectionFactoryImpl extends SOAPConnectionFactory {
+
+ /**
+ * Create a new <CODE>SOAPConnection</CODE>.
+ *
+ * @return the new <CODE>SOAPConnection</CODE> object.
+ * @throws SOAPException if there was an exception
+ * creating the <CODE>SOAPConnection</CODE> object.
+ */
+ public SOAPConnection createConnection() throws SOAPException {
+
+ return new SOAPConnectionImpl();
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionFactoryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java Thu Sep 15 11:52:11 2005
@@ -1,199 +1,199 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.saaj;
-
-import org.w3c.dom.Node;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.clientapi.Call;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMAttribute;
-import org.apache.axis2.om.OMNode;
-import org.apache.axis2.om.OMText;
-import org.apache.axis2.util.SessionUtils;
-
-import javax.activation.DataHandler;
-import javax.xml.soap.SOAPConnection;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.soap.SOAPEnvelope;
-import javax.xml.soap.AttachmentPart;
-import javax.xml.namespace.QName;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import java.util.Iterator;
-
-/**
- * Class SOAPConnectionImpl
- *
- * @author Ashutosh Shahi (ashutosh.shahi@gmail.com)
- */
-public class SOAPConnectionImpl extends SOAPConnection {
-
- /* (non-Javadoc)
- * @see javax.xml.soap.SOAPConnection#call(javax.xml.soap.SOAPMessage, java.lang.Object)
- */
- public SOAPMessage call(SOAPMessage request, Object endpoint)
- throws SOAPException {
- try {
- OMElement envelope = ((SOAPEnvelopeImpl) request.getSOAPPart()
- .getEnvelope()).getOMEnvelope();
-
- //parse the omEnvelope element and stuff it with the attachment
- //specific omText nodes
- insertAttachmentNodes(envelope, request);
-
- Call call = new Call();
- URL url = new URL(endpoint.toString());
- call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
- call.setTransportInfo(Constants.TRANSPORT_HTTP,
- Constants.TRANSPORT_HTTP,
- false);
- call.setTo(
- new EndpointReference(url.toString()));
- String axisOp = request.getSOAPBody().getFirstChild().getNodeName();
- NodeImpl bodyContentNode = (NodeImpl)request.getSOAPBody().getFirstChild();
- OMElement bodyContent = (OMElement)bodyContentNode.getOMNode();
- OMElement result = call.invokeBlocking(axisOp, bodyContent);
- org.apache.axis2.soap.SOAPEnvelope responseEnv = (org.apache.axis2.soap.SOAPEnvelope) ((OMElement)result.getParent()).getParent();
- SOAPEnvelopeImpl response = new SOAPEnvelopeImpl(responseEnv);
-
- SOAPMessageImpl sMsg = new SOAPMessageImpl(response);
- extractAttachmentNodes(responseEnv, sMsg);
- return sMsg;
-
- } catch (MalformedURLException mue) {
- throw new SOAPException(mue);
- } catch (AxisFault af) {
- throw new SOAPException(af);
- }
- }
-
-
- /* (non-Javadoc)
- * @see javax.xml.soap.SOAPConnection#close()
- */
- public void close() throws SOAPException {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * This method recursively stuffs the OMElement with appropriate OMText nodes
- * that are prepared out of attachment contents whereever those attachments are referenced
- * @param element
- * @param soapMsg
- */
- private void insertAttachmentNodes(OMElement element, SOAPMessage soapMsg) throws SOAPException {
- Iterator childIter = element.getChildElements();
- while(childIter.hasNext()) {
- OMElement child = (OMElement)childIter.next();
- //check if there is an href attribute
- OMAttribute hrefAttr = (OMAttribute)child.getFirstAttribute(new QName("href"));
- String hrefContentId = validateHref(hrefAttr);
-
- if (hrefContentId!=null) {//This is an element referencing an attachment!
- OMText omText = getOMTextForReferencedAttachment(hrefContentId, soapMsg);
- child.build();
- child.removeAttribute(hrefAttr);
- child.addChild(omText);
-
- } else { //possibly there can be references in the children of this element
- //so recurse through.
- insertAttachmentNodes(child, soapMsg);
- }
- }
- }
-
- /**
- * The method recursively looks for the binary text nodes and adds them as attachment
- * to soapMessage at the same time removing them from soapEnv and putting appropriate
- * contentId
- * @param element
- * @param soapMsg
- */
- private void extractAttachmentNodes(OMElement element, SOAPMessage soapMsg){
- Iterator childIter = element.getChildren();
- while(childIter.hasNext()) {
- OMNode child = (OMNode)childIter.next();
- if(child instanceof OMText){
- OMText binaryNode = (OMText)child;
- DataHandler actualDH = binaryNode.getDataHandler();
- if(actualDH != null){
- AttachmentPart ap = soapMsg.createAttachmentPart(actualDH);
- String contentId = SessionUtils.generateSessionId();
- ap.setContentId(contentId);
- ap.setContentType(actualDH.getContentType());
- OMElement parent = (OMElement)child.getParent();
- OMAttribute attr = org.apache.axis2.om.OMAbstractFactory.getOMFactory().createOMAttribute("href", null,"cid:"+contentId);
- parent.addAttribute(attr);
- binaryNode.detach();
- soapMsg.addAttachmentPart(ap);
- }
- } else{
- if(child instanceof OMElement) {
- OMElement childElement = (OMElement)child;
- extractAttachmentNodes(childElement, soapMsg);
- }
- }
- }
- }
- /**
- * This method checks the value of attribute and if it is a valid CID then
- * returns the contentID (with cid: prefix stripped off) or else returns null.
- * A null return value can be assumed that this attribute is not an attachment
- * referencing attribute
- */
- private String validateHref(OMAttribute attr) {
- String contentId;
- if(attr!=null) {
- contentId = attr.getValue();
- } else {
- return null;
- }
-
- if (contentId.startsWith("cid:")) {
- contentId = contentId.substring(4);
- return contentId;
- }
- return null;
- }
-
- /**
- * This method looks up the attachment part corresponding to the given contentId and
- * returns the OMText node thta has the content of the attachment.
- * @param contentId
- * @param soapMsg
- * @return
- */
- private OMText getOMTextForReferencedAttachment(String contentId, SOAPMessage soapMsg) throws SOAPException{
- Iterator attachIter = soapMsg.getAttachments();
- while(attachIter.hasNext()) {
- AttachmentPart attachment = (AttachmentPart)attachIter.next();
- if(attachment.getContentId().equals(contentId)) {
- try {
- return ((AttachmentPartImpl)attachment).getOMText();
- } catch (Exception e) {
- throw new SOAPException(e);
- }
- }
- }
- throw new SOAPException("No attachment found with the given contentID");
- }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.saaj;
+
+import org.w3c.dom.Node;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.clientapi.Call;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMNode;
+import org.apache.axis2.om.OMText;
+import org.apache.axis2.util.SessionUtils;
+
+import javax.activation.DataHandler;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.namespace.QName;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import java.util.Iterator;
+
+/**
+ * Class SOAPConnectionImpl
+ *
+ * @author Ashutosh Shahi (ashutosh.shahi@gmail.com)
+ */
+public class SOAPConnectionImpl extends SOAPConnection {
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPConnection#call(javax.xml.soap.SOAPMessage, java.lang.Object)
+ */
+ public SOAPMessage call(SOAPMessage request, Object endpoint)
+ throws SOAPException {
+ try {
+ OMElement envelope = ((SOAPEnvelopeImpl) request.getSOAPPart()
+ .getEnvelope()).getOMEnvelope();
+
+ //parse the omEnvelope element and stuff it with the attachment
+ //specific omText nodes
+ insertAttachmentNodes(envelope, request);
+
+ Call call = new Call();
+ URL url = new URL(endpoint.toString());
+ call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
+ call.setTransportInfo(Constants.TRANSPORT_HTTP,
+ Constants.TRANSPORT_HTTP,
+ false);
+ call.setTo(
+ new EndpointReference(url.toString()));
+ String axisOp = request.getSOAPBody().getFirstChild().getNodeName();
+ NodeImpl bodyContentNode = (NodeImpl)request.getSOAPBody().getFirstChild();
+ OMElement bodyContent = (OMElement)bodyContentNode.getOMNode();
+ OMElement result = call.invokeBlocking(axisOp, bodyContent);
+ org.apache.axis2.soap.SOAPEnvelope responseEnv = (org.apache.axis2.soap.SOAPEnvelope) ((OMElement)result.getParent()).getParent();
+ SOAPEnvelopeImpl response = new SOAPEnvelopeImpl(responseEnv);
+
+ SOAPMessageImpl sMsg = new SOAPMessageImpl(response);
+ extractAttachmentNodes(responseEnv, sMsg);
+ return sMsg;
+
+ } catch (MalformedURLException mue) {
+ throw new SOAPException(mue);
+ } catch (AxisFault af) {
+ throw new SOAPException(af);
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPConnection#close()
+ */
+ public void close() throws SOAPException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * This method recursively stuffs the OMElement with appropriate OMText nodes
+ * that are prepared out of attachment contents whereever those attachments are referenced
+ * @param element
+ * @param soapMsg
+ */
+ private void insertAttachmentNodes(OMElement element, SOAPMessage soapMsg) throws SOAPException {
+ Iterator childIter = element.getChildElements();
+ while(childIter.hasNext()) {
+ OMElement child = (OMElement)childIter.next();
+ //check if there is an href attribute
+ OMAttribute hrefAttr = (OMAttribute)child.getFirstAttribute(new QName("href"));
+ String hrefContentId = validateHref(hrefAttr);
+
+ if (hrefContentId!=null) {//This is an element referencing an attachment!
+ OMText omText = getOMTextForReferencedAttachment(hrefContentId, soapMsg);
+ child.build();
+ child.removeAttribute(hrefAttr);
+ child.addChild(omText);
+
+ } else { //possibly there can be references in the children of this element
+ //so recurse through.
+ insertAttachmentNodes(child, soapMsg);
+ }
+ }
+ }
+
+ /**
+ * The method recursively looks for the binary text nodes and adds them as attachment
+ * to soapMessage at the same time removing them from soapEnv and putting appropriate
+ * contentId
+ * @param element
+ * @param soapMsg
+ */
+ private void extractAttachmentNodes(OMElement element, SOAPMessage soapMsg){
+ Iterator childIter = element.getChildren();
+ while(childIter.hasNext()) {
+ OMNode child = (OMNode)childIter.next();
+ if(child instanceof OMText){
+ OMText binaryNode = (OMText)child;
+ DataHandler actualDH = binaryNode.getDataHandler();
+ if(actualDH != null){
+ AttachmentPart ap = soapMsg.createAttachmentPart(actualDH);
+ String contentId = SessionUtils.generateSessionId();
+ ap.setContentId(contentId);
+ ap.setContentType(actualDH.getContentType());
+ OMElement parent = (OMElement)child.getParent();
+ OMAttribute attr = org.apache.axis2.om.OMAbstractFactory.getOMFactory().createOMAttribute("href", null,"cid:"+contentId);
+ parent.addAttribute(attr);
+ binaryNode.detach();
+ soapMsg.addAttachmentPart(ap);
+ }
+ } else{
+ if(child instanceof OMElement) {
+ OMElement childElement = (OMElement)child;
+ extractAttachmentNodes(childElement, soapMsg);
+ }
+ }
+ }
+ }
+ /**
+ * This method checks the value of attribute and if it is a valid CID then
+ * returns the contentID (with cid: prefix stripped off) or else returns null.
+ * A null return value can be assumed that this attribute is not an attachment
+ * referencing attribute
+ */
+ private String validateHref(OMAttribute attr) {
+ String contentId;
+ if(attr!=null) {
+ contentId = attr.getValue();
+ } else {
+ return null;
+ }
+
+ if (contentId.startsWith("cid:")) {
+ contentId = contentId.substring(4);
+ return contentId;
+ }
+ return null;
+ }
+
+ /**
+ * This method looks up the attachment part corresponding to the given contentId and
+ * returns the OMText node thta has the content of the attachment.
+ * @param contentId
+ * @param soapMsg
+ * @return
+ */
+ private OMText getOMTextForReferencedAttachment(String contentId, SOAPMessage soapMsg) throws SOAPException{
+ Iterator attachIter = soapMsg.getAttachments();
+ while(attachIter.hasNext()) {
+ AttachmentPart attachment = (AttachmentPart)attachIter.next();
+ if(attachment.getContentId().equals(contentId)) {
+ try {
+ return ((AttachmentPartImpl)attachment).getOMText();
+ } catch (Exception e) {
+ throw new SOAPException(e);
+ }
+ }
+ }
+ throw new SOAPException("No attachment found with the given contentID");
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
------------------------------------------------------------------------------
svn:eol-style = native