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 2005/12/07 07:02:52 UTC

svn commit: r354727 - in /webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom: AttrImpl.java ChildNode.java DOMUtil.java DocumentImpl.java ElementImpl.java ParentNode.java TextImpl.java

Author: ruchithf
Date: Tue Dec  6 22:02:35 2005
New Revision: 354727

URL: http://svn.apache.org/viewcvs?rev=354727&view=rev
Log:
Got DOOM to work with integration-security scenario 2a (UsernameToken Sig)


Modified:
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ChildNode.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DOMUtil.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java?rev=354727&r1=354726&r2=354727&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java Tue Dec  6 22:02:35 2005
@@ -372,4 +372,7 @@
 	}    
     
 
+	public String toString() {
+		return (this.namespace == null)?this.attrName: this.namespace.getPrefix() + ":" + this.attrName;
+	}
 }

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ChildNode.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ChildNode.java?rev=354727&r1=354726&r2=354727&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ChildNode.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ChildNode.java Tue Dec  6 22:02:35 2005
@@ -26,7 +26,7 @@
  */
 public abstract class ChildNode extends NodeImpl {
 
-	protected ChildNode previousSubling;
+	protected ChildNode previousSibling;
 	
 	protected ChildNode nextSibling;
 	
@@ -51,10 +51,10 @@
 		return this.nextSibling;
 	}
 	public OMNode getPreviousOMSibling() {
-		return this.previousSubling;
+		return this.previousSibling;
 	}
 	public Node getPreviousSibling() {
-		return this.previousSubling;
+		return this.previousSibling;
 	}
 
 	///
@@ -69,7 +69,7 @@
 
 	public void setPreviousOMSibling(OMNode node) {
 		if(node instanceof ChildNode)
-			this.previousSubling = (ChildNode)node;
+			this.previousSibling = (ChildNode)node;
 		else
 			throw new OMException("The node is not a " + ChildNode.class);		
 	}
@@ -94,12 +94,17 @@
 		if(this.parentNode == null) {
 			throw new OMException("Parent level elements cannot be ditached");
 		} else {
-			if(previousSubling == null) { // This is the first child
-				this.parentNode.setFirstChild(nextSibling);
+			if(previousSibling == null) { // This is the first child
+				if(nextSibling != null) {
+					this.parentNode.setFirstChild(nextSibling);
+				} else {
+					this.parentNode.firstChild = null;
+					this.parentNode.lastChild = null;
+				}
 			} else {
 				((OMNodeEx)this.getPreviousOMSibling()).setNextOMSibling(nextSibling);
 			} if (this.nextSibling != null) {
-				this.nextSibling.setPreviousOMSibling(this.previousSubling);
+				this.nextSibling.setPreviousOMSibling(this.previousSibling);
 			}
 			this.parentNode = null; 
 		}
@@ -122,9 +127,9 @@
 		
 		if(sibling instanceof ChildNode) {
 			ChildNode domSibling = (ChildNode)sibling;
-			domSibling.previousSubling = this;
+			domSibling.previousSibling = this;
 			if(this.nextSibling != null) {
-				this.nextSibling.previousSubling = domSibling;
+				this.nextSibling.previousSibling = domSibling;
 			}
 			domSibling.nextSibling = this.nextSibling;
 			this.nextSibling = domSibling;
@@ -142,11 +147,11 @@
 		if(sibling instanceof ChildNode) {
 			ChildNode domSibling = (ChildNode)sibling;
 			domSibling.nextSibling = this;
-			if(this.previousSubling != null) {
-				this.previousSubling.nextSibling = domSibling;
+			if(this.previousSibling != null) {
+				this.previousSibling.nextSibling = domSibling;
 			}
-			domSibling.previousSubling = this.previousSubling;
-			this.previousSubling = domSibling;
+			domSibling.previousSibling = this.previousSibling;
+			this.previousSibling = domSibling;
 			
 		} else {
 			throw new OMException("The given child is not of type " + ChildNode.class);

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DOMUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DOMUtil.java?rev=354727&r1=354726&r2=354727&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DOMUtil.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DOMUtil.java Tue Dec  6 22:02:35 2005
@@ -48,7 +48,7 @@
 	 * @return
 	 */
 	public static String getLocalName(String qualifiedName) {
-		if(qualifiedName.indexOf(":") > -1) {
+		if(qualifiedName.indexOf(":") > -1 && !qualifiedName.trim().endsWith(":")) {
 			return qualifiedName.split(":")[1];
 		} else  {
 			return qualifiedName;

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java?rev=354727&r1=354726&r2=354727&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java Tue Dec  6 22:02:35 2005
@@ -15,6 +15,7 @@
  */
 package org.apache.axis2.om.impl.dom;
 
+import org.apache.axis2.om.OMConstants;
 import org.apache.axis2.om.OMContainer;
 import org.apache.axis2.om.OMDocument;
 import org.apache.axis2.om.OMElement;
@@ -140,14 +141,18 @@
 	
 	public Attr createAttributeNS(String namespaceURI, String qualifiedName)
 			throws DOMException {
-		
-		String localName = DOMUtil.getLocalName(qualifiedName);
-		String prefix = DOMUtil.getPrefix(qualifiedName);
-		
-		this.checkQName(prefix,localName);
-		
-		return new AttrImpl(this,localName,
-				new NamespaceImpl(namespaceURI, prefix));
+		if(!namespaceURI.equals(OMConstants.XMLNS_NS_URI)) {
+			String localName = DOMUtil.getLocalName(qualifiedName);
+			String prefix = DOMUtil.getPrefix(qualifiedName);
+			
+			this.checkQName(prefix,localName);
+			
+			return new AttrImpl(this,localName,
+					new NamespaceImpl(namespaceURI, prefix));
+		} else {
+			//Do nothing since we handle the 'xmlns:' internally
+			return null;
+		}
 	}
 	
 	public CDATASection createCDATASection(String arg0) throws DOMException {
@@ -173,8 +178,10 @@
 		
 		String localName = DOMUtil.getLocalName(qualifiedName);
 		String prefix = DOMUtil.getPrefix(qualifiedName);
-		
-		this.checkQName(prefix,localName);
+
+		if(ns != null && (prefix != null || "".equals(prefix))) {
+			this.checkQName(prefix,localName);
+		}
 		
 		NamespaceImpl namespace = new NamespaceImpl(ns, prefix);
 		return new ElementImpl(this, localName, namespace);
@@ -226,21 +233,21 @@
 				} else {
 					newElement = createElementNS(importedNode.getNamespaceURI(),importedNode.getNodeName());
 				}
-				
+				 
 				//Copy element's attributes, if any.
                 NamedNodeMap sourceAttrs = importedNode.getAttributes();
                 if (sourceAttrs != null) {
                     int length = sourceAttrs.getLength();
                     for (int index = 0; index < length; index++) {
                         Attr attr = (Attr)sourceAttrs.item(index);
-                        
-                        Attr newAttr = (Attr) importNode(attr, true);
-                        if(attr.getLocalName() == null) {
+                        if(attr.getNamespaceURI() != null && !attr.getNamespaceURI().equals(OMConstants.XMLNS_NS_URI)) {
+                        	Attr newAttr = (Attr) importNode(attr, true);
+                            newElement.setAttributeNodeNS(newAttr);
+                        } else if(attr.getLocalName() == null) {
+                        	Attr newAttr = (Attr) importNode(attr, true);
                         	newElement.setAttributeNode(newAttr);
-                        } else {
-                        	newElement.setAttributeNodeNS(newAttr);
                         }
-                        
+                     
                     }
                 }
                 newNode = newElement;

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java?rev=354727&r1=354726&r2=354727&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java Tue Dec  6 22:02:35 2005
@@ -138,8 +138,15 @@
 	 * @see org.w3c.dom.Node#getNodeName()
 	 */
 	public String getNodeName() {
-		return (this.namespace != null) ? this.namespace.getPrefix() + ":"
-				+ this.localName : this.localName;
+		if(this.namespace != null) {
+			if(this.namespace.getPrefix() == null || "".equals(this.namespace.getPrefix())) {
+				return this.localName;
+			} else {
+				return this.namespace.getPrefix() + ":" + this.localName;
+			}
+		} else {
+			return this.localName;
+		}
 	}
 
 	/**
@@ -177,7 +184,7 @@
 	 * @see org.w3c.dom.Element#getTagName()
 	 */
 	public String getTagName() {
-		return (this.namespace != null) ? this.namespace.getPrefix() + ":" + this.localName : this.localName;
+		return this.getNodeName();
 	}
 
 	/**
@@ -477,7 +484,21 @@
 	 * Returns whether this element contains any attr or not
 	 */
     public boolean hasAttributes() {
-    	return this.attributes==null?false:this.attributes.getLength()>0;
+    	
+    	boolean flag = false;
+    	if(this.attributes != null) {
+    		flag = (this.attributes.getLength() > 0);
+    	}
+    	
+    	if(!flag) {
+    		if(this.namespaces != null) {
+    			flag = !this.namespaces.isEmpty();
+    		} else if(this.namespace != null) {
+    			flag = true;
+    		}
+    	}
+    	
+    	return flag;
     }
 
 	/* (non-Javadoc)
@@ -540,11 +561,10 @@
         if (namespaces == null) {
             this.namespaces = new HashMap(5);
         }
-        if(namespace != null) {
+        if(namespace != null && (namespace.getPrefix() != null || "".equals(namespace.getPrefix()))) {
         	if(!namespace.getPrefix().startsWith(OMConstants.XMLNS_NS_PREFIX)) {
         		namespaces.put(namespace.getPrefix(), namespace);
         	}
-        	
         }
         return namespace;
 	}
@@ -881,7 +901,7 @@
      * @see java.lang.Object#toString()
      */
     public String toString() {
-    	return (this.namespace != null)?namespace.getName():"" + this.localName;
+    	return (this.namespace != null)? namespace.getPrefix() + ":" + this.localName :"" + this.localName;
     }
 	/* (non-Javadoc)
 	 * @see org.apache.axis2.om.OMElement#getChildElements()
@@ -978,11 +998,25 @@
 			while (nsDecls.hasNext()) {
 				String prefix = (String) nsDecls.next();
 				if(!prefix.equals(OMConstants.XMLNS_NS_PREFIX)){
-					OMNamespace ns = (OMNamespace)this.namespaces.get(prefix);
-					AttrImpl attr = new AttrImpl(this.ownerNode,prefix, ns.getName());
-					attr.setOMNamespace(new NamespaceImpl(OMConstants.XMLNS_NS_URI, OMConstants.XMLNS_NS_PREFIX));
+					OMNamespace ns = (OMNamespace) this.namespaces.get(prefix);
+					AttrImpl attr = new AttrImpl(this.ownerNode, prefix, ns
+							.getName());
+					attr.setOMNamespace(new NamespaceImpl(
+							OMConstants.XMLNS_NS_URI,
+							OMConstants.XMLNS_NS_PREFIX));
 					attributeMap.addItem(attr);
 				}
+			}
+			
+			//Set the default NS attr if any
+			if (this.namespace != null
+					&& (this.namespace.getPrefix() == null || ""
+							.equals(this.namespace.getPrefix()))
+					&& this.namespace.getName() != null) {
+
+				AttrImpl attr = new AttrImpl(this.ownerNode, "xmlns",
+						this.namespace.getName());
+				attributeMap.addItem(attr);
 			}
     	}
     	

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java?rev=354727&r1=354726&r2=354727&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java Tue Dec  6 22:02:35 2005
@@ -183,7 +183,7 @@
 				this.firstChild.isFirstChild(true);
 			} else {
 				this.lastChild.nextSibling = newDomChild;
-				newDomChild.previousSubling = this.lastChild;
+				newDomChild.previousSibling = this.lastChild;
 			
 				this.lastChild = newDomChild;
 			}
@@ -206,7 +206,7 @@
 							DocumentFragmentimpl docFrag = (DocumentFragmentimpl)newChild;
 							this.firstChild = docFrag.firstChild;
 							docFrag.lastChild.nextSibling = refDomChild;
-							refDomChild.previousSubling = docFrag.lastChild.nextSibling; 
+							refDomChild.previousSibling = docFrag.lastChild.nextSibling; 
 							
 						} else {
 							
@@ -214,32 +214,32 @@
 							this.firstChild = newDomChild;
 							
 							newDomChild.nextSibling = refDomChild;
-							refDomChild.previousSubling = newDomChild;
+							refDomChild.previousSibling = newDomChild;
 							
 							this.firstChild.isFirstChild(true);
 							refDomChild.isFirstChild(false);
-							newDomChild.previousSubling = null; //Just to be sure :-)
+							newDomChild.previousSibling = null; //Just to be sure :-)
 							
 						}
 					} else { //If the refChild is not the fist child
-						ChildNode previousNode = refDomChild.previousSubling;
+						ChildNode previousNode = refDomChild.previousSibling;
 						
 						if(newChild instanceof DocumentFragmentimpl) {
 							//the newChild is a document fragment
 							DocumentFragmentimpl docFrag = (DocumentFragmentimpl)newChild;
 							
 							previousNode.nextSibling = docFrag.firstChild;
-							docFrag.firstChild.previousSubling = previousNode;
+							docFrag.firstChild.previousSibling = previousNode;
 							
 							docFrag.lastChild.nextSibling = refDomChild;
-							refDomChild.previousSubling = docFrag.lastChild;
+							refDomChild.previousSibling = docFrag.lastChild;
 						} else {
 							
 							previousNode.nextSibling = newDomChild;
-							newDomChild.previousSubling = previousNode;
+							newDomChild.previousSibling = previousNode;
 							
 							newDomChild.nextSibling = refDomChild;
-							refDomChild.previousSubling = newDomChild;
+							refDomChild.previousSibling = newDomChild;
 						}
 						
 					}
@@ -305,28 +305,32 @@
 //					docFrag.firstChild.previousSubling = oldDomChild.previousSubling;
 //					
 				} else {
-					newDomChild.nextSibling = oldDomChild.nextSibling;
-					newDomChild.previousSubling = oldDomChild.previousSubling;
-					
-					oldDomChild.previousSubling.nextSibling = newDomChild;
-					
-					//If the old child is not the last
-					if(oldDomChild.nextSibling != null) {
-						oldDomChild.nextSibling.previousSubling = newDomChild;
+					if(oldDomChild.isFirstChild()) {
+						oldDomChild.detach();
+						this.addChild(newDomChild);
 					} else {
-						this.lastChild = newDomChild;
-					}
-					
-					if(newDomChild.parentNode == null) {
-						newDomChild.parentNode = this;
+						newDomChild.nextSibling = oldDomChild.nextSibling;
+						newDomChild.previousSibling = oldDomChild.previousSibling;
+						
+						oldDomChild.previousSibling.nextSibling = newDomChild;
+						
+						//If the old child is not the last
+						if(oldDomChild.nextSibling != null) {
+							oldDomChild.nextSibling.previousSibling = newDomChild;
+						} else {
+							this.lastChild = newDomChild;
+						}
+						
+						if(newDomChild.parentNode == null) {
+							newDomChild.parentNode = this;
+						}
 					}
-					
 				}
 				found = true;
 				
 				//remove the old child's references to this tree
 				oldDomChild.nextSibling = null;
-				oldDomChild.previousSubling = null;
+				oldDomChild.previousSibling = null;
 				oldDomChild.parentNode = null;
 			}	
 		}
@@ -368,21 +372,21 @@
 					tempNode.parentNode = null;
 				} else if (this.lastChild == tempNode) {
 					//not the first child, but the last child 
-					ChildNode prevSib = tempNode.previousSubling;
+					ChildNode prevSib = tempNode.previousSibling;
 					prevSib.nextSibling = null;
 					tempNode.parentNode = null;
-					tempNode.previousSubling = null;
+					tempNode.previousSibling = null;
 				} else {
 	
 					ChildNode oldDomChild = (ChildNode)oldChild;
-					ChildNode privChild = oldDomChild.previousSubling;
+					ChildNode privChild = oldDomChild.previousSibling;
 					
 					privChild.nextSibling = oldDomChild.nextSibling;
-					oldDomChild.nextSibling.previousSubling = privChild;
+					oldDomChild.nextSibling.previousSibling = privChild;
 					
 					//Remove old child's references to this tree
 					oldDomChild.nextSibling = null;
-					oldDomChild.previousSubling = null;
+					oldDomChild.previousSibling = null;
 				}
 				//Child found
 				childFound = true;

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java?rev=354727&r1=354726&r2=354727&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java Tue Dec  6 22:02:35 2005
@@ -489,6 +489,10 @@
 		throw new UnsupportedOperationException("TODO");
 	}
 
+
+	public String toString() {
+		return (this.textValue != null)?textValue.toString() : "";
+	}
     
 	
 }