You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ma...@apache.org on 2017/08/28 19:21:26 UTC
[1/4] archiva git commit: Reformat code
Repository: archiva
Updated Branches:
refs/heads/archiva-2.x 1d3714453 -> 85687a34e
Reformat code
Project: http://git-wip-us.apache.org/repos/asf/archiva/repo
Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/940412eb
Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/940412eb
Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/940412eb
Branch: refs/heads/archiva-2.x
Commit: 940412ebfb7c79bba7c2c1ee116b2b9e1394c058
Parents: 28f5125
Author: Martin Stockhammer <ma...@apache.org>
Authored: Sun Aug 27 16:18:57 2017 +0200
Committer: Martin Stockhammer <ma...@apache.org>
Committed: Mon Aug 28 20:36:30 2017 +0200
----------------------------------------------------------------------
.../core/ArtifactMissingChecksumsConsumer.java | 48 ++++++------
.../consumers/core/AutoRemoveConsumer.java | 32 ++++----
.../consumers/core/AutoRenameConsumer.java | 40 +++++-----
.../consumers/core/MetadataUpdaterConsumer.java | 80 ++++++++++----------
.../core/ValidateChecksumConsumer.java | 28 ++++---
.../repository/AbstractRepositoryPurge.java | 21 ++---
...CleanupReleasedSnapshotsRepositoryPurge.java | 71 ++++++++---------
.../core/repository/DaysOldRepositoryPurge.java | 46 +++++------
.../core/repository/RepositoryPurge.java | 2 +-
.../repository/RepositoryPurgeConsumer.java | 74 +++++++++---------
.../repository/RepositoryPurgeException.java | 4 +-
.../RetentionCountRepositoryPurge.java | 42 +++++-----
12 files changed, 241 insertions(+), 247 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/archiva/blob/940412eb/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
index ebb5997..9984b0b 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
@@ -82,17 +82,17 @@ public class ArtifactMissingChecksumsConsumer
//configuration.addChangeListener( this );
- initIncludes();
+ initIncludes( );
}
@Override
- public String getId()
+ public String getId( )
{
return this.id;
}
@Override
- public String getDescription()
+ public String getDescription( )
{
return this.description;
}
@@ -101,7 +101,7 @@ public class ArtifactMissingChecksumsConsumer
public void beginScan( ManagedRepository repo, Date whenGathered )
throws ConsumerException
{
- this.repositoryDir = new File( repo.getLocation() );
+ this.repositoryDir = new File( repo.getLocation( ) );
}
@Override
@@ -112,7 +112,7 @@ public class ArtifactMissingChecksumsConsumer
}
@Override
- public void completeScan()
+ public void completeScan( )
{
/* do nothing */
}
@@ -120,17 +120,17 @@ public class ArtifactMissingChecksumsConsumer
@Override
public void completeScan( boolean executeOnEntireRepo )
{
- completeScan();
+ completeScan( );
}
@Override
- public List<String> getExcludes()
+ public List<String> getExcludes( )
{
- return getDefaultArtifactExclusions();
+ return getDefaultArtifactExclusions( );
}
@Override
- public List<String> getIncludes()
+ public List<String> getIncludes( )
{
return includes;
}
@@ -153,48 +153,48 @@ public class ArtifactMissingChecksumsConsumer
private void createFixChecksum( String path, ChecksumAlgorithm checksumAlgorithm )
{
File artifactFile = new File( this.repositoryDir, path );
- File checksumFile = new File( this.repositoryDir, path + "." + checksumAlgorithm.getExt() );
+ File checksumFile = new File( this.repositoryDir, path + "." + checksumAlgorithm.getExt( ) );
- if ( checksumFile.exists() )
+ if ( checksumFile.exists( ) )
{
checksum = new ChecksummedFile( artifactFile );
try
{
if ( !checksum.isValidChecksum( checksumAlgorithm ) )
{
- checksum.fixChecksums( new ChecksumAlgorithm[]{ checksumAlgorithm } );
- log.info( "Fixed checksum file {}", checksumFile.getAbsolutePath() );
- triggerConsumerInfo( "Fixed checksum file " + checksumFile.getAbsolutePath() );
+ checksum.fixChecksums( new ChecksumAlgorithm[]{checksumAlgorithm} );
+ log.info( "Fixed checksum file {}", checksumFile.getAbsolutePath( ) );
+ triggerConsumerInfo( "Fixed checksum file " + checksumFile.getAbsolutePath( ) );
}
}
catch ( IOException e )
{
log.error( "Cannot calculate checksum for file {} :", checksumFile, e );
triggerConsumerError( TYPE_CHECKSUM_CANNOT_CALC, "Cannot calculate checksum for file " + checksumFile +
- ": " + e.getMessage() );
+ ": " + e.getMessage( ) );
}
}
- else if ( !checksumFile.exists() )
+ else if ( !checksumFile.exists( ) )
{
checksum = new ChecksummedFile( artifactFile );
try
{
checksum.createChecksum( checksumAlgorithm );
- log.info( "Created missing checksum file {}", checksumFile.getAbsolutePath() );
- triggerConsumerInfo( "Created missing checksum file " + checksumFile.getAbsolutePath() );
+ log.info( "Created missing checksum file {}", checksumFile.getAbsolutePath( ) );
+ triggerConsumerInfo( "Created missing checksum file " + checksumFile.getAbsolutePath( ) );
}
catch ( IOException e )
{
log.error( "Cannot create checksum for file {} :", checksumFile, e );
triggerConsumerError( TYPE_CHECKSUM_CANNOT_CREATE, "Cannot create checksum for file " + checksumFile +
- ": " + e.getMessage() );
+ ": " + e.getMessage( ) );
}
}
else
{
- log.warn( "Checksum file {} is not a file. ", checksumFile.getAbsolutePath() );
+ log.warn( "Checksum file {} is not a file. ", checksumFile.getAbsolutePath( ) );
triggerConsumerWarning( TYPE_CHECKSUM_NOT_FILE,
- "Checksum file " + checksumFile.getAbsolutePath() + " is not a file." );
+ "Checksum file " + checksumFile.getAbsolutePath( ) + " is not a file." );
}
}
@@ -217,17 +217,17 @@ public class ArtifactMissingChecksumsConsumer
*/
- private void initIncludes()
+ private void initIncludes( )
{
includes = new ArrayList<>( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) );
}
@PostConstruct
- public void initialize()
+ public void initialize( )
{
//configuration.addChangeListener( this );
- initIncludes();
+ initIncludes( );
}
}
http://git-wip-us.apache.org/repos/asf/archiva/blob/940412eb/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRemoveConsumer.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRemoveConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRemoveConsumer.java
index 4d8608c..9b74798 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRemoveConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRemoveConsumer.java
@@ -42,8 +42,6 @@ import java.util.List;
/**
* AutoRemoveConsumer
- *
- *
*/
@Service( "knownRepositoryContentConsumer#auto-remove" )
@Scope( "prototype" )
@@ -81,13 +79,13 @@ public class AutoRemoveConsumer
private List<String> includes = new ArrayList<>( 0 );
@Override
- public String getId()
+ public String getId( )
{
return this.id;
}
@Override
- public String getDescription()
+ public String getDescription( )
{
return this.description;
}
@@ -96,7 +94,7 @@ public class AutoRemoveConsumer
public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
- this.repositoryDir = new File( repository.getLocation() );
+ this.repositoryDir = new File( repository.getLocation( ) );
}
@Override
@@ -107,7 +105,7 @@ public class AutoRemoveConsumer
}
@Override
- public void completeScan()
+ public void completeScan( )
{
/* do nothing */
}
@@ -115,17 +113,17 @@ public class AutoRemoveConsumer
@Override
public void completeScan( boolean executeOnEntireRepo )
{
- completeScan();
+ completeScan( );
}
@Override
- public List<String> getExcludes()
+ public List<String> getExcludes( )
{
return null;
}
@Override
- public List<String> getIncludes()
+ public List<String> getIncludes( )
{
return includes;
}
@@ -135,11 +133,11 @@ public class AutoRemoveConsumer
throws ConsumerException
{
File file = new File( this.repositoryDir, path );
- if ( file.exists() )
+ if ( file.exists( ) )
{
- log.info( "(Auto) Removing File: {}", file.getAbsolutePath() );
- triggerConsumerInfo( "(Auto) Removing File: " + file.getAbsolutePath() );
- file.delete();
+ log.info( "(Auto) Removing File: {}", file.getAbsolutePath( ) );
+ triggerConsumerInfo( "(Auto) Removing File: " + file.getAbsolutePath( ) );
+ file.delete( );
}
}
@@ -155,7 +153,7 @@ public class AutoRemoveConsumer
{
if ( ConfigurationNames.isRepositoryScanning( propertyName ) )
{
- initIncludes();
+ initIncludes( );
}
}
@@ -165,16 +163,16 @@ public class AutoRemoveConsumer
/* do nothing */
}
- private void initIncludes()
+ private void initIncludes( )
{
includes = new ArrayList<>( filetypes.getFileTypePatterns( FileTypes.AUTO_REMOVE ) );
}
@PostConstruct
- public void initialize()
+ public void initialize( )
{
configuration.addChangeListener( this );
- initIncludes();
+ initIncludes( );
}
}
http://git-wip-us.apache.org/repos/asf/archiva/blob/940412eb/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRenameConsumer.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRenameConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRenameConsumer.java
index 7e59e2f..977ad42 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRenameConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRenameConsumer.java
@@ -40,8 +40,6 @@ import java.util.Map;
/**
* AutoRenameConsumer
- *
- *
*/
@Service( "knownRepositoryContentConsumer#auto-rename" )
@Scope( "prototype" )
@@ -49,7 +47,7 @@ public class AutoRenameConsumer
extends AbstractMonitoredConsumer
implements KnownRepositoryContentConsumer
{
- private Logger log = LoggerFactory.getLogger( AutoRenameConsumer.class );
+ private Logger log = LoggerFactory.getLogger( AutoRenameConsumer.class );
private String id = "auto-rename";
@@ -61,9 +59,9 @@ public class AutoRenameConsumer
private List<String> includes = new ArrayList<>( 3 );
- private Map<String, String> extensionRenameMap = new HashMap<>();
+ private Map<String, String> extensionRenameMap = new HashMap<>( );
- public AutoRenameConsumer()
+ public AutoRenameConsumer( )
{
includes.add( "**/*.distribution-tgz" );
includes.add( "**/*.distribution-zip" );
@@ -75,13 +73,13 @@ public class AutoRenameConsumer
}
@Override
- public String getId()
+ public String getId( )
{
return this.id;
}
@Override
- public String getDescription()
+ public String getDescription( )
{
return this.description;
}
@@ -90,7 +88,7 @@ public class AutoRenameConsumer
public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
- this.repositoryDir = new File( repository.getLocation() );
+ this.repositoryDir = new File( repository.getLocation( ) );
}
@Override
@@ -101,7 +99,7 @@ public class AutoRenameConsumer
}
@Override
- public void completeScan()
+ public void completeScan( )
{
/* do nothing */
}
@@ -109,17 +107,17 @@ public class AutoRenameConsumer
@Override
public void completeScan( boolean executeOnEntireRepo )
{
- completeScan();
+ completeScan( );
}
@Override
- public List<String> getExcludes()
+ public List<String> getExcludes( )
{
return null;
}
@Override
- public List<String> getIncludes()
+ public List<String> getIncludes( )
{
return includes;
}
@@ -129,16 +127,16 @@ public class AutoRenameConsumer
throws ConsumerException
{
File file = new File( this.repositoryDir, path );
- if ( file.exists() )
+ if ( file.exists( ) )
{
- Iterator<String> itExtensions = this.extensionRenameMap.keySet().iterator();
- while ( itExtensions.hasNext() )
+ Iterator<String> itExtensions = this.extensionRenameMap.keySet( ).iterator( );
+ while ( itExtensions.hasNext( ) )
{
- String extension = itExtensions.next();
+ String extension = itExtensions.next( );
if ( path.endsWith( extension ) )
{
String fixedExtension = this.extensionRenameMap.get( extension );
- String correctedPath = path.substring( 0, path.length() - extension.length() ) + fixedExtension;
+ String correctedPath = path.substring( 0, path.length( ) - extension.length( ) ) + fixedExtension;
File to = new File( this.repositoryDir, correctedPath );
try
{
@@ -149,14 +147,14 @@ public class AutoRenameConsumer
{
log.warn( "Unable to rename {} to {} :", path, correctedPath, e );
triggerConsumerWarning( RENAME_FAILURE, "Unable to rename " + path + " to " + correctedPath +
- ": " + e.getMessage() );
+ ": " + e.getMessage( ) );
}
}
}
- log.info( "(Auto) Removing File: {} ", file.getAbsolutePath() );
- triggerConsumerInfo( "(Auto) Removing File: " + file.getAbsolutePath() );
- file.delete();
+ log.info( "(Auto) Removing File: {} ", file.getAbsolutePath( ) );
+ triggerConsumerInfo( "(Auto) Removing File: " + file.getAbsolutePath( ) );
+ file.delete( );
}
}
http://git-wip-us.apache.org/repos/asf/archiva/blob/940412eb/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java
----------------------------------------------------------------------
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 69f2b32..4d1c58e 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
@@ -51,8 +51,6 @@ import java.util.List;
/**
* MetadataUpdaterConsumer will create and update the metadata present within the repository.
- *
- *
*/
@Service( "knownRepositoryContentConsumer#metadata-updater" )
@Scope( "prototype" )
@@ -98,13 +96,13 @@ public class MetadataUpdaterConsumer
private long scanStartTimestamp = 0;
@Override
- public String getDescription()
+ public String getDescription( )
{
return description;
}
@Override
- public String getId()
+ public String getId( )
{
return id;
}
@@ -120,17 +118,17 @@ public class MetadataUpdaterConsumer
{
try
{
- this.repository = repositoryFactory.getManagedRepositoryContent( repoConfig.getId() );
- this.repositoryDir = new File( repository.getRepoRoot() );
- this.scanStartTimestamp = System.currentTimeMillis();
+ this.repository = repositoryFactory.getManagedRepositoryContent( repoConfig.getId( ) );
+ this.repositoryDir = new File( repository.getRepoRoot( ) );
+ this.scanStartTimestamp = System.currentTimeMillis( );
}
catch ( RepositoryNotFoundException e )
{
- throw new ConsumerException( e.getMessage(), e );
+ throw new ConsumerException( e.getMessage( ), e );
}
catch ( RepositoryException e )
{
- throw new ConsumerException( e.getMessage(), e );
+ throw new ConsumerException( e.getMessage( ), e );
}
}
@@ -142,7 +140,7 @@ public class MetadataUpdaterConsumer
}
@Override
- public void completeScan()
+ public void completeScan( )
{
/* do nothing here */
}
@@ -150,17 +148,17 @@ public class MetadataUpdaterConsumer
@Override
public void completeScan( boolean executeOnEntireRepo )
{
- completeScan();
+ completeScan( );
}
@Override
- public List<String> getExcludes()
+ public List<String> getExcludes( )
{
- return getDefaultArtifactExclusions();
+ return getDefaultArtifactExclusions( );
}
@Override
- public List<String> getIncludes()
+ public List<String> getIncludes( )
{
return this.includes;
}
@@ -180,7 +178,7 @@ public class MetadataUpdaterConsumer
}
catch ( LayoutException e )
{
- log.info( "Not processing path that is not an artifact: {} ({})", path, e.getMessage() );
+ log.info( "Not processing path that is not an artifact: {} ({})", path, e.getMessage( ) );
}
}
}
@@ -194,9 +192,9 @@ public class MetadataUpdaterConsumer
private void updateProjectMetadata( ArtifactReference artifact, String path )
{
- ProjectReference projectRef = new ProjectReference();
- projectRef.setGroupId( artifact.getGroupId() );
- projectRef.setArtifactId( artifact.getArtifactId() );
+ ProjectReference projectRef = new ProjectReference( );
+ projectRef.setGroupId( artifact.getGroupId( ) );
+ projectRef.setArtifactId( artifact.getArtifactId( ) );
try
{
@@ -204,7 +202,7 @@ public class MetadataUpdaterConsumer
File projectMetadata = new File( this.repositoryDir, metadataPath );
- if ( projectMetadata.exists() && ( projectMetadata.lastModified() >= this.scanStartTimestamp ) )
+ if ( projectMetadata.exists( ) && ( projectMetadata.lastModified( ) >= this.scanStartTimestamp ) )
{
// This metadata is up to date. skip it.
log.debug( "Skipping uptodate metadata: {}", this.metadataTools.toPath( projectRef ) );
@@ -218,36 +216,36 @@ public class MetadataUpdaterConsumer
{
log.warn( "Unable to convert path [{}] to an internal project reference: ", path, e );
triggerConsumerWarning( TYPE_METADATA_BAD_INTERNAL_REF,
- "Unable to convert path [" + path + "] to an internal project reference: "
- + e.getMessage() );
+ "Unable to convert path [" + path + "] to an internal project reference: "
+ + e.getMessage( ) );
}
catch ( RepositoryMetadataException e )
{
log.error( "Unable to write project metadat for artifact [{}]:", path, e );
triggerConsumerError( TYPE_METADATA_WRITE_FAILURE,
- "Unable to write project metadata for artifact [" + path + "]: " + e.getMessage() );
+ "Unable to write project metadata for artifact [" + path + "]: " + e.getMessage( ) );
}
catch ( IOException e )
{
log.warn( "Project metadata not written due to IO warning: ", e );
triggerConsumerWarning( TYPE_METADATA_IO,
- "Project metadata not written due to IO warning: " + e.getMessage() );
+ "Project metadata not written due to IO warning: " + e.getMessage( ) );
}
catch ( ContentNotFoundException e )
{
log.warn( "Project metadata not written because no versions were found to update: ", e );
triggerConsumerWarning( TYPE_METADATA_IO,
- "Project metadata not written because no versions were found to update: "
- + e.getMessage() );
+ "Project metadata not written because no versions were found to update: "
+ + e.getMessage( ) );
}
}
private void updateVersionMetadata( ArtifactReference artifact, String path )
{
- VersionedReference versionRef = new VersionedReference();
- versionRef.setGroupId( artifact.getGroupId() );
- versionRef.setArtifactId( artifact.getArtifactId() );
- versionRef.setVersion( artifact.getVersion() );
+ VersionedReference versionRef = new VersionedReference( );
+ versionRef.setGroupId( artifact.getGroupId( ) );
+ versionRef.setArtifactId( artifact.getArtifactId( ) );
+ versionRef.setVersion( artifact.getVersion( ) );
try
{
@@ -255,7 +253,7 @@ public class MetadataUpdaterConsumer
File projectMetadata = new File( this.repositoryDir, metadataPath );
- if ( projectMetadata.exists() && ( projectMetadata.lastModified() >= this.scanStartTimestamp ) )
+ if ( projectMetadata.exists( ) && ( projectMetadata.lastModified( ) >= this.scanStartTimestamp ) )
{
// This metadata is up to date. skip it.
log.debug( "Skipping uptodate metadata: {}", this.metadataTools.toPath( versionRef ) );
@@ -269,27 +267,27 @@ public class MetadataUpdaterConsumer
{
log.warn( "Unable to convert path [{}] to an internal version reference: ", path, e );
triggerConsumerWarning( TYPE_METADATA_BAD_INTERNAL_REF,
- "Unable to convert path [" + path + "] to an internal version reference: "
- + e.getMessage() );
+ "Unable to convert path [" + path + "] to an internal version reference: "
+ + e.getMessage( ) );
}
catch ( RepositoryMetadataException e )
{
- log.error( "Unable to write version metadata for artifact [{}]: ", path, e );
+ log.error( "Unable to write version metadata for artifact [{}]: ", path, e );
triggerConsumerError( TYPE_METADATA_WRITE_FAILURE,
- "Unable to write version metadata for artifact [" + path + "]: " + e.getMessage() );
+ "Unable to write version metadata for artifact [" + path + "]: " + e.getMessage( ) );
}
catch ( IOException e )
{
log.warn( "Version metadata not written due to IO warning: ", e );
triggerConsumerWarning( TYPE_METADATA_IO,
- "Version metadata not written due to IO warning: " + e.getMessage() );
+ "Version metadata not written due to IO warning: " + e.getMessage( ) );
}
catch ( ContentNotFoundException e )
{
- log.warn( "Version metadata not written because no versions were found to update: ", e );
+ log.warn( "Version metadata not written because no versions were found to update: ", e );
triggerConsumerWarning( TYPE_METADATA_IO,
- "Version metadata not written because no versions were found to update: "
- + e.getMessage() );
+ "Version metadata not written because no versions were found to update: "
+ + e.getMessage( ) );
}
}
@@ -310,16 +308,16 @@ public class MetadataUpdaterConsumer
}
*/
- private void initIncludes()
+ private void initIncludes( )
{
includes = new ArrayList<>( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) );
}
@PostConstruct
- public void initialize()
+ public void initialize( )
{
//configuration.addChangeListener( this );
- initIncludes();
+ initIncludes( );
}
}
http://git-wip-us.apache.org/repos/asf/archiva/blob/940412eb/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java
index 5eecbfb..8e2a926 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java
@@ -45,8 +45,6 @@ import java.util.List;
/**
* ValidateChecksumConsumer - validate the provided checksum against the file it represents.
- *
- *
*/
@Service( "knownRepositoryContentConsumer#validate-checksums" )
@Scope( "prototype" )
@@ -83,13 +81,13 @@ public class ValidateChecksumConsumer
private List<String> includes;
@Override
- public String getId()
+ public String getId( )
{
return this.id;
}
@Override
- public String getDescription()
+ public String getDescription( )
{
return this.description;
}
@@ -98,7 +96,7 @@ public class ValidateChecksumConsumer
public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
- this.repositoryDir = new File( repository.getLocation() );
+ this.repositoryDir = new File( repository.getLocation( ) );
}
@Override
@@ -109,7 +107,7 @@ public class ValidateChecksumConsumer
}
@Override
- public void completeScan()
+ public void completeScan( )
{
/* nothing to do */
}
@@ -117,17 +115,17 @@ public class ValidateChecksumConsumer
@Override
public void completeScan( boolean executeOnEntireRepo )
{
- completeScan();
+ completeScan( );
}
@Override
- public List<String> getExcludes()
+ public List<String> getExcludes( )
{
return null;
}
@Override
- public List<String> getIncludes()
+ public List<String> getIncludes( )
{
return this.includes;
}
@@ -148,13 +146,13 @@ public class ValidateChecksumConsumer
catch ( FileNotFoundException e )
{
log.error( "File not found during checksum validation: ", e );
- triggerConsumerError( CHECKSUM_NOT_FOUND, "File not found during checksum validation: " + e.getMessage() );
+ triggerConsumerError( CHECKSUM_NOT_FOUND, "File not found during checksum validation: " + e.getMessage( ) );
}
catch ( DigesterException e )
{
log.error( "Digester failure during checksum validation on {}", checksumFile );
triggerConsumerError( CHECKSUM_DIGESTER_FAILURE,
- "Digester failure during checksum validation on " + checksumFile );
+ "Digester failure during checksum validation on " + checksumFile );
}
catch ( IOException e )
{
@@ -171,15 +169,15 @@ public class ValidateChecksumConsumer
}
@PostConstruct
- public void initialize()
+ public void initialize( )
throws PlexusSisuBridgeException
{
checksum = plexusSisuBridge.lookup( ChecksumFile.class );
- List<Digester> allDigesters = new ArrayList<>( digesterUtils.getAllDigesters() );
- includes = new ArrayList<>( allDigesters.size() );
+ List<Digester> allDigesters = new ArrayList<>( digesterUtils.getAllDigesters( ) );
+ includes = new ArrayList<>( allDigesters.size( ) );
for ( Digester digester : allDigesters )
{
- includes.add( "**/*" + digester.getFilenameExtension() );
+ includes.add( "**/*" + digester.getFilenameExtension( ) );
}
}
}
http://git-wip-us.apache.org/repos/asf/archiva/blob/940412eb/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java
----------------------------------------------------------------------
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 302e37d..9b1615f 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
@@ -364,15 +364,16 @@ public abstract class AbstractRepositoryPurge
}
}
- private void deleteSilently(Path path) {
+ private void deleteSilently( Path path )
+ {
try
{
Files.deleteIfExists( path );
- triggerAuditEvent( repository.getRepository( ).getId( ), path.toString(), AuditEvent.PURGE_FILE );
+ triggerAuditEvent( repository.getRepository( ).getId( ), path.toString( ), AuditEvent.PURGE_FILE );
}
catch ( IOException e )
{
- log.error("Error occured during file deletion {}: {} ",path,e.getMessage(), e);
+ log.error( "Error occured during file deletion {}: {} ", path, e.getMessage( ), e );
}
}
@@ -388,24 +389,24 @@ public abstract class AbstractRepositoryPurge
*/
private void purgeSupportFiles( Path artifactFile )
{
- Path parentDir = artifactFile.getParent();
+ Path parentDir = artifactFile.getParent( );
- if ( !Files.exists(parentDir) )
+ if ( !Files.exists( parentDir ) )
{
return;
}
- final String artifactName = artifactFile.getFileName().toString();
+ final String artifactName = artifactFile.getFileName( ).toString( );
try
{
- Files.find(parentDir, 3,
- ( path, basicFileAttributes ) -> path.getFileName().toString().startsWith(artifactName)
- && Files.isRegularFile( path ) ).forEach( this::deleteSilently );
+ Files.find( parentDir, 3,
+ ( path, basicFileAttributes ) -> path.getFileName( ).toString( ).startsWith( artifactName )
+ && Files.isRegularFile( path ) ).forEach( this::deleteSilently );
}
catch ( IOException e )
{
- log.error("Purge of support files failed {}: {}", artifactFile, e.getMessage(), e);
+ log.error( "Purge of support files failed {}: {}", artifactFile, e.getMessage( ), e );
}
}
http://git-wip-us.apache.org/repos/asf/archiva/blob/940412eb/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
----------------------------------------------------------------------
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 c344a6d..14b0d4d 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
@@ -93,9 +93,9 @@ public class CleanupReleasedSnapshotsRepositoryPurge
{
try
{
- File artifactFile = new File( repository.getRepoRoot(), path );
+ File artifactFile = new File( repository.getRepoRoot( ), path );
- if ( !artifactFile.exists() )
+ if ( !artifactFile.exists( ) )
{
// Nothing to do here, file doesn't exist, skip it.
return;
@@ -103,28 +103,28 @@ public class CleanupReleasedSnapshotsRepositoryPurge
ArtifactReference artifactRef = repository.toArtifactReference( path );
- if ( !VersionUtil.isSnapshot( artifactRef.getVersion() ) )
+ if ( !VersionUtil.isSnapshot( artifactRef.getVersion( ) ) )
{
// Nothing to do here, not a snapshot, skip it.
return;
}
- ProjectReference reference = new ProjectReference();
- reference.setGroupId( artifactRef.getGroupId() );
- reference.setArtifactId( artifactRef.getArtifactId() );
+ ProjectReference reference = new ProjectReference( );
+ reference.setGroupId( artifactRef.getGroupId( ) );
+ reference.setArtifactId( artifactRef.getArtifactId( ) );
// Gether the released versions
- List<String> releasedVersions = new ArrayList<>();
+ List<String> releasedVersions = new ArrayList<>( );
- List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
+ List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories( );
for ( ManagedRepository repo : repos )
{
- if ( repo.isReleases() )
+ if ( repo.isReleases( ) )
{
try
{
ManagedRepositoryContent repoContent =
- repoContentFactory.getManagedRepositoryContent( repo.getId() );
+ repoContentFactory.getManagedRepositoryContent( repo.getId( ) );
for ( String version : repoContent.getVersions( reference ) )
{
if ( !VersionUtil.isSnapshot( version ) )
@@ -144,30 +144,30 @@ public class CleanupReleasedSnapshotsRepositoryPurge
}
}
- Collections.sort( releasedVersions, VersionComparator.getInstance() );
+ Collections.sort( releasedVersions, VersionComparator.getInstance( ) );
// Now clean out any version that is earlier than the highest released version.
boolean needsMetadataUpdate = false;
- VersionedReference versionRef = new VersionedReference();
- versionRef.setGroupId( artifactRef.getGroupId() );
- versionRef.setArtifactId( artifactRef.getArtifactId() );
+ VersionedReference versionRef = new VersionedReference( );
+ versionRef.setGroupId( artifactRef.getGroupId( ) );
+ versionRef.setArtifactId( artifactRef.getArtifactId( ) );
- MetadataRepository metadataRepository = repositorySession.getRepository();
+ MetadataRepository metadataRepository = repositorySession.getRepository( );
- if ( releasedVersions.contains( VersionUtil.getReleaseVersion( artifactRef.getVersion() ) ) )
+ if ( releasedVersions.contains( VersionUtil.getReleaseVersion( artifactRef.getVersion( ) ) ) )
{
- versionRef.setVersion( artifactRef.getVersion() );
+ versionRef.setVersion( artifactRef.getVersion( ) );
repository.deleteVersion( versionRef );
for ( RepositoryListener listener : listeners )
{
- listener.deleteArtifact( metadataRepository, repository.getId(), artifactRef.getGroupId(),
- artifactRef.getArtifactId(), artifactRef.getVersion(),
- artifactFile.getName() );
+ listener.deleteArtifact( metadataRepository, repository.getId( ), artifactRef.getGroupId( ),
+ artifactRef.getArtifactId( ), artifactRef.getVersion( ),
+ artifactFile.getName( ) );
}
- metadataRepository.removeProjectVersion( repository.getId(), artifactRef.getGroupId(),
- artifactRef.getArtifactId(), artifactRef.getVersion());
+ metadataRepository.removeProjectVersion( repository.getId( ), artifactRef.getGroupId( ),
+ artifactRef.getArtifactId( ), artifactRef.getVersion( ) );
needsMetadataUpdate = true;
}
@@ -176,34 +176,35 @@ public class CleanupReleasedSnapshotsRepositoryPurge
{
updateMetadata( artifactRef );
}
- } catch ( RepositoryAdminException e )
+ }
+ catch ( RepositoryAdminException e )
{
- throw new RepositoryPurgeException( e.getMessage(), e );
+ throw new RepositoryPurgeException( e.getMessage( ), e );
}
catch ( LayoutException e )
{
- log.debug( "Not processing file that is not an artifact: {}", e.getMessage() );
+ log.debug( "Not processing file that is not an artifact: {}", e.getMessage( ) );
}
catch ( ContentNotFoundException e )
{
- throw new RepositoryPurgeException( e.getMessage(), e );
+ throw new RepositoryPurgeException( e.getMessage( ), e );
}
catch ( MetadataRepositoryException e )
{
- log.error("Could not remove metadata during cleanup of released snapshots of {}", path, e);
+ log.error( "Could not remove metadata during cleanup of released snapshots of {}", path, e );
}
}
private void updateMetadata( ArtifactReference artifact )
{
- VersionedReference versionRef = new VersionedReference();
- versionRef.setGroupId( artifact.getGroupId() );
- versionRef.setArtifactId( artifact.getArtifactId() );
- versionRef.setVersion( artifact.getVersion() );
-
- ProjectReference projectRef = new ProjectReference();
- projectRef.setGroupId( artifact.getGroupId() );
- projectRef.setArtifactId( artifact.getArtifactId() );
+ VersionedReference versionRef = new VersionedReference( );
+ versionRef.setGroupId( artifact.getGroupId( ) );
+ versionRef.setArtifactId( artifact.getArtifactId( ) );
+ versionRef.setVersion( artifact.getVersion( ) );
+
+ ProjectReference projectRef = new ProjectReference( );
+ projectRef.setGroupId( artifact.getGroupId( ) );
+ projectRef.setArtifactId( artifact.getArtifactId( ) );
try
{
http://git-wip-us.apache.org/repos/asf/archiva/blob/940412eb/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurge.java
----------------------------------------------------------------------
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 ae807b3..2231ffc 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
@@ -70,9 +70,9 @@ public class DaysOldRepositoryPurge
{
try
{
- File artifactFile = new File( repository.getRepoRoot(), path );
+ File artifactFile = new File( repository.getRepoRoot( ), path );
- if ( !artifactFile.exists() )
+ if ( !artifactFile.exists( ) )
{
return;
}
@@ -83,24 +83,24 @@ public class DaysOldRepositoryPurge
olderThanThisDate.add( Calendar.DATE, -daysOlder );
// respect retention count
- VersionedReference reference = new VersionedReference();
- reference.setGroupId( artifact.getGroupId() );
- reference.setArtifactId( artifact.getArtifactId() );
- reference.setVersion( 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 ) );
- Collections.sort( versions, VersionComparator.getInstance() );
+ Collections.sort( versions, VersionComparator.getInstance( ) );
- if ( retentionCount > versions.size() )
+ if ( retentionCount > versions.size( ) )
{
// Done. nothing to do here. skip it.
return;
}
- int countToPurge = versions.size() - retentionCount;
+ int countToPurge = versions.size( ) - retentionCount;
- Set<ArtifactReference> artifactsToDelete = new HashSet<>();
+ Set<ArtifactReference> artifactsToDelete = new HashSet<>( );
for ( String version : versions )
{
if ( countToPurge-- <= 0 )
@@ -109,39 +109,39 @@ public class DaysOldRepositoryPurge
}
ArtifactReference newArtifactReference = repository.toArtifactReference(
- artifactFile.getAbsolutePath() );
+ artifactFile.getAbsolutePath( ) );
newArtifactReference.setVersion( version );
File newArtifactFile = repository.toFile( newArtifactReference );
// Is this a generic snapshot "1.0-SNAPSHOT" ?
- if ( VersionUtil.isGenericSnapshot( newArtifactReference.getVersion() ) )
+ if ( VersionUtil.isGenericSnapshot( newArtifactReference.getVersion( ) ) )
{
- if ( newArtifactFile.lastModified() < olderThanThisDate.getTimeInMillis() )
+ if ( newArtifactFile.lastModified( ) < olderThanThisDate.getTimeInMillis( ) )
{
- artifactsToDelete.addAll(repository.getRelatedArtifacts(newArtifactReference) );
+ artifactsToDelete.addAll( repository.getRelatedArtifacts( newArtifactReference ) );
}
}
// Is this a timestamp snapshot "1.0-20070822.123456-42" ?
- else if ( VersionUtil.isUniqueSnapshot( newArtifactReference.getVersion() ) )
+ else if ( VersionUtil.isUniqueSnapshot( newArtifactReference.getVersion( ) ) )
{
- Calendar timestampCal = uniqueSnapshotToCalendar( newArtifactReference.getVersion() );
+ Calendar timestampCal = uniqueSnapshotToCalendar( newArtifactReference.getVersion( ) );
- if ( timestampCal.getTimeInMillis() < olderThanThisDate.getTimeInMillis() )
+ if ( timestampCal.getTimeInMillis( ) < olderThanThisDate.getTimeInMillis( ) )
{
- artifactsToDelete.addAll( repository.getRelatedArtifacts(newArtifactReference));
+ artifactsToDelete.addAll( repository.getRelatedArtifacts( newArtifactReference ) );
}
}
}
- purge(artifactsToDelete);
+ purge( artifactsToDelete );
}
catch ( ContentNotFoundException e )
{
- throw new RepositoryPurgeException( e.getMessage(), e );
+ throw new RepositoryPurgeException( e.getMessage( ), e );
}
catch ( LayoutException e )
{
- log.debug( "Not processing file that is not an artifact: {}", e.getMessage() );
+ log.debug( "Not processing file that is not an artifact: {}", e.getMessage( ) );
}
}
@@ -151,10 +151,10 @@ public class DaysOldRepositoryPurge
// This needs to be broken down into ${base}-${timestamp}-${build_number}
Matcher m = VersionUtil.UNIQUE_SNAPSHOT_PATTERN.matcher( version );
- if ( m.matches() )
+ if ( m.matches( ) )
{
Matcher mtimestamp = VersionUtil.TIMESTAMP_PATTERN.matcher( m.group( 2 ) );
- if ( mtimestamp.matches() )
+ if ( mtimestamp.matches( ) )
{
String tsDate = mtimestamp.group( 1 );
String tsTime = mtimestamp.group( 2 );
http://git-wip-us.apache.org/repos/asf/archiva/blob/940412eb/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurge.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurge.java
index 0aae754..8c6aa11 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurge.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurge.java
@@ -27,7 +27,7 @@ public interface RepositoryPurge
/**
* Perform checking on artifact for repository purge
*
- * @param path path to the scanned artifact
+ * @param path path to the scanned artifact
*/
void process( String path )
throws RepositoryPurgeException;
http://git-wip-us.apache.org/repos/asf/archiva/blob/940412eb/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
index f7711e2..f761bfc 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
@@ -87,7 +87,7 @@ public class RepositoryPurgeConsumer
@Named( value = "fileTypes" )
private FileTypes filetypes;
- private List<String> includes = new ArrayList<>();
+ private List<String> includes = new ArrayList<>( );
private RepositoryPurge repoPurge;
@@ -99,8 +99,8 @@ public class RepositoryPurgeConsumer
*
*/
@Inject
- @Autowired(required = false)
- private List<RepositoryListener> listeners = Collections.emptyList();
+ @Autowired( required = false )
+ private List<RepositoryListener> listeners = Collections.emptyList( );
@Inject
private RepositorySessionFactory repositorySessionFactory;
@@ -108,25 +108,25 @@ public class RepositoryPurgeConsumer
private RepositorySession repositorySession;
@Override
- public String getId()
+ public String getId( )
{
return this.id;
}
@Override
- public String getDescription()
+ public String getDescription( )
{
return this.description;
}
@Override
- public List<String> getExcludes()
+ public List<String> getExcludes( )
{
- return getDefaultArtifactExclusions();
+ return getDefaultArtifactExclusions( );
}
@Override
- public List<String> getIncludes()
+ public List<String> getIncludes( )
{
return this.includes;
}
@@ -138,35 +138,35 @@ public class RepositoryPurgeConsumer
ManagedRepositoryContent repositoryContent;
try
{
- repositoryContent = repositoryContentFactory.getManagedRepositoryContent( repository.getId() );
+ repositoryContent = repositoryContentFactory.getManagedRepositoryContent( repository.getId( ) );
}
catch ( RepositoryNotFoundException e )
{
- throw new ConsumerException( "Can't run repository purge: " + e.getMessage(), e );
+ throw new ConsumerException( "Can't run repository purge: " + e.getMessage( ), e );
}
catch ( RepositoryException e )
{
- throw new ConsumerException( "Can't run repository purge: " + e.getMessage(), e );
+ throw new ConsumerException( "Can't run repository purge: " + e.getMessage( ), e );
}
- repositorySession = repositorySessionFactory.createSession();
+ repositorySession = repositorySessionFactory.createSession( );
- if ( repository.getDaysOlder() != 0 )
+ if ( repository.getDaysOlder( ) != 0 )
{
- repoPurge = new DaysOldRepositoryPurge( repositoryContent, repository.getDaysOlder(),
- repository.getRetentionCount(), repositorySession, listeners );
+ repoPurge = new DaysOldRepositoryPurge( repositoryContent, repository.getDaysOlder( ),
+ repository.getRetentionCount( ), repositorySession, listeners );
}
else
{
repoPurge =
- new RetentionCountRepositoryPurge( repositoryContent, repository.getRetentionCount(), repositorySession,
- listeners );
+ new RetentionCountRepositoryPurge( repositoryContent, repository.getRetentionCount( ), repositorySession,
+ listeners );
}
cleanUp = new CleanupReleasedSnapshotsRepositoryPurge( repositoryContent, metadataTools, managedRepositoryAdmin,
- repositoryContentFactory, repositorySession, listeners );
+ repositoryContentFactory, repositorySession, listeners );
- deleteReleasedSnapshots = repository.isDeleteReleasedSnapshots();
+ deleteReleasedSnapshots = repository.isDeleteReleasedSnapshots( );
}
@Override
@@ -190,7 +190,7 @@ public class RepositoryPurgeConsumer
}
catch ( RepositoryPurgeException rpe )
{
- throw new ConsumerException( rpe.getMessage(), rpe );
+ throw new ConsumerException( rpe.getMessage( ), rpe );
}
}
@@ -202,15 +202,15 @@ public class RepositoryPurgeConsumer
}
@Override
- public void completeScan()
+ public void completeScan( )
{
- repositorySession.close();
+ repositorySession.close( );
}
@Override
public void completeScan( boolean executeOnEntireRepo )
{
- completeScan();
+ completeScan( );
}
@Override
@@ -218,7 +218,7 @@ public class RepositoryPurgeConsumer
{
if ( ConfigurationNames.isRepositoryScanning( propertyName ) )
{
- initIncludes();
+ initIncludes( );
}
}
@@ -228,27 +228,27 @@ public class RepositoryPurgeConsumer
/* do nothing */
}
- private void initIncludes()
+ private void initIncludes( )
{
includes = new ArrayList<>( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) );
}
@PostConstruct
- public void initialize()
+ public void initialize( )
{
configuration.addChangeListener( this );
- initIncludes();
+ initIncludes( );
}
@Override
- public boolean isProcessUnmodified()
+ public boolean isProcessUnmodified( )
{
// we need to check all files for deletion, especially if not modified
return true;
}
- public ArchivaConfiguration getConfiguration()
+ public ArchivaConfiguration getConfiguration( )
{
return configuration;
}
@@ -258,7 +258,7 @@ public class RepositoryPurgeConsumer
this.configuration = configuration;
}
- public RepositoryContentFactory getRepositoryContentFactory()
+ public RepositoryContentFactory getRepositoryContentFactory( )
{
return repositoryContentFactory;
}
@@ -268,7 +268,7 @@ public class RepositoryPurgeConsumer
this.repositoryContentFactory = repositoryContentFactory;
}
- public MetadataTools getMetadataTools()
+ public MetadataTools getMetadataTools( )
{
return metadataTools;
}
@@ -278,7 +278,7 @@ public class RepositoryPurgeConsumer
this.metadataTools = metadataTools;
}
- public FileTypes getFiletypes()
+ public FileTypes getFiletypes( )
{
return filetypes;
}
@@ -288,7 +288,7 @@ public class RepositoryPurgeConsumer
this.filetypes = filetypes;
}
- public RepositoryPurge getRepoPurge()
+ public RepositoryPurge getRepoPurge( )
{
return repoPurge;
}
@@ -298,7 +298,7 @@ public class RepositoryPurgeConsumer
this.repoPurge = repoPurge;
}
- public RepositoryPurge getCleanUp()
+ public RepositoryPurge getCleanUp( )
{
return cleanUp;
}
@@ -308,7 +308,7 @@ public class RepositoryPurgeConsumer
this.cleanUp = cleanUp;
}
- public boolean isDeleteReleasedSnapshots()
+ public boolean isDeleteReleasedSnapshots( )
{
return deleteReleasedSnapshots;
}
@@ -318,7 +318,7 @@ public class RepositoryPurgeConsumer
this.deleteReleasedSnapshots = deleteReleasedSnapshots;
}
- public RepositorySessionFactory getRepositorySessionFactory()
+ public RepositorySessionFactory getRepositorySessionFactory( )
{
return repositorySessionFactory;
}
@@ -328,7 +328,7 @@ public class RepositoryPurgeConsumer
this.repositorySessionFactory = repositorySessionFactory;
}
- public RepositorySession getRepositorySession()
+ public RepositorySession getRepositorySession( )
{
return repositorySession;
}
http://git-wip-us.apache.org/repos/asf/archiva/blob/940412eb/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeException.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeException.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeException.java
index 87a06e8..bdd15e7 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeException.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeException.java
@@ -26,9 +26,9 @@ package org.apache.archiva.consumers.core.repository;
public class RepositoryPurgeException
extends Exception
{
- public RepositoryPurgeException()
+ public RepositoryPurgeException( )
{
- super();
+ super( );
}
public RepositoryPurgeException( String message, Throwable cause )
http://git-wip-us.apache.org/repos/asf/archiva/blob/940412eb/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java
----------------------------------------------------------------------
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 1d1558a..98357b3 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
@@ -57,53 +57,53 @@ public class RetentionCountRepositoryPurge
{
try
{
- File artifactFile = new File( repository.getRepoRoot(), path );
+ File artifactFile = new File( repository.getRepoRoot( ), path );
- if ( !artifactFile.exists() )
+ if ( !artifactFile.exists( ) )
{
return;
}
ArtifactReference artifact = repository.toArtifactReference( path );
- if ( VersionUtil.isSnapshot( artifact.getVersion() ) )
+ if ( VersionUtil.isSnapshot( artifact.getVersion( ) ) )
{
- VersionedReference reference = new VersionedReference();
- reference.setGroupId( artifact.getGroupId() );
- reference.setArtifactId( artifact.getArtifactId() );
- reference.setVersion( 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 ) );
- Collections.sort( versions, VersionComparator.getInstance() );
+ Collections.sort( versions, VersionComparator.getInstance( ) );
- if ( retentionCount > versions.size() )
+ if ( retentionCount > versions.size( ) )
{
- log.trace("No deletion, because retention count is higher than actual number of artifacts.");
+ 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<>();
+ int countToPurge = versions.size( ) - retentionCount;
+ Set<ArtifactReference> artifactsToDelete = new HashSet<>( );
for ( String version : versions )
{
if ( countToPurge-- <= 0 )
{
break;
}
- artifactsToDelete.addAll(repository.getRelatedArtifacts( getNewArtifactReference( artifact, version) ));
+ artifactsToDelete.addAll( repository.getRelatedArtifacts( getNewArtifactReference( artifact, version ) ) );
}
- purge(artifactsToDelete);
+ purge( artifactsToDelete );
}
}
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);
+ log.error( "Repostory artifact not found {}", path );
}
}
@@ -113,12 +113,12 @@ public class RetentionCountRepositoryPurge
private ArtifactReference getNewArtifactReference( ArtifactReference reference, String version )
throws LayoutException
{
- ArtifactReference artifact = new ArtifactReference();
- artifact.setGroupId( reference.getGroupId() );
- artifact.setArtifactId( reference.getArtifactId() );
+ ArtifactReference artifact = new ArtifactReference( );
+ artifact.setGroupId( reference.getGroupId( ) );
+ artifact.setArtifactId( reference.getArtifactId( ) );
artifact.setVersion( version );
- artifact.setClassifier( reference.getClassifier() );
- artifact.setType( reference.getType() );
+ artifact.setClassifier( reference.getClassifier( ) );
+ artifact.setType( reference.getType( ) );
return artifact;
}
[3/4] archiva git commit: Fixing metadata removal. Adding mocks for
verification.
Posted by ma...@apache.org.
Fixing metadata removal. Adding mocks for verification.
- Prevent redundant removals for same artifacts
- Adding metadata removal for each file removal
- Adding mock verifications for metadata removal in unit tests
Project: http://git-wip-us.apache.org/repos/asf/archiva/repo
Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/1d6f9dd2
Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/1d6f9dd2
Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/1d6f9dd2
Branch: refs/heads/archiva-2.x
Commit: 1d6f9dd226684b7522b8b2c8d60ffa55c4c7b350
Parents: 1d37144
Author: Martin Stockhammer <ma...@ars.de>
Authored: Thu Aug 24 21:14:04 2017 +0200
Committer: Martin Stockhammer <ma...@apache.org>
Committed: Mon Aug 28 20:36:30 2017 +0200
----------------------------------------------------------------------
.../repository/AbstractRepositoryPurge.java | 363 ++++++++++++++-----
.../core/repository/ArtifactFilenameFilter.java | 49 ---
...CleanupReleasedSnapshotsRepositoryPurge.java | 8 +-
.../core/repository/DaysOldRepositoryPurge.java | 26 +-
.../repository/RepositoryPurgeConsumer.java | 4 -
.../RetentionCountRepositoryPurge.java | 27 +-
.../repository/AbstractRepositoryPurgeTest.java | 25 ++
...nupReleasedSnapshotsRepositoryPurgeTest.java | 93 ++++-
.../repository/DaysOldRepositoryPurgeTest.java | 103 +++++-
.../repository/RepositoryPurgeConsumerTest.java | 115 +++++-
.../RetentionCountRepositoryPurgeTest.java | 92 ++++-
11 files changed, 705 insertions(+), 200 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/archiva/blob/1d6f9dd2/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java
----------------------------------------------------------------------
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 1f2a9e3..4c99fd6 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
@@ -37,9 +37,11 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FilenameFilter;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* Base class for all repository purge tasks.
@@ -47,7 +49,7 @@ import java.util.Set;
public abstract class AbstractRepositoryPurge
implements RepositoryPurge
{
- protected Logger log = LoggerFactory.getLogger( getClass() );
+ protected Logger log = LoggerFactory.getLogger( getClass( ) );
protected final ManagedRepositoryContent repository;
@@ -67,6 +69,116 @@ public abstract class AbstractRepositoryPurge
this.listeners = listeners;
}
+ /*
+ * We have to track namespace, project, project version, artifact version and classifier
+ * There is no metadata class that contains all these properties.
+ */
+ class ArtifactInfo
+ {
+ final String namespace;
+ final String name;
+ final String projectVersion;
+ String version;
+ String classifier;
+
+ ArtifactInfo( String namespace, String name, String projectVersion, String version )
+ {
+ this.namespace = namespace;
+ this.name = name;
+ this.projectVersion = projectVersion;
+ this.version = version;
+ }
+
+ ArtifactInfo( String namespace, String name, String projectVersion )
+ {
+ this.namespace = namespace;
+ this.name = name;
+ this.projectVersion = projectVersion;
+ }
+
+ /*
+ * Creates a info object without version and classifier
+ */
+ ArtifactInfo projectVersionLevel( )
+ {
+ return new ArtifactInfo( this.namespace, this.name, this.projectVersion );
+ }
+
+ public void setClassifier( String classifier )
+ {
+ this.classifier = classifier;
+ }
+
+ public String getNamespace( )
+ {
+ return namespace;
+ }
+
+ public String getName( )
+ {
+ return name;
+ }
+
+ public String getProjectVersion( )
+ {
+ return projectVersion;
+ }
+
+ public String getVersion( )
+ {
+ return version;
+ }
+
+ public String getClassifier( )
+ {
+ return classifier;
+ }
+
+ public boolean hasClassifier( )
+ {
+ return classifier != null && !"".equals( classifier );
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o ) return true;
+ if ( o == null || getClass( ) != o.getClass( ) ) return false;
+
+ ArtifactInfo that = (ArtifactInfo) o;
+
+ if ( !namespace.equals( that.namespace ) ) return false;
+ if ( !name.equals( that.name ) ) return false;
+ if ( !projectVersion.equals( that.projectVersion ) ) return false;
+ if ( !( version != null ? version.equals( that.version ) : that.version == null ) ) return false;
+ return classifier != null ? classifier.equals( that.classifier ) : that.classifier == null;
+ }
+
+ @Override
+ public int hashCode( )
+ {
+ int result = namespace.hashCode( );
+ result = 31 * result + name.hashCode( );
+ result = 31 * result + projectVersion.hashCode( );
+ result = 31 * result + ( version != null ? version.hashCode( ) : 0 );
+ result = 31 * result + ( classifier != null ? classifier.hashCode( ) : 0 );
+ return result;
+ }
+
+ @Override
+ public String toString( )
+ {
+ final StringBuilder sb = new StringBuilder( "ArtifactInfo{" );
+ sb.append( "namespace='" ).append( namespace ).append( '\'' );
+ sb.append( ", name='" ).append( name ).append( '\'' );
+ sb.append( ", projectVersion='" ).append( projectVersion ).append( '\'' );
+ sb.append( ", version='" ).append( version ).append( '\'' );
+ sb.append( ", classifier='" ).append( classifier ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString( );
+ }
+ }
+
/**
* Purge the repo. Update db and index of removed artifacts.
*
@@ -74,110 +186,192 @@ public abstract class AbstractRepositoryPurge
*/
protected void purge( Set<ArtifactReference> 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<String, Collection<ArtifactMetadata>> metaResolved = new HashMap<>( );
for ( ArtifactReference reference : references )
{
- File artifactFile = repository.toFile( reference );
+ String baseVersion = VersionUtil.getBaseVersion( reference.getVersion( ) );
+ // Needed for tracking in the hashmap
+ String metaBaseId = reference.getGroupId( ) + "/" + reference.getArtifactId( ) + "/" + baseVersion;
- for ( RepositoryListener listener : listeners )
+ if ( !metaResolved.containsKey( metaBaseId ) )
{
- listener.deleteArtifact( metadataRepository, repository.getId(), reference.getGroupId(),
- reference.getArtifactId(), reference.getVersion(),
- artifactFile.getName() );
+ try
+ {
+ metaResolved.put( metaBaseId, metadataRepository.getArtifacts( repository.getId( ), reference.getGroupId( ),
+ reference.getArtifactId( ), baseVersion ) );
+ }
+ catch ( MetadataResolutionException e )
+ {
+ log.error( "Error during metadata retrieval {}: {}", metaBaseId, e.getMessage( ) );
+ }
}
+ Path artifactFile = repository.toFile( reference ).toPath( );
- // TODO: this needs to be logged
- artifactFile.delete();
+ for ( RepositoryListener listener : listeners )
+ {
+ listener.deleteArtifact( metadataRepository, repository.getId( ), reference.getGroupId( ),
+ reference.getArtifactId( ), reference.getVersion( ),
+ artifactFile.getFileName( ).toString( ) );
+ }
try
{
- repository.deleteArtifact( reference );
+ Files.delete( artifactFile );
+ log.debug( "File deleted: {}", artifactFile.toAbsolutePath( ) );
}
- catch ( ContentNotFoundException e )
+ catch ( IOException e )
{
- log.warn( "skip error deleting artifact {}: {}", reference, e.getMessage() );
+ log.error( "Could not delete file {}: {}", artifactFile.toAbsolutePath( ), e.getMessage( ), e );
+ continue;
}
-
try
{
- metadataRepository.removeProjectVersion( repository.getId(), reference.getGroupId(),
- reference.getArtifactId(), reference.getVersion() );
+ repository.deleteArtifact( reference );
}
- catch ( MetadataRepositoryException e )
+ catch ( ContentNotFoundException e )
{
- log.warn( "skip error removeProjectVersion artifact {}: {}", reference, e.getMessage() );
+ log.warn( "skip error deleting artifact {}: {}", reference, e.getMessage( ) );
}
- boolean snapshotVersion = VersionUtil.isSnapshot( reference.getVersion() );
+ boolean snapshotVersion = VersionUtil.isSnapshot( reference.getVersion( ) );
- try
+
+ // If this is a snapshot we have to search for artifacts with the same version. And remove all of them.
+ if ( snapshotVersion )
{
- if ( snapshotVersion )
+ Collection<ArtifactMetadata> artifacts =
+ metaResolved.get( metaBaseId );
+ if ( artifacts != null )
{
- String baseVersion = VersionUtil.getBaseVersion( reference.getVersion() );
- Collection<ArtifactMetadata> artifacts =
- metadataRepository.getArtifacts( repository.getId(), reference.getGroupId(),
- reference.getArtifactId(), baseVersion );
- if ( artifacts != null )
+ // cleanup snapshots metadata
+ for ( ArtifactMetadata artifactMetadata : artifacts )
{
- // cleanup snapshots metadata
- for ( ArtifactMetadata artifactMetadata : artifacts )
+ // Artifact metadata and reference version should match.
+ if ( artifactMetadata.getVersion( ).equals( reference.getVersion( ) ) )
{
-
- // TODO: mismatch between artifact (snapshot) version and project (base) version here
- if ( artifactMetadata.getVersion().equals( reference.getVersion() ) )
+ ArtifactInfo info = new ArtifactInfo( artifactMetadata.getNamespace( ), artifactMetadata.getProject( ), artifactMetadata.getProjectVersion( ), artifactMetadata.getVersion( ) );
+ if ( StringUtils.isNotBlank( reference.getClassifier( ) ) )
{
- if ( StringUtils.isNotBlank( reference.getClassifier() ) )
- {
-
- // cleanup facet which contains classifier information
- MavenArtifactFacet mavenArtifactFacet =
- (MavenArtifactFacet) artifactMetadata.getFacet(
- MavenArtifactFacet.FACET_ID );
-
- if ( StringUtils.equals( reference.getClassifier(),
- mavenArtifactFacet.getClassifier() ) )
- {
- artifactMetadata.removeFacet( MavenArtifactFacet.FACET_ID );
- String groupId = reference.getGroupId(), artifactId =
- reference.getArtifactId(),
- version = reference.getVersion();
- MavenArtifactFacet mavenArtifactFacetToCompare = new MavenArtifactFacet();
- mavenArtifactFacetToCompare.setClassifier( reference.getClassifier() );
- metadataRepository.removeArtifact( repository.getId(), groupId, artifactId,
- version, mavenArtifactFacetToCompare );
- metadataRepository.save();
- }
-
- }
- else
- {
- metadataRepository.removeArtifact( artifactMetadata, VersionUtil.getBaseVersion(
- reference.getVersion() ) );
- }
-
+ info.setClassifier( reference.getClassifier( ) );
+ metaRemovalList.put( info, artifactMetadata );
+ }
+ else
+ {
+ // metadataRepository.removeArtifact( artifactMetadata, baseVersion );
+ metaRemovalList.put( info, artifactMetadata );
}
}
}
}
}
- catch ( MetadataResolutionException e )
+ else // otherwise we delete the artifact version
{
- log.warn( "skip error deleting metadata {}: {}", reference, e.getMessage() );
+ ArtifactInfo info = new ArtifactInfo( reference.getGroupId( ), reference.getArtifactId( ), baseVersion, reference.getVersion( ) );
+ for ( ArtifactMetadata metadata : metaResolved.get( metaBaseId ) )
+ {
+ metaRemovalList.put( info, metadata );
+ }
}
- catch ( MetadataRepositoryException e )
+ triggerAuditEvent( repository.getRepository( ).getId( ), ArtifactReference.toKey( reference ),
+ AuditEvent.PURGE_ARTIFACT );
+ purgeSupportFiles( artifactFile );
+ }
+ purgeMetadata( metadataRepository, metaRemovalList );
+ repositorySession.save( );
+
+ }
+ }
+
+ /*
+ * Purges the metadata. First removes the artifacts. After that empty versions will be removed.
+ */
+ private void purgeMetadata( MetadataRepository metadataRepository, Map<ArtifactInfo, ArtifactMetadata> dataList )
+ {
+ Set<ArtifactInfo> projectLevelMetadata = new HashSet<>( );
+ for ( Map.Entry<ArtifactInfo, ArtifactMetadata> infoEntry : dataList.entrySet( ) )
+ {
+ ArtifactInfo info = infoEntry.getKey( );
+ try
+ {
+ removeArtifact( metadataRepository, info, infoEntry.getValue( ) );
+ log.debug( "Removed artifact from MetadataRepository {}", info );
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ log.error( "Could not remove artifact from MetadataRepository {}: {}", info, e.getMessage( ), e );
+ }
+ projectLevelMetadata.add( info.projectVersionLevel( ) );
+ }
+ metadataRepository.save( );
+ Collection<ArtifactMetadata> artifacts = null;
+ // Get remaining artifacts and remove project if empty
+ for ( ArtifactInfo info : projectLevelMetadata )
+ {
+ try
+ {
+ artifacts = metadataRepository.getArtifacts( repository.getId( ), info.getNamespace( ), info.getName( ),
+ info.getProjectVersion( ) );
+ if ( artifacts.size( ) == 0 )
{
- log.warn( "skip error deleting metadata {}: {}", reference, e.getMessage() );
+ metadataRepository.removeProjectVersion( repository.getId( ), info.getNamespace( ),
+ info.getName( ), info.getProjectVersion( ) );
+ log.debug( "Removed project version from MetadataRepository {}", info );
}
+ }
+ catch ( MetadataResolutionException | MetadataRepositoryException e )
+ {
+ log.error( "Could not remove project version from MetadataRepository {}: {}", info, e.getMessage( ), e );
+ }
+ }
+ metadataRepository.save( );
- repositorySession.save();
+ }
- triggerAuditEvent( repository.getRepository().getId(), ArtifactReference.toKey( reference ),
- AuditEvent.PURGE_ARTIFACT );
- purgeSupportFiles( artifactFile );
+ /*
+ * Removes the artifact from the metadataRepository. If a classifier is set, the facet will be removed.
+ */
+ private void removeArtifact( MetadataRepository metadataRepository, ArtifactInfo artifactInfo, ArtifactMetadata artifactMetadata ) throws MetadataRepositoryException
+ {
+ if ( artifactInfo.hasClassifier( ) )
+ {
+ // cleanup facet which contains classifier information
+ MavenArtifactFacet mavenArtifactFacet =
+ (MavenArtifactFacet) artifactMetadata.getFacet(
+ MavenArtifactFacet.FACET_ID );
+
+ if ( StringUtils.equals( artifactInfo.classifier,
+ mavenArtifactFacet.getClassifier( ) ) )
+ {
+ artifactMetadata.removeFacet( MavenArtifactFacet.FACET_ID );
+ String groupId = artifactInfo.getNamespace( ), artifactId =
+ artifactInfo.getName( ),
+ version = artifactInfo.getProjectVersion( );
+ MavenArtifactFacet mavenArtifactFacetToCompare = new MavenArtifactFacet( );
+ mavenArtifactFacetToCompare.setClassifier( artifactInfo.getClassifier( ) );
+ metadataRepository.removeArtifact( repository.getId( ), groupId, artifactId,
+ version, mavenArtifactFacetToCompare );
+ metadataRepository.save( );
}
}
+ else
+ {
+ metadataRepository.removeArtifact( artifactMetadata, artifactInfo.getProjectVersion( ) );
+ }
+ }
+
+ private void deleteSilently(Path path) {
+ try
+ {
+ Files.deleteIfExists( path );
+ triggerAuditEvent( repository.getRepository( ).getId( ), path.toString(), AuditEvent.PURGE_FILE );
+ }
+ catch ( IOException e )
+ {
+ log.error("Error occured during file deletion {}: {} ",path,e.getMessage(), e);
+ }
}
/**
@@ -190,29 +384,28 @@ public abstract class AbstractRepositoryPurge
*
* @param artifactFile the file to base off of.
*/
- private void purgeSupportFiles( File artifactFile )
+ private void purgeSupportFiles( Path artifactFile )
{
- File parentDir = artifactFile.getParentFile();
+ Path parentDir = artifactFile.getParent();
- if ( !parentDir.exists() )
+ if ( !Files.exists(parentDir) )
{
return;
}
- FilenameFilter filter = new ArtifactFilenameFilter( artifactFile.getName() );
+ final String artifactName = artifactFile.getFileName().toString();
- File[] files = parentDir.listFiles( filter );
-
- for ( File file : files )
+ try
{
- if ( file.exists() && file.isFile() )
- {
- String fileName = file.getName();
- file.delete();
- // TODO: log that it was deleted
- triggerAuditEvent( repository.getRepository().getId(), fileName, AuditEvent.PURGE_FILE );
- }
+ Files.find(parentDir, 3,
+ ( path, basicFileAttributes ) -> path.getFileName().toString().startsWith(artifactName)
+ && Files.isRegularFile( path ) ).forEach( this::deleteSilently );
}
+ catch ( IOException e )
+ {
+ log.error("Purge of support files failed {}: {}", artifactFile, e.getMessage(), e);
+ }
+
}
private void triggerAuditEvent( String repoId, String resource, String action )
http://git-wip-us.apache.org/repos/asf/archiva/blob/1d6f9dd2/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/ArtifactFilenameFilter.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/ArtifactFilenameFilter.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/ArtifactFilenameFilter.java
deleted file mode 100644
index f1f2c62..0000000
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/ArtifactFilenameFilter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.apache.archiva.consumers.core.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.FilenameFilter;
-import java.io.File;
-
-/**
- * Filename filter for getting all the files related to a specific artifact.
- *
- */
-public class ArtifactFilenameFilter
- implements FilenameFilter
-{
- private String filename;
-
- public ArtifactFilenameFilter()
- {
- // no op
- }
-
- public ArtifactFilenameFilter( String filename )
- {
- this.filename = filename;
- }
-
- @Override
- public boolean accept( File dir, String name )
- {
- return ( name.startsWith( filename ) );
- }
-}
http://git-wip-us.apache.org/repos/asf/archiva/blob/1d6f9dd2/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
----------------------------------------------------------------------
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 a91cc52..777d1e6 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
@@ -23,6 +23,7 @@ import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
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.repository.events.RepositoryListener;
import org.apache.archiva.common.utils.VersionComparator;
@@ -159,13 +160,14 @@ public class CleanupReleasedSnapshotsRepositoryPurge
versionRef.setVersion( artifactRef.getVersion() );
repository.deleteVersion( versionRef );
- // FIXME: looks incomplete, might not delete related metadata?
for ( RepositoryListener listener : listeners )
{
listener.deleteArtifact( metadataRepository, repository.getId(), artifactRef.getGroupId(),
artifactRef.getArtifactId(), artifactRef.getVersion(),
artifactFile.getName() );
}
+ metadataRepository.removeProjectVersion( repository.getId(), artifactRef.getGroupId(),
+ artifactRef.getArtifactId(), artifactRef.getVersion());
needsMetadataUpdate = true;
}
@@ -186,6 +188,10 @@ public class CleanupReleasedSnapshotsRepositoryPurge
{
throw new RepositoryPurgeException( e.getMessage(), e );
}
+ catch ( MetadataRepositoryException e )
+ {
+ log.error("Could not remove metadata during cleanup of released snapshots of {}", path, e);
+ }
}
private void updateMetadata( ArtifactReference artifact )
http://git-wip-us.apache.org/repos/asf/archiva/blob/1d6f9dd2/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurge.java
----------------------------------------------------------------------
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 da0591c..6ba811b 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
@@ -33,12 +33,7 @@ import org.apache.archiva.repository.layout.LayoutException;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
import java.util.regex.Matcher;
/**
@@ -99,6 +94,7 @@ public class DaysOldRepositoryPurge
int countToPurge = versions.size() - retentionCount;
+ Set<ArtifactReference> artifactsToDelete = new HashSet<>();
for ( String version : versions )
{
if ( countToPurge-- <= 0 )
@@ -117,7 +113,7 @@ public class DaysOldRepositoryPurge
{
if ( newArtifactFile.lastModified() < olderThanThisDate.getTimeInMillis() )
{
- doPurgeAllRelated( newArtifactReference );
+ artifactsToDelete.addAll(repository.getRelatedArtifacts(newArtifactReference) );
}
}
// Is this a timestamp snapshot "1.0-20070822.123456-42" ?
@@ -127,10 +123,11 @@ public class DaysOldRepositoryPurge
if ( timestampCal.getTimeInMillis() < olderThanThisDate.getTimeInMillis() )
{
- doPurgeAllRelated( newArtifactReference );
+ artifactsToDelete.addAll( repository.getRelatedArtifacts(newArtifactReference));
}
}
}
+ purge(artifactsToDelete);
}
catch ( ContentNotFoundException e )
{
@@ -175,17 +172,4 @@ public class DaysOldRepositoryPurge
return null;
}
- private void doPurgeAllRelated( ArtifactReference reference )
- {
- try
- {
- Set<ArtifactReference> related = repository.getRelatedArtifacts( reference );
- purge( related );
- }
- catch ( ContentNotFoundException e )
- {
- // Nothing to do here - it means the repository would have been constructed incorrectly
- log.debug( e.getMessage(), e );
- }
- }
}
http://git-wip-us.apache.org/repos/asf/archiva/blob/1d6f9dd2/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
index 41e4761..af71b9e 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
@@ -102,9 +102,6 @@ public class RepositoryPurgeConsumer
@Autowired(required = false)
private List<RepositoryListener> listeners = Collections.emptyList();
- /**
- * FIXME: this could be multiple implementations and needs to be configured.
- */
@Inject
private RepositorySessionFactory repositorySessionFactory;
@@ -189,7 +186,6 @@ public class RepositoryPurgeConsumer
{
cleanUp.process( path );
}
-
repoPurge.process( path );
}
catch ( RepositoryPurgeException rpe )
http://git-wip-us.apache.org/repos/asf/archiva/blob/1d6f9dd2/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java
----------------------------------------------------------------------
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 5cbcaa4..29d1e55 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
@@ -32,6 +32,7 @@ import org.apache.archiva.repository.layout.LayoutException;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -78,21 +79,22 @@ public class RetentionCountRepositoryPurge
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 )
{
break;
}
-
- doPurgeAllRelated( artifact, version );
+ artifactsToDelete.addAll(repository.getRelatedArtifacts( getNewArtifactReference( artifact, version) ));
}
+ purge(artifactsToDelete);
}
}
catch ( LayoutException le )
@@ -101,12 +103,14 @@ public class RetentionCountRepositoryPurge
}
catch ( ContentNotFoundException e )
{
- // Nothing to do here.
- // TODO: Log this condition?
+ log.error("Repostory artifact not found {}", path);
}
}
- private void doPurgeAllRelated( ArtifactReference reference, String version )
+ /*
+ * Returns a new artifact reference with different version
+ */
+ private ArtifactReference getNewArtifactReference( ArtifactReference reference, String version )
throws LayoutException
{
ArtifactReference artifact = new ArtifactReference();
@@ -115,16 +119,7 @@ public class RetentionCountRepositoryPurge
artifact.setVersion( version );
artifact.setClassifier( reference.getClassifier() );
artifact.setType( reference.getType() );
+ return artifact;
- try
- {
- Set<ArtifactReference> related = repository.getRelatedArtifacts( artifact );
- purge( related );
- }
- catch ( ContentNotFoundException e )
- {
- // Nothing to do here.
- // TODO: Log this?
- }
}
}
http://git-wip-us.apache.org/repos/asf/archiva/blob/1d6f9dd2/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
index 9412ac7..7645966 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
@@ -21,8 +21,11 @@ package org.apache.archiva.consumers.core.repository;
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
+import org.apache.archiva.common.utils.VersionUtil;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.storage.maven2.Maven2RepositoryPathTranslator;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
@@ -41,6 +44,14 @@ import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.LinkOption;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -194,6 +205,10 @@ public abstract class AbstractRepositoryPurgeTest
return new File( "target/test-" + getName() + "/" + TEST_REPO_ID );
}
+ protected Path getTestRepoRootPath() {
+ return Paths.get("target/test-"+getName()+"/"+TEST_REPO_ID);
+ }
+
protected String prepareTestRepos()
throws Exception
{
@@ -218,4 +233,14 @@ public abstract class AbstractRepositoryPurgeTest
{
return StringUtils.substringAfterLast( getClass().getName(), "." );
}
+
+ protected List<ArtifactMetadata> getArtifactMetadataFromDir( String repoId, String projectName, Path repoDir, Path vDir ) throws IOException
+ {
+ Maven2RepositoryPathTranslator translator = new Maven2RepositoryPathTranslator( new ArrayList<>( ) );
+ return Files.find(vDir, 1,
+ (path, basicFileAttributes) -> basicFileAttributes.isRegularFile() && path.getFileName().toString().startsWith(projectName))
+ .map( path ->
+ translator.getArtifactForPath( repoId, repoDir.relativize( path ).toString() )
+ ).collect( Collectors.toList());
+ }
}
http://git-wip-us.apache.org/repos/asf/archiva/blob/1d6f9dd2/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
index 5909657..697ec24 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
@@ -22,6 +22,8 @@ package org.apache.archiva.consumers.core.repository;
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.model.MetadataFacet;
import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.metadata.MetadataTools;
@@ -30,15 +32,21 @@ import org.custommonkey.xmlunit.XMLAssert;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
import java.io.File;
import java.nio.charset.Charset;
+import java.nio.file.Path;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.*;
/**
@@ -92,7 +100,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
removeMavenIndexes();
}
- //@Test
+ @Test
public void testReleasedSnapshotsExistsInSameRepo()
throws Exception
{
@@ -101,17 +109,35 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), false, null );
String repoRoot = prepareTestRepos();
+ String projectNs = "org.apache.maven.plugins";
+ String projectPath = projectNs.replaceAll("\\.","/");
+ String projectName = "maven-plugin-plugin";
+ String projectVersion = "2.3-SNAPSHOT";
+ String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
+ Path repo = getTestRepoRootPath();
+ Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
+ Set<String> deletedVersions = new HashSet<>();
+ deletedVersions.add("2.3-SNAPSHOT");
// test listeners for the correct artifacts
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins",
"maven-plugin-plugin", "2.3-SNAPSHOT", "maven-plugin-plugin-2.3-SNAPSHOT.jar" );
listenerControl.replay();
+ // Provide the metadata list
+ List<ArtifactMetadata> ml = getArtifactMetadataFromDir(TEST_REPO_ID , projectName, repo.getParent(), vDir );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, projectVersion)).thenReturn(ml);
+
+
repoPurge.process( PATH_TO_RELEASED_SNAPSHOT_IN_SAME_REPO );
listenerControl.verify();
- String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-plugin-plugin";
+ // Verify the metadataRepository invocations
+ // complete snapshot version removal for released
+ verify(metadataRepository, times(1)).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
+ verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq("2.3"));
// check if the snapshot was removed
assertDeleted( projectRoot + "/2.3-SNAPSHOT" );
@@ -149,7 +175,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
XMLAssert.assertXpathEvaluatesTo( "20070315032817", "//metadata/versioning/lastUpdated", metadataXml );
}
- //@Test
+ @Test
public void testNonArtifactFile()
throws Exception
{
@@ -179,7 +205,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
assertTrue( file.exists() );
}
- //@Test
+ @Test
public void testReleasedSnapshotsExistsInDifferentRepo()
throws Exception
{
@@ -192,6 +218,18 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
getRepoConfiguration( RELEASES_TEST_REPO_ID, RELEASES_TEST_REPO_NAME ), false, null );
String repoRoot = prepareTestRepos();
+ String projectNs = "org.apache.archiva";
+ String projectPath = projectNs.replaceAll("\\.","/");
+ String projectName = "released-artifact-in-diff-repo";
+ String projectVersion = "1.0-SNAPSHOT";
+ String releaseVersion = "1.0";
+ String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
+ Path repo = getTestRepoRootPath();
+ Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
+ Path releaseDir = repo.getParent().resolve(RELEASES_TEST_REPO_ID).resolve(projectPath).resolve(projectName).resolve(releaseVersion);
+ Set<String> deletedVersions = new HashSet<>();
+ deletedVersions.add("1.0-SNAPSHOT");
+
// test listeners for the correct artifacts
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.archiva",
@@ -199,11 +237,25 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
"released-artifact-in-diff-repo-1.0-SNAPSHOT.jar" );
listenerControl.replay();
+ // Provide the metadata list
+ List<ArtifactMetadata> ml = getArtifactMetadataFromDir(TEST_REPO_ID , projectName, repo.getParent(), vDir );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, projectVersion)).thenReturn(ml);
+
+ List<ArtifactMetadata> ml2 = getArtifactMetadataFromDir(RELEASES_TEST_REPO_ID , projectName, repo.getParent(), releaseDir );
+ when(metadataRepository.getArtifacts(RELEASES_TEST_REPO_ID, projectNs,
+ projectName, releaseVersion)).thenReturn(ml2);
+
+
repoPurge.process( PATH_TO_RELEASED_SNAPSHOT_IN_DIFF_REPO );
listenerControl.verify();
- String projectRoot = repoRoot + "/org/apache/archiva/released-artifact-in-diff-repo";
+ // Verify the metadataRepository invocations
+ // Complete version removal for cleanup
+ verify(metadataRepository, times(1)).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
+ verify(metadataRepository, never()).removeProjectVersion(eq(RELEASES_TEST_REPO_ID), eq(projectNs), eq(projectName), eq(releaseVersion));
+
// check if the snapshot was removed
assertDeleted( projectRoot + "/1.0-SNAPSHOT" );
@@ -241,15 +293,44 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), false, null );
String repoRoot = prepareTestRepos();
+ String projectNs = "org.apache.maven.plugins";
+ String projectPath = projectNs.replaceAll("\\.","/");
+ String projectName = "maven-source-plugin";
+ String projectVersion = "2.0.2";
+ String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
+ Path repo = getTestRepoRootPath();
+ Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
+ Path vDir2 = repo.resolve(projectPath).resolve(projectName).resolve("2.0.3-SNAPSHOT");
+ Path vDir3 = repo.resolve(projectPath).resolve(projectName).resolve("2.0.4-SNAPSHOT");
// test listeners for the correct artifacts - no deletions
listenerControl.replay();
+ // Provide the metadata list
+ List<ArtifactMetadata> ml = getArtifactMetadataFromDir(TEST_REPO_ID , projectName, repo.getParent(), vDir );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, projectVersion)).thenReturn(ml);
+ List<ArtifactMetadata> m2 = getArtifactMetadataFromDir(TEST_REPO_ID , projectName, repo.getParent(), vDir2 );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, "2.0.3-SNAPSHOT")).thenReturn(ml);
+ List<ArtifactMetadata> m3 = getArtifactMetadataFromDir(TEST_REPO_ID , projectName, repo.getParent(), vDir3 );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, "2.0.4-SNAPSHOT")).thenReturn(ml);
+
+
repoPurge.process( CleanupReleasedSnapshotsRepositoryPurgeTest.PATH_TO_HIGHER_SNAPSHOT_EXISTS_IN_SAME_REPO );
listenerControl.verify();
- String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-source-plugin";
+ // Verify the metadataRepository invocations
+ // No removal
+ verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
+ verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq("2.0.3-SNAPSHOT"));
+ verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq("2.0.4-SNAPSHOT"));
+ verify(metadataRepository, never()).removeArtifact(any(ArtifactMetadata.class), any(String.class));
+ verify(metadataRepository, never()).removeArtifact(any(String.class), any(String.class), any(String.class), any(String.class), any( MetadataFacet.class));
+
+
// check if the snapshot was not removed
assertExists( projectRoot + "/2.0.3-SNAPSHOT" );
http://git-wip-us.apache.org/repos/asf/archiva/blob/1d6f9dd2/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java
----------------------------------------------------------------------
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 21b03da..fbc25fd 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
@@ -20,15 +20,25 @@ package org.apache.archiva.consumers.core.repository;
*/
import java.io.File;
+import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+
import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.commons.lang.time.DateUtils;
import org.junit.After;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.*;
/**
*/
@@ -66,10 +76,18 @@ public class DaysOldRepositoryPurgeTest
Collections.singletonList( listener ) );
String repoRoot = prepareTestRepos();
-
- String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-install-plugin";
-
- setLastModified( projectRoot + "/2.2-SNAPSHOT/", OLD_TIMESTAMP );
+ String projectNs = "org.apache.maven.plugins";
+ String projectPath = projectNs.replaceAll("\\.","/");
+ String projectName = "maven-install-plugin";
+ String projectVersion = "2.2-SNAPSHOT";
+ String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
+ Path repo = getTestRepoRootPath();
+ Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
+ Set<String> deletedVersions = new HashSet<>();
+ deletedVersions.add("2.2-SNAPSHOT");
+ deletedVersions.add("2.2-20061118.060401-2");
+
+ setLastModified( projectRoot + "/" + projectVersion + "/", OLD_TIMESTAMP );
// test listeners for the correct artifacts
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins",
@@ -84,10 +102,26 @@ public class DaysOldRepositoryPurgeTest
"maven-install-plugin-2.2-20061118.060401-2.pom" );
listenerControl.replay();
+ // Provide the metadata list
+ List<ArtifactMetadata> ml = getArtifactMetadataFromDir(TEST_REPO_ID , projectName, repo.getParent(), vDir );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, projectVersion)).thenReturn(ml);
+
repoPurge.process( PATH_TO_BY_DAYS_OLD_ARTIFACT );
listenerControl.verify();
+ // Verify the metadataRepository invocations
+ verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
+ ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
+ verify(metadataRepository, times(2)).removeArtifact(metadataArg.capture(), eq(projectVersion));
+ List<ArtifactMetadata> metaL = metadataArg.getAllValues();
+ for (ArtifactMetadata meta : metaL) {
+ assertTrue(meta.getId().startsWith(projectName));
+ assertTrue(deletedVersions.contains(meta.getVersion()));
+ }
+
+
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar" );
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.md5" );
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.sha1" );
@@ -128,10 +162,17 @@ public class DaysOldRepositoryPurgeTest
repoConfiguration.getRetentionCount(), repositorySession, listeners );
String repoRoot = prepareTestRepos();
-
- String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-assembly-plugin";
-
- setLastModified( projectRoot + "/1.1.2-SNAPSHOT/", OLD_TIMESTAMP );
+ String projectNs = "org.apache.maven.plugins";
+ String projectPath = projectNs.replaceAll("\\.","/");
+ String projectName = "maven-assembly-plugin";
+ String projectVersion = "1.1.2-SNAPSHOT";
+ String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
+ Path repo = getTestRepoRootPath();
+ Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
+ Set<String> deletedVersions = new HashSet<>();
+ deletedVersions.add("1.1.2-20070427.065136-1");
+
+ setLastModified( projectRoot + "/" + projectVersion + "/", OLD_TIMESTAMP );
// test listeners for the correct artifacts
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins",
@@ -142,10 +183,27 @@ public class DaysOldRepositoryPurgeTest
"maven-assembly-plugin-1.1.2-20070427.065136-1.pom" );
listenerControl.replay();
+ // Provide the metadata list
+ List<ArtifactMetadata> ml = getArtifactMetadataFromDir(TEST_REPO_ID , projectName, repo.getParent(), vDir );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, projectVersion)).thenReturn(ml);
+
+
repoPurge.process( PATH_TO_TEST_ORDER_OF_DELETION );
listenerControl.verify();
+ // Verify the metadataRepository invocations
+ verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
+ ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
+ verify(metadataRepository, times(deletedVersions.size())).removeArtifact(metadataArg.capture(), eq(projectVersion));
+ List<ArtifactMetadata> metaL = metadataArg.getAllValues();
+ for (ArtifactMetadata meta : metaL) {
+ assertTrue(meta.getId().startsWith(projectName));
+ assertTrue(deletedVersions.contains(meta.getVersion()));
+ }
+
+
assertDeleted( projectRoot + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070427.065136-1.jar" );
assertDeleted( projectRoot + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070427.065136-1.jar.sha1" );
assertDeleted( projectRoot + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070427.065136-1.jar.md5" );
@@ -179,8 +237,18 @@ public class DaysOldRepositoryPurgeTest
repoConfiguration.getRetentionCount(), repositorySession, listeners );
String repoRoot = prepareTestRepos();
+ String projectNs = "org.codehaus.plexus";
+ String projectPath = projectNs.replaceAll("\\.","/");
+ String projectName = "plexus-utils";
+ String projectVersion = "1.4.3-SNAPSHOT";
+ String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
+ Path repo = getTestRepoRootPath();
+ Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
+ Set<String> deletedVersions = new HashSet<>();
+ deletedVersions.add("1.4.3-20070113.163208-4");
+
- String versionRoot = repoRoot + "/org/codehaus/plexus/plexus-utils/1.4.3-SNAPSHOT";
+ String versionRoot = projectRoot + "/"+ projectVersion;
Calendar currentDate = Calendar.getInstance( DateUtils.UTC_TIME_ZONE );
setLastModified( versionRoot, currentDate.getTimeInMillis() );
@@ -209,10 +277,27 @@ public class DaysOldRepositoryPurgeTest
"1.4.3-20070113.163208-4", "plexus-utils-1.4.3-20070113.163208-4.pom" );
listenerControl.replay();
+ // Provide the metadata list
+ List<ArtifactMetadata> ml = getArtifactMetadataFromDir(TEST_REPO_ID , projectName, repo.getParent(), vDir );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, projectVersion)).thenReturn(ml);
+
+
repoPurge.process( PATH_TO_BY_DAYS_OLD_METADATA_DRIVEN_ARTIFACT );
listenerControl.verify();
+ // Verify the metadataRepository invocations
+ verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
+ ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
+ verify(metadataRepository, times(deletedVersions.size())).removeArtifact(metadataArg.capture(), eq(projectVersion));
+ List<ArtifactMetadata> metaL = metadataArg.getAllValues();
+ for (ArtifactMetadata meta : metaL) {
+ assertTrue(meta.getId().startsWith(projectName));
+ assertTrue(deletedVersions.contains(meta.getVersion()));
+ }
+
+
// this should be deleted since the filename version (timestamp) is older than
// 100 days even if the last modified date was <100 days ago
assertDeleted( versionRoot + "/plexus-utils-1.4.3-20070113.163208-4.jar" );
http://git-wip-us.apache.org/repos/asf/archiva/blob/1d6f9dd2/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
index 74e4631..6d5c33b 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
@@ -30,19 +30,38 @@ import org.apache.archiva.configuration.FileType;
import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.model.MetadataFacet;
+import org.apache.archiva.metadata.model.facets.RepositoryProblemFacet;
import org.apache.archiva.mock.MockRepositorySessionFactory;
import org.apache.commons.io.FileUtils;
import org.custommonkey.xmlunit.XMLAssert;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
import org.springframework.test.context.ContextConfiguration;
+import sun.awt.image.ImageWatched;
import java.io.File;
+import java.io.IOException;
import java.nio.charset.Charset;
-
+import java.nio.file.Files;
+import java.nio.file.LinkOption;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static com.sun.imageio.plugins.jpeg.JPEG.version;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.*;
/**
*/
@@ -152,10 +171,37 @@ public class RepositoryPurgeConsumerTest
repoPurgeConsumer.beginScan( repoConfiguration, null );
String repoRoot = prepareTestRepos();
+ String projectNs = "org.jruby.plugins";
+ String projectPath = projectNs.replaceAll("\\.","/");
+ String projectName = "jruby-rake-plugin";
+ String projectVersion = "1.0RC1-SNAPSHOT";
+ String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
+ String versionRoot = projectRoot + "/" + projectVersion;
+
+ Path repo = getTestRepoRootPath();
+ Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
+
+ // Provide the metadata list
+ List<ArtifactMetadata> ml = getArtifactMetadataFromDir( TEST_REPO_ID, projectName, repo, vDir );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, projectVersion)).thenReturn(ml);
+ Set<String> deletedVersions = new HashSet<>();
+ deletedVersions.add("1.0RC1-20070504.153317-1");
+ deletedVersions.add("1.0RC1-20070504.160758-2");
repoPurgeConsumer.processFile( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
- String versionRoot = repoRoot + "/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT";
+ // Verify the metadataRepository invocations
+ verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
+ ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
+ verify(metadataRepository, times(2)).removeArtifact(metadataArg.capture(), eq(projectVersion));
+ List<ArtifactMetadata> metaL = metadataArg.getAllValues();
+ for (ArtifactMetadata meta : metaL) {
+ assertTrue(meta.getId().startsWith(projectName));
+ assertTrue(deletedVersions.contains(meta.getVersion()));
+ }
+
+
// assert if removed from repo
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar" );
@@ -247,12 +293,38 @@ public class RepositoryPurgeConsumerTest
repoPurgeConsumer.beginScan( repoConfiguration, null );
String repoRoot = prepareTestRepos();
- String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-install-plugin";
+ String projectNs = "org.apache.maven.plugins";
+ String projectPath = projectNs.replaceAll("\\.","/");
+ String projectName = "maven-install-plugin";
+ String projectVersion = "2.2-SNAPSHOT";
+ String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
+
+ setLastModified( projectRoot + "/"+projectVersion);
+
- setLastModified( projectRoot + "/2.2-SNAPSHOT" );
+ Path repo = getTestRepoRootPath();
+ Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
+
+ // Provide the metadata list
+ List<ArtifactMetadata> ml = getArtifactMetadataFromDir( TEST_REPO_ID, projectName, repo, vDir );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, projectVersion)).thenReturn(ml);
+ Set<String> deletedVersions = new HashSet<>();
+ deletedVersions.add("2.2-SNAPSHOT");
+ deletedVersions.add("2.2-20061118.060401-2");
repoPurgeConsumer.processFile( PATH_TO_BY_DAYS_OLD_ARTIFACT );
+ // Verify the metadataRepository invocations
+ verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
+ ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
+ verify(metadataRepository, times(2)).removeArtifact(metadataArg.capture(), eq(projectVersion));
+ List<ArtifactMetadata> metaL = metadataArg.getAllValues();
+ for (ArtifactMetadata meta : metaL) {
+ assertTrue(meta.getId().startsWith(projectName));
+ assertTrue(deletedVersions.contains(meta.getVersion()));
+ }
+
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar" );
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.md5" );
assertDeleted( projectRoot + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.sha1" );
@@ -305,12 +377,29 @@ public class RepositoryPurgeConsumerTest
repoPurgeConsumer.beginScan( repoConfiguration, null );
String repoRoot = prepareTestRepos();
+ String projectNs = "org.apache.maven.plugins";
+ String projectPath = projectNs.replaceAll("\\.","/");
+ String projectName = "maven-plugin-plugin";
+ String projectVersion = "2.3-SNAPSHOT";
+ String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
+
+ Path repo = getTestRepoRootPath();
+ Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
+
+ // Provide the metadata list
+ List<ArtifactMetadata> ml = getArtifactMetadataFromDir( TEST_REPO_ID, projectName, repo, vDir );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, projectVersion)).thenReturn(ml);
repoPurgeConsumer.processFile(
CleanupReleasedSnapshotsRepositoryPurgeTest.PATH_TO_RELEASED_SNAPSHOT_IN_SAME_REPO );
+ verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
+ ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
+ verify(metadataRepository, never()).removeArtifact(any(), any());
+ verify(metadataRepository, never()).removeArtifact( any(), any(), any(), any(), any(MetadataFacet.class) );
+
// check if the snapshot wasn't removed
- String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-plugin-plugin";
assertExists( projectRoot + "/2.3-SNAPSHOT" );
assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar" );
@@ -350,11 +439,25 @@ public class RepositoryPurgeConsumerTest
repoPurgeConsumer.beginScan( repoConfiguration, null );
String repoRoot = prepareTestRepos();
+ String projectNs = "org.apache.maven.plugins";
+ String projectPath = projectNs.replaceAll("\\.","/");
+ String projectName = "maven-plugin-plugin";
+ String projectVersion = "2.3-SNAPSHOT";
+ String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
+ Path repo = getTestRepoRootPath();
+ Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
+
+ // Provide the metadata list
+ List<ArtifactMetadata> ml = getArtifactMetadataFromDir(TEST_REPO_ID , projectName, repo.getParent(), vDir );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, projectVersion)).thenReturn(ml);
repoPurgeConsumer.processFile(
CleanupReleasedSnapshotsRepositoryPurgeTest.PATH_TO_RELEASED_SNAPSHOT_IN_SAME_REPO );
- String projectRoot = repoRoot + "/org/apache/maven/plugins/maven-plugin-plugin";
+ verify(metadataRepository, times(1)).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
+ ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
+ verify(metadataRepository, never()).removeArtifact(any(), any());
// check if the snapshot was removed
assertDeleted( projectRoot + "/2.3-SNAPSHOT" );
http://git-wip-us.apache.org/repos/asf/archiva/blob/1d6f9dd2/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java
----------------------------------------------------------------------
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 f7e21f1..ca7685b 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
@@ -19,13 +19,23 @@ package org.apache.archiva.consumers.core.repository;
* under the License.
*/
+import java.nio.file.Path;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+
import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.repository.events.RepositoryListener;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.*;
/**
* Test RetentionsCountRepositoryPurgeTest
@@ -62,6 +72,17 @@ public class RetentionCountRepositoryPurgeTest
throws Exception
{
String repoRoot = prepareTestRepos();
+ String projectNs = "org.jruby.plugins";
+ String projectPath = projectNs.replaceAll("\\.","/");
+ String projectName = "jruby-rake-plugin";
+ String projectVersion = "1.0RC1-SNAPSHOT";
+ String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
+ Path repo = getTestRepoRootPath();
+ Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
+ Set<String> deletedVersions = new HashSet<>();
+ deletedVersions.add("1.0RC1-20070504.153317-1");
+ deletedVersions.add("1.0RC1-20070504.160758-2");
+ String versionRoot = projectRoot + "/" + projectVersion;
// test listeners for the correct artifacts
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin",
@@ -87,11 +108,26 @@ public class RetentionCountRepositoryPurgeTest
"1.0RC1-20070504.160758-2", "jruby-rake-plugin-1.0RC1-20070504.160758-2.pom" );
listenerControl.replay();
+ // Provide the metadata list
+ List<ArtifactMetadata> ml = getArtifactMetadataFromDir(TEST_REPO_ID , projectName, repo.getParent(), vDir );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, projectVersion)).thenReturn(ml);
+
+
repoPurge.process( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
listenerControl.verify();
- String versionRoot = repoRoot + "/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT";
+ // Verify the metadataRepository invocations
+ verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
+ ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
+ verify(metadataRepository, times(deletedVersions.size())).removeArtifact(metadataArg.capture(), eq(projectVersion));
+ List<ArtifactMetadata> metaL = metadataArg.getAllValues();
+ for (ArtifactMetadata meta : metaL) {
+ assertTrue(meta.getId().startsWith(projectName));
+ assertTrue(deletedVersions.contains(meta.getVersion()));
+ }
+
// assert if removed from repo
assertDeleted( versionRoot + "/jruby-rake-plugin-1.0RC1-20070504.153317-1.jar" );
@@ -132,6 +168,17 @@ public class RetentionCountRepositoryPurgeTest
throws Exception
{
String repoRoot = prepareTestRepos();
+ String projectNs = "org.codehaus.castor";
+ String projectPath = projectNs.replaceAll("\\.","/");
+ String projectName = "castor-anttasks";
+ String projectVersion = "1.1.2-SNAPSHOT";
+ String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
+ Path repo = getTestRepoRootPath();
+ Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
+ Set<String> deletedVersions = new HashSet<>();
+ deletedVersions.add("1.1.2-20070427.065136-1");
+ String versionRoot = projectRoot + "/" + projectVersion;
+
// test listeners for the correct artifacts
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.codehaus.castor", "castor-anttasks",
@@ -140,11 +187,25 @@ public class RetentionCountRepositoryPurgeTest
"1.1.2-20070427.065136-1", "castor-anttasks-1.1.2-20070427.065136-1.pom" );
listenerControl.replay();
+ // Provide the metadata list
+ List<ArtifactMetadata> ml = getArtifactMetadataFromDir(TEST_REPO_ID , projectName, repo.getParent(), vDir );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, projectVersion)).thenReturn(ml);
+
repoPurge.process( PATH_TO_BY_RETENTION_COUNT_POM );
listenerControl.verify();
- String versionRoot = repoRoot + "/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT";
+ // Verify the metadataRepository invocations
+ verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
+ ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
+ verify(metadataRepository, times(deletedVersions.size())).removeArtifact(metadataArg.capture(), eq(projectVersion));
+ List<ArtifactMetadata> metaL = metadataArg.getAllValues();
+ for (ArtifactMetadata meta : metaL) {
+ assertTrue(meta.getId().startsWith(projectName));
+ assertTrue(deletedVersions.contains(meta.getVersion()));
+ }
+
// assert if removed from repo
assertDeleted( versionRoot + "/castor-anttasks-1.1.2-20070427.065136-1.jar" );
@@ -181,6 +242,17 @@ public class RetentionCountRepositoryPurgeTest
throws Exception
{
String repoRoot = prepareTestRepos();
+ String projectNs = "org.apache.maven.plugins";
+ String projectPath = projectNs.replaceAll("\\.","/");
+ String projectName = "maven-assembly-plugin";
+ String projectVersion = "1.1.2-SNAPSHOT";
+ String projectRoot = repoRoot + "/" + projectPath+"/"+projectName;
+ Path repo = getTestRepoRootPath();
+ Path vDir = repo.resolve(projectPath).resolve(projectName).resolve(projectVersion);
+ Set<String> deletedVersions = new HashSet<>();
+ deletedVersions.add("1.1.2-20070427.065136-1");
+ String versionRoot = projectRoot + "/" + projectVersion;
+
// test listeners for the correct artifacts
listener.deleteArtifact( metadataRepository, getRepository().getId(), "org.apache.maven.plugins",
@@ -191,11 +263,25 @@ public class RetentionCountRepositoryPurgeTest
"maven-assembly-plugin-1.1.2-20070427.065136-1.pom" );
listenerControl.replay();
+ // Provide the metadata list
+ List<ArtifactMetadata> ml = getArtifactMetadataFromDir(TEST_REPO_ID , projectName, repo.getParent(), vDir );
+ when(metadataRepository.getArtifacts(TEST_REPO_ID, projectNs,
+ projectName, projectVersion)).thenReturn(ml);
+
repoPurge.process( PATH_TO_TEST_ORDER_OF_DELETION );
listenerControl.verify();
- String versionRoot = repoRoot + "/org/apache/maven/plugins/maven-assembly-plugin/1.1.2-SNAPSHOT";
+ // Verify the metadataRepository invocations
+ verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
+ ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
+ verify(metadataRepository, times(deletedVersions.size())).removeArtifact(metadataArg.capture(), eq(projectVersion));
+ List<ArtifactMetadata> metaL = metadataArg.getAllValues();
+ for (ArtifactMetadata meta : metaL) {
+ assertTrue(meta.getId().startsWith(projectName));
+ assertTrue(deletedVersions.contains(meta.getVersion()));
+ }
+
assertDeleted( versionRoot + "/maven-assembly-plugin-1.1.2-20070427.065136-1.jar" );
assertDeleted( versionRoot + "/maven-assembly-plugin-1.1.2-20070427.065136-1.jar.sha1" );
[2/4] archiva git commit: Remove unused imports
Posted by ma...@apache.org.
Remove unused imports
Project: http://git-wip-us.apache.org/repos/asf/archiva/repo
Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/28f51257
Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/28f51257
Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/28f51257
Branch: refs/heads/archiva-2.x
Commit: 28f51257dc9086623478f2a597683349b72d0fcc
Parents: 1d6f9dd
Author: Martin Stockhammer <ma...@apache.org>
Authored: Sun Aug 27 16:16:53 2017 +0200
Committer: Martin Stockhammer <ma...@apache.org>
Committed: Mon Aug 28 20:36:30 2017 +0200
----------------------------------------------------------------------
.../archiva/consumers/core/AutoRemoveConsumer.java | 4 ++--
.../archiva/consumers/core/AutoRenameConsumer.java | 4 ++--
.../consumers/core/MetadataUpdaterConsumer.java | 3 ---
.../consumers/core/ValidateChecksumConsumer.java | 4 ++--
.../core/repository/AbstractRepositoryPurge.java | 12 +++++++-----
.../CleanupReleasedSnapshotsRepositoryPurge.java | 6 +++---
.../core/repository/DaysOldRepositoryPurge.java | 14 ++++++++++----
.../core/repository/RepositoryPurgeConsumer.java | 2 +-
.../repository/RetentionCountRepositoryPurge.java | 4 ++--
.../core/AbstractArtifactConsumerTest.java | 9 +++++----
.../repository/AbstractRepositoryPurgeTest.java | 3 ---
...CleanupReleasedSnapshotsRepositoryPurgeTest.java | 1 -
.../core/repository/DaysOldRepositoryPurgeTest.java | 16 ++++++++--------
.../repository/RepositoryPurgeConsumerTest.java | 12 +-----------
.../RetentionCountRepositoryPurgeTest.java | 12 ++++++------
15 files changed, 49 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRemoveConsumer.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRemoveConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRemoveConsumer.java
index b323e01..4d8608c 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRemoveConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRemoveConsumer.java
@@ -28,10 +28,10 @@ import org.apache.archiva.consumers.ConsumerException;
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.redback.components.registry.Registry;
import org.apache.archiva.redback.components.registry.RegistryListener;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRenameConsumer.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRenameConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRenameConsumer.java
index 9445bc9..7e59e2f 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRenameConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRenameConsumer.java
@@ -24,10 +24,10 @@ import org.apache.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.archiva.consumers.ConsumerException;
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.commons.io.FileUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
import java.io.File;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java
----------------------------------------------------------------------
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 fe158db..69f2b32 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
@@ -21,7 +21,6 @@ package org.apache.archiva.consumers.core;
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.ConfigurationNames;
import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.archiva.consumers.ConsumerException;
@@ -37,8 +36,6 @@ import org.apache.archiva.repository.RepositoryNotFoundException;
import org.apache.archiva.repository.layout.LayoutException;
import org.apache.archiva.repository.metadata.MetadataTools;
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
-import org.apache.archiva.redback.components.registry.Registry;
-import org.apache.archiva.redback.components.registry.RegistryListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java
index 4f7de37..5eecbfb 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java
@@ -29,10 +29,10 @@ import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.codehaus.plexus.digest.ChecksumFile;
import org.codehaus.plexus.digest.Digester;
import org.codehaus.plexus.digest.DigesterException;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java
----------------------------------------------------------------------
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 4c99fd6..302e37d 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
@@ -19,9 +19,9 @@ package org.apache.archiva.consumers.core.repository;
* under the License.
*/
-import org.apache.archiva.metadata.model.facets.AuditEvent;
import org.apache.archiva.common.utils.VersionUtil;
import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.model.facets.AuditEvent;
import org.apache.archiva.metadata.model.maven2.MavenArtifactFacet;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.MetadataRepositoryException;
@@ -35,13 +35,15 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.*;
-import java.util.stream.Collectors;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* Base class for all repository purge tasks.
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
----------------------------------------------------------------------
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 777d1e6..c344a6d 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
@@ -22,12 +22,11 @@ package org.apache.archiva.consumers.core.repository;
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.common.utils.VersionComparator;
+import org.apache.archiva.common.utils.VersionUtil;
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.repository.events.RepositoryListener;
-import org.apache.archiva.common.utils.VersionComparator;
-import org.apache.archiva.common.utils.VersionUtil;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference;
@@ -36,6 +35,7 @@ import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryNotFoundException;
+import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.layout.LayoutException;
import org.apache.archiva.repository.metadata.MetadataTools;
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurge.java
----------------------------------------------------------------------
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 6ba811b..ae807b3 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
@@ -19,21 +19,27 @@ package org.apache.archiva.consumers.core.repository;
* under the License.
*/
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.repository.events.RepositoryListener;
-import org.apache.commons.lang.time.DateUtils;
import org.apache.archiva.common.utils.VersionComparator;
import org.apache.archiva.common.utils.VersionUtil;
+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.ManagedRepositoryContent;
+import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.layout.LayoutException;
+import org.apache.commons.lang.time.DateUtils;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+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.regex.Matcher;
/**
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
index af71b9e..f7711e2 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumer.java
@@ -30,13 +30,13 @@ import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
import org.apache.archiva.redback.components.registry.Registry;
+import org.apache.archiva.redback.components.registry.RegistryListener;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryNotFoundException;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.metadata.MetadataTools;
-import org.apache.archiva.redback.components.registry.RegistryListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java
----------------------------------------------------------------------
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 29d1e55..1d1558a 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
@@ -19,14 +19,14 @@ package org.apache.archiva.consumers.core.repository;
* under the License.
*/
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.common.utils.VersionComparator;
import org.apache.archiva.common.utils.VersionUtil;
+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.ManagedRepositoryContent;
+import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.layout.LayoutException;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java
index 1176bc5..ac68984 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java
@@ -19,17 +19,17 @@ package org.apache.archiva.consumers.core;
* under the License.
*/
-import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.utils.BaseFile;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.FileType;
import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
+import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
+import org.apache.commons.lang.StringUtils;
import org.apache.maven.index.NexusIndexer;
import org.apache.maven.index.context.IndexingContext;
import org.junit.After;
-import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -38,8 +38,9 @@ import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
import java.io.File;
-import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-import org.apache.commons.lang.StringUtils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
@RunWith( ArchivaSpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
index 7645966..0e59983 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
@@ -20,8 +20,6 @@ package org.apache.archiva.consumers.core.repository;
*/
import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
-import org.apache.archiva.common.utils.VersionUtil;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySession;
@@ -46,7 +44,6 @@ import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
-import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
index 697ec24..c3e650d 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
@@ -32,7 +32,6 @@ import org.custommonkey.xmlunit.XMLAssert;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.ArgumentCaptor;
import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java
----------------------------------------------------------------------
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 fbc25fd..7ec3c3c 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
@@ -19,6 +19,14 @@ package org.apache.archiva.consumers.core.repository;
* under the License.
*/
+import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.repository.events.RepositoryListener;
+import org.apache.commons.lang.time.DateUtils;
+import org.junit.After;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
import java.io.File;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
@@ -28,14 +36,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.metadata.model.ArtifactMetadata;
-import org.apache.archiva.repository.events.RepositoryListener;
-import org.apache.commons.lang.time.DateUtils;
-import org.junit.After;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
index 6d5c33b..b4ef96d 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
@@ -32,7 +32,6 @@ import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.MetadataFacet;
-import org.apache.archiva.metadata.model.facets.RepositoryProblemFacet;
import org.apache.archiva.mock.MockRepositorySessionFactory;
import org.apache.commons.io.FileUtils;
import org.custommonkey.xmlunit.XMLAssert;
@@ -41,24 +40,15 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.springframework.test.context.ContextConfiguration;
-import sun.awt.image.ImageWatched;
import java.io.File;
-import java.io.IOException;
import java.nio.charset.Charset;
-import java.nio.file.Files;
-import java.nio.file.LinkOption;
import java.nio.file.Path;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.stream.Collectors;
-import static com.sun.imageio.plugins.jpeg.JPEG.version;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
http://git-wip-us.apache.org/repos/asf/archiva/blob/28f51257/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java
----------------------------------------------------------------------
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 ca7685b..06e2108 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
@@ -19,12 +19,6 @@ package org.apache.archiva.consumers.core.repository;
* under the License.
*/
-import java.nio.file.Path;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.repository.events.RepositoryListener;
@@ -33,6 +27,12 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+import java.nio.file.Path;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
[4/4] archiva git commit: [MRM-1958] Merging fix from master tree
Posted by ma...@apache.org.
[MRM-1958] Merging fix from master tree
Replace streams with old style code
Fix mock verifications
Project: http://git-wip-us.apache.org/repos/asf/archiva/repo
Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/85687a34
Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/85687a34
Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/85687a34
Branch: refs/heads/archiva-2.x
Commit: 85687a34e0c1368b30fbfba6e551a002291d3ee2
Parents: 940412e
Author: Martin Stockhammer <ma...@apache.org>
Authored: Mon Aug 28 21:19:13 2017 +0200
Committer: Martin Stockhammer <ma...@apache.org>
Committed: Mon Aug 28 21:19:13 2017 +0200
----------------------------------------------------------------------
.../repository/AbstractRepositoryPurge.java | 32 +++++++++++++++--
.../core/AbstractArtifactConsumerTest.java | 1 +
.../repository/AbstractRepositoryPurgeTest.java | 36 +++++++++++++++-----
.../repository/RepositoryPurgeConsumerTest.java | 6 ++--
4 files changed, 61 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/archiva/blob/85687a34/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurge.java
----------------------------------------------------------------------
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 9b1615f..de2d489 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
@@ -36,8 +36,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileVisitOption;
+import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -400,9 +405,7 @@ public abstract class AbstractRepositoryPurge
try
{
- Files.find( parentDir, 3,
- ( path, basicFileAttributes ) -> path.getFileName( ).toString( ).startsWith( artifactName )
- && Files.isRegularFile( path ) ).forEach( this::deleteSilently );
+ deleteArtifactFiles( parentDir, 3, artifactName );
}
catch ( IOException e )
{
@@ -411,6 +414,29 @@ public abstract class AbstractRepositoryPurge
}
+ public static void deleteArtifactFiles(final Path directory, final int maxDepth, final String artifactName) throws IOException
+ {
+ Files.walkFileTree(directory, new HashSet<FileVisitOption>( ), maxDepth, new SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult visitFile( Path file, BasicFileAttributes attrs) throws IOException {
+ if (file.getFileName().toString().startsWith(artifactName)) {
+ try {
+ Files.delete( file );
+ } catch (IOException e) {
+ // We do not stop, if an error occurs.
+ }
+ }
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
+ return FileVisitResult.CONTINUE;
+ }
+
+ });
+ }
+
private void triggerAuditEvent( String repoId, String resource, String action )
{
String msg =
http://git-wip-us.apache.org/repos/asf/archiva/blob/85687a34/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java
index ac68984..394093f 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java
@@ -19,6 +19,7 @@ package org.apache.archiva.consumers.core;
* under the License.
*/
+import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.utils.BaseFile;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.FileType;
http://git-wip-us.apache.org/repos/asf/archiva/blob/85687a34/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
index 0e59983..4df51b6 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
@@ -20,9 +20,11 @@ package org.apache.archiva.consumers.core.repository;
*/
import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
import org.apache.archiva.metadata.repository.storage.maven2.Maven2RepositoryPathTranslator;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.events.RepositoryListener;
@@ -43,12 +45,16 @@ import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
+import java.nio.file.FileVisitOption;
+import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
-import java.util.stream.Collectors;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -231,13 +237,27 @@ public abstract class AbstractRepositoryPurgeTest
return StringUtils.substringAfterLast( getClass().getName(), "." );
}
- protected List<ArtifactMetadata> getArtifactMetadataFromDir( String repoId, String projectName, Path repoDir, Path vDir ) throws IOException
+ protected List<ArtifactMetadata> getArtifactMetadataFromDir( final String repoId, final String projectName, final Path repoDir, final Path vDir ) throws IOException
{
- Maven2RepositoryPathTranslator translator = new Maven2RepositoryPathTranslator( new ArrayList<>( ) );
- return Files.find(vDir, 1,
- (path, basicFileAttributes) -> basicFileAttributes.isRegularFile() && path.getFileName().toString().startsWith(projectName))
- .map( path ->
- translator.getArtifactForPath( repoId, repoDir.relativize( path ).toString() )
- ).collect( Collectors.toList());
+ final Maven2RepositoryPathTranslator translator = new Maven2RepositoryPathTranslator( new ArrayList<ArtifactMappingProvider>( ) );
+ final List<ArtifactMetadata> result = new ArrayList<>( );
+ Files.walkFileTree(vDir, new HashSet<FileVisitOption>( ), 1, new SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult visitFile( Path file, BasicFileAttributes attrs) throws IOException {
+ if (file.getFileName().toString().startsWith(projectName)) {
+ ArtifactMetadata m = translator.getArtifactForPath( repoId, repoDir.relativize( file ).toString() );
+ result.add(m);
+ }
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
+ return FileVisitResult.CONTINUE;
+ }
+
+ });
+ return result;
}
+
}
http://git-wip-us.apache.org/repos/asf/archiva/blob/85687a34/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
index b4ef96d..f444e5a 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
@@ -386,8 +386,8 @@ public class RepositoryPurgeConsumerTest
verify(metadataRepository, never()).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
- verify(metadataRepository, never()).removeArtifact(any(), any());
- verify(metadataRepository, never()).removeArtifact( any(), any(), any(), any(), any(MetadataFacet.class) );
+ verify(metadataRepository, never()).removeArtifact(any(ArtifactMetadata.class), any(String.class));
+ verify(metadataRepository, never()).removeArtifact( any(String.class), any(String.class), any(String.class), any(String.class), any(MetadataFacet.class) );
// check if the snapshot wasn't removed
@@ -447,7 +447,7 @@ public class RepositoryPurgeConsumerTest
verify(metadataRepository, times(1)).removeProjectVersion(eq(TEST_REPO_ID), eq(projectNs), eq(projectName), eq(projectVersion));
ArgumentCaptor<ArtifactMetadata> metadataArg = ArgumentCaptor.forClass(ArtifactMetadata.class);
- verify(metadataRepository, never()).removeArtifact(any(), any());
+ verify(metadataRepository, never()).removeArtifact(any(ArtifactMetadata.class), any(String.class));
// check if the snapshot was removed
assertDeleted( projectRoot + "/2.3-SNAPSHOT" );