cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r899507 - in /cxf/branches/2.1.x-fixes: ./ tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/model/XNode.java
Date Fri, 15 Jan 2010 01:12:02 GMT
Author: dkulp
Date: Fri Jan 15 01:12:01 2010
New Revision: 899507

URL: http://svn.apache.org/viewvc?rev=899507&view=rev
Log:
Merged revisions 899429 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.2.x-fixes

................
  r899429 | dkulp | 2010-01-14 16:48:27 -0500 (Thu, 14 Jan 2010) | 12 lines
  
  Merged revisions 899428 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r899428 | dkulp | 2010-01-14 16:47:00 -0500 (Thu, 14 Jan 2010) | 4 lines
    
    Using full XPaths for wsdl validation when they are very simple is
    apparently VERY expensive.   Do a much quicker basic search.   A very
    complex wsdl I have (500+ operations, 3000+ classes generated) now
    does a wsdl2java in 30 secs compared to over 2 minutes.
  ........
................

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
    cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/model/XNode.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java?rev=899507&r1=899506&r2=899507&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
(original)
+++ cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
Fri Jan 15 01:12:01 2010
@@ -201,10 +201,8 @@
     }
 
     private boolean isExist(List<Document> docs, XNode vNode) {
-        XPathUtils xpather = new XPathUtils(vNode.getNSMap());
-        String expression = vNode.toString();
         for (Document doc : docs) {
-            if (xpather.isExist(expression, doc, XPathConstants.NODE)) {
+            if (vNode.matches(doc)) {
                 return true;
             }
         }
@@ -235,8 +233,8 @@
 
             List<Document> wsdlDocs = getWSDLDocuments();
             for (XNode vNode : vNodes) {
-
                 if (!isExist(wsdlDocs, vNode)) {
+                    //System.out.println("Fail: " + vNode.getXPath());
                     FailureLocation loc = getFailureLocation(wsdlDocs, vNode.getFailurePoint());
 
                     vResults.addError(new Message("FAILED_AT_POINT",

Modified: cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/model/XNode.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/model/XNode.java?rev=899507&r1=899506&r2=899507&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/model/XNode.java
(original)
+++ cxf/branches/2.1.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/model/XNode.java
Fri Jan 15 01:12:01 2010
@@ -24,6 +24,10 @@
 import java.util.Stack;
 import javax.xml.namespace.QName;
 
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
 import org.apache.cxf.common.util.StringUtils;
 
 public class XNode {
@@ -165,4 +169,53 @@
         nsMap.put(prefix, name.getNamespaceURI());
         return sb.toString();
     }
+
+    
+    private boolean matches(Element el) { 
+        if (el.getLocalName().equals(name.getLocalPart())
+            && el.getNamespaceURI().equals(name.getNamespaceURI())) {
+            if (!StringUtils.isEmpty(attributeName) && !StringUtils.isEmpty(attributeValue))
{
+                String v = el.getAttribute(attributeName);
+                if (attributeValue.equals(v) || (StringUtils.isEmpty(v) && isDefaultAttributeValue))
{
+                    return true;
+                }
+            } else {
+                return true;
+            }
+        }
+        return false;
+    }
+    private boolean matches(Element el, Stack<XNode> stack) {
+        if (matches(el)) {
+            if (stack.isEmpty()) {
+                return true;
+            }
+            XNode next = stack.pop();
+            Node nd = el.getFirstChild();
+            while (nd != null) {
+                if (nd instanceof Element) {
+                    el = (Element)nd;
+                    if (next.matches(el, stack)) {
+                        return true;
+                    }
+                }
+                nd = nd.getNextSibling();
+            }
+            stack.push(next);
+        }
+        return false;
+    }
+    
+    public boolean matches(Document doc) {
+        Stack<XNode> nodes = new Stack<XNode>();
+        nodes.push(this);
+        XNode pNode = getParentNode();
+        while (pNode != null) {
+            nodes.push(pNode);
+            pNode = pNode.getParentNode();
+        }
+        pNode = nodes.pop();
+        return pNode.matches(doc.getDocumentElement(), nodes);
+        
+    }
 }



Mime
View raw message