From 8d800b6e1a1e9190356cc3c2bafa5af254239878 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Wed, 9 Oct 2019 19:48:54 +0200 Subject: [PATCH] Removing dependency on ComponentContainer (spring-utils) --- .../archiva-configuration/pom.xml | 2 + .../DefaultArchivaConfiguration.java | 103 +----------------- .../archiva-plexus-bridge/pom.xml | 2 + .../resources/repository-servlet-simple.xml | 2 - pom.xml | 2 +- 5 files changed, 7 insertions(+), 104 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-configuration/pom.xml b/archiva-modules/archiva-base/archiva-configuration/pom.xml index dfa2a2072..dfb6a9b05 100644 --- a/archiva-modules/archiva-base/archiva-configuration/pom.xml +++ b/archiva-modules/archiva-base/archiva-configuration/pom.xml @@ -114,10 +114,12 @@ + commons-io commons-io diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java index b8b78d3b1..af7e2ef6d 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java @@ -25,10 +25,6 @@ import org.apache.archiva.configuration.io.registry.ConfigurationRegistryWriter; import org.apache.archiva.policies.AbstractUpdatePolicy; import org.apache.archiva.policies.CachedFailuresPolicy; import org.apache.archiva.policies.ChecksumPolicy; -import org.apache.archiva.policies.DownloadErrorPolicy; -import org.apache.archiva.policies.Policy; -import org.apache.archiva.policies.PostDownloadPolicy; -import org.apache.archiva.policies.PreDownloadPolicy; import org.apache.archiva.redback.components.evaluator.DefaultExpressionEvaluator; import org.apache.archiva.redback.components.evaluator.EvaluatorException; import org.apache.archiva.redback.components.evaluator.ExpressionEvaluator; @@ -37,10 +33,8 @@ import org.apache.archiva.redback.components.registry.Registry; import org.apache.archiva.redback.components.registry.RegistryException; import org.apache.archiva.redback.components.registry.RegistryListener; import org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry; -import org.apache.archiva.redback.components.springutils.ComponentContainer; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; -import org.apache.commons.collections4.MapUtils; import org.apache.commons.configuration.BaseConfiguration; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; @@ -55,18 +49,8 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; /** *

@@ -108,36 +92,11 @@ public class DefaultArchivaConfiguration @Named(value = "commons-configuration") private Registry registry; - @Inject - private ComponentContainer componentContainer; - /** * The configuration that has been converted. */ private Configuration configuration; - /** - * see #initialize - * - * @todo these don't strictly belong in here - */ - private Map prePolicies; - - /** - * see #initialize - * - * @todo these don't strictly belong in here - */ - private Map postPolicies; - - /** - * see #initialize - * - * @todo these don't strictly belong in here - */ - private Map downloadErrorPolicies; - - /** * see #initialize * default-value="${user.home}/.m2/archiva.xml" @@ -340,17 +299,7 @@ public class DefaultArchivaConfiguration } // Validate existance of policy key. - if (policyExists(policyId)) { - Policy policy = findPolicy(policyId); - // Does option exist? - if (!policy.getOptions().contains(setting)) { - setting = policy.getDefaultOption().getId(); - } - connector.addPolicy(policyId, setting); - } else { - // Policy key doesn't exist. Don't add it to golden version. - log.warn("Policy [{}] does not exist.", policyId); - } + connector.addPolicy(policyId, setting); } if (connectorValid) { @@ -429,51 +378,6 @@ public class DefaultArchivaConfiguration return value; } - private Policy findPolicy(String policyId) { - if (MapUtils.isEmpty(prePolicies)) { - log.error("No PreDownloadPolicies found!"); - return null; - } - - if (MapUtils.isEmpty(postPolicies)) { - log.error("No PostDownloadPolicies found!"); - return null; - } - - Policy policy; - - policy = prePolicies.get(policyId); - if (policy != null) { - return policy; - } - - policy = postPolicies.get(policyId); - if (policy != null) { - return policy; - } - - policy = downloadErrorPolicies.get(policyId); - if (policy != null) { - return policy; - } - - return null; - } - - private boolean policyExists(String policyId) { - if (MapUtils.isEmpty(prePolicies)) { - log.error("No PreDownloadPolicies found!"); - return false; - } - - if (MapUtils.isEmpty(postPolicies)) { - log.error("No PostDownloadPolicies found!"); - return false; - } - - return (prePolicies.containsKey(policyId) || postPolicies.containsKey(policyId) - || downloadErrorPolicies.containsKey(policyId)); - } private Registry readDefaultConfiguration() { // if it contains some old configuration, remove it (Archiva 0.9) @@ -734,9 +638,6 @@ public class DefaultArchivaConfiguration @PostConstruct public void initialize() { - this.postPolicies = componentContainer.buildMapWithRole(PostDownloadPolicy.class); - this.prePolicies = componentContainer.buildMapWithRole(PreDownloadPolicy.class); - this.downloadErrorPolicies = componentContainer.buildMapWithRole(DownloadErrorPolicy.class); // Resolve expressions in the userConfigFilename and altConfigFilename try { ExpressionEvaluator expressionEvaluator = new DefaultExpressionEvaluator(); diff --git a/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml b/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml index 96f4fcef3..cd702af9e 100644 --- a/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml +++ b/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml @@ -78,11 +78,13 @@ maven-artifact test + diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/repository-servlet-simple.xml b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/repository-servlet-simple.xml index 10979d0f3..435ca0d00 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/repository-servlet-simple.xml +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/repository-servlet-simple.xml @@ -51,8 +51,6 @@ - - diff --git a/pom.xml b/pom.xml index 29a372946..b5b7210e4 100644 --- a/pom.xml +++ b/pom.xml @@ -1363,7 +1363,7 @@ commons-logging commons-logging - 1.2 + ${commons.logging.version} -- 2.39.5