maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r660586 - in /maven/wagon/trunk: wagon-provider-api/src/main/java/org/apache/maven/wagon/ wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/ wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wa...
Date Tue, 27 May 2008 16:27:56 GMT
Author: brett
Date: Tue May 27 09:27:39 2008
New Revision: 660586

URL: http://svn.apache.org/viewvc?rev=660586&view=rev
Log:
[WAGON-100] add some consistency to error firing:
- no events fired from resourceExists / directory operations (other than the file-by-file
ones)
- make sure all outgoing exceptions fire an error (session or transfer) and are not duplicated
- other clean up

Modified:
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java
    maven/wagon/trunk/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
    maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
    maven/wagon/trunk/wagon-providers/wagon-s3/src/main/java/org/apache/maven/wagon/providers/s3/AbstractS3Wagon.java
    maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
    maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java
    maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java
    maven/wagon/trunk/wagon-providers/wagon-ssh-ganymed/src/main/java/org/apache/maven/wagon/providers/ssh/ganymed/AbstractGanymedWagon.java
    maven/wagon/trunk/wagon-providers/wagon-ssh-ganymed/src/main/java/org/apache/maven/wagon/providers/ssh/ganymed/ScpWagon.java
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java
    maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
(original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
Tue May 27 09:27:39 2008
@@ -97,7 +97,22 @@
     public void openConnection()
         throws ConnectionException, AuthenticationException
     {
-        openConnectionInternal();
+        try
+        {
+            openConnectionInternal();
+        }
+        catch ( ConnectionException e )
+        {
+            fireSessionConnectionRefused();
+            
+            throw e;
+        }
+        catch ( AuthenticationException e )
+        {
+            fireSessionConnectionRefused();
+            
+            throw e;
+        }
     }
 
     public void connect( Repository repository )
@@ -178,7 +193,22 @@
         
         fireSessionOpening();
 
-        openConnectionInternal();
+        try
+        {
+            openConnectionInternal();
+        }
+        catch ( ConnectionException e )
+        {
+            fireSessionConnectionRefused();
+            
+            throw e;
+        }
+        catch ( AuthenticationException e )
+        {
+            fireSessionConnectionRefused();
+            
+            throw e;
+        }
 
         fireSessionOpened();
     }
@@ -191,7 +221,15 @@
     {
         fireSessionDisconnecting();
 
-        closeConnection();
+        try
+        {
+            closeConnection();
+        }
+        catch ( ConnectionException e )
+        {
+            fireSessionError( e );
+            throw e;
+        }
 
         fireSessionDisconnected();
     }
@@ -328,6 +366,8 @@
         }
         catch ( FileNotFoundException e )
         {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
             throw new TransferFailedException( "Specified source file does not exist: " +
source, e );
         }
         catch ( IOException e )
@@ -563,7 +603,6 @@
 
     protected void fireSessionConnectionRefused()
     {
-
         long timestamp = System.currentTimeMillis();
 
         SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_CONNECTION_REFUSED
);
@@ -684,6 +723,8 @@
         }
         catch ( IOException e )
         {
+            fireTransferError( resource, e, requestType );
+            
             throw new TransferFailedException( "Failed to post-process the source file",
e );
         }
     }
@@ -691,7 +732,7 @@
     public void putDirectory( File sourceDirectory, String destinationDirectory )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
-        throw new TransferFailedException( "directory copy not supported for " + getClass().getName()
);
+        throw new UnsupportedOperationException( "The wagon you are using has not implemented
putDirectory()" );
     }
 
     public boolean supportsDirectoryCopy()
@@ -741,7 +782,6 @@
                 jar.write( buffer, 0, bytesRead );
             }
         }
-
         finally
         {
             is.close();

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java
(original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java
Tue May 27 09:27:39 2008
@@ -24,6 +24,7 @@
 import java.io.OutputStream;
 
 import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
 import org.apache.maven.wagon.resource.Resource;
 import org.codehaus.plexus.util.IOUtil;
 
@@ -64,14 +65,30 @@
 
         inputData.setResource( resource );
 
-        fillInputData( inputData );
+        try
+        {
+            fillInputData( inputData );
+        }
+        catch ( TransferFailedException e )
+        {
+            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+            throw e;
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+            throw e;
+        }
 
         InputStream is = inputData.getInputStream();
 
         if ( is == null )
         {
-            throw new TransferFailedException(
-                getRepository().getUrl() + " - Could not open input stream for resource:
'" + resource + "'" );
+            TransferFailedException e =
+                new TransferFailedException( getRepository().getUrl()
+                    + " - Could not open input stream for resource: '" + resource + "'" );
+            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+            throw e;
         }
 
         createParentDirectories( destination );
@@ -90,7 +107,20 @@
 
         inputData.setResource( resource );
 
-        fillInputData( inputData );
+        try
+        {
+            fillInputData( inputData );
+        }
+        catch ( TransferFailedException e )
+        {
+            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+            throw e;
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+            throw e;
+        }
 
         InputStream is = inputData.getInputStream();
 
@@ -101,8 +131,11 @@
 
             if ( is == null )
             {
-                throw new TransferFailedException(
-                    getRepository().getUrl() + " - Could not open input stream for resource:
'" + resource + "'" );
+                TransferFailedException e =
+                    new TransferFailedException( getRepository().getUrl()
+                        + " - Could not open input stream for resource: '" + resource + "'"
);
+                fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+                throw e;
             }
 
             createParentDirectories( destination );
@@ -117,7 +150,6 @@
         return retValue;
     }
 
-
     // source doesn't exist exception
     public void put( File source, String resourceName )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
@@ -130,14 +162,26 @@
 
         outputData.setResource( resource );
 
-        fillOutputData( outputData );
+        try
+        {
+            fillOutputData( outputData );
+        }
+        catch ( TransferFailedException e )
+        {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+            throw e;
+        }
 
         OutputStream os = outputData.getOutputStream();
 
         if ( os == null )
         {
-            throw new TransferFailedException(
-                getRepository().getUrl() + " - Could not open output stream for resource:
'" + resource + "'" );
+            TransferFailedException e =
+                new TransferFailedException( getRepository().getUrl()
+                    + " - Could not open output stream for resource: '" + resource + "'"
);
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+            throw e;
         }
 
         putTransfer( outputData.getResource(), source, os, true );

Modified: maven/wagon/trunk/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java
Tue May 27 09:27:39 2008
@@ -128,14 +128,8 @@
 
             if ( !FTPReply.isPositiveCompletion( reply ) )
             {
-                fireSessionConnectionRefused();
-
-                fireSessionDisconnecting();
-
                 ftp.disconnect();
 
-                fireSessionDisconnected();
-
                 throw new AuthenticationException( "FTP server refused connection." );
             }
         }
@@ -147,11 +141,7 @@
                 {
                     fireSessionError( e );
 
-                    fireSessionDisconnecting();
-
                     ftp.disconnect();
-
-                    fireSessionDisconnected();
                 }
                 catch ( IOException f )
                 {
@@ -166,8 +156,6 @@
         {
             if ( !ftp.login( username, password ) )
             {
-                fireSessionConnectionRefused();
-
                 throw new AuthenticationException( "Cannot login to remote system" );
             }
 
@@ -220,7 +208,6 @@
         super.firePutCompleted( resource, file );
     }
 
-
     protected void fireGetCompleted( Resource resource, File localFile )
     {
         try
@@ -254,7 +241,6 @@
         }
     }
 
-
     public void fillOutputData( OutputData outputData )
         throws TransferFailedException
     {
@@ -405,7 +391,6 @@
         }
     }
 
-
     public class PrintCommandListener
         implements ProtocolCommandListener
     {

Modified: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
Tue May 27 09:27:39 2008
@@ -42,6 +42,7 @@
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.authentication.AuthenticationException;
 import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
 import org.apache.maven.wagon.proxy.ProxyInfo;
 import org.apache.maven.wagon.resource.Resource;
 import org.apache.maven.wagon.shared.http.HtmlFileListParser;
@@ -202,6 +203,8 @@
         }
         catch ( IOException e )
         {
+            fireTransferError( new Resource( resourceName ), e, TransferEvent.REQUEST_PUT
);
+            
             throw new TransferFailedException( "Error transferring file", e );
         }
     }

Modified: maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
Tue May 27 09:27:39 2008
@@ -37,6 +37,7 @@
 import org.apache.commons.httpclient.HostConfiguration;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
@@ -182,7 +183,17 @@
                 getMethod.addRequestHeader( hdr );
             }
 
-            int statusCode = execute( getMethod );
+            int statusCode;
+            try
+            {
+                statusCode = execute( getMethod );
+            }
+            catch ( IOException e )
+            {
+                fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+                throw new TransferFailedException( e.getMessage(), e );
+            }
 
             fireTransferDebug( url + " - Status code: " + statusCode );
 
@@ -196,24 +207,36 @@
                     return false;
 
                 case SC_NULL:
-                    throw new TransferFailedException( "Failed to transfer file: " + url
);
+                {
+                    TransferFailedException e = new TransferFailedException( "Failed to transfer
file: " + url );
+                    fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+                    throw e;
+                }
 
                 case HttpStatus.SC_FORBIDDEN:
+                    fireSessionConnectionRefused();
                     throw new AuthorizationException( "Access denied to: " + url );
 
                 case HttpStatus.SC_UNAUTHORIZED:
+                    fireSessionConnectionRefused();
                     throw new AuthorizationException( "Not authorized." );
 
                 case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
+                    fireSessionConnectionRefused();
                     throw new AuthorizationException( "Not authorized by proxy." );
 
                 case HttpStatus.SC_NOT_FOUND:
                     throw new ResourceDoesNotExistException( "File: " + url + " does not
exist" );
 
-                    //add more entries here
+                //add more entries here
                 default :
-                    throw new TransferFailedException(
-                        "Failed to transfer file: " + url + ". Return code is: " + statusCode
);
+                {
+                    TransferFailedException e =
+                            new TransferFailedException( "Failed to transfer file: " + url
+ ". Return code is: "
+                                + statusCode );
+                    fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+                    throw e;
+                }
             }
 
             InputStream is = null;
@@ -357,7 +380,17 @@
         {
             firePutStarted( resource, source );
             
-            int statusCode = execute( putMethod );
+            int statusCode;
+            try
+            {
+                statusCode = execute( putMethod );
+            }
+            catch ( IOException e )
+            {
+                fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+                throw new TransferFailedException( e.getMessage(), e );
+            }
 
             fireTransferDebug( url + " - Status code: " + statusCode );
 
@@ -372,27 +405,37 @@
                     break;
 
                 case SC_NULL:
-                    throw new TransferFailedException( "Failed to transfer file: " + url
);
+                {
+                    TransferFailedException e = new TransferFailedException( "Failed to transfer
file: " + url );
+                    fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+                    throw e;
+                }
 
                 case HttpStatus.SC_FORBIDDEN:
+                    fireSessionConnectionRefused();
                     throw new AuthorizationException( "Access denied to: " + url );
 
                 case HttpStatus.SC_NOT_FOUND:
                     throw new ResourceDoesNotExistException( "File: " + url + " does not
exist" );
 
-                    //add more entries here
+                //add more entries here
                 default :
-                    throw new TransferFailedException(
-                        "Failed to transfer file: " + url + ". Return code is: " + statusCode
);
+                {
+                    TransferFailedException e =
+                            new TransferFailedException( "Failed to transfer file: " + url
+ ". Return code is: "
+                                + statusCode );
+                    fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+                    throw e;
+                }
             }
 
-            putMethod.releaseConnection();
-
             firePutCompleted( resource, source );
         }
         finally
         {
             IOUtil.close(is);
+            
+            putMethod.releaseConnection();
         }
     }
 
@@ -401,7 +444,15 @@
     {
         String url = getRepository().getUrl() + "/" + resourceName;
         HeadMethod headMethod = new HeadMethod( url );
-        int statusCode = execute( headMethod );
+        int statusCode;
+        try
+        {
+            statusCode = execute( headMethod );
+        }
+        catch ( IOException e )
+        {
+            throw new TransferFailedException( e.getMessage(), e );
+        }
         try
         {
             switch ( statusCode )
@@ -439,21 +490,12 @@
         }
     }
 
-    protected int execute(HttpMethod httpMethod)
-        throws TransferFailedException
+    protected int execute(HttpMethod httpMethod) throws HttpException, IOException
     {
         int statusCode = SC_NULL;
         httpMethod.getParams().setSoTimeout( getTimeout() );
         setHeaders(httpMethod);
-        try
-        {
-            // execute the method.
-            statusCode = client.executeMethod( httpMethod );
-        }
-        catch ( IOException e )
-        {
-            throw new TransferFailedException( e.getMessage(), e );
-        }
+        statusCode = client.executeMethod( httpMethod );
         return statusCode;
     }
 

Modified: maven/wagon/trunk/wagon-providers/wagon-s3/src/main/java/org/apache/maven/wagon/providers/s3/AbstractS3Wagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-s3/src/main/java/org/apache/maven/wagon/providers/s3/AbstractS3Wagon.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-s3/src/main/java/org/apache/maven/wagon/providers/s3/AbstractS3Wagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-s3/src/main/java/org/apache/maven/wagon/providers/s3/AbstractS3Wagon.java
Tue May 27 09:27:39 2008
@@ -135,6 +135,8 @@
         }
         catch( IOException e )
         {
+            fireTransferError( resource, e, TransferEvent.REQUEST_GET );            
+            
             throw new TransferFailedException( "", e );
         }
 
@@ -151,19 +153,21 @@
         try
         {
             s3Object = s3Service.getObjectDetails( bucket, resource.getName() );
+        }
+        catch ( S3ServiceException e )
+        {
+            fireTransferError( resource, e, TransferEvent.REQUEST_GET );            
+            
+            throw new TransferFailedException( "Cannot get object from S3", e );
+        }
 
-            Date lastModified = s3Object.getLastModifiedDate();
-
-            if( lastModified.getTime() > timestamp )
-            {
-                get( resourceName, destination );
+        Date lastModified = s3Object.getLastModifiedDate();
 
-                return true;
-            }
-        }
-        catch( S3ServiceException e )
+        if ( lastModified.getTime() > timestamp )
         {
-            throw new TransferFailedException( "Cannot put object to S3", e );
+            get( resourceName, destination );
+
+            return true;
         }
 
         return false;
@@ -201,6 +205,8 @@
         }
         catch( S3ServiceException e )
         {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
             throw new TransferFailedException( "Cannot put object to S3", e );
         }
 

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
Tue May 27 09:27:39 2008
@@ -373,7 +373,7 @@
             }
         }
 
-        String msg = "Error occured while downloading '" + resource + "' from the remote
repository:" + getRepository();
+        String msg = "Error occured while downloading '" + resource + "' from the remote
repository:" + getRepository() + ": " + e.getMessage();
 
         throw new TransferFailedException( msg, e );
     }

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java
Tue May 27 09:27:39 2008
@@ -22,7 +22,6 @@
 import org.apache.maven.wagon.CommandExecutionException;
 import org.apache.maven.wagon.CommandExecutor;
 import org.apache.maven.wagon.PermissionModeUtils;
-import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.repository.RepositoryPermissions;
 
 public class ScpHelper
@@ -33,33 +32,26 @@
 
     public static void createRemoteDirectories( String path, RepositoryPermissions permissions,
                                                 CommandExecutor commandExecutor )
-        throws TransferFailedException
+        throws CommandExecutionException
     {
-        try
+        String umaskCmd = null;
+        if ( permissions != null )
         {
-            String umaskCmd = null;
-            if ( permissions != null )
-            {
-                String dirPerms = permissions.getDirectoryMode();
-
-                if ( dirPerms != null )
-                {
-                    umaskCmd = "umask " + PermissionModeUtils.getUserMaskFor( dirPerms );
-                }
-            }
-
-            String mkdirCmd = "mkdir -p " + path;
+            String dirPerms = permissions.getDirectoryMode();
 
-            if ( umaskCmd != null )
+            if ( dirPerms != null )
             {
-                mkdirCmd = umaskCmd + "; " + mkdirCmd;
+                umaskCmd = "umask " + PermissionModeUtils.getUserMaskFor( dirPerms );
             }
-
-            commandExecutor.executeCommand( mkdirCmd );
         }
-        catch ( CommandExecutionException e )
+
+        String mkdirCmd = "mkdir -p " + path;
+
+        if ( umaskCmd != null )
         {
-            throw new TransferFailedException( "Error performing commands for file transfer",
e );
+            mkdirCmd = umaskCmd + "; " + mkdirCmd;
         }
+
+        commandExecutor.executeCommand( mkdirCmd );
     }
 }

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java
Tue May 27 09:27:39 2008
@@ -212,7 +212,7 @@
     }
 
 
-    private void executeScpCommand( File localFile, String remoteFile, boolean put )
+    private void executeScpCommand( Resource resource, File localFile, boolean put )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
         boolean putty = scpExecutable.indexOf( "pscp" ) >= 0;
@@ -224,6 +224,8 @@
         }
         catch ( FileNotFoundException e )
         {
+            fireSessionConnectionRefused();
+            
             throw new AuthorizationException( e.getMessage() );
         }
         Commandline cl = createBaseCommandLine( putty, scpExecutable, privateKey );
@@ -240,6 +242,10 @@
         {
             cl.createArgument().setLine( scpArgs );
         }
+        
+        String resourceName = normalizeResource( resource );
+        String remoteFile = getRepository().getBasedir() + "/" + resourceName;
+        
         String qualifiedRemoteFile = this.buildRemoteHost() + ":" + remoteFile;
         if ( put )
         {
@@ -266,16 +272,27 @@
                 }
                 else
                 {
-                    throw new TransferFailedException( "Exit code: " + exitCode + " - " +
err.getOutput() );
+                    TransferFailedException e = new TransferFailedException( "Exit code:
" + exitCode + " - " + err.getOutput() );
+
+                    fireTransferError( resource, e, put ? TransferEvent.REQUEST_PUT : TransferEvent.REQUEST_GET
);
+
+                    throw e;
                 }
             }
         }
         catch ( CommandLineException e )
         {
+            fireTransferError( resource, e, put ? TransferEvent.REQUEST_PUT : TransferEvent.REQUEST_GET
);
+
             throw new TransferFailedException( "Error executing command line", e );
         }
     }
 
+    private String normalizeResource( Resource resource )
+    {
+        return StringUtils.replace( resource.getName(), "\\", "/" );
+    }
+
     public void put( File source, String destination )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
@@ -285,7 +302,7 @@
 
         if ( !source.exists() )
         {
-            throw new TransferFailedException( "Specified source file does not exist: " +
source );
+            throw new ResourceDoesNotExistException( "Specified source file does not exist:
" + source );
         }
 
         String basedir = getRepository().getBasedir();
@@ -320,6 +337,8 @@
         }
         catch ( CommandExecutionException e )
         {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+            
             throw new TransferFailedException( "Error executing command for transfer", e
);
         }
         
@@ -329,7 +348,7 @@
 
         firePutStarted( resource, source );
 
-        executeScpCommand( source, basedir + "/" + resourceName, true );
+        executeScpCommand( resource, source, true );
 
         postProcessListeners( resource, source, TransferEvent.REQUEST_PUT );
 
@@ -352,6 +371,8 @@
         }
         catch ( CommandExecutionException e )
         {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
             throw new TransferFailedException( "Error executing command for transfer", e
);
         }
         firePutCompleted( resource, source );
@@ -378,7 +399,7 @@
 
         fireGetStarted( resource, destination );
 
-        executeScpCommand( destination, basedir + "/" + path, false );
+        executeScpCommand( resource, destination, false );
 
         postProcessListeners( resource, destination, TransferEvent.REQUEST_GET );
 

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh-ganymed/src/main/java/org/apache/maven/wagon/providers/ssh/ganymed/AbstractGanymedWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh-ganymed/src/main/java/org/apache/maven/wagon/providers/ssh/ganymed/AbstractGanymedWagon.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-ganymed/src/main/java/org/apache/maven/wagon/providers/ssh/ganymed/AbstractGanymedWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-ganymed/src/main/java/org/apache/maven/wagon/providers/ssh/ganymed/AbstractGanymedWagon.java
Tue May 27 09:27:39 2008
@@ -130,7 +130,6 @@
         }
         catch ( IOException e )
         {
-            fireSessionError( e );
             throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(),
e );
         }
 
@@ -162,7 +161,6 @@
         catch ( IOException e )
         {
             closeConnection();
-            fireSessionError( e );
             throw new AuthenticationException( "Cannot authenticate. Reason: " + e.getMessage(),
e );
         }
     }

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh-ganymed/src/main/java/org/apache/maven/wagon/providers/ssh/ganymed/ScpWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh-ganymed/src/main/java/org/apache/maven/wagon/providers/ssh/ganymed/ScpWagon.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-ganymed/src/main/java/org/apache/maven/wagon/providers/ssh/ganymed/ScpWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-ganymed/src/main/java/org/apache/maven/wagon/providers/ssh/ganymed/ScpWagon.java
Tue May 27 09:27:39 2008
@@ -94,6 +94,8 @@
         }
         catch ( CommandExecutionException e )
         {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+            
             throw new TransferFailedException( "Error performing commands for file transfer",
e );
         }
 
@@ -113,6 +115,8 @@
         }
         catch ( IOException e )
         {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
             throw new TransferFailedException( "Error transferring file. Reason: " + e.getMessage(),
e );
         }
 
@@ -129,6 +133,8 @@
         }
         catch ( CommandExecutionException e )
         {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
             throw new TransferFailedException( "Error performing commands for file transfer",
e );
         }
     }
@@ -153,6 +159,8 @@
         }
         catch ( FileNotFoundException e )
         {
+            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
             throw new TransferFailedException( "Error writing output file. Reason: " + e.getMessage(),
e );
         }
 
@@ -176,6 +184,8 @@
             }
             else
             {
+                fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
                 throw new TransferFailedException( "Error transferring file. Reason: " +
e.getMessage(), e );
             }
         }

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
Tue May 27 09:27:39 2008
@@ -25,6 +25,7 @@
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
 import org.apache.maven.wagon.providers.ssh.ScpHelper;
 import org.apache.maven.wagon.repository.RepositoryPermissions;
 import org.apache.maven.wagon.resource.Resource;
@@ -68,28 +69,30 @@
 
         firePutInitiated( resource, source );
 
-        ScpHelper.createRemoteDirectories( getPath( basedir, dir ), getRepository().getPermissions(),
this );
+        try
+        {
+            ScpHelper.createRemoteDirectories( getPath( basedir, dir ), getRepository().getPermissions(),
this );
 
-        RepositoryPermissions permissions = getRepository().getPermissions();
+            RepositoryPermissions permissions = getRepository().getPermissions();
 
-        put( source, basedir, resource, getOctalMode( permissions ) );
+            put( source, basedir, resource, getOctalMode( permissions ) );
 
-        setFileGroup( permissions, basedir, resource );
+            setFileGroup( permissions, basedir, resource );
+        }
+        catch ( CommandExecutionException e )
+        {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+            
+            throw new TransferFailedException( e.getMessage(), e );
+        }
     }
 
     private void setFileGroup( RepositoryPermissions permissions, String basedir, Resource
resource )
-        throws TransferFailedException
+        throws CommandExecutionException
     {
-        try
+        if ( permissions != null && permissions.getGroup() != null )
         {
-            if ( permissions != null && permissions.getGroup() != null )
-            {
-                executeCommand( "chgrp -f " + permissions.getGroup() + " " + getPath( basedir,
resource.getName() ) );
-            }
-        }
-        catch ( CommandExecutionException e )
-        {
-            throw new TransferFailedException( "Error performing commands for file transfer",
e );
+            executeCommand( "chgrp -f " + permissions.getGroup() + " " + getPath( basedir,
resource.getName() ) );
         }
     }
 
@@ -179,15 +182,19 @@
         }
         catch ( IOException e )
         {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );            
+            
             String msg = "Error occured while deploying '" + resourceName + "' to remote
repository: " +
-                getRepository().getUrl();
+                getRepository().getUrl() + ": " + e.getMessage();
 
             throw new TransferFailedException( msg, e );
         }
         catch ( JSchException e )
         {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );            
+            
             String msg = "Error occured while deploying '" + resourceName + "' to remote
repository: " +
-                getRepository().getUrl();
+                getRepository().getUrl() + ": " + e.getMessage();
 
             throw new TransferFailedException( msg, e );
         }
@@ -203,26 +210,26 @@
     }
 
     private void checkAck( InputStream in )
-        throws IOException, TransferFailedException
+        throws IOException
     {
         int code = in.read();
         if ( code == -1 )
         {
-            throw new TransferFailedException( "Unexpected end of data" );
+            throw new IOException( "Unexpected end of data" );
         }
         else if ( code == 1 )
         {
             String line = readLine( in );
 
-            throw new TransferFailedException( "SCP terminated with error: '" + line + "'"
);
+            throw new IOException( "SCP terminated with error: '" + line + "'" );
         }
         else if ( code == 2 )
         {
-            throw new TransferFailedException( "SCP terminated with error (code: " + code
+ ")" );
+            throw new IOException( "SCP terminated with error (code: " + code + ")" );
         }
         else if ( code != 0 )
         {
-            throw new TransferFailedException( "SCP terminated with unknown error code" );
+            throw new IOException( "SCP terminated with unknown error code" );
         }
     }
 
@@ -274,7 +281,7 @@
                 }
                 else
                 {
-                    throw new TransferFailedException( "Exit code: " + exitCode + " - " +
line );
+                    throw new IOException( "Exit code: " + exitCode + " - " + line );
                 }
             }
 
@@ -288,13 +295,13 @@
 
             if ( line.charAt( 4 ) != ACK_SEPARATOR && line.charAt( 5 ) != ACK_SEPARATOR
)
             {
-                throw new TransferFailedException( "Invalid transfer header: " + line );
+                throw new IOException( "Invalid transfer header: " + line );
             }
 
             int index = line.indexOf( ACK_SEPARATOR, 5 );
             if ( index < 0 )
             {
-                throw new TransferFailedException( "Invalid transfer header: " + line );
+                throw new IOException( "Invalid transfer header: " + line );
             }
 
             int filesize = Integer.valueOf( line.substring( 5, index ) ).intValue();
@@ -311,7 +318,7 @@
 
             if ( destination.length() != filesize )
             {
-                throw new TransferFailedException(
+                throw new IOException(
                     "Expected file length: " + filesize + "; received = " + destination.length()
);
             }
 

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java
Tue May 27 09:27:39 2008
@@ -78,9 +78,18 @@
 
             channel.cd( "/" );
             
-            mkdirs( channel, basedir + "/", directoryMode );
-            
-            mkdirs( channel, resourceName, directoryMode );
+            try
+            {
+                mkdirs( channel, basedir + "/", directoryMode );
+                
+                mkdirs( channel, resourceName, directoryMode );
+            }
+            catch ( TransferFailedException e )
+            {
+                fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+                throw e;
+            }
 
             putFile( channel, source, resource, permissions );
 
@@ -92,6 +101,8 @@
         }
         catch ( SftpException e )
         {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+            
             String msg = "Error occured while deploying '" + resourceName + "' " + "to remote
repository: " +
                 getRepository().getUrl();
 
@@ -99,6 +110,8 @@
         }
         catch ( JSchException e )
         {
+            fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
             String msg = "Error occured while deploying '" + resourceName + "' " + "to remote
repository: " +
                 getRepository().getUrl();
 
@@ -172,7 +185,7 @@
     }
 
     private void mkdirs( ChannelSftp channel, String resourceName, int mode )
-        throws TransferFailedException, SftpException
+        throws SftpException, TransferFailedException
     {
         String[] dirs = PathUtils.dirnames( resourceName );
         for ( int i = 0; i < dirs.length; i++ )

Modified: maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java?rev=660586&r1=660585&r2=660586&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
Tue May 27 09:27:39 2008
@@ -25,6 +25,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.DavException;
@@ -40,6 +41,7 @@
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
 import org.apache.maven.wagon.repository.Repository;
 import org.apache.maven.wagon.resource.Resource;
 import org.apache.maven.wagon.shared.http.AbstractHttpClientWagon;
@@ -97,7 +99,14 @@
         firePutInitiated( resource, source );
 
         //Parent directories need to be created before posting
-        mkdirs( dir );
+        try
+        {
+            mkdirs( dir );
+        }
+        catch ( IOException e )
+        {
+            fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+        }
 
         super.put(source, resource);
     }
@@ -117,10 +126,11 @@
      * They are created one at a time until the whole path exists.
      *
      * @param dir path to be created in server from repository basedir
+     * @throws IOException 
+     * @throws HttpException 
      * @throws TransferFailedException
      */
-    private void mkdirs( String dir )
-        throws TransferFailedException
+    private void mkdirs( String dir ) throws HttpException, IOException
     {
         Repository repository = getRepository();
         String basedir = repository.getBasedir();
@@ -150,12 +160,12 @@
             status = doMkCol( url );
             if ( status != HttpStatus.SC_OK && status != HttpStatus.SC_CREATED )
             {
-                throw new TransferFailedException( "Unable to create collection: " + url
+ "; status code = " + status );
+                throw new IOException( "Unable to create collection: " + url + "; status
code = " + status );
             }
         }
     }
 
-    private int doMkCol(String url) throws TransferFailedException
+    private int doMkCol(String url) throws HttpException, IOException
     {
         MkColMethod method = null;
         try
@@ -205,7 +215,7 @@
 
     }
 
-    private boolean isDirectory(String url) throws TransferFailedException
+    private boolean isDirectory( String url ) throws IOException, DavException
     {
         DavPropertyNameSet nameSet = new DavPropertyNameSet();
         nameSet.add(DavPropertyName.create(DavConstants.PROPERTY_RESOURCETYPE));
@@ -229,14 +239,6 @@
             }
             return false;
         }
-        catch (DavException e)
-        {
-            throw new TransferFailedException(e.getMessage(), e);
-        }
-        catch (IOException e)
-        {
-            throw new TransferFailedException(e.getMessage(), e);
-        }
         finally
         {
             if (method != null) method.releaseConnection();
@@ -247,10 +249,10 @@
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
         final String url = getRepository().getUrl() + '/' + destinationDirectory;
-        if (isDirectory(url))
+        PropFindMethod method = null;
+        try
         {
-            PropFindMethod method = null;
-            try
+            if (isDirectory(url))
             {
                 DavPropertyNameSet nameSet = new DavPropertyNameSet();
                 nameSet.add(DavPropertyName.create(DavConstants.PROPERTY_DISPLAYNAME));
@@ -279,18 +281,18 @@
                     throw new ResourceDoesNotExistException( "Destination directory does
not exist: " + url ); 
                 }
             }
-            catch (DavException e)
-            {
-                throw new TransferFailedException(e.getMessage(), e);
-            }
-            catch (IOException e)
-            {
-                throw new TransferFailedException(e.getMessage(), e); 
-            }
-            finally
-            {
-                if (method != null) method.releaseConnection();
-            }
+        }
+        catch (DavException e)
+        {
+            throw new TransferFailedException(e.getMessage(), e);
+        }
+        catch (IOException e)
+        {
+            throw new TransferFailedException(e.getMessage(), e); 
+        }
+        finally
+        {
+            if (method != null) method.releaseConnection();
         }
         throw new ResourceDoesNotExistException("Destination path exists but is not a " +
"WebDAV collection (directory): " + url );
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-commits-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-commits-help@maven.apache.org


Mime
View raw message