diff options
author | Martin Stockhammer <martin_s@apache.org> | 2020-04-21 16:27:02 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2020-04-21 16:27:02 +0200 |
commit | f0757c35dec03eff60224a92d00597b866510047 (patch) | |
tree | cdd17cdad7d7be481883e459c002aae1d45c473a /archiva-modules/archiva-base/archiva-consumers | |
parent | b55ac5e29f81d58971c714e561ed6e4423f829b0 (diff) | |
download | archiva-f0757c35dec03eff60224a92d00597b866510047.tar.gz archiva-f0757c35dec03eff60224a92d00597b866510047.zip |
Switching new new repository content API for core consumers
Diffstat (limited to 'archiva-modules/archiva-base/archiva-consumers')
7 files changed, 212 insertions, 152 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java index e94b613bf..f2384ace5 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java @@ -28,6 +28,8 @@ import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.repository.ContentNotFoundException; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.metadata.audit.RepositoryListener; +import org.apache.archiva.repository.content.Artifact; +import org.apache.archiva.repository.content.ItemNotFoundException; import org.apache.archiva.repository.storage.StorageAsset; import org.apache.archiva.repository.storage.util.StorageUtil; import org.apache.commons.lang3.StringUtils; @@ -183,63 +185,57 @@ public abstract class AbstractRepositoryPurge * * @param references */ - protected void purge( Set<ArtifactReference> references ) + protected void purge( Set<Artifact> references ) { if ( references != null && !references.isEmpty( ) ) { MetadataRepository metadataRepository = repositorySession.getRepository( ); Map<ArtifactInfo, ArtifactMetadata> metaRemovalList = new HashMap<>( ); Map<String, Collection<ArtifactMetadata>> metaResolved = new HashMap<>( ); - for ( ArtifactReference reference : references ) + for ( Artifact reference : references ) { - String baseVersion = VersionUtil.getBaseVersion( reference.getVersion( ) ); + String baseVersion = reference.getVersion( ).getVersion( ); + String namespace = reference.getVersion( ).getProject( ).getNamespace( ).getNamespace( ); // Needed for tracking in the hashmap - String metaBaseId = reference.getGroupId( ) + "/" + reference.getArtifactId( ) + "/" + baseVersion; + String metaBaseId = reference.toKey(); if ( !metaResolved.containsKey( metaBaseId ) ) { try { metaResolved.put( metaBaseId, metadataRepository.getArtifacts(repositorySession, repository.getId( ), - reference.getGroupId( ), reference.getArtifactId( ), baseVersion ) ); + namespace, reference.getId( ), baseVersion ) ); } catch ( MetadataResolutionException e ) { log.error( "Error during metadata retrieval {}: {}", metaBaseId, e.getMessage( ) ); } } - StorageAsset artifactFile = repository.toFile( reference ); + StorageAsset artifactFile = reference.getAsset(); for ( RepositoryListener listener : listeners ) { - listener.deleteArtifact( metadataRepository, repository.getId( ), reference.getGroupId( ), - reference.getArtifactId( ), reference.getVersion( ), + listener.deleteArtifact( metadataRepository, repository.getId( ), namespace, + reference.getId( ), reference.getVersion( ).getVersion(), artifactFile.getName( )); } - try + if (reference.exists()) { - artifactFile.getStorage().removeAsset(artifactFile); - log.debug( "File deleted: {}", artifactFile ); - } - catch ( IOException e ) - { - log.error( "Could not delete file {}: {}", artifactFile.toString(), e.getMessage( ), e ); - continue; - } - try - { - repository.deleteArtifact( reference ); - } - catch ( ContentNotFoundException e ) - { - log.warn( "skip error deleting artifact {}: {}", reference, e.getMessage( ) ); - } - catch ( org.apache.archiva.repository.ContentAccessException e ) - { - e.printStackTrace( ); + try + { + repository.deleteItem( reference ); + } + catch ( org.apache.archiva.repository.ContentAccessException e ) + { + log.error( "Error while trying to delete artifact {}: {}", reference.toString( ), e.getMessage( ), e ); + } + catch ( ItemNotFoundException e ) + { + log.error( "Asset deleted from background other thread: {}", e.getMessage( ) ); + } } - boolean snapshotVersion = VersionUtil.isSnapshot( reference.getVersion( ) ); + boolean snapshotVersion = VersionUtil.isSnapshot( baseVersion ); // If this is a snapshot we have to search for artifacts with the same version. And remove all of them. @@ -253,7 +249,7 @@ public abstract class AbstractRepositoryPurge for ( ArtifactMetadata artifactMetadata : artifacts ) { // Artifact metadata and reference version should match. - if ( artifactMetadata.getVersion( ).equals( reference.getVersion( ) ) ) + if ( artifactMetadata.getVersion( ).equals( reference.getArtifactVersion( ) ) ) { ArtifactInfo info = new ArtifactInfo( artifactMetadata.getNamespace( ), artifactMetadata.getProject( ), artifactMetadata.getProjectVersion( ), artifactMetadata.getVersion( ) ); if ( StringUtils.isNotBlank( reference.getClassifier( ) ) ) @@ -272,15 +268,15 @@ public abstract class AbstractRepositoryPurge } else // otherwise we delete the artifact version { - ArtifactInfo info = new ArtifactInfo( reference.getGroupId( ), reference.getArtifactId( ), baseVersion, reference.getVersion( ) ); + ArtifactInfo info = new ArtifactInfo( namespace, reference.getId( ), baseVersion, reference.getArtifactVersion() ); for ( ArtifactMetadata metadata : metaResolved.get( metaBaseId ) ) { metaRemovalList.put( info, metadata ); } } - triggerAuditEvent( repository.getRepository( ).getId( ), ArtifactReference.toKey( reference ), + triggerAuditEvent( repository.getRepository( ).getId( ), reference.toKey(), AuditEvent.PURGE_ARTIFACT ); - purgeSupportFiles( artifactFile ); + // purgeSupportFiles( artifactFile ); } purgeMetadata( metadataRepository, metaRemovalList ); try diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurge.java index f5ae868b8..bc65d9959 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurge.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurge.java @@ -21,22 +21,31 @@ package org.apache.archiva.consumers.core.repository; import org.apache.archiva.common.utils.VersionComparator; import org.apache.archiva.common.utils.VersionUtil; +import org.apache.archiva.metadata.audit.RepositoryListener; import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.archiva.model.ArtifactReference; -import org.apache.archiva.model.VersionedReference; import org.apache.archiva.repository.ContentNotFoundException; import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.ManagedRepositoryContent; -import org.apache.archiva.metadata.audit.RepositoryListener; +import org.apache.archiva.repository.content.Artifact; +import org.apache.archiva.repository.content.ContentItem; +import org.apache.archiva.repository.content.ItemNotFoundException; +import org.apache.archiva.repository.content.base.ArchivaItemSelector; import org.apache.archiva.repository.storage.StorageAsset; +import org.apache.commons.lang3.StringUtils; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.TimeZone; import java.util.regex.Matcher; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Purge from repository all snapshots older than the specified days in the repository configuration. @@ -57,7 +66,7 @@ public class DaysOldRepositoryPurge this.retentionPeriod = retentionPeriod; this.retentionCount = retentionCount; timestampParser = new SimpleDateFormat( "yyyyMMdd.HHmmss" ); - timestampParser.setTimeZone( TimeZone.getTimeZone("UTC")); + timestampParser.setTimeZone( TimeZone.getTimeZone( "UTC" ) ); } @Override @@ -66,74 +75,101 @@ public class DaysOldRepositoryPurge { try { - Path artifactFile = Paths.get( repository.getRepoRoot( ), path ); - if ( !Files.exists(artifactFile) ) + ContentItem item = repository.toItem( path ); + if ( item instanceof Artifact ) { - return; - } - - ArtifactReference artifact = repository.toArtifactReference( path ); - - Calendar olderThanThisDate = Calendar.getInstance( TimeZone.getTimeZone("UTC") ); - olderThanThisDate.add( Calendar.DATE, -retentionPeriod ); + Artifact artifactItem = (Artifact) item; - // respect retention count - VersionedReference reference = new VersionedReference( ); - reference.setGroupId( artifact.getGroupId( ) ); - reference.setArtifactId( artifact.getArtifactId( ) ); - reference.setVersion( artifact.getVersion( ) ); - - List<String> versions = new ArrayList<>( repository.getVersions( reference ) ); - - Collections.sort( versions, VersionComparator.getInstance( ) ); + if ( !artifactItem.exists( ) ) + { + return; + } - if ( retentionCount > versions.size( ) ) - { - // Done. nothing to do here. skip it. - return; - } + // ArtifactReference artifact = repository.toArtifactReference( path ); + + Calendar olderThanThisDate = Calendar.getInstance( TimeZone.getTimeZone( "UTC" ) ); + olderThanThisDate.add( Calendar.DATE, -retentionPeriod ); + + // respect retention count + // VersionedReference reference = new VersionedReference( ); + // reference.setGroupId( artifact.getGroupId( ) ); + // reference.setArtifactId( artifact.getArtifactId( ) ); + // reference.setVersion( artifact.getVersion( ) ); + ArchivaItemSelector selector = ArchivaItemSelector.builder( ) + .withNamespace( artifactItem.getVersion( ).getProject( ).getNamespace( ).getNamespace( ) ) + .withProjectId( artifactItem.getVersion( ).getProject( ).getId( ) ) + .withVersion( artifactItem.getVersion( ).getVersion( ) ) + .withClassifier( "*" ) + .includeRelatedArtifacts( ) + .build( ); + + List<String> artifactVersions; + try( Stream<? extends Artifact> stream = repository.newArtifactStream( selector )){ + artifactVersions = stream.map( a -> a.getArtifactVersion( ) ) + .filter( StringUtils::isNotEmpty ) + .distinct() + .collect( Collectors.toList( ) ); + } - int countToPurge = versions.size( ) - retentionCount; + Collections.sort( artifactVersions, VersionComparator.getInstance( ) ); - Set<ArtifactReference> artifactsToDelete = new HashSet<>( ); - for ( String version : versions ) - { - if ( countToPurge-- <= 0 ) + if ( retentionCount > artifactVersions.size( ) ) { - break; + // Done. nothing to do here. skip it. + return; } - ArtifactReference newArtifactReference = repository.toArtifactReference( - artifactFile.toAbsolutePath( ).toString() ); - newArtifactReference.setVersion( version ); + int countToPurge = artifactVersions.size( ) - retentionCount; - StorageAsset newArtifactFile = repository.toFile( newArtifactReference ); - // Is this a generic snapshot "1.0-SNAPSHOT" ? - if ( VersionUtil.isGenericSnapshot( newArtifactReference.getVersion( ) ) ) + ArchivaItemSelector.Builder artifactSelectorBuilder = ArchivaItemSelector.builder( ) + .withNamespace( artifactItem.getVersion( ).getProject( ).getNamespace( ).getNamespace( ) ) + .withProjectId( artifactItem.getVersion( ).getProject( ).getId( ) ) + .withVersion( artifactItem.getVersion( ).getVersion( ) ) + .withArtifactId( artifactItem.getId() ) + .withClassifier( "*" ) + .includeRelatedArtifacts( ); + + Set<Artifact> artifactsToDelete = new HashSet<>( ); + for ( String version : artifactVersions ) { - if ( newArtifactFile.getModificationTime().toEpochMilli() < olderThanThisDate.getTimeInMillis( ) ) + if ( countToPurge-- <= 0 ) { - artifactsToDelete.addAll( repository.getRelatedArtifacts( repository.toVersion(newArtifactReference) ) ); + break; } - } - // Is this a timestamp snapshot "1.0-20070822.123456-42" ? - else if ( VersionUtil.isUniqueSnapshot( newArtifactReference.getVersion( ) ) ) - { - Calendar timestampCal = uniqueSnapshotToCalendar( newArtifactReference.getVersion( ) ); - if ( timestampCal.getTimeInMillis( ) < olderThanThisDate.getTimeInMillis( ) ) + ArchivaItemSelector artifactSelector = artifactSelectorBuilder.withArtifactVersion( version ).build( ); + try { - artifactsToDelete.addAll( repository.getRelatedArtifacts( repository.toVersion(newArtifactReference) ) ); + + + // Is this a generic snapshot "1.0-SNAPSHOT" ? + if ( VersionUtil.isGenericSnapshot( version ) ) + { + List<? extends Artifact> artifactList = repository.getArtifacts( artifactSelector ); + if ( artifactList.size()>0 && artifactList.get(0).getAsset().getModificationTime( ).toEpochMilli( ) < olderThanThisDate.getTimeInMillis( ) ) + { + artifactsToDelete.addAll( artifactList ); + } + } + // Is this a timestamp snapshot "1.0-20070822.123456-42" ? + else if ( VersionUtil.isUniqueSnapshot( version ) ) + { + Calendar timestampCal = uniqueSnapshotToCalendar( version ); + + if ( timestampCal.getTimeInMillis( ) < olderThanThisDate.getTimeInMillis( ) ) + { + artifactsToDelete.addAll( repository.getArtifacts( artifactSelector ) ); + } + } + } catch ( IllegalArgumentException e ) { + log.error( "Bad selector for artifact: {}", e.getMessage( ), e ); + // continue } } + purge( artifactsToDelete ); } - purge( artifactsToDelete ); - } - catch ( ContentNotFoundException e ) - { - throw new RepositoryPurgeException( e.getMessage( ), e ); } catch ( LayoutException e ) { @@ -163,7 +199,7 @@ public class DaysOldRepositoryPurge try { versionDate = timestampParser.parse( tsDate + "." + tsTime ); - Calendar cal = Calendar.getInstance( TimeZone.getTimeZone("UTC") ); + Calendar cal = Calendar.getInstance( TimeZone.getTimeZone( "UTC" ) ); cal.setTime( versionDate ); return cal; diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java index af617c143..3a4ae7ce9 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java @@ -28,6 +28,12 @@ import org.apache.archiva.repository.ContentNotFoundException; import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.metadata.audit.RepositoryListener; +import org.apache.archiva.repository.content.Artifact; +import org.apache.archiva.repository.content.ContentItem; +import org.apache.archiva.repository.content.ItemSelector; +import org.apache.archiva.repository.content.Version; +import org.apache.archiva.repository.content.base.ArchivaItemSelector; +import org.apache.commons.lang3.StringUtils; import java.nio.file.Files; import java.nio.file.Path; @@ -37,6 +43,8 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Purge the repository by retention count. Retain only the specified number of snapshots. @@ -59,58 +67,78 @@ public class RetentionCountRepositoryPurge { try { - Path artifactFile = Paths.get( repository.getRepoRoot( ), path ); - - if ( !Files.exists(artifactFile) ) + ContentItem item = repository.toItem( path ); + if (item instanceof Artifact ) { - return; - } + Artifact artifact = (Artifact) item; + if (!artifact.exists()) { + return; + } - ArtifactReference artifact = repository.toArtifactReference( path ); + if ( VersionUtil.isSnapshot( artifact.getVersion( ).getVersion() ) ) + { + ArchivaItemSelector selector = ArchivaItemSelector.builder( ) + .withNamespace( artifact.getVersion( ).getProject( ).getNamespace( ).getNamespace( ) ) + .withProjectId( artifact.getVersion( ).getProject( ).getId( ) ) + .withArtifactId( artifact.getId( ) ) + .withVersion( artifact.getVersion( ).getVersion( ) ) + .withClassifier( "*" ) + .includeRelatedArtifacts() + .build( ); - if ( VersionUtil.isSnapshot( artifact.getVersion( ) ) ) - { - VersionedReference reference = new VersionedReference( ); - reference.setGroupId( artifact.getGroupId( ) ); - reference.setArtifactId( artifact.getArtifactId( ) ); - reference.setVersion( artifact.getVersion( ) ); - List<String> versions = new ArrayList<>( repository.getVersions( reference ) ); + List<String> versions; + try( Stream<? extends Artifact> stream = repository.newArtifactStream( selector) ){ + versions = stream.map( a -> a.getArtifactVersion( ) ) + .filter( StringUtils::isNotEmpty ) + .distinct() + .collect( Collectors.toList( ) ); + } - Collections.sort( versions, VersionComparator.getInstance( ) ); + Collections.sort( versions, VersionComparator.getInstance( ) ); - if ( retentionCount > versions.size( ) ) - { - log.trace( "No deletion, because retention count is higher than actual number of artifacts." ); - // Done. nothing to do here. skip it. - return; - } + if ( retentionCount > versions.size( ) ) + { + log.trace( "No deletion, because retention count is higher than actual number of artifacts." ); + // Done. nothing to do here. skip it. + return; + } - int countToPurge = versions.size( ) - retentionCount; - Set<ArtifactReference> artifactsToDelete = new HashSet<>( ); - for ( String version : versions ) - { - if ( countToPurge-- <= 0 ) + ArchivaItemSelector.Builder selectorBuilder = ArchivaItemSelector.builder( ) + .withNamespace( artifact.getVersion( ).getProject( ).getNamespace( ).getNamespace( ) ) + .withProjectId( artifact.getVersion( ).getProject( ).getId( ) ) + .withArtifactId( artifact.getId( ) ) + .withClassifier( "*" ) + .includeRelatedArtifacts() + .withVersion( artifact.getVersion( ).getVersion( ) ); + int countToPurge = versions.size( ) - retentionCount; + Set<Artifact> artifactsToDelete = new HashSet<>( ); + for ( String version : versions ) { - break; + if ( countToPurge-- <= 0 ) + { + break; + } + List<? extends Artifact> delArtifacts = repository.getArtifacts( selectorBuilder.withArtifactVersion( version ).build( ) ); + if (delArtifacts!=null && delArtifacts.size()>0) + { + artifactsToDelete.addAll( delArtifacts ); + } } - VersionedReference ref = repository.toVersion( getNewArtifactReference( artifact, version ) ); - artifactsToDelete.addAll( repository.getRelatedArtifacts( ref ) ); + purge( artifactsToDelete ); } - purge( artifactsToDelete ); + } else { + throw new RepositoryPurgeException( "Bad artifact path " + path ); } } catch ( LayoutException le ) { throw new RepositoryPurgeException( le.getMessage( ), le ); } - catch ( ContentNotFoundException e ) - { - log.error( "Repostory artifact not found {}", path ); - } catch ( org.apache.archiva.repository.ContentAccessException e ) { - e.printStackTrace( ); + log.error( "Error while accessing the repository data: {}", e.getMessage( ), e ); + throw new RepositoryPurgeException( e.getMessage( ), e ); } } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java index ccdbeab63..0deb60d6e 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java @@ -109,10 +109,10 @@ public class DaysOldRepositoryPurgeTest listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.apache.maven.plugins", "maven-install-plugin", "2.2-SNAPSHOT", "maven-install-plugin-2.2-SNAPSHOT.pom"+exts[i]); listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.apache.maven.plugins", - "maven-install-plugin", "2.2-20061118.060401-2", + "maven-install-plugin", "2.2-SNAPSHOT", "maven-install-plugin-2.2-20061118.060401-2.jar"+exts[i]); listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.apache.maven.plugins", - "maven-install-plugin", "2.2-20061118.060401-2", + "maven-install-plugin", "2.2-SNAPSHOT", "maven-install-plugin-2.2-20061118.060401-2.pom"+exts[i]); } listenerControl.replay(); @@ -203,10 +203,10 @@ public class DaysOldRepositoryPurgeTest String[] exts = {".md5",".sha1",""}; for (int i=0; i<exts.length; i++) { listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.apache.maven.plugins", - "maven-assembly-plugin", "1.1.2-20070427.065136-1", + "maven-assembly-plugin", "1.1.2-SNAPSHOT", "maven-assembly-plugin-1.1.2-20070427.065136-1.jar"+exts[i]); listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.apache.maven.plugins", - "maven-assembly-plugin", "1.1.2-20070427.065136-1", + "maven-assembly-plugin", "1.1.2-SNAPSHOT", "maven-assembly-plugin-1.1.2-20070427.065136-1.pom"+exts[i]); } listenerControl.replay(); @@ -313,9 +313,9 @@ public class DaysOldRepositoryPurgeTest for (int i=0; i<exts.length; i++) { listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.codehaus.plexus", "plexus-utils", - "1.4.3-20070113.163208-4", "plexus-utils-1.4.3-20070113.163208-4.jar"+exts[i]); + "1.4.3-SNAPSHOT", "plexus-utils-1.4.3-20070113.163208-4.jar"+exts[i]); listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.codehaus.plexus", "plexus-utils", - "1.4.3-20070113.163208-4", "plexus-utils-1.4.3-20070113.163208-4.pom"+exts[i]); + "1.4.3-SNAPSHOT", "plexus-utils-1.4.3-20070113.163208-4.pom"+exts[i]); } listenerControl.replay(); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java index 143339eba..97afa7b92 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java @@ -100,27 +100,27 @@ public class RetentionCountRepositoryPurgeTest String[] exts = { ".md5", ".sha1", ""}; for (int i=0 ; i<exts.length; i++) { listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin", - "1.0RC1-20070504.153317-1", "jruby-rake-plugin-1.0RC1-20070504.153317-1.jar"+exts[i]); + "1.0RC1-SNAPSHOT", "jruby-rake-plugin-1.0RC1-20070504.153317-1.jar"+exts[i]); listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin", - "1.0RC1-20070504.153317-1", "jruby-rake-plugin-1.0RC1-20070504.153317-1.pom"+exts[i]); + "1.0RC1-SNAPSHOT", "jruby-rake-plugin-1.0RC1-20070504.153317-1.pom"+exts[i]); listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin", - "1.0RC1-20070504.160758-2", "jruby-rake-plugin-1.0RC1-20070504.160758-2.jar"+exts[i]); + "1.0RC1-SNAPSHOT", "jruby-rake-plugin-1.0RC1-20070504.160758-2.jar"+exts[i]); listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin", - "1.0RC1-20070504.160758-2", "jruby-rake-plugin-1.0RC1-20070504.160758-2.pom"+exts[i]); + "1.0RC1-SNAPSHOT", "jruby-rake-plugin-1.0RC1-20070504.160758-2.pom"+exts[i]); } listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin", - "1.0RC1-20070504.160758-2", "jruby-rake-plugin-1.0RC1-20070504.160758-2-javadoc.jar"); + "1.0RC1-SNAPSHOT", "jruby-rake-plugin-1.0RC1-20070504.160758-2-javadoc.jar"); listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin", - "1.0RC1-20070504.160758-2", "jruby-rake-plugin-1.0RC1-20070504.160758-2-javadoc.zip"); + "1.0RC1-SNAPSHOT", "jruby-rake-plugin-1.0RC1-20070504.160758-2-javadoc.zip"); listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin", - "1.0RC1-20070504.153317-1", "jruby-rake-plugin-1.0RC1-20070504.153317-1-javadoc.jar"); + "1.0RC1-SNAPSHOT", "jruby-rake-plugin-1.0RC1-20070504.153317-1-javadoc.jar"); listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin", - "1.0RC1-20070504.153317-1", "jruby-rake-plugin-1.0RC1-20070504.153317-1-javadoc.zip"); + "1.0RC1-SNAPSHOT", "jruby-rake-plugin-1.0RC1-20070504.153317-1-javadoc.zip"); listenerControl.replay(); @@ -198,17 +198,17 @@ public class RetentionCountRepositoryPurgeTest // test listeners for the correct artifacts listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.codehaus.castor", "castor-anttasks", - "1.1.2-20070427.065136-1", "castor-anttasks-1.1.2-20070427.065136-1.jar.md5" ); + "1.1.2-SNAPSHOT", "castor-anttasks-1.1.2-20070427.065136-1.jar.md5" ); listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.codehaus.castor", "castor-anttasks", - "1.1.2-20070427.065136-1", "castor-anttasks-1.1.2-20070427.065136-1.jar.sha1" ); + "1.1.2-SNAPSHOT", "castor-anttasks-1.1.2-20070427.065136-1.jar.sha1" ); listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.codehaus.castor", "castor-anttasks", - "1.1.2-20070427.065136-1", "castor-anttasks-1.1.2-20070427.065136-1.jar" ); + "1.1.2-SNAPSHOT", "castor-anttasks-1.1.2-20070427.065136-1.jar" ); listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.codehaus.castor", "castor-anttasks", - "1.1.2-20070427.065136-1", "castor-anttasks-1.1.2-20070427.065136-1.pom.md5" ); + "1.1.2-SNAPSHOT", "castor-anttasks-1.1.2-20070427.065136-1.pom.md5" ); listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.codehaus.castor", "castor-anttasks", - "1.1.2-20070427.065136-1", "castor-anttasks-1.1.2-20070427.065136-1.pom.sha1" ); + "1.1.2-SNAPSHOT", "castor-anttasks-1.1.2-20070427.065136-1.pom.sha1" ); listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.codehaus.castor", "castor-anttasks", - "1.1.2-20070427.065136-1", "castor-anttasks-1.1.2-20070427.065136-1.pom" ); + "1.1.2-SNAPSHOT", "castor-anttasks-1.1.2-20070427.065136-1.pom" ); listenerControl.replay(); // Provide the metadata list @@ -280,22 +280,22 @@ public class RetentionCountRepositoryPurgeTest // test listeners for the correct artifacts listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins", - "maven-assembly-plugin", "1.1.2-20070427.065136-1", + "maven-assembly-plugin", "1.1.2-SNAPSHOT", "maven-assembly-plugin-1.1.2-20070427.065136-1.jar.md5" ); listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins", - "maven-assembly-plugin", "1.1.2-20070427.065136-1", + "maven-assembly-plugin", "1.1.2-SNAPSHOT", "maven-assembly-plugin-1.1.2-20070427.065136-1.jar.sha1" ); listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins", - "maven-assembly-plugin", "1.1.2-20070427.065136-1", + "maven-assembly-plugin", "1.1.2-SNAPSHOT", "maven-assembly-plugin-1.1.2-20070427.065136-1.jar" ); listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins", - "maven-assembly-plugin", "1.1.2-20070427.065136-1", + "maven-assembly-plugin", "1.1.2-SNAPSHOT", "maven-assembly-plugin-1.1.2-20070427.065136-1.pom.md5" ); listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins", - "maven-assembly-plugin", "1.1.2-20070427.065136-1", + "maven-assembly-plugin", "1.1.2-SNAPSHOT", "maven-assembly-plugin-1.1.2-20070427.065136-1.pom.sha1" ); listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins", - "maven-assembly-plugin", "1.1.2-20070427.065136-1", + "maven-assembly-plugin", "1.1.2-SNAPSHOT", "maven-assembly-plugin-1.1.2-20070427.065136-1.pom" ); listenerControl.replay(); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context-purge-consumer-test.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context-purge-consumer-test.xml index 00b9a6a41..ad3e7652f 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context-purge-consumer-test.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context-purge-consumer-test.xml @@ -28,7 +28,7 @@ default-lazy-init="true"> <context:annotation-config/> - <context:component-scan base-package="org.apache.archiva.metadata.repository"/> + <context:component-scan base-package="org.apache.archiva.metadata.repository,org.apache.archiva.repository.maven.content"/> <!-- for testing repo purge using retention count --> diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context.xml index b342fe414..1ce2a8f93 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context.xml @@ -27,7 +27,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd" default-lazy-init="true"> <context:annotation-config/> - <context:component-scan base-package="org.apache.archiva.metadata.repository"/> + <context:component-scan base-package="org.apache.archiva.metadata.repository,org.apache.archiva.repository.maven.content,org.apache.archiva.metadata.maven"/> <bean name="commons-configuration" class="org.apache.archiva.components.registry.commons.CommonsConfigurationRegistry"> <property name="initialConfiguration"> |