mirror of https://github.com/apache/archiva.git
Removing dependency on ComponentContainer (spring-utils)
This commit is contained in:
parent
7e5e437bb5
commit
8d800b6e1a
|
@ -114,10 +114,12 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva.redback.components</groupId>
|
||||
<artifactId>spring-utils</artifactId>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -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<String, PreDownloadPolicy> prePolicies;
|
||||
|
||||
/**
|
||||
* see #initialize
|
||||
*
|
||||
* @todo these don't strictly belong in here
|
||||
*/
|
||||
private Map<String, PostDownloadPolicy> postPolicies;
|
||||
|
||||
/**
|
||||
* see #initialize
|
||||
*
|
||||
* @todo these don't strictly belong in here
|
||||
*/
|
||||
private Map<String, DownloadErrorPolicy> 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();
|
||||
|
|
|
@ -78,11 +78,13 @@
|
|||
<artifactId>maven-artifact</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva.redback.components</groupId>
|
||||
<artifactId>spring-utils</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -51,8 +51,6 @@
|
|||
|
||||
<alias name="registry#default" alias="commons-configuration"/>
|
||||
|
||||
<bean name="componentContainer" class="org.apache.archiva.redback.components.springutils.ComponentContainer"/>
|
||||
|
||||
<alias name="userConfiguration#redback" alias="userConfiguration#default"/>
|
||||
<alias name="authorizer#rbac" alias="authorizer#default"/>
|
||||
<alias name="userManager#configurable" alias="userManager#default"/>
|
||||
|
|
Loading…
Reference in New Issue