protected void handleFile()

in archiva-jarinfo/archiva-jarinfo-cli/src/main/java/org/apache/archiva/jarinfo/bundler/JarInfoBundler.java [171:223]


    protected void handleFile( File file, int depth, Collection results )
        throws IOException
    {
        ArtifactRef ref = null;
        LOG.info( "Handle File " + file.getAbsolutePath() + ", depth:" + depth );
        
        try {
            ref = toArtifactRef( file );
            LOG.info( "Artifact: " + ref );
        } catch(IOException e) {
            LOG.warn("Invalid artifact: [" + file.getAbsolutePath() + "]: " + e.getMessage());
        } 

        try
        {
            File outputFile = new File( file.getAbsolutePath() + "info" );

            if ( !needsUpdating( outputFile ) )
            {
                LOG.info( "Skipping (up-to-date): " + outputFile.getName() );
                return;
            }
            
            analysisCount++;

            long start = System.nanoTime();
            LOG.info( "Analyzing: " + file.getName() + " ... " );
            JarDetails details = jarAnalysis.analyze( file );
            if ( !details.getAssignedId().valid() && (ref != null) )
            {
                // Inspected Ids have no value now.
                details.getInspectedIds().clearAll();
                // Set Assigned Ids.
                details.getAssignedId().setGroupId( ref.getGroupId() );
                details.getAssignedId().setArtifactId( ref.getArtifactId() );
                details.getAssignedId().setVersion( ref.getVersion() );
            }
            long mid = System.nanoTime();
            double seconds = ( ( (double) ( mid - start ) / 100000 ) / 1000 );
            LOG.info( "Scan of " + file.getName() + " completed in " + seconds + " second(s)" );

            ( new JarDetailsWriter() ).write( details, outputFile );
            addToBundle( outputFile );
        }
        catch ( IOException e )
        {
            LOG.warn( "Unable to analyze jar file [" + file.getAbsolutePath() + "]: " + e.getMessage(), e );
        }
        catch ( JarInfoException e )
        {
            LOG.warn( "Unable to write jarinfo for file [" + file.getAbsolutePath() + "]: " + e.getMessage(), e );
        }
    }