import org.apache.archiva.repository.ContentNotFoundException; | import org.apache.archiva.repository.ContentNotFoundException; | ||||
import org.apache.archiva.repository.ManagedRepositoryContent; | import org.apache.archiva.repository.ManagedRepositoryContent; | ||||
import org.apache.archiva.metadata.audit.RepositoryListener; | 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.StorageAsset; | ||||
import org.apache.archiva.repository.storage.util.StorageUtil; | import org.apache.archiva.repository.storage.util.StorageUtil; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
* | * | ||||
* @param references | * @param references | ||||
*/ | */ | ||||
protected void purge( Set<ArtifactReference> references ) | |||||
protected void purge( Set<Artifact> references ) | |||||
{ | { | ||||
if ( references != null && !references.isEmpty( ) ) | if ( references != null && !references.isEmpty( ) ) | ||||
{ | { | ||||
MetadataRepository metadataRepository = repositorySession.getRepository( ); | MetadataRepository metadataRepository = repositorySession.getRepository( ); | ||||
Map<ArtifactInfo, ArtifactMetadata> metaRemovalList = new HashMap<>( ); | Map<ArtifactInfo, ArtifactMetadata> metaRemovalList = new HashMap<>( ); | ||||
Map<String, Collection<ArtifactMetadata>> metaResolved = 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 | // Needed for tracking in the hashmap | ||||
String metaBaseId = reference.getGroupId( ) + "/" + reference.getArtifactId( ) + "/" + baseVersion; | |||||
String metaBaseId = reference.toKey(); | |||||
if ( !metaResolved.containsKey( metaBaseId ) ) | if ( !metaResolved.containsKey( metaBaseId ) ) | ||||
{ | { | ||||
try | try | ||||
{ | { | ||||
metaResolved.put( metaBaseId, metadataRepository.getArtifacts(repositorySession, repository.getId( ), | metaResolved.put( metaBaseId, metadataRepository.getArtifacts(repositorySession, repository.getId( ), | ||||
reference.getGroupId( ), reference.getArtifactId( ), baseVersion ) ); | |||||
namespace, reference.getId( ), baseVersion ) ); | |||||
} | } | ||||
catch ( MetadataResolutionException e ) | catch ( MetadataResolutionException e ) | ||||
{ | { | ||||
log.error( "Error during metadata retrieval {}: {}", metaBaseId, e.getMessage( ) ); | log.error( "Error during metadata retrieval {}: {}", metaBaseId, e.getMessage( ) ); | ||||
} | } | ||||
} | } | ||||
StorageAsset artifactFile = repository.toFile( reference ); | |||||
StorageAsset artifactFile = reference.getAsset(); | |||||
for ( RepositoryListener listener : listeners ) | 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( )); | 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. | // If this is a snapshot we have to search for artifacts with the same version. And remove all of them. | ||||
for ( ArtifactMetadata artifactMetadata : artifacts ) | for ( ArtifactMetadata artifactMetadata : artifacts ) | ||||
{ | { | ||||
// Artifact metadata and reference version should match. | // 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( ) ); | ArtifactInfo info = new ArtifactInfo( artifactMetadata.getNamespace( ), artifactMetadata.getProject( ), artifactMetadata.getProjectVersion( ), artifactMetadata.getVersion( ) ); | ||||
if ( StringUtils.isNotBlank( reference.getClassifier( ) ) ) | if ( StringUtils.isNotBlank( reference.getClassifier( ) ) ) | ||||
} | } | ||||
else // otherwise we delete the artifact version | 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 ) ) | for ( ArtifactMetadata metadata : metaResolved.get( metaBaseId ) ) | ||||
{ | { | ||||
metaRemovalList.put( info, metadata ); | metaRemovalList.put( info, metadata ); | ||||
} | } | ||||
} | } | ||||
triggerAuditEvent( repository.getRepository( ).getId( ), ArtifactReference.toKey( reference ), | |||||
triggerAuditEvent( repository.getRepository( ).getId( ), reference.toKey(), | |||||
AuditEvent.PURGE_ARTIFACT ); | AuditEvent.PURGE_ARTIFACT ); | ||||
purgeSupportFiles( artifactFile ); | |||||
// purgeSupportFiles( artifactFile ); | |||||
} | } | ||||
purgeMetadata( metadataRepository, metaRemovalList ); | purgeMetadata( metadataRepository, metaRemovalList ); | ||||
try | try |
import org.apache.archiva.common.utils.VersionComparator; | import org.apache.archiva.common.utils.VersionComparator; | ||||
import org.apache.archiva.common.utils.VersionUtil; | 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.metadata.repository.RepositorySession; | ||||
import org.apache.archiva.model.ArtifactReference; | import org.apache.archiva.model.ArtifactReference; | ||||
import org.apache.archiva.model.VersionedReference; | |||||
import org.apache.archiva.repository.ContentNotFoundException; | import org.apache.archiva.repository.ContentNotFoundException; | ||||
import org.apache.archiva.repository.LayoutException; | import org.apache.archiva.repository.LayoutException; | ||||
import org.apache.archiva.repository.ManagedRepositoryContent; | 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.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.ParseException; | ||||
import java.text.SimpleDateFormat; | 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.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. | * Purge from repository all snapshots older than the specified days in the repository configuration. | ||||
this.retentionPeriod = retentionPeriod; | this.retentionPeriod = retentionPeriod; | ||||
this.retentionCount = retentionCount; | this.retentionCount = retentionCount; | ||||
timestampParser = new SimpleDateFormat( "yyyyMMdd.HHmmss" ); | timestampParser = new SimpleDateFormat( "yyyyMMdd.HHmmss" ); | ||||
timestampParser.setTimeZone( TimeZone.getTimeZone("UTC")); | |||||
timestampParser.setTimeZone( TimeZone.getTimeZone( "UTC" ) ); | |||||
} | } | ||||
@Override | @Override | ||||
{ | { | ||||
try | 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 ) | catch ( LayoutException e ) | ||||
{ | { | ||||
try | try | ||||
{ | { | ||||
versionDate = timestampParser.parse( tsDate + "." + tsTime ); | versionDate = timestampParser.parse( tsDate + "." + tsTime ); | ||||
Calendar cal = Calendar.getInstance( TimeZone.getTimeZone("UTC") ); | |||||
Calendar cal = Calendar.getInstance( TimeZone.getTimeZone( "UTC" ) ); | |||||
cal.setTime( versionDate ); | cal.setTime( versionDate ); | ||||
return cal; | return cal; |
import org.apache.archiva.repository.LayoutException; | import org.apache.archiva.repository.LayoutException; | ||||
import org.apache.archiva.repository.ManagedRepositoryContent; | import org.apache.archiva.repository.ManagedRepositoryContent; | ||||
import org.apache.archiva.metadata.audit.RepositoryListener; | 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.Files; | ||||
import java.nio.file.Path; | import java.nio.file.Path; | ||||
import java.util.HashSet; | import java.util.HashSet; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Set; | 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. | * Purge the repository by retention count. Retain only the specified number of snapshots. | ||||
{ | { | ||||
try | 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 ) | catch ( LayoutException le ) | ||||
{ | { | ||||
throw new RepositoryPurgeException( le.getMessage( ), le ); | throw new RepositoryPurgeException( le.getMessage( ), le ); | ||||
} | } | ||||
catch ( ContentNotFoundException e ) | |||||
{ | |||||
log.error( "Repostory artifact not found {}", path ); | |||||
} | |||||
catch ( org.apache.archiva.repository.ContentAccessException e ) | 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 ); | |||||
} | } | ||||
} | } | ||||
listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.apache.maven.plugins", | listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.apache.maven.plugins", | ||||
"maven-install-plugin", "2.2-SNAPSHOT", "maven-install-plugin-2.2-SNAPSHOT.pom"+exts[i]); | "maven-install-plugin", "2.2-SNAPSHOT", "maven-install-plugin-2.2-SNAPSHOT.pom"+exts[i]); | ||||
listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.apache.maven.plugins", | 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]); | "maven-install-plugin-2.2-20061118.060401-2.jar"+exts[i]); | ||||
listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.apache.maven.plugins", | 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]); | "maven-install-plugin-2.2-20061118.060401-2.pom"+exts[i]); | ||||
} | } | ||||
listenerControl.replay(); | listenerControl.replay(); | ||||
String[] exts = {".md5",".sha1",""}; | String[] exts = {".md5",".sha1",""}; | ||||
for (int i=0; i<exts.length; i++) { | for (int i=0; i<exts.length; i++) { | ||||
listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.apache.maven.plugins", | 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]); | "maven-assembly-plugin-1.1.2-20070427.065136-1.jar"+exts[i]); | ||||
listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.apache.maven.plugins", | 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]); | "maven-assembly-plugin-1.1.2-20070427.065136-1.pom"+exts[i]); | ||||
} | } | ||||
listenerControl.replay(); | listenerControl.replay(); | ||||
for (int i=0; i<exts.length; i++) { | for (int i=0; i<exts.length; i++) { | ||||
listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.codehaus.plexus", "plexus-utils", | 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", | 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(); | listenerControl.replay(); | ||||
String[] exts = { ".md5", ".sha1", ""}; | String[] exts = { ".md5", ".sha1", ""}; | ||||
for (int i=0 ; i<exts.length; i++) { | for (int i=0 ; i<exts.length; i++) { | ||||
listener.deleteArtifact(metadataRepository, getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin", | 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", | 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", | 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", | 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", | 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", | 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", | 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", | 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(); | listenerControl.replay(); | ||||
// test listeners for the correct artifacts | // test listeners for the correct artifacts | ||||
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.codehaus.castor", "castor-anttasks", | 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", | 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", | 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", | 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", | 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", | 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(); | listenerControl.replay(); | ||||
// Provide the metadata list | // Provide the metadata list | ||||
// test listeners for the correct artifacts | // test listeners for the correct artifacts | ||||
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins", | 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" ); | "maven-assembly-plugin-1.1.2-20070427.065136-1.jar.md5" ); | ||||
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins", | 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" ); | "maven-assembly-plugin-1.1.2-20070427.065136-1.jar.sha1" ); | ||||
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins", | 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" ); | "maven-assembly-plugin-1.1.2-20070427.065136-1.jar" ); | ||||
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins", | 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" ); | "maven-assembly-plugin-1.1.2-20070427.065136-1.pom.md5" ); | ||||
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins", | 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" ); | "maven-assembly-plugin-1.1.2-20070427.065136-1.pom.sha1" ); | ||||
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins", | 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" ); | "maven-assembly-plugin-1.1.2-20070427.065136-1.pom" ); | ||||
listenerControl.replay(); | listenerControl.replay(); | ||||
default-lazy-init="true"> | default-lazy-init="true"> | ||||
<context:annotation-config/> | <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 --> | <!-- for testing repo purge using retention count --> | ||||
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" | 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"> | default-lazy-init="true"> | ||||
<context:annotation-config/> | <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"> | <bean name="commons-configuration" class="org.apache.archiva.components.registry.commons.CommonsConfigurationRegistry"> | ||||
<property name="initialConfiguration"> | <property name="initialConfiguration"> |
* | * | ||||
* @param selector the selector with the artifact coordinates | * @param selector the selector with the artifact coordinates | ||||
* @return a artifact object | * @return a artifact object | ||||
* @throws ItemNotFoundException if the selector coordinates do not specify a artifact | |||||
* @throws IllegalArgumentException if the selector coordinates do not specify a artifact | |||||
* @throws ContentAccessException if the access to the underlying storage failed | * @throws ContentAccessException if the access to the underlying storage failed | ||||
*/ | */ | ||||
Artifact getArtifact(ItemSelector selector) throws ContentAccessException; | Artifact getArtifact(ItemSelector selector) throws ContentAccessException; | ||||
* | * | ||||
* @param selector the selector for the artifacts | * @param selector the selector for the artifacts | ||||
* @return a list of artifacts. | * @return a list of artifacts. | ||||
* @throws ItemNotFoundException if the specified coordinates cannot be found in the repository | |||||
* @throws IllegalArgumentException if the specified coordinates cannot be found in the repository | |||||
* @throws ContentAccessException if the access to the underlying storage failed | * @throws ContentAccessException if the access to the underlying storage failed | ||||
*/ | */ | ||||
List<? extends Artifact> getArtifacts( ItemSelector selector) throws ContentAccessException; | List<? extends Artifact> getArtifacts( ItemSelector selector) throws ContentAccessException; | ||||
VersionedReference toVersion( String groupId, String artifactId, String version ); | VersionedReference toVersion( String groupId, String artifactId, String version ); | ||||
/** | |||||
* Returns the version reference that represents the generic version, which means that | |||||
* snapshot versions are converted to <VERSION>-SNAPSHOT | |||||
* @param artifactReference the artifact reference | |||||
* @return the generic version | |||||
*/ | |||||
VersionedReference toGenericVersion( ArtifactReference artifactReference ); | |||||
/** | /** | ||||
* Return the version reference that matches exactly the version string of the artifact | * Return the version reference that matches exactly the version string of the artifact | ||||
* | * |
* under the License. | * under the License. | ||||
*/ | */ | ||||
import org.apache.archiva.model.ArtifactReference; | |||||
/** | /** | ||||
* Represents a artifact of a repository. This object contains unique coordinates of the | * Represents a artifact of a repository. This object contains unique coordinates of the | ||||
* artifact. A artifact has exactly one file representation in the repository. | * artifact. A artifact has exactly one file representation in the repository. | ||||
*/ | */ | ||||
ArtifactType getArtifactType(); | ArtifactType getArtifactType(); | ||||
/** | |||||
* Returns a unique key | |||||
* @return | |||||
*/ | |||||
String toKey(); | |||||
} | } |
return sb.toString( ); | return sb.toString( ); | ||||
} | } | ||||
public static String defaultString( String value ) | |||||
{ | |||||
if ( value == null ) | |||||
{ | |||||
return ""; | |||||
} | |||||
return value.trim(); | |||||
} | |||||
public String toKey( ) | |||||
{ | |||||
StringBuilder key = new StringBuilder(); | |||||
key.append( defaultString( getVersion().getProject().getNamespace().getNamespace() )).append( ":" ); | |||||
key.append( defaultString( getId() ) ).append( ":" ); | |||||
key.append( defaultString( getVersion().getVersion() ) ).append( ":" ); | |||||
key.append( defaultString( getClassifier() ) ).append( ":" ); | |||||
key.append( defaultString( getType() ) ); | |||||
return key.toString(); | |||||
} | |||||
private static class Builder | private static class Builder | ||||
extends ContentItemBuilder<ArchivaArtifact, ArtifactOptBuilder, WithVersionObjectBuilder> | extends ContentItemBuilder<ArchivaArtifact, ArtifactOptBuilder, WithVersionObjectBuilder> | ||||
implements ArtifactVersionBuilder, WithVersionObjectBuilder, ArtifactWithIdBuilder, ArtifactOptBuilder | implements ArtifactVersionBuilder, WithVersionObjectBuilder, ArtifactWithIdBuilder, ArtifactOptBuilder |
* under the License. | * under the License. | ||||
*/ | */ | ||||
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.ItemSelector; | ||||
import org.apache.archiva.repository.content.Namespace; | |||||
import org.apache.archiva.repository.content.Project; | |||||
import org.apache.archiva.repository.content.Version; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
{ | { | ||||
private final ArchivaItemSelector selector = new ArchivaItemSelector( ); | private final ArchivaItemSelector selector = new ArchivaItemSelector( ); | ||||
public Builder withItem( ContentItem item ) { | |||||
if (item instanceof Namespace ) { | |||||
Namespace ns = (Namespace) item; | |||||
selector.namespace = ns.getNamespace(); | |||||
} else if (item instanceof Project ) { | |||||
Project proj = (Project)item; | |||||
selector.namespace = proj.getNamespace( ).getNamespace( ); | |||||
selector.projectId = proj.getId( ); | |||||
} else if (item instanceof Version) { | |||||
Version version = (Version)item; | |||||
selector.namespace = version.getProject( ).getNamespace( ).getNamespace( ); | |||||
selector.projectId = version.getProject( ).getId( ); | |||||
selector.version = version.getVersion( ); | |||||
} else if (item instanceof Artifact ) { | |||||
Artifact artifact = (Artifact)item; | |||||
selector.namespace = artifact.getVersion( ).getProject( ).getNamespace( ).getNamespace( ); | |||||
selector.projectId = artifact.getVersion( ).getProject( ).getId( ); | |||||
selector.version = artifact.getVersion( ).getVersion( ); | |||||
selector.artifactId = artifact.getId( ); | |||||
selector.artifactVersion = artifact.getArtifactVersion( ); | |||||
selector.extension = artifact.getExtension( ); | |||||
} | |||||
for (Map.Entry<String, String> att : item.getAttributes().entrySet()) { | |||||
selector.setAttribute( att.getKey( ), att.getValue( ) ); | |||||
} | |||||
return this; | |||||
} | |||||
public Builder withNamespace( String namespace ) | public Builder withNamespace( String namespace ) | ||||
{ | { | ||||
if (namespace!=null) | if (namespace!=null) |
return null; | return null; | ||||
} | } | ||||
@Override | |||||
public VersionedReference toGenericVersion( ArtifactReference artifactReference ) | |||||
{ | |||||
return null; | |||||
} | |||||
@Override | @Override | ||||
public VersionedReference toVersion( ArtifactReference artifactReference ) | public VersionedReference toVersion( ArtifactReference artifactReference ) | ||||
{ | { |
return null; | return null; | ||||
} | } | ||||
@Override | |||||
public VersionedReference toGenericVersion( ArtifactReference artifactReference ) | |||||
{ | |||||
return null; | |||||
} | |||||
@Override | @Override | ||||
public VersionedReference toVersion( ArtifactReference artifactReference ) | public VersionedReference toVersion( ArtifactReference artifactReference ) | ||||
{ | { |
return null; | return null; | ||||
} | } | ||||
@Override | |||||
public VersionedReference toGenericVersion( ArtifactReference artifactReference ) | |||||
{ | |||||
return null; | |||||
} | |||||
@Override | @Override | ||||
public VersionedReference toVersion( ArtifactReference artifactReference ) | public VersionedReference toVersion( ArtifactReference artifactReference ) | ||||
{ | { |
fileNamePattern.append( Pattern.quote( extension ) ); | fileNamePattern.append( Pattern.quote( extension ) ); | ||||
} | } | ||||
} else { | } else { | ||||
fileNamePattern.append( "[A-Za-z0-9]+" ); | |||||
fileNamePattern.append( "[A-Za-z0-9.]+" ); | |||||
} | } | ||||
final Pattern pattern = Pattern.compile( fileNamePattern.toString() ); | final Pattern pattern = Pattern.compile( fileNamePattern.toString() ); | ||||
return p.and( a -> pattern.matcher( a.getName( ) ).matches()); | return p.and( a -> pattern.matcher( a.getName( ) ).matches()); | ||||
return new VersionedReference().groupId( groupId ).artifactId( artifactId ).version( version ); | return new VersionedReference().groupId( groupId ).artifactId( artifactId ).version( version ); | ||||
} | } | ||||
@Override | |||||
public VersionedReference toGenericVersion( ArtifactReference artifactReference ) | |||||
{ | |||||
return toVersion( artifactReference.getGroupId( ), artifactReference.getArtifactId( ), VersionUtil.getBaseVersion( artifactReference.getVersion( ) )); | |||||
} | |||||
/** | /** | ||||
* Return the version the artifact is part of | * Return the version the artifact is part of | ||||
* @param artifactReference | * @param artifactReference |
@Inject | @Inject | ||||
protected List<? extends ArtifactMappingProvider> artifactMappingProviders; | protected List<? extends ArtifactMappingProvider> artifactMappingProviders; | ||||
@Inject | |||||
@Named("MavenContentHelper") | |||||
MavenContentHelper mavenContentHelper; | |||||
private static final Set<RepositoryType> REPOSITORY_TYPES = new HashSet<>( ); | private static final Set<RepositoryType> REPOSITORY_TYPES = new HashSet<>( ); | ||||
static { | static { | ||||
throw new RepositoryException( "Repository layout "+repository.getLayout()+" is not supported by this implementation." ); | throw new RepositoryException( "Repository layout "+repository.getLayout()+" is not supported by this implementation." ); | ||||
} | } | ||||
ManagedDefaultRepositoryContent content = new ManagedDefaultRepositoryContent(repository, artifactMappingProviders, filetypes ,fileLockManager); | ManagedDefaultRepositoryContent content = new ManagedDefaultRepositoryContent(repository, artifactMappingProviders, filetypes ,fileLockManager); | ||||
content.setMavenContentHelper( mavenContentHelper ); | |||||
return content; | return content; | ||||
} | } | ||||
default-lazy-init="true"> | default-lazy-init="true"> | ||||
<context:annotation-config/> | <context:annotation-config/> | ||||
<context:component-scan base-package="org.apache.archiva.dependency.tree.maven2,org.apache.archiva.metadata.repository.storage.maven2, | |||||
org.apache.archiva.repository.content.maven2"/> | |||||
<context:component-scan base-package="org.apache.archiva.repository.maven.dependency.tree,org.apache.archiva.repository.maven.metadata.storage, | |||||
org.apache.archiva.repository.maven.content"/> | |||||