maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r312531 - in /maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh: AbstractSshWagon.java ScpWagon.java SftpWagon.java
Date Mon, 10 Oct 2005 03:17:39 GMT
Author: brett
Date: Sun Oct  9 20:17:31 2005
New Revision: 312531

URL: http://svn.apache.org/viewcvs?rev=312531&view=rev
Log:
refactor scp/sftp wagon into a common base class

Added:
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
  (with props)
Modified:
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/SftpWagon.java

Added: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java?rev=312531&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
(added)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
Sun Oct  9 20:17:31 2005
@@ -0,0 +1,293 @@
+/*
+ * Copyright (c) 2005 Your Corporation. All Rights Reserved.
+ */
+package org.apache.maven.wagon.providers.ssh;
+
+import com.jcraft.jsch.ChannelExec;
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.Proxy;
+import com.jcraft.jsch.ProxyHTTP;
+import com.jcraft.jsch.ProxySOCKS5;
+import com.jcraft.jsch.Session;
+import com.jcraft.jsch.UserInfo;
+import org.apache.maven.wagon.AbstractWagon;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.WagonConstants;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.resource.Resource;
+
+import java.io.File;
+
+/**
+ * TODO: describe
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public abstract class AbstractSshWagon
+    extends AbstractWagon
+    implements SshCommandExecutor
+{
+    public static final int DEFAULT_SSH_PORT = 22;
+
+    public static final int SOCKS5_PROXY_PORT = 1080;
+
+    protected Session session;
+
+    public static final String EXEC_CHANNEL = "exec";
+
+    public void openConnection()
+        throws AuthenticationException
+    {
+        if ( authenticationInfo == null )
+        {
+            throw new IllegalArgumentException( "Authentication Credentials cannot be null
for SSH protocol" );
+        }
+
+        JSch jsch = new JSch();
+
+        int port = getRepository().getPort();
+
+        if ( port == WagonConstants.UNKNOWN_PORT )
+        {
+            port = DEFAULT_SSH_PORT;
+        }
+
+        String host = getRepository().getHost();
+
+        try
+        {
+            session = jsch.getSession( authenticationInfo.getUserName(), host, port );
+        }
+        catch ( JSchException e )
+        {
+            fireSessionError( e );
+
+            throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(),
e );
+        }
+
+        // If user don't define a password, he want to use a private key
+        if ( authenticationInfo.getPassword() == null )
+        {
+            File privateKey;
+
+            if ( authenticationInfo.getPrivateKey() != null )
+            {
+                privateKey = new File( authenticationInfo.getPrivateKey() );
+            }
+            else
+            {
+                privateKey = findPrivateKey();
+            }
+
+            if ( privateKey.exists() )
+            {
+                if ( authenticationInfo.getPassphrase() == null )
+                {
+                    authenticationInfo.setPassphrase( "" );
+                }
+
+                fireSessionDebug( "Using private key: " + privateKey );
+
+                try
+                {
+                    jsch.addIdentity( privateKey.getAbsolutePath(), authenticationInfo.getPassphrase()
);
+                }
+                catch ( JSchException e )
+                {
+                    fireSessionError( e );
+
+                    throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(),
e );
+                }
+            }
+            else
+            {
+                String msg = "Private key was not found. You must define a private key or
a password for repo: " +
+                    getRepository().getName();
+
+                throw new AuthenticationException( msg );
+            }
+        }
+
+        if ( proxyInfo != null && proxyInfo.getHost() != null )
+        {
+            Proxy proxy;
+
+            int proxyPort = proxyInfo.getPort();
+
+            // HACK: if port == 1080 we will use SOCKS5 Proxy, otherwise will use HTTP Proxy
+            if ( proxyPort == SOCKS5_PROXY_PORT )
+            {
+                proxy = new ProxySOCKS5( proxyInfo.getHost() );
+                ( (ProxySOCKS5) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword()
);
+            }
+            else
+            {
+                proxy = new ProxyHTTP( proxyInfo.getHost(), proxyPort );
+                ( (ProxyHTTP) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword()
);
+            }
+
+            try
+            {
+                proxy.connect( session, host, port );
+            }
+            catch ( Exception e )
+            {
+                fireSessionError( e );
+
+                throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(),
e );
+            }
+        }
+
+        // username and password will be given via UserInfo interface.
+        UserInfo ui = new ScpWagon.WagonUserInfo( authenticationInfo );
+
+        session.setUserInfo( ui );
+
+        try
+        {
+            session.connect();
+        }
+        catch ( JSchException e )
+        {
+            fireSessionError( e );
+
+            throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(),
e );
+        }
+    }
+
+    private File findPrivateKey()
+    {
+        String privateKeyDirectory = System.getProperty( "wagon.privateKeyDirectory" );
+
+        if ( privateKeyDirectory == null )
+        {
+            privateKeyDirectory = System.getProperty( "user.home" );
+        }
+
+        File privateKey = new File( privateKeyDirectory, ".ssh/id_dsa" );
+
+        if ( !privateKey.exists() )
+        {
+            privateKey = new File( privateKeyDirectory, ".ssh/id_rsa" );
+        }
+
+        return privateKey;
+    }
+
+    public void executeCommand( String command )
+        throws TransferFailedException
+    {
+        ChannelExec channel = null;
+
+        try
+        {
+            fireTransferDebug( "Executing command: " + command );
+
+            channel = (ChannelExec) session.openChannel( EXEC_CHANNEL );
+
+            channel.setCommand( command );
+
+            channel.connect();
+        }
+        catch ( JSchException e )
+        {
+            throw new TransferFailedException( "Cannot execute remote command: " + command,
e );
+        }
+        finally
+        {
+            if ( channel != null )
+            {
+                channel.disconnect();
+            }
+        }
+    }
+
+    public void closeConnection()
+    {
+        if ( session != null )
+        {
+            session.disconnect();
+        }
+    }
+
+    protected void handleGetException( Resource resource, Exception e, File destination )
+        throws TransferFailedException, ResourceDoesNotExistException
+    {
+        fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+        if ( destination.exists() )
+        {
+            boolean deleted = destination.delete();
+
+            if ( !deleted )
+            {
+                destination.deleteOnExit();
+            }
+        }
+
+        String msg = "Error occured while downloading from the remote repository:" + getRepository();
+
+        // TODO: this might be too hokey?
+        if ( "No such file".equals( e.getMessage() ) )
+        {
+            // SFTP only
+            throw new ResourceDoesNotExistException( msg, e );
+        }
+        else
+        {
+            throw new TransferFailedException( msg, e );
+        }
+    }
+
+    // ----------------------------------------------------------------------
+    // JSch user info
+    // ----------------------------------------------------------------------
+    // TODO: are the prompt values really right? Is there an alternative to UserInfo?
+
+    private static class WagonUserInfo
+        implements UserInfo
+    {
+        private AuthenticationInfo authInfo;
+
+        WagonUserInfo( AuthenticationInfo authInfo )
+        {
+            this.authInfo = authInfo;
+        }
+
+        public String getPassphrase()
+        {
+            return authInfo.getPassphrase();
+        }
+
+        public String getPassword()
+        {
+            return authInfo.getPassword();
+        }
+
+        public boolean promptPassphrase( String arg0 )
+        {
+            return true;
+        }
+
+        public boolean promptPassword( String arg0 )
+        {
+            return true;
+        }
+
+        public boolean promptYesNo( String arg0 )
+        {
+            return true;
+        }
+
+        public void showMessage( String message )
+        {
+            // TODO: is this really debug?
+            //fireTransferDebug( message );
+        }
+    }
+}

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java?rev=312531&r1=312530&r2=312531&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java
Sun Oct  9 20:17:31 2005
@@ -17,21 +17,11 @@
  */
 
 import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.JSch;
 import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Proxy;
-import com.jcraft.jsch.ProxyHTTP;
-import com.jcraft.jsch.ProxySOCKS5;
-import com.jcraft.jsch.Session;
-import com.jcraft.jsch.UserInfo;
-import org.apache.maven.wagon.AbstractWagon;
 import org.apache.maven.wagon.LazyFileOutputStream;
 import org.apache.maven.wagon.PathUtils;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.WagonConstants;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
 import org.apache.maven.wagon.authorization.AuthorizationException;
 import org.apache.maven.wagon.events.TransferEvent;
 import org.apache.maven.wagon.repository.RepositoryPermissions;
@@ -57,176 +47,19 @@
  * @todo [BP] add compression flag
  */
 public class ScpWagon
-    extends AbstractWagon
-    implements SshCommandExecutor
+    extends AbstractSshWagon
 {
-    public static String EXEC_CHANNEL = "exec";
+    private static final byte LF = '\n';
 
-    public static int DEFAULT_SSH_PORT = 22;
+    private static final char PATH_SEPARATOR = '/';
 
-    public static int SOCKS5_PROXY_PORT = 1080;
+    private static final int BUFFER_SIZE = 1024;
 
-    protected Session session = null;
+    private static final char ACK_CHAR = 'C';
 
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
+    private static final char ACK_SEPARATOR = ' ';
 
-    public void openConnection()
-        throws AuthenticationException
-    {
-        try
-        {
-            if ( authenticationInfo == null )
-            {
-                throw new IllegalArgumentException( "Authentication Credentials cannot be
null for SSH protocol" );
-            }
-
-            JSch jsch = new JSch();
-
-            int port = getRepository().getPort();
-
-            if ( port == WagonConstants.UNKNOWN_PORT )
-            {
-                port = DEFAULT_SSH_PORT;
-            }
-
-            String host = getRepository().getHost();
-
-            session = jsch.getSession( authenticationInfo.getUserName(), host, port );
-
-            // If user don't define a password, he want to use a private key
-            if ( authenticationInfo.getPassword() == null )
-            {
-                File privateKey;
-
-                if ( authenticationInfo.getPrivateKey() != null )
-                {
-                    privateKey = new File( authenticationInfo.getPrivateKey() );
-                }
-                else
-                {
-                    privateKey = findPrivateKey();
-                }
-
-                if ( privateKey.exists() )
-                {
-                    if ( authenticationInfo.getPassphrase() == null )
-                    {
-                        authenticationInfo.setPassphrase( "" );
-                    }
-
-                    fireSessionDebug( "Using private key: " + privateKey );
-
-                    jsch.addIdentity( privateKey.getAbsolutePath(), authenticationInfo.getPassphrase()
);
-                }
-                else
-                {
-                    String msg = "Private key was not found. You must define a private key
or a password for repo: " +
-                                 getRepository().getName();
-
-                    throw new AuthenticationException( msg );
-                }
-            }
-
-            if ( proxyInfo != null && proxyInfo.getHost() != null )
-            {
-                Proxy proxy;
-
-                int proxyPort = proxyInfo.getPort();
-
-                // HACK: if port == 1080 we will use SOCKS5 Proxy, otherwise will use HTTP
Proxy
-                if ( proxyPort == SOCKS5_PROXY_PORT )
-                {
-                    proxy = new ProxySOCKS5( proxyInfo.getHost() );
-                    ( (ProxySOCKS5) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword()
);
-                }
-                else
-                {
-                    proxy = new ProxyHTTP( proxyInfo.getHost(), proxyPort );
-                    ( (ProxyHTTP) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword()
);
-                }
-
-                proxy.connect( session, host, port );
-            }
-
-            // username and password will be given via UserInfo interface.
-            UserInfo ui = new WagonUserInfo( authenticationInfo );
-
-            session.setUserInfo( ui );
-
-            session.connect();
-        }
-        catch ( Exception e )
-        {
-            fireSessionError( e );
-
-            throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(),
e );
-        }
-    }
-
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
-
-    private File findPrivateKey()
-    {
-        String privateKeyDirectory = System.getProperty( "wagon.privateKeyDirectory" );
-
-        if ( privateKeyDirectory == null )
-        {
-            privateKeyDirectory = System.getProperty( "user.home" );
-        }
-
-        File privateKey = new File( privateKeyDirectory, ".ssh/id_dsa" );
-
-        if ( !privateKey.exists() )
-        {
-            privateKey = new File( privateKeyDirectory, ".ssh/id_rsa" );
-        }
-
-        return privateKey;
-    }
-
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
-
-    public void closeConnection()
-    {
-        if ( session != null )
-        {
-            session.disconnect();
-        }
-    }
-
-    public void executeCommand( String command )
-        throws TransferFailedException
-    {
-        ChannelExec channel = null;
-
-        try
-        {
-            fireTransferDebug( "Executing command: " + command );
-
-            channel = (ChannelExec) session.openChannel( EXEC_CHANNEL );
-
-            channel.setCommand( command );
-
-            channel.connect();
-        }
-        catch ( JSchException e )
-        {
-            throw new TransferFailedException( "Cannot execute remote command: " + command,
e );
-        }
-        finally
-        {
-            if ( channel != null )
-            {
-                channel.disconnect();
-            }
-        }
-    }
+    private static final char ZERO_CHAR = '0';
 
     public void put( File source, String resourceName )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
@@ -292,9 +125,9 @@
 
             command = "C0644 " + filesize + " ";
 
-            if ( resourceName.lastIndexOf( '/' ) > 0 )
+            if ( resourceName.lastIndexOf( PATH_SEPARATOR ) > 0 )
             {
-                command += resourceName.substring( resourceName.lastIndexOf( '/' ) + 1 );
+                command += resourceName.substring( resourceName.lastIndexOf( PATH_SEPARATOR
) + 1 );
             }
             else
             {
@@ -314,10 +147,10 @@
 
             putTransfer( resource, source, out, false );
 
-            byte[] buf = new byte[1024];
+            byte[] buf = new byte[BUFFER_SIZE];
 
             // send '\0'
-            buf[ 0 ] = 0;
+            buf[0] = 0;
 
             out.write( buf, 0, 1 );
 
@@ -331,14 +164,14 @@
         catch ( IOException e )
         {
             String msg = "Error occured while deploying '" + resourceName + "' to remote
repository: " +
-                         getRepository().getUrl();
+                getRepository().getUrl();
 
             throw new TransferFailedException( msg, e );
         }
         catch ( JSchException e )
         {
             String msg = "Error occured while deploying '" + resourceName + "' to remote
repository: " +
-                         getRepository().getUrl();
+                getRepository().getUrl();
 
             throw new TransferFailedException( msg, e );
         }
@@ -404,10 +237,10 @@
 
             channel.connect();
 
-            byte[] buf = new byte[1024];
+            byte[] buf = new byte[BUFFER_SIZE];
 
             // send '\0'
-            buf[ 0 ] = 0;
+            buf[0] = 0;
 
             out.write( buf, 0, 1 );
 
@@ -418,7 +251,7 @@
                 // TODO: is this really an ACK, or just an in.read()? If the latter, change
checkAck method to not return a value, but throw an exception on non-zero result
                 int c = checkAck( in, true );
 
-                if ( c != 'C' )
+                if ( c != ACK_CHAR )
                 {
                     break;
                 }
@@ -439,12 +272,12 @@
                         throw new TransferFailedException( "Unexpected end of data." );
                     }
 
-                    if ( buf[ 0 ] == ' ' )
+                    if ( buf[0] == ACK_SEPARATOR )
                     {
                         break;
                     }
 
-                    filesize = filesize * 10 + ( buf[ 0 ] - '0' );
+                    filesize = filesize * 10 + ( buf[0] - ZERO_CHAR );
                 }
 
                 resource.setContentLength( filesize );
@@ -456,14 +289,14 @@
                         throw new TransferFailedException( "Unexpected end of data." );
                     }
 
-                    if ( buf[ i ] == (byte) 0x0a )
+                    if ( buf[i] == LF )
                     {
                         break;
                     }
                 }
 
                 // send '\0'
-                buf[ 0 ] = 0;
+                buf[0] = 0;
 
                 out.write( buf, 0, 1 );
 
@@ -531,7 +364,7 @@
                 }
 
                 // send '\0'
-                buf[ 0 ] = 0;
+                buf[0] = 0;
 
                 out.write( buf, 0, 1 );
 
@@ -559,87 +392,12 @@
         }
     }
 
-    protected void handleGetException( Resource resource, Exception e, File destination )
-        throws TransferFailedException, ResourceDoesNotExistException
-    {
-        fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-
-        if ( destination.exists() )
-        {
-            boolean deleted = destination.delete();
-
-            if ( !deleted )
-            {
-                destination.deleteOnExit();
-            }
-        }
-
-        String msg = "Error occured while downloading from the remote repository:" + getRepository();
-
-        // this sucks....
-        if( e.toString().equals("No such file"))  
-        {
-            throw new ResourceDoesNotExistException( msg, e );
-        }
-        else
-        {
-            throw new TransferFailedException( msg, e );
-        }
-    }
-
     public boolean getIfNewer( String resourceName, File destination, long timestamp )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
         throw new UnsupportedOperationException( "getIfNewer is scp wagon must be still implemented"
);
     }
 
-// ----------------------------------------------------------------------
-// JSch user info
-// ----------------------------------------------------------------------
-// TODO: are the prompt values really right? Is there an alternative to UserInfo?
-
-    public static class WagonUserInfo
-        implements UserInfo
-    {
-        AuthenticationInfo authInfo;
-
-        WagonUserInfo( AuthenticationInfo authInfo )
-        {
-            this.authInfo = authInfo;
-        }
-
-        public String getPassphrase()
-        {
-            return authInfo.getPassphrase();
-        }
-
-        public String getPassword()
-        {
-            return authInfo.getPassword();
-        }
-
-        public boolean promptPassphrase( String arg0 )
-        {
-            return true;
-        }
-
-        public boolean promptPassword( String arg0 )
-        {
-            return true;
-        }
-
-        public boolean promptYesNo( String arg0 )
-        {
-            return true;
-        }
-
-        public void showMessage( String message )
-        {
-            // TODO: is this really debug?
-            //fireTransferDebug( message );
-        }
-    }
-
     static int checkAck( InputStream in, boolean isGet )
         throws IOException, ResourceDoesNotExistException, TransferFailedException
     {
@@ -666,7 +424,7 @@
 
                 sb.append( (char) c );
             }
-            while ( c != '\n' );
+            while ( c != LF );
 
             String message = sb.toString();
             if ( b == 1 )

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/SftpWagon.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/SftpWagon.java?rev=312531&r1=312530&r2=312531&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/SftpWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/SftpWagon.java
Sun Oct  9 20:17:31 2005
@@ -39,13 +39,16 @@
  * @todo [BP] add compression flag
  */
 public class SftpWagon
-    extends ScpWagon
-    implements SshCommandExecutor
+    extends AbstractSshWagon
 {
     private static final String SFTP_CHANNEL = "sftp";
 
     private static final int S_IFDIR = 0x4000;
 
+    private static final char PATH_SEPARATOR = '/';
+
+    private static final long MILLIS_PER_SEC = 1000L;
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -67,9 +70,9 @@
 
         String filename;
 
-        if ( resourceName.lastIndexOf( '/' ) > 0 )
+        if ( resourceName.lastIndexOf( PATH_SEPARATOR ) > 0 )
         {
-            filename = resourceName.substring( resourceName.lastIndexOf( '/' ) + 1 );
+            filename = resourceName.substring( resourceName.lastIndexOf( PATH_SEPARATOR )
+ 1 );
         }
         else
         {
@@ -96,10 +99,9 @@
 
             if ( permissions != null && permissions.getGroup() != null )
             {
-                int group;
                 try
                 {
-                    group = Integer.valueOf( permissions.getGroup() ).intValue();
+                    int group = Integer.valueOf( permissions.getGroup() ).intValue();
                     channel.chgrp( group, filename );
                 }
                 catch ( NumberFormatException e )
@@ -111,10 +113,9 @@
 
             if ( permissions != null && permissions.getFileMode() != null )
             {
-                int mode;
                 try
                 {
-                    mode = Integer.valueOf( permissions.getFileMode() ).intValue();
+                    int mode = Integer.valueOf( permissions.getFileMode() ).intValue();
                     channel.chmod( mode, filename );
                 }
                 catch ( NumberFormatException e )
@@ -134,15 +135,15 @@
         }
         catch ( SftpException e )
         {
-            String msg = "Error occured while deploying '" + resourceName + "' " +
-                         "to remote repository: " + getRepository().getUrl();
+            String msg = "Error occured while deploying '" + resourceName + "' " + "to remote
repository: " +
+                getRepository().getUrl();
 
             throw new TransferFailedException( msg, e );
         }
         catch ( JSchException e )
         {
-            String msg = "Error occured while deploying '" + resourceName + "' " +
-                         "to remote repository: " + getRepository().getUrl();
+            String msg = "Error occured while deploying '" + resourceName + "' " + "to remote
repository: " +
+                getRepository().getUrl();
 
             throw new TransferFailedException( msg, e );
         }
@@ -187,7 +188,7 @@
         {
             try
             {
-                SftpATTRS attrs = channel.stat( dirs[ i ] );
+                SftpATTRS attrs = channel.stat( dirs[i] );
                 if ( ( attrs.getPermissions() & S_IFDIR ) == 0 )
                 {
                     throw new TransferFailedException(
@@ -197,12 +198,12 @@
             catch ( SftpException e )
             {
                 // doesn't exist, make it and try again
-                channel.mkdir( dirs[ i ] );
+                channel.mkdir( dirs[i] );
                 if ( mode != -1 )
                 {
                     try
                     {
-                        channel.chmod( mode, dirs[ i ] );
+                        channel.chmod( mode, dirs[i] );
                     }
                     catch ( final SftpException e1 )
                     {
@@ -212,7 +213,7 @@
                 }
             }
 
-            channel.cd( dirs[ i ] );
+            channel.cd( dirs[i] );
         }
     }
 
@@ -229,7 +230,7 @@
         dir = StringUtils.replace( dir, "\\", "/" );
 
         // we already setuped the root directory. Ignore beginning /
-        if ( dir.length() > 0 && dir.charAt( 0 ) == '/' )
+        if ( dir.length() > 0 && dir.charAt( 0 ) == PATH_SEPARATOR )
         {
             dir = dir.substring( 1 );
         }
@@ -239,9 +240,9 @@
         fireGetInitiated( resource, destination );
 
         String filename;
-        if ( resourceName.lastIndexOf( '/' ) > 0 )
+        if ( resourceName.lastIndexOf( PATH_SEPARATOR ) > 0 )
         {
-            filename = resourceName.substring( resourceName.lastIndexOf( '/' ) + 1 );
+            filename = resourceName.substring( resourceName.lastIndexOf( PATH_SEPARATOR )
+ 1 );
         }
         else
         {
@@ -258,7 +259,7 @@
 
             channel.cd( dir );
 
-            if ( timestamp <= 0 || channel.stat( filename ).getMTime() * 1000L > timestamp
)
+            if ( timestamp <= 0 || channel.stat( filename ).getMTime() * MILLIS_PER_SEC
> timestamp )
             {
                 fireGetStarted( resource, destination );
 



---------------------------------------------------------------------
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