Map sums = new HashMap( 2 );
// TODO: configure these on the repository
try
{
ChecksumObserver checksumObserver = new ChecksumObserver( "MD5" );
wagon.addTransferListener( checksumObserver );
checksums.put( "md5", checksumObserver );
checksumObserver = new ChecksumObserver( "SHA-1" );
wagon.addTransferListener( checksumObserver );
checksums.put( "sha1", checksumObserver );
}
catch ( NoSuchAlgorithmException e )
{
throw new TransferFailedException( "Unable to add checksum methods: " + e.getMessage(), e );
}
try
{
Repository artifactRepository = new Repository( repository.getId(), repository.getUrl() );
if ( serverPermissionsMap.containsKey( repository.getId() ) )
{
RepositoryPermissions perms = (RepositoryPermissions) serverPermissionsMap.get( repository.getId() );
getLogger().debug(
"adding permissions to wagon connection: " + perms.getFileMode() + " " + perms.getDirectoryMode() );
artifactRepository.setPermissions( perms );
}
else
{
getLogger().debug( "not adding permissions to wagon connection" );
}
wagon.connect( artifactRepository, getAuthenticationInfo( repository.getId() ), getProxy( protocol ) );
wagon.put( source, remotePath );
wagon.removeTransferListener( downloadMonitor );
// Pre-store the checksums as any future puts will overwrite them
for ( Iterator i = checksums.keySet().iterator(); i.hasNext(); )
{
String extension = (String) i.next();
ChecksumObserver observer = (ChecksumObserver) checksums.get( extension );
sums.put( extension, observer.getActualChecksum() );
}
// We do this in here so we can checksum the artifact metadata too, otherwise it could be metadata itself
for ( Iterator i = checksums.keySet().iterator(); i.hasNext(); )
{