From a49b01fef6e78e4e566c75652aaacff54ac6a8ec Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 6 Jun 2022 07:11:36 +0100 Subject: MRM-2051: upgrade dom4j (v2 branch) (#107) * upgrade dom4j * compile issue * Update XMLReader.java * Update XMLReader.java * Update Maven2RepositoryMetadataResolverTest.java --- .../archiva-base/archiva-common/pom.xml | 2 +- .../archiva-xml-tools-1.0-SNAPSHOT.pom | 4 +-- .../archiva-base/archiva-xml-tools/pom.xml | 2 +- .../java/org/apache/archiva/xml/XMLReader.java | 32 ++++++++++++---------- .../archiva-karaf/archiva-features/pom.xml | 2 +- .../archiva-common/1.2.1/archiva-common-1.2.1.pom | 4 +-- .../apache/archiva/archiva/1.2.1/archiva-1.2.1.pom | 4 +-- .../apache/archiva/archiva/1.2.2/archiva-1.2.2.pom | 4 +-- .../plexus/plexus-spring/1.2/plexus-spring-1.2.pom | 4 +-- .../Maven2RepositoryMetadataResolverTest.java | 6 ++-- .../archiva-xml-tools-1.0-SNAPSHOT.pom | 4 +-- .../apache/archiva/archiva/1.2.1/archiva-1.2.1.pom | 4 +-- .../org/testng/testng/5.8/testng-5.8-jdk15.pom | 2 +- pom.xml | 5 ++-- 14 files changed, 42 insertions(+), 37 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-common/pom.xml b/archiva-modules/archiva-base/archiva-common/pom.xml index 978563b6a..34fcaa050 100644 --- a/archiva-modules/archiva-base/archiva-common/pom.xml +++ b/archiva-modules/archiva-base/archiva-common/pom.xml @@ -51,7 +51,7 @@ org.eclipse.sisu.plexus - dom4j + org.dom4j dom4j test diff --git a/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 b/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 index efa42d3f0..b45a5f3a5 100644 --- a/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 +++ b/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 @@ -34,9 +34,9 @@ archiva-common - dom4j + org.dom4j dom4j - 1.6.1 + ${dom4j.version} jaxen diff --git a/archiva-modules/archiva-base/archiva-xml-tools/pom.xml b/archiva-modules/archiva-base/archiva-xml-tools/pom.xml index 1aae2ec50..0e4bf1450 100644 --- a/archiva-modules/archiva-base/archiva-xml-tools/pom.xml +++ b/archiva-modules/archiva-base/archiva-xml-tools/pom.xml @@ -42,7 +42,7 @@ commons-io - dom4j + org.dom4j dom4j diff --git a/archiva-modules/archiva-base/archiva-xml-tools/src/main/java/org/apache/archiva/xml/XMLReader.java b/archiva-modules/archiva-base/archiva-xml-tools/src/main/java/org/apache/archiva/xml/XMLReader.java index d889e92d8..933510f2d 100644 --- a/archiva-modules/archiva-base/archiva-xml-tools/src/main/java/org/apache/archiva/xml/XMLReader.java +++ b/archiva-modules/archiva-base/archiva-xml-tools/src/main/java/org/apache/archiva/xml/XMLReader.java @@ -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 elementIterator = elem.elementIterator(); + while ( elementIterator.hasNext() ) + { + e = elementIterator.next(); + removeNamespaces(e); + } - Iterator it = elem.elementIterator(); - while ( it.hasNext() ) + Attribute attribute; + Iterator attributeIterator = elem.attributeIterator(); + LinkedHashMap 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()); + for (Map.Entry entry : newAttributes.entrySet()) { + elem.addAttribute(entry.getKey(), entry.getValue()); } } diff --git a/archiva-modules/archiva-karaf/archiva-features/pom.xml b/archiva-modules/archiva-karaf/archiva-features/pom.xml index 73beef629..f092b6bfc 100644 --- a/archiva-modules/archiva-karaf/archiva-features/pom.xml +++ b/archiva-modules/archiva-karaf/archiva-features/pom.xml @@ -39,7 +39,7 @@ 3.1_6 1.2_5 1.3.1_1-SNAPSHOT - 1.6.1_4 + 2.1.3_1 2.4.3_1 2.3.18_1 3.12.1.ga_1 diff --git a/archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva-common/1.2.1/archiva-common-1.2.1.pom b/archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva-common/1.2.1/archiva-common-1.2.1.pom index bddde3bb7..360cc46f9 100644 --- a/archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva-common/1.2.1/archiva-common-1.2.1.pom +++ b/archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva-common/1.2.1/archiva-common-1.2.1.pom @@ -61,9 +61,9 @@ 2.7.0 - dom4j + org.dom4j dom4j - 1.6.1 + ${dom4j.version} test diff --git a/archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.pom b/archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.pom index cccf51781..0bf4b0f6c 100644 --- a/archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.pom +++ b/archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.pom @@ -501,9 +501,9 @@ 10.1.3.1 - dom4j + org.dom4j dom4j - 1.6.1 + ${dom4j.version} hsqldb diff --git a/archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva/1.2.2/archiva-1.2.2.pom b/archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva/1.2.2/archiva-1.2.2.pom index cccf51781..0bf4b0f6c 100644 --- a/archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva/1.2.2/archiva-1.2.2.pom +++ b/archiva-modules/metadata/test-repository/src/main/resources/org/apache/archiva/archiva/1.2.2/archiva-1.2.2.pom @@ -501,9 +501,9 @@ 10.1.3.1 - dom4j + org.dom4j dom4j - 1.6.1 + ${dom4j.version} hsqldb diff --git a/archiva-modules/metadata/test-repository/src/main/resources/org/codehaus/plexus/plexus-spring/1.2/plexus-spring-1.2.pom b/archiva-modules/metadata/test-repository/src/main/resources/org/codehaus/plexus/plexus-spring/1.2/plexus-spring-1.2.pom index 1b13027c1..cc7397558 100644 --- a/archiva-modules/metadata/test-repository/src/main/resources/org/codehaus/plexus/plexus-spring/1.2/plexus-spring-1.2.pom +++ b/archiva-modules/metadata/test-repository/src/main/resources/org/codehaus/plexus/plexus-spring/1.2/plexus-spring-1.2.pom @@ -57,9 +57,9 @@ 1.0-alpha-22 - dom4j + org.dom4j dom4j - 1.6.1 + ${dom4j.version} com.opensymphony diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java index 24e9b2609..dbc1f5f19 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java @@ -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 diff --git a/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 b/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 index efa42d3f0..b45a5f3a5 100644 --- a/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 +++ b/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 @@ -34,9 +34,9 @@ archiva-common - dom4j + org.dom4j dom4j - 1.6.1 + ${dom4j.version} jaxen diff --git a/archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.pom b/archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.pom index cccf51781..0bf4b0f6c 100755 --- a/archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.pom +++ b/archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.pom @@ -501,9 +501,9 @@ 10.1.3.1 - dom4j + org.dom4j dom4j - 1.6.1 + ${dom4j.version} hsqldb diff --git a/archiva-modules/plugins/stage-repository-merge/src/test/resources/test-repository-with-conflict-artifacts/org/testng/testng/5.8/testng-5.8-jdk15.pom b/archiva-modules/plugins/stage-repository-merge/src/test/resources/test-repository-with-conflict-artifacts/org/testng/testng/5.8/testng-5.8-jdk15.pom index 4e7b53b08..f5217b20e 100755 --- a/archiva-modules/plugins/stage-repository-merge/src/test/resources/test-repository-with-conflict-artifacts/org/testng/testng/5.8/testng-5.8-jdk15.pom +++ b/archiva-modules/plugins/stage-repository-merge/src/test/resources/test-repository-with-conflict-artifacts/org/testng/testng/5.8/testng-5.8-jdk15.pom @@ -44,7 +44,7 @@ qdox qdox - 1.6.1 + ${dom4j.version} provided diff --git a/pom.xml b/pom.xml index 7dc7571a0..e70bef38f 100644 --- a/pom.xml +++ b/pom.xml @@ -57,6 +57,7 @@ 1.4 2.11.0 2.6 + 2.1.3 3.0.5 2.0.8 @@ -706,9 +707,9 @@ ${derbyVersion} - dom4j + org.dom4j dom4j - 1.6.1 + ${dom4j.version} org.hsqldb -- cgit v1.2.3