//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;
}
public void beginScan( ManagedRepository repo, Date whenGathered )
throws ConsumerException
{
- this.repositoryDir = new File( repo.getLocation() );
+ this.repositoryDir = new File( repo.getLocation( ) );
}
@Override
}
@Override
- public void completeScan()
+ public void completeScan( )
{
/* do nothing */
}
@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;
}
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." );
}
}
*/
- 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( );
}
}
/**
* AutoRemoveConsumer
- *
- *
*/
@Service( "knownRepositoryContentConsumer#auto-remove" )
@Scope( "prototype" )
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;
}
public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
- this.repositoryDir = new File( repository.getLocation() );
+ this.repositoryDir = new File( repository.getLocation( ) );
}
@Override
}
@Override
- public void completeScan()
+ public void completeScan( )
{
/* do nothing */
}
@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;
}
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( );
}
}
{
if ( ConfigurationNames.isRepositoryScanning( propertyName ) )
{
- initIncludes();
+ initIncludes( );
}
}
/* 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( );
}
}
/**
* AutoRenameConsumer
- *
- *
*/
@Service( "knownRepositoryContentConsumer#auto-rename" )
@Scope( "prototype" )
extends AbstractMonitoredConsumer
implements KnownRepositoryContentConsumer
{
- private Logger log = LoggerFactory.getLogger( AutoRenameConsumer.class );
+ private Logger log = LoggerFactory.getLogger( AutoRenameConsumer.class );
private String id = "auto-rename";
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" );
}
@Override
- public String getId()
+ public String getId( )
{
return this.id;
}
@Override
- public String getDescription()
+ public String getDescription( )
{
return this.description;
}
public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
- this.repositoryDir = new File( repository.getLocation() );
+ this.repositoryDir = new File( repository.getLocation( ) );
}
@Override
}
@Override
- public void completeScan()
+ public void completeScan( )
{
/* do nothing */
}
@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;
}
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
{
{
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( );
}
}
/**
* MetadataUpdaterConsumer will create and update the metadata present within the repository.
- *
- *
*/
@Service( "knownRepositoryContentConsumer#metadata-updater" )
@Scope( "prototype" )
private long scanStartTimestamp = 0;
@Override
- public String getDescription()
+ public String getDescription( )
{
return description;
}
@Override
- public String getId()
+ public String getId( )
{
return id;
}
{
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 );
}
}
}
@Override
- public void completeScan()
+ public void completeScan( )
{
/* do nothing here */
}
@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;
}
}
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( ) );
}
}
}
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
{
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 ) );
{
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
{
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 ) );
{
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( ) );
}
}
}
*/
- 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( );
}
}
/**
* ValidateChecksumConsumer - validate the provided checksum against the file it represents.
- *
- *
*/
@Service( "knownRepositoryContentConsumer#validate-checksums" )
@Scope( "prototype" )
private List<String> includes;
@Override
- public String getId()
+ public String getId( )
{
return this.id;
}
@Override
- public String getDescription()
+ public String getDescription( )
{
return this.description;
}
public void beginScan( ManagedRepository repository, Date whenGathered )
throws ConsumerException
{
- this.repositoryDir = new File( repository.getLocation() );
+ this.repositoryDir = new File( repository.getLocation( ) );
}
@Override
}
@Override
- public void completeScan()
+ public void completeScan( )
{
/* nothing to do */
}
@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;
}
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 )
{
}
@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( ) );
}
}
}
}
}
- 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 );
}
}
*/
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 );
}
}
{
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;
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 ) )
}
}
- 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;
}
{
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
{
{
try
{
- File artifactFile = new File( repository.getRepoRoot(), path );
+ File artifactFile = new File( repository.getRepoRoot( ), path );
- if ( !artifactFile.exists() )
+ if ( !artifactFile.exists( ) )
{
return;
}
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 )
}
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( ) );
}
}
// 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 );
/**
* 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;
@Named( value = "fileTypes" )
private FileTypes filetypes;
- private List<String> includes = new ArrayList<>();
+ private List<String> includes = new ArrayList<>( );
private RepositoryPurge repoPurge;
*
*/
@Inject
- @Autowired(required = false)
- private List<RepositoryListener> listeners = Collections.emptyList();
+ @Autowired( required = false )
+ private List<RepositoryListener> listeners = Collections.emptyList( );
@Inject
private RepositorySessionFactory repositorySessionFactory;
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;
}
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
}
catch ( RepositoryPurgeException rpe )
{
- throw new ConsumerException( rpe.getMessage(), rpe );
+ throw new ConsumerException( rpe.getMessage( ), rpe );
}
}
}
@Override
- public void completeScan()
+ public void completeScan( )
{
- repositorySession.close();
+ repositorySession.close( );
}
@Override
public void completeScan( boolean executeOnEntireRepo )
{
- completeScan();
+ completeScan( );
}
@Override
{
if ( ConfigurationNames.isRepositoryScanning( propertyName ) )
{
- initIncludes();
+ initIncludes( );
}
}
/* 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;
}
this.configuration = configuration;
}
- public RepositoryContentFactory getRepositoryContentFactory()
+ public RepositoryContentFactory getRepositoryContentFactory( )
{
return repositoryContentFactory;
}
this.repositoryContentFactory = repositoryContentFactory;
}
- public MetadataTools getMetadataTools()
+ public MetadataTools getMetadataTools( )
{
return metadataTools;
}
this.metadataTools = metadataTools;
}
- public FileTypes getFiletypes()
+ public FileTypes getFiletypes( )
{
return filetypes;
}
this.filetypes = filetypes;
}
- public RepositoryPurge getRepoPurge()
+ public RepositoryPurge getRepoPurge( )
{
return repoPurge;
}
this.repoPurge = repoPurge;
}
- public RepositoryPurge getCleanUp()
+ public RepositoryPurge getCleanUp( )
{
return cleanUp;
}
this.cleanUp = cleanUp;
}
- public boolean isDeleteReleasedSnapshots()
+ public boolean isDeleteReleasedSnapshots( )
{
return deleteReleasedSnapshots;
}
this.deleteReleasedSnapshots = deleteReleasedSnapshots;
}
- public RepositorySessionFactory getRepositorySessionFactory()
+ public RepositorySessionFactory getRepositorySessionFactory( )
{
return repositorySessionFactory;
}
this.repositorySessionFactory = repositorySessionFactory;
}
- public RepositorySession getRepositorySession()
+ public RepositorySession getRepositorySession( )
{
return repositorySession;
}
public class RepositoryPurgeException
extends Exception
{
- public RepositoryPurgeException()
+ public RepositoryPurgeException( )
{
- super();
+ super( );
}
public RepositoryPurgeException( String message, Throwable cause )
{
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 );
}
}
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;
}