}
public void putDirectory( Wagon wagon, File sourceDirectory, String destinationDirectory )
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
{
Repository repository = wagon.getRepository();
String basedir = repository.getBasedir();
String destDir = StringUtils.replace( destinationDirectory, "\\", "/" );
String path = getPath( basedir, destDir );
try
{
if ( repository.getPermissions() != null )
{
String dirPerms = repository.getPermissions().getDirectoryMode();
if ( dirPerms != null )
{
String umaskCmd = "umask " + PermissionModeUtils.getUserMaskFor( dirPerms );
executor.executeCommand( umaskCmd );
}
}
//String mkdirCmd = "mkdir -p " + path;
String mkdirCmd = "mkdir -p \"" + path + "\"";
executor.executeCommand( mkdirCmd );
}
catch ( CommandExecutionException e )
{
throw new TransferFailedException( "Error performing commands for file transfer", e );
}
File zipFile;
try
{
zipFile = File.createTempFile( "wagon", ".zip" );
zipFile.deleteOnExit();
List<String> files = FileUtils.getFileNames( sourceDirectory, "**/**", "", false );
createZip( files, zipFile, sourceDirectory );
}
catch ( IOException e )
{
throw new TransferFailedException( "Unable to create ZIP archive of directory", e );
}
wagon.put( zipFile, getPath( destDir, zipFile.getName() ) );
try
{
//executor.executeCommand(
// "cd " + path + "; unzip -q -o " + zipFile.getName() + "; rm -f " + zipFile.getName() );
executor.executeCommand( "cd \"" + path + "\"; unzip -q -o \"" + zipFile.getName() + "\"; rm -f \"" + zipFile.getName() + "\"" );
zipFile.delete();
RepositoryPermissions permissions = repository.getPermissions();
if ( permissions != null && permissions.getGroup() != null )
{
//executor.executeCommand( "chgrp -Rf " + permissions.getGroup() + " " + path );
executor.executeCommand( "chgrp -Rf " + permissions.getGroup() + " \"" + path + "\"" );