]> source.dussan.org Git - archiva.git/commitdiff
MRM-2051: upgrade dom4j (v2 branch) (#107)
authorPJ Fanning <pjfanning@users.noreply.github.com>
Mon, 6 Jun 2022 06:11:36 +0000 (07:11 +0100)
committerGitHub <noreply@github.com>
Mon, 6 Jun 2022 06:11:36 +0000 (16:11 +1000)
* upgrade dom4j

* compile issue

* Update XMLReader.java

* Update XMLReader.java

* Update Maven2RepositoryMetadataResolverTest.java

14 files changed:
archiva-modules/archiva-base/archiva-common/pom.xml
archiva-modules/archiva-base/archiva-repository-scanner/src/test/repositories/default-repository/org/apache/maven/archiva/archiva-xml-tools/1.0-SNAPSHOT/archiva-xml-tools-1.0-SNAPSHOT.pom
archiva-modules/archiva-base/archiva-xml-tools/pom.xml
archiva-modules/archiva-base/archiva-xml-tools/src/main/java/org/apache/archiva/xml/XMLReader.java
archiva-modules/archiva-karaf/archiva-features/pom.xml
archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva-common/1.2.1/archiva-common-1.2.1.pom
archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.pom
archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva/1.2.2/archiva-1.2.2.pom
archiva-modules/metadata/test-repository/src/main/resources/org/codehaus/plexus/plexus-spring/1.2/plexus-spring-1.2.pom
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
archiva-modules/plugins/maven2-repository/src/test/repositories/default-repository/org/apache/maven/archiva/archiva-xml-tools/1.0-SNAPSHOT/archiva-xml-tools-1.0-SNAPSHOT.pom
archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.pom
archiva-modules/plugins/stage-repository-merge/src/test/resources/test-repository-with-conflict-artifacts/org/testng/testng/5.8/testng-5.8-jdk15.pom
pom.xml

index 978563b6a8c0ba1ccf1cb79c9c41a0e2b7ff16da..34fcaa050b3c07e8ce8870bafc8a5b2dd23c3db9 100644 (file)
@@ -51,7 +51,7 @@
       <artifactId>org.eclipse.sisu.plexus</artifactId>
     </dependency>
     <dependency>
-      <groupId>dom4j</groupId>
+      <groupId>org.dom4j</groupId>
       <artifactId>dom4j</artifactId>
       <scope>test</scope>
     </dependency>
index efa42d3f0f17af4b6f8972791c04001ecd386f04..b45a5f3a52abe212673851ef31e643b8ffe33246 100644 (file)
@@ -34,9 +34,9 @@
       <artifactId>archiva-common</artifactId>
     </dependency>
     <dependency>
-      <groupId>dom4j</groupId>
+      <groupId>org.dom4j</groupId>
       <artifactId>dom4j</artifactId>
-      <version>1.6.1</version>
+      <version>${dom4j.version}</version>
     </dependency>
     <dependency>
       <groupId>jaxen</groupId>
index 1aae2ec503751b43f568d8d902adc2415a1f7296..0e4bf14501e1ec2768b114f8b503f9b6b61dcebd 100644 (file)
@@ -42,7 +42,7 @@
       <artifactId>commons-io</artifactId>
     </dependency>
     <dependency>
-      <groupId>dom4j</groupId>
+      <groupId>org.dom4j</groupId>
       <artifactId>dom4j</artifactId>
     </dependency>
     <dependency>
index d889e92d8e5d8d7a75dab98f702e6be61350a614..933510f2d6478ba3714c3743019c645868cc6f3f 100644 (file)
@@ -40,6 +40,7 @@ import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -201,22 +202,25 @@ public class XMLReader
     {
         elem.setQName( QName.get( elem.getName(), Namespace.NO_NAMESPACE, elem.getQualifiedName() ) );
 
-        Node n;
+        Element e;
+        Iterator<Element> elementIterator = elem.elementIterator();
+        while ( elementIterator.hasNext() )
+        {
+            e = elementIterator.next();
+            removeNamespaces(e);
+        }
 
-        Iterator<Node> it = elem.elementIterator();
-        while ( it.hasNext() )
+        Attribute attribute;
+        Iterator<Attribute> attributeIterator = elem.attributeIterator();
+        LinkedHashMap<String, String> newAttributes = new LinkedHashMap<>();
+        while ( attributeIterator.hasNext() )
         {
-            n = it.next();
-
-            switch ( n.getNodeType() )
-            {
-                case Node.ATTRIBUTE_NODE:
-                    ( (Attribute) n ).setNamespace( Namespace.NO_NAMESPACE );
-                    break;
-                case Node.ELEMENT_NODE:
-                    removeNamespaces( (Element) n );
-                    break;
-            }
+            attribute = attributeIterator.next();
+            newAttributes.put(attribute.getName(), attribute.getValue());
+        }
+        elem.setAttributes(new ArrayList<Attribute>());
+        for (Map.Entry<String, String> entry : newAttributes.entrySet()) {
+            elem.addAttribute(entry.getKey(), entry.getValue());
         }
     }
 
index 73beef6292337491f5f1fde9ca94ff9938186f43..f092b6bfce9b670d3b77e0a6ec61c233e248dfed 100644 (file)
@@ -39,7 +39,7 @@
     <commons-httpclient.bundle.version>3.1_6</commons-httpclient.bundle.version>
     <commons-jxpath.bundle.version>1.2_5</commons-jxpath.bundle.version>
     <commons-validator.bundle.version>1.3.1_1-SNAPSHOT</commons-validator.bundle.version>
-    <dom4j.bundle.version>1.6.1_4</dom4j.bundle.version>
+    <dom4j.bundle.version>2.1.3_1</dom4j.bundle.version>
     <ehcache.bundle.version>2.4.3_1</ehcache.bundle.version>
     <freemarker.bundle.version>2.3.18_1</freemarker.bundle.version>
     <javassist.bundle.version>3.12.1.ga_1</javassist.bundle.version>
index bddde3bb779a82f422a9f3bdd3b00e2587eff207..360cc46f91cac197a3ebfd305a58c6ef8b8c49bb 100644 (file)
@@ -61,9 +61,9 @@
       <version>2.7.0</version>
     </dependency>
     <dependency>
-      <groupId>dom4j</groupId>
+      <groupId>org.dom4j</groupId>
       <artifactId>dom4j</artifactId>
-      <version>1.6.1</version>
+      <version>${dom4j.version}</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
index cccf5178154922601c3862fdcd9de6ebca03bef4..0bf4b0f6c8195886ac7775bfa7d48154ed595995 100644 (file)
         <version>10.1.3.1</version>
       </dependency>
       <dependency>
-        <groupId>dom4j</groupId>
+        <groupId>org.dom4j</groupId>
         <artifactId>dom4j</artifactId>
-        <version>1.6.1</version>
+        <version>${dom4j.version}</version>
       </dependency>
       <dependency>
         <groupId>hsqldb</groupId>
index cccf5178154922601c3862fdcd9de6ebca03bef4..0bf4b0f6c8195886ac7775bfa7d48154ed595995 100644 (file)
         <version>10.1.3.1</version>
       </dependency>
       <dependency>
-        <groupId>dom4j</groupId>
+        <groupId>org.dom4j</groupId>
         <artifactId>dom4j</artifactId>
-        <version>1.6.1</version>
+        <version>${dom4j.version}</version>
       </dependency>
       <dependency>
         <groupId>hsqldb</groupId>
index 1b13027c1c27e52a92f5c4a67a7a0794be63ba36..cc7397558b6be103a3fac8bf52e9dc3e7d5727c7 100644 (file)
@@ -57,9 +57,9 @@
       <version>1.0-alpha-22</version>
     </dependency>
     <dependency>
-      <groupId>dom4j</groupId>
+      <groupId>org.dom4j</groupId>
       <artifactId>dom4j</artifactId>
-      <version>1.6.1</version>
+      <version>${dom4j.version}</version>
     </dependency>
     <dependency>
       <groupId>com.opensymphony</groupId>
index 24e9b2609cc744ca028f0e0223814a25aa56d35e..dbc1f5f192c3740e1acbc8edd888085422a0e6ff 100644 (file)
@@ -211,7 +211,7 @@ public class Maven2RepositoryMetadataResolverTest
         assertDependency( dependencies.get( 3 ), "org.codehaus.plexus", "plexus-component-api", "1.0-alpha-22" );
         assertDependency( dependencies.get( 4 ), "org.codehaus.plexus", "plexus-spring", "1.2", "test" );
         assertDependency( dependencies.get( 5 ), "xalan", "xalan", "2.7.0" );
-        assertDependency( dependencies.get( 6 ), "dom4j", "dom4j", "1.6.1", "test" );
+        assertDependency( dependencies.get( 6 ), "org.dom4j", "dom4j", "${dom4j.version}", "test" );
         assertDependency( dependencies.get( 7 ), "junit", "junit", "3.8.1", "test" );
         assertDependency( dependencies.get( 8 ), "easymock", "easymock", "1.2_Java1.3", "test" );
         assertDependency( dependencies.get( 9 ), "easymock", "easymockclassextension", "1.2", "test" );
@@ -668,8 +668,8 @@ public class Maven2RepositoryMetadataResolverTest
 
         assertArtifact( artifacts.get( 0 ), "plexus-spring-1.2-sources.jar", 0, EMPTY_SHA1, EMPTY_MD5 );
         assertArtifact( artifacts.get( 1 ), "plexus-spring-1.2.jar", 0, EMPTY_SHA1, EMPTY_MD5 );
-        assertArtifact( artifacts.get( 2 ), "plexus-spring-1.2.pom", 7407, "96b14cf880e384b2d15e8193c57b65c5420ca4c5",
-                        "f83aa25f016212a551a4b2249985effc" );
+        assertArtifact( artifacts.get( 2 ), "plexus-spring-1.2.pom", 7422, "28e86d3e2723e4894587e4b758231f76febce942",
+                "9f663d8e7adf6adff4133653b59d1e28" );
     }
 
     @Test
index efa42d3f0f17af4b6f8972791c04001ecd386f04..b45a5f3a52abe212673851ef31e643b8ffe33246 100644 (file)
@@ -34,9 +34,9 @@
       <artifactId>archiva-common</artifactId>
     </dependency>
     <dependency>
-      <groupId>dom4j</groupId>
+      <groupId>org.dom4j</groupId>
       <artifactId>dom4j</artifactId>
-      <version>1.6.1</version>
+      <version>${dom4j.version}</version>
     </dependency>
     <dependency>
       <groupId>jaxen</groupId>
index cccf5178154922601c3862fdcd9de6ebca03bef4..0bf4b0f6c8195886ac7775bfa7d48154ed595995 100755 (executable)
         <version>10.1.3.1</version>
       </dependency>
       <dependency>
-        <groupId>dom4j</groupId>
+        <groupId>org.dom4j</groupId>
         <artifactId>dom4j</artifactId>
-        <version>1.6.1</version>
+        <version>${dom4j.version}</version>
       </dependency>
       <dependency>
         <groupId>hsqldb</groupId>
index 4e7b53b084728c48443f91282d8068e9e9e21415..f5217b20ef5f20c748906a586f8fe9c7635ebb62 100755 (executable)
@@ -44,7 +44,7 @@
         <dependency>
             <groupId>qdox</groupId>
             <artifactId>qdox</artifactId>
-            <version>1.6.1</version>
+            <version>${dom4j.version}</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git a/pom.xml b/pom.xml
index 7dc7571a07fd13eb8c9fc7de2c9065766ecfaee5..e70bef38f9daf64fe6b1fb523031e026434b81f9 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -57,6 +57,7 @@
     <commons-fileupload.version>1.4</commons-fileupload.version>
     <commons-io.version>2.11.0</commons-io.version>
     <commons-lang.version>2.6</commons-lang.version>
+    <dom4j.version>2.1.3</dom4j.version>
 
     <maven3x.version>3.0.5</maven3x.version>
     <maven.version>2.0.8</maven.version>
         <version>${derbyVersion}</version>
       </dependency>
       <dependency>
-        <groupId>dom4j</groupId>
+        <groupId>org.dom4j</groupId>
         <artifactId>dom4j</artifactId>
-        <version>1.6.1</version>
+        <version>${dom4j.version}</version>
       </dependency>
       <dependency>
         <groupId>org.hsqldb</groupId>