protected void getTransfer()

in wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java [325:380]


    protected void getTransfer( Resource resource, File destination, InputStream input, boolean closeInput,
                                long maxSize )
        throws TransferFailedException
    {
        // ensure that the destination is created only when we are ready to transfer
        fireTransferDebug( "attempting to create parent directories for destination: " + destination.getName() );
        createParentDirectories( destination );

        fireGetStarted( resource, destination );

        OutputStream output = null;
        try
        {
            output = new LazyFileOutputStream( destination );
            getTransfer( resource, output, input, closeInput, maxSize );
            output.close();
            output = null;
        }
        catch ( final IOException e )
        {
            if ( destination.exists() )
            {
                boolean deleted = destination.delete();

                if ( !deleted )
                {
                    destination.deleteOnExit();
                }
            }

            fireTransferError( resource, e, TransferEvent.REQUEST_GET );

            String msg = "GET request of: " + resource.getName() + " from " + repository.getName() + " failed";

            throw new TransferFailedException( msg, e );
        }
        catch ( TransferFailedException e )
        {
            if ( destination.exists() )
            {
                boolean deleted = destination.delete();

                if ( !deleted )
                {
                    destination.deleteOnExit();
                }
            }
            throw e;
        }
        finally
        {
            IOUtil.close( output );
        }

        fireGetCompleted( resource, destination );
    }