maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r662346 - in /maven/wagon/trunk: wagon-provider-api/src/main/java/org/apache/maven/wagon/ wagon-provider-api/src/test/java/org/apache/maven/wagon/ wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/ w...
Date Mon, 02 Jun 2008 07:21:46 GMT
Author: brett
Date: Mon Jun  2 00:21:46 2008
New Revision: 662346

URL: http://svn.apache.org/viewvc?rev=662346&view=rev
Log:
[WAGON-101] simplification of get* calls

Modified:
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java
    maven/wagon/trunk/wagon-provider-api/src/test/java/org/apache/maven/wagon/WagonMock.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-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.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/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

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=662346&r1=662345&r2=662346&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
Mon Jun  2 00:21:46 2008
@@ -58,17 +58,7 @@
     public void get( String resourceName, File destination )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
-        Resource resource = new Resource( resourceName );
-
-        fireGetInitiated( resource, destination );
-
-        InputStream is = getInputStream( resource );
-
-        checkInputStream( is, resource );
-
-        createParentDirectories( destination );
-
-        getTransfer( resource, destination, is );
+        getIfNewer( resourceName, destination, 0 );
     }
 
     protected void checkInputStream( InputStream is, Resource resource )
@@ -224,19 +214,7 @@
     public void getToStream( String resourceName, OutputStream stream )
         throws ResourceDoesNotExistException, TransferFailedException
     {
-        Resource resource = new Resource( resourceName );
-
-        fireGetInitiated( resource, null );
-
-        InputStream is = getInputStream( resource );
-
-        checkInputStream( is, resource );
-
-        fireGetStarted( resource, null );
-
-        getTransfer( resource, stream, is );
-
-        fireGetCompleted( resource, null );
+        getIfNewerToStream( resourceName, stream, 0 );
     }
 
     public void putFromStream( InputStream stream, String destination )

Modified: maven/wagon/trunk/wagon-provider-api/src/test/java/org/apache/maven/wagon/WagonMock.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/test/java/org/apache/maven/wagon/WagonMock.java?rev=662346&r1=662345&r2=662346&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/test/java/org/apache/maven/wagon/WagonMock.java
(original)
+++ maven/wagon/trunk/wagon-provider-api/src/test/java/org/apache/maven/wagon/WagonMock.java
Mon Jun  2 00:21:46 2008
@@ -98,12 +98,6 @@
 
     }
 
-    public boolean getIfNewer( String resourceName, File destination, long timestamp )
-        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
-    {
-        return false;
-    }
-
     public void openConnectionInternal()
     {
     }

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=662346&r1=662345&r2=662346&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
Mon Jun  2 00:21:46 2008
@@ -19,7 +19,6 @@
  * under the License.
  */
 
-import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;

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=662346&r1=662345&r2=662346&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
Mon Jun  2 00:21:46 2008
@@ -30,6 +30,7 @@
 import org.apache.maven.wagon.PathUtils;
 import org.apache.maven.wagon.PermissionModeUtils;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.StreamWagon;
 import org.apache.maven.wagon.Streams;
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.WagonConstants;
@@ -57,14 +58,6 @@
 
     protected static final int DEFAULT_SSH_PORT = 22;
 
-    public boolean getIfNewer( String resourceName, File destination, long timestamp )
-        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
-    {
-        fireSessionDebug( "getIfNewer in SCP wagon is not supported - performing an unconditional
get" );
-        get( resourceName, destination );
-        return true;
-    }
-
     protected String getOctalMode( RepositoryPermissions permissions )
     {
         String mode = null;

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=662346&r1=662345&r2=662346&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
Mon Jun  2 00:21:46 2008
@@ -21,8 +21,6 @@
 
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.List;
 
 import org.apache.maven.wagon.CommandExecutionException;
 import org.apache.maven.wagon.PathUtils;
@@ -35,7 +33,6 @@
 import org.apache.maven.wagon.providers.ssh.AbstractSshWagon;
 import org.apache.maven.wagon.repository.RepositoryPermissions;
 import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -90,6 +87,14 @@
     //
     // ----------------------------------------------------------------------
 
+    public boolean getIfNewer( String resourceName, File destination, long timestamp )
+        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+    {
+        fireSessionDebug( "getIfNewer in SCP wagon is not supported - performing an unconditional
get" );
+        get( resourceName, destination );
+        return true;
+    }
+
     /**
      * @return The hostname of the remote server prefixed with the username, which comes
either from the repository URL
      *         or from the authenticationInfo.

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=662346&r1=662345&r2=662346&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
Mon Jun  2 00:21:46 2008
@@ -61,6 +61,14 @@
 public class ScpWagon
     extends AbstractJschWagon
 {
+    public boolean getIfNewer( String resourceName, File destination, long timestamp )
+        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+    {
+        fireSessionDebug( "getIfNewer in SCP wagon is not supported - performing an unconditional
get" );
+        get( resourceName, destination );
+        return true;
+    }
+
     public void put( File source, String destination )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {

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=662346&r1=662345&r2=662346&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
Mon Jun  2 00:21:46 2008
@@ -203,78 +203,6 @@
         }
     }
 
-    public boolean getIfNewer( Resource resource, File destination, long timestamp )
-        throws ResourceDoesNotExistException, TransferFailedException
-    {
-        String filename = getResourceFilename( resource.getName() );
-
-        String dir = getResourceDirectory( resource.getName() );
-
-        // we already setuped the root directory. Ignore beginning /
-        if ( dir.length() > 0 && dir.charAt( 0 ) == PATH_SEPARATOR )
-        {
-            dir = dir.substring( 1 );
-        }
-
-        ChannelSftp channel = null;
-        
-        boolean bDownloaded = true;
-        try
-        {
-            channel = (ChannelSftp) session.openChannel( SFTP_CHANNEL );
-
-            channel.connect();
-
-            SftpATTRS attrs = changeToRepositoryDirectory( channel, dir, filename );
-
-            long lastModified = attrs.getMTime() * MILLIS_PER_SEC;
-            if ( timestamp <= 0 || lastModified > timestamp )
-            {
-                resource.setContentLength( attrs.getSize() );
-                
-                resource.setLastModified( lastModified );
-                
-                fireGetStarted( resource, destination );
-
-                channel.get( filename, destination.getAbsolutePath() );
-
-                postProcessListeners( resource, destination, TransferEvent.REQUEST_GET );
-
-                fireGetCompleted( resource, destination );
-
-                String[] dirs = PathUtils.dirnames( dir );
-
-                for ( int i = 0; i < dirs.length; i++ )
-                {
-                    channel.cd( ".." );
-                }
-
-                bDownloaded = true;
-            }
-            else
-            {
-                bDownloaded = false;
-            }
-        }
-        catch ( SftpException e )
-        {
-            handleGetException( resource, e, destination );
-        }
-        catch ( JSchException e )
-        {
-            handleGetException( resource, e, destination );
-        }
-        finally
-        {
-            if ( channel != null )
-            {
-                channel.disconnect();
-            }
-        }
-
-        return bDownloaded;
-    }
-
     private SftpATTRS changeToRepositoryDirectory( ChannelSftp channel, String dir, String
filename )
         throws ResourceDoesNotExistException, SftpException
     {
@@ -351,24 +279,6 @@
         }
     }
 
-    public void get( String resourceName, File destination )
-        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
-    {
-        getIfNewer( resourceName, destination, 0 );
-    }
-
-    public boolean getIfNewer( String resourceName, File destination, long timestamp )
-        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
-    {
-        createParentDirectories( destination );
-
-        Resource resource = getResource( resourceName );
-
-        fireGetInitiated( resource, destination );
-
-        return getIfNewer( resource, destination, timestamp );
-    }
-
     public void putDirectory( File sourceDirectory, String destinationDirectory )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
@@ -592,4 +502,88 @@
             }
         }
     }
+
+    public boolean getIfNewer( String resourceName, File destination, long timestamp )
+        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+    {
+        createParentDirectories( destination );
+
+        Resource resource = getResource( resourceName );
+
+        fireGetInitiated( resource, destination );
+
+        String filename = getResourceFilename( resource.getName() );
+
+        String dir = getResourceDirectory( resource.getName() );
+
+        // we already setuped the root directory. Ignore beginning /
+        if ( dir.length() > 0 && dir.charAt( 0 ) == PATH_SEPARATOR )
+        {
+            dir = dir.substring( 1 );
+        }
+
+        ChannelSftp channel = null;
+
+        boolean bDownloaded = true;
+        try
+        {
+            channel = (ChannelSftp) session.openChannel( SFTP_CHANNEL );
+
+            channel.connect();
+
+            SftpATTRS attrs = changeToRepositoryDirectory( channel, dir, filename );
+
+            long lastModified = attrs.getMTime() * MILLIS_PER_SEC;
+            if ( timestamp <= 0 || lastModified > timestamp )
+            {
+                resource.setContentLength( attrs.getSize() );
+
+                resource.setLastModified( lastModified );
+
+                fireGetStarted( resource, destination );
+
+                channel.get( filename, destination.getAbsolutePath() );
+
+                postProcessListeners( resource, destination, TransferEvent.REQUEST_GET );
+
+                fireGetCompleted( resource, destination );
+
+                String[] dirs = PathUtils.dirnames( dir );
+
+                for ( int i = 0; i < dirs.length; i++ )
+                {
+                    channel.cd( ".." );
+                }
+
+                bDownloaded = true;
+            }
+            else
+            {
+                bDownloaded = false;
+            }
+        }
+        catch ( SftpException e )
+        {
+            handleGetException( resource, e, destination );
+        }
+        catch ( JSchException e )
+        {
+            handleGetException( resource, e, destination );
+        }
+        finally
+        {
+            if ( channel != null )
+            {
+                channel.disconnect();
+            }
+        }
+
+        return bDownloaded;
+    }
+
+    public void get( String resourceName, File destination )
+        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+    {
+        getIfNewer( resourceName, destination, 0 );        
+    }
 }



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