public void processFile()

in archive-releases-consumer/src/main/java/org/apache/archiva/plugins/archivereleases/ArchiveReleasesConsumer.java [172:258]


    public void processFile( String path, boolean executeOnEntireRepo )
        throws ConsumerException
    {
        File artifactFile = new File( repository.getLocation(), path );

        // NOTE: as below, assumes a Maven 2 repository layout
        if ( artifactFile.getParentFile().getName().endsWith( "-SNAPSHOT" ) )
        {
            log.debug( "Skipping entry [" + path + "] as it appears to be a snapshot" );
            return;
        }

        if ( filetypes.matchesDefaultExclusions( path ) )
        {
            log.debug( "Skipping entry [" + path + "] as it is in the default exclusions" );
            return;
        }

        if ( !matchesList( whitelist, path ) )
        {
            log.debug( "Skipping entry [" + path + "] as it does not match whitelist" );
            return;
        }

        if ( matchesList( blacklist, path ) )
        {
            log.debug( "Skipping entry [" + path + " as it matches the blacklist" );
            return;
        }

        if ( fileNewerThanTarget( artifactFile ) )
        {
            log.debug( "Skipping entry [" + path + "] from repository [" + repository.getId()
                           + "] as it is newer than the target of " + olderThan );
            return;
        }

        // look at other files in the directory, if any are new then don't archive
        // NOTE: this assumes a Maven 2 repository layout - would be good to get the repository API properly extracted
        //  without depending on the metadata storage
        File dir = artifactFile.getParentFile();
        for ( File f : dir.listFiles() )
        {
            if ( !filetypes.matchesDefaultExclusions( f.getName() ) )
            {
                if ( matchesList( includes, f.getName() ) )
                {
                    if ( fileNewerThanTarget( f ) )
                    {
                        log.debug( "Skipping entry [" + path + "] from repository [" + repository.getId()
                                       + "] as another artifact file [" + f.getName() + "] is newer than the target of "
                                       + olderThan );
                        return;
                    }
                }
                else
                {
                    // File that is not an artifact and not excluded is not going to get found
                    log.warn( "Skipping entry [" + path + "] from repository [" + repository.getId()
                                  + "] due to immovable file [" + f.getName() + "]" );
                    return;
                }
            }
        }

        totalSize += artifactFile.length();

        File targetFile = new File( repositoryArchive, path );
        if ( dryRun )
        {
            log.info( "DRY RUN: would archive file [" + artifactFile.getAbsolutePath() + "] to [" + targetFile + "]" );
        }
        else
        {
            log.info( "archiving file [" + artifactFile.getAbsolutePath() + "] to [" + targetFile + "]" );

            try
            {
                FileUtils.moveFileToDirectory( artifactFile, targetFile.getParentFile(), true );
            }
            catch ( IOException e )
            {
                log.error(
                    "Error moving file [" + artifactFile.getAbsolutePath() + "] to [" + targetFile + "]: " + e.getLocalizedMessage(), e );
            }
        }
    }