ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1334351 - in /webservices/axiom/branches/AXIOM-420: ./ modules/axiom-compat/src/main/java/org/apache/axiom/om/impl/llom/factory/ modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/ modules/axiom-impl/src/main/java/org/apache/ax...
Date Sat, 05 May 2012 08:55:07 GMT
Author: veithen
Date: Sat May  5 08:55:06 2012
New Revision: 1334351

URL: http://svn.apache.org/viewvc?rev=1334351&view=rev
Log:
Merged latest changes from trunk.

Added:
    webservices/axiom/branches/AXIOM-420/modules/axiom-compat/src/main/java/org/apache/axiom/om/impl/llom/factory/
      - copied from r1334350, webservices/commons/trunk/modules/axiom/modules/axiom-compat/src/main/java/org/apache/axiom/om/impl/llom/factory/
    webservices/axiom/branches/AXIOM-420/modules/axiom-compat/src/main/java/org/apache/axiom/om/impl/llom/factory/OMXMLBuilderFactory.java
      - copied unchanged from r1334350, webservices/commons/trunk/modules/axiom/modules/axiom-compat/src/main/java/org/apache/axiom/om/impl/llom/factory/OMXMLBuilderFactory.java
Removed:
    webservices/axiom/branches/AXIOM-420/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMXMLBuilderFactory.java
Modified:
    webservices/axiom/branches/AXIOM-420/   (props changed)
    webservices/axiom/branches/AXIOM-420/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
    webservices/axiom/branches/AXIOM-420/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1DefaultPrefix.java
    webservices/axiom/branches/AXIOM-420/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1QualifiedPrefix.java

Propchange: webservices/axiom/branches/AXIOM-420/
------------------------------------------------------------------------------
  Merged /webservices/commons/trunk/modules/axiom:r1334121-1334350

Modified: webservices/axiom/branches/AXIOM-420/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-420/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=1334351&r1=1334350&r2=1334351&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-420/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
(original)
+++ webservices/axiom/branches/AXIOM-420/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
Sat May  5 08:55:06 2012
@@ -273,26 +273,7 @@ public class OMSourcedElementImpl extend
                 throw new OMException("Error parsing data source document for element " +
getLocalName(), ex);
             }
 
-            String readerLocalName = readerFromDS.getLocalName();
-            if (localName == null) {
-                // The local name was not known in advance; initialize it from the reader
-                localName = readerLocalName;
-            } else {
-                // Make sure element local name and namespace matches what was expected
-                if (!readerLocalName.equals(getLocalName())) {
-                    throw new OMException("Element name from data source is " +
-                            readerLocalName + ", not the expected " + getLocalName());
-                }
-            }
-            if (definedNamespaceSet) {
-                String readerURI = readerFromDS.getNamespaceURI();
-                readerURI = (readerURI == null) ? "" : readerURI;
-                String uri = (getNamespace() == null) ? "" : getNamespace().getNamespaceURI();
-                if (!readerURI.equals(uri)) {
-                    throw new OMException("Element namespace from data source is " +
-                            readerURI + ", not the expected " + uri);
-                }
-            }
+            validateName(readerFromDS.getPrefix(), readerFromDS.getLocalName(), readerFromDS.getNamespaceURI());
 
             // Set the builder for this element. Note that the StAXOMBuilder constructor
will also
             // update the namespace of the element, so we don't need to do that here.
@@ -306,6 +287,50 @@ public class OMSourcedElementImpl extend
     }
 
     /**
+     * Validates that the actual name of the element obtained from StAX matches the information
+     * specified when the sourced element was constructed or retrieved through the
+     * {@link QNameAwareOMDataSource} interface. Also updates the local name if necessary.
Note that
+     * the namespace information is not updated; this is the responsibility of the builder
(and is
+     * done at the same time as namespace repairing).
+     * 
+     * @param staxPrefix
+     * @param staxLocalName
+     * @param staxNamespaceURI
+     */
+    void validateName(String staxPrefix, String staxLocalName, String staxNamespaceURI) {
+        if (localName == null) {
+            // The local name was not known in advance; initialize it from the reader
+            localName = staxLocalName;
+        } else {
+            // Make sure element local name and namespace matches what was expected
+            if (!staxLocalName.equals(localName)) {
+                throw new OMException("Element name from data source is " +
+                        staxLocalName + ", not the expected " + localName);
+            }
+        }
+        if (definedNamespaceSet) {
+            if (staxNamespaceURI == null) {
+                staxNamespaceURI = "";
+            }
+            String namespaceURI = definedNamespace == null ? "" : definedNamespace.getNamespaceURI();
+            if (!staxNamespaceURI.equals(namespaceURI)) {
+                throw new OMException("Element namespace from data source is " +
+                        staxNamespaceURI + ", not the expected " + namespaceURI);
+            }
+            if (!(definedNamespace instanceof DeferredNamespace)) {
+                if (staxPrefix == null) {
+                    staxPrefix = "";
+                }
+                String prefix = definedNamespace == null ? "" : definedNamespace.getPrefix();
+                if (!staxPrefix.equals(prefix)) {
+                    throw new OMException("Element prefix from data source is '" +
+                            staxPrefix + "', not the expected '" + prefix + "'");
+                }
+            }
+        }
+    }
+    
+    /**
      * Check if element has been expanded into tree.
      *
      * @return <code>true</code> if expanded, <code>false</code>
if not

Modified: webservices/axiom/branches/AXIOM-420/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1DefaultPrefix.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-420/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1DefaultPrefix.java?rev=1334351&r1=1334350&r2=1334351&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-420/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1DefaultPrefix.java
(original)
+++ webservices/axiom/branches/AXIOM-420/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1DefaultPrefix.java
Sat May  5 08:55:06 2012
@@ -41,20 +41,19 @@ public class TestName1DefaultPrefix exte
     protected void runTest() throws Throwable {
         OMFactory f = metaFactory.getOMFactory();
 
-        // Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses
the default prefix
+        // Create OMSE with an unknown prefix
         OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
         OMNamespace ns =
-                f.createOMNamespace("http://www.sosnoski.com/uwjws/library", "DUMMYPREFIX");
+                f.createOMNamespace("http://www.sosnoski.com/uwjws/library", null);
         OMElement element =
                 f.createOMElement(new TestDataSource(testDocument), "library", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 
-        // Test getting the namespace, localpart and prefix.  This should used not result
in expansion
+        // Test getting the local name and namespace URI. This should used not result in
expansion
         assertTrue(element.getLocalName().equals("library"));
         assertTrue(element.getNamespace().getNamespaceURI().equals(
                 "http://www.sosnoski.com/uwjws/library"));
-        assertTrue(element.getNamespace().getPrefix().equals("DUMMYPREFIX"));
 
         // Serialize and cache.  This should cause expansion.  The prefix should be updated
to match the testDocument string
         StringWriter writer = new StringWriter();
@@ -68,8 +67,6 @@ public class TestName1DefaultPrefix exte
                 "http://www.sosnoski.com/uwjws/library"));
         assertTrue(element.getNamespace().getPrefix().equals(""));
         assertTrue(element.getDefaultNamespace() != null);
-        assertTrue(result.indexOf("DUMMYPREFIX") <
-                0);  // Make sure that the serialized string does not contain DUMMYPREFIX
         assertTrue("Serialized text error" + result, result.indexOf("1930110111") > 0);
 
         // Serialize again
@@ -84,8 +81,6 @@ public class TestName1DefaultPrefix exte
                 "http://www.sosnoski.com/uwjws/library"));
         assertTrue(element.getNamespace().getPrefix().equals(""));
         assertTrue(element.getDefaultNamespace() != null);
-        assertTrue(result.indexOf("DUMMYPREFIX") <
-                0);  // Make sure that the serialized string does not contain DUMMYPREFIX
         assertTrue("Serialized text error" + result, result.indexOf("1930110111") > 0);
     }
 }

Modified: webservices/axiom/branches/AXIOM-420/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1QualifiedPrefix.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-420/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1QualifiedPrefix.java?rev=1334351&r1=1334350&r2=1334351&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-420/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1QualifiedPrefix.java
(original)
+++ webservices/axiom/branches/AXIOM-420/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestName1QualifiedPrefix.java
Sat May  5 08:55:06 2012
@@ -41,19 +41,18 @@ public class TestName1QualifiedPrefix ex
     protected void runTest() throws Throwable {
         OMFactory f = metaFactory.getOMFactory();
 
-        // Create OMSE with a DUMMYPREFIX prefix even though the underlying element uses
the default prefix
+        // Create OMSE with an unknown prefix
         OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
-        OMNamespace ns = f.createOMNamespace("http://www.sosnoski.com/uwjws/library", "");
+        OMNamespace ns = f.createOMNamespace("http://www.sosnoski.com/uwjws/library", null);
         OMElement element =
                 f.createOMElement(new TestDataSource(testDocument2), "library", ns);
         OMElement root = f.createOMElement("root", rootNS);
         root.addChild(element);
 
-        // Test getting the namespace, localpart and prefix.  This should used not result
in expansion
+        // Test getting the local name and namespace URI. This should used not result in
expansion
         assertTrue(element.getLocalName().equals("library"));
         assertTrue(element.getNamespace().getNamespaceURI().equals(
                 "http://www.sosnoski.com/uwjws/library"));
-        assertTrue(element.getNamespace().getPrefix().equals(""));
 
         // Serialize and cache.  This should cause expansion and update the name to match
the testDocument string
         StringWriter writer = new StringWriter();



Mime
View raw message