From 720ebf3874e44d494e327df84872d8523ba885e0 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Wed, 17 Jun 2020 20:41:34 +0200 Subject: [PATCH] Code cleanup --- .../core/MetadataUpdaterConsumer.java | 3 - ...eanupReleasedSnapshotsRepositoryPurge.java | 6 -- .../maven/MavenRepositoryProxyHandler.java | 58 ++++++++----------- .../maven/metadata/MetadataToolsTest.java | 14 ++--- 4 files changed, 31 insertions(+), 50 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java index adbec863c..ba070f638 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java @@ -23,8 +23,6 @@ import org.apache.archiva.configuration.FileTypes; import org.apache.archiva.consumers.AbstractMonitoredConsumer; import org.apache.archiva.consumers.ConsumerException; import org.apache.archiva.consumers.KnownRepositoryContentConsumer; -import org.apache.archiva.model.ProjectReference; -import org.apache.archiva.model.VersionedReference; import org.apache.archiva.repository.BaseRepositoryContentLayout; import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.ManagedRepository; @@ -33,7 +31,6 @@ import org.apache.archiva.repository.RepositoryException; import org.apache.archiva.repository.RepositoryNotFoundException; import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.content.Artifact; -import org.apache.archiva.repository.content.ItemSelector; import org.apache.archiva.repository.content.Project; import org.apache.archiva.repository.metadata.RepositoryMetadataException; import org.apache.archiva.repository.metadata.base.MetadataTools; diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java index b0383affb..14f55c1d4 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java @@ -25,8 +25,6 @@ import org.apache.archiva.metadata.audit.RepositoryListener; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.apache.archiva.metadata.repository.RepositorySession; -import org.apache.archiva.model.ProjectReference; -import org.apache.archiva.model.VersionedReference; import org.apache.archiva.repository.BaseRepositoryContentLayout; import org.apache.archiva.repository.ContentNotFoundException; import org.apache.archiva.repository.LayoutException; @@ -142,10 +140,6 @@ public class CleanupReleasedSnapshotsRepositoryPurge // Now clean out any version that is earlier than the highest released version. boolean needsMetadataUpdate = false; - VersionedReference versionRef = new VersionedReference( ); - versionRef.setGroupId( artifactRef.getNamespace( ).getId() ); - versionRef.setArtifactId( artifactRef.getId( ) ); - ArchivaItemSelector.Builder versionSelectorBuilder = ArchivaItemSelector.builder( ) .withNamespace( artifactRef.getNamespace().getId() ) .withProjectId( artifactRef.getId( ) ) diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/main/java/org/apache/archiva/proxy/maven/MavenRepositoryProxyHandler.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/main/java/org/apache/archiva/proxy/maven/MavenRepositoryProxyHandler.java index 32560ebdd..477185a10 100644 --- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/main/java/org/apache/archiva/proxy/maven/MavenRepositoryProxyHandler.java +++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/main/java/org/apache/archiva/proxy/maven/MavenRepositoryProxyHandler.java @@ -148,34 +148,31 @@ public class MavenRepositoryProxyHandler extends DefaultRepositoryProxyHandler { throw new ProxyException("Unsupported target repository protocol: " + protocol); } - if (wagon == null) { - throw new ProxyException("Unsupported target repository protocol: " + protocol); - } - boolean connected = connectToRepository(connector, wagon, remoteRepository); if (connected) { - transferArtifact(wagon, remoteRepository, remotePath, repository, resource.getFilePath(), workingDirectory, - tmpResource); + transferArtifact(wagon, remoteRepository, remotePath, resource.getFilePath(), + tmpResource); // TODO: these should be used to validate the download based on the policies, not always downloaded // to // save on connections since md5 is rarely used - for (int i=0; i