You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by pe...@apache.org on 2006/11/20 22:17:11 UTC

svn commit: r477342 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh: AbstractSshMessage.java SSHUserInfo.java ScpFromMessageBySftp.java ScpToMessageBySftp.java

Author: peterreilly
Date: Mon Nov 20 13:17:10 2006
New Revision: 477342

URL: http://svn.apache.org/viewvc?view=rev&rev=477342
Log:
checkstyle

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/AbstractSshMessage.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHUserInfo.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/AbstractSshMessage.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/AbstractSshMessage.java?view=diff&rev=477342&r1=477341&r2=477342
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/AbstractSshMessage.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/AbstractSshMessage.java Mon Nov 20 13:17:10 2006
@@ -23,8 +23,6 @@
 import com.jcraft.jsch.JSchException;
 import com.jcraft.jsch.Session;
 import com.jcraft.jsch.ChannelSftp;
-import com.jcraft.jsch.SftpATTRS;
-import com.jcraft.jsch.SftpException;
 import com.jcraft.jsch.SftpProgressMonitor;
 
 import java.io.IOException;
@@ -231,7 +229,11 @@
 
     private ProgressMonitor monitor = null;
 
-    protected SftpProgressMonitor getProgressMonitor(){
+    /**
+     * Get the progress monitor.
+     * @return the progress monitor.
+     */
+    protected SftpProgressMonitor getProgressMonitor() {
         if (monitor == null) {
             monitor = new ProgressMonitor();
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHUserInfo.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHUserInfo.java?view=diff&rev=477342&r1=477341&r2=477342
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHUserInfo.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHUserInfo.java Mon Nov 20 13:17:10 2006
@@ -190,6 +190,16 @@
         //log(message, Project.MSG_DEBUG);
     }
 
+    /**
+     * Implementation of UIKeyboardInteractive#promptKeyboardInteractive.
+     * @param destination not used.
+     * @param name        not used.
+     * @param instruction not used.
+     * @param prompt      the method checks if this is one in length.
+     * @param echo        the method checks if the first element is false.
+     * @return the password in an size one array if there is a password
+     *         and if the prompt and echo checks pass.
+     */
     public String[] promptKeyboardInteractive(String destination,
                                               String name,
                                               String instruction,

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java?view=diff&rev=477342&r1=477341&r2=477342
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java Mon Nov 20 13:17:10 2006
@@ -20,15 +20,9 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.io.EOFException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.FileOutputStream;
-import java.io.ByteArrayOutputStream;
 
 import com.jcraft.jsch.JSchException;
 import com.jcraft.jsch.Session;
-import com.jcraft.jsch.Channel;
 import com.jcraft.jsch.ChannelSftp;
 import com.jcraft.jsch.SftpException;
 import com.jcraft.jsch.SftpATTRS;
@@ -91,12 +85,13 @@
             try {
                 SftpATTRS attrs = channel.stat(remoteFile);
                 if (attrs.isDir() && !remoteFile.endsWith("/")) {
-                    remoteFile=remoteFile+"/";
+                    remoteFile = remoteFile + "/";
                 }
-            } catch(SftpException ee) {
+            } catch (SftpException ee) {
+                // Ignored
             }
             getDir(channel, remoteFile, localFile);
-        } catch(SftpException e) {
+        } catch (SftpException e) {
             throw new JSchException(e.toString());
         } finally {
             if (channel != null) {
@@ -109,10 +104,10 @@
     private void getDir(ChannelSftp channel,
                         String remoteFile,
                         File localFile) throws IOException, SftpException {
-        String pwd=remoteFile;
-        if (remoteFile.lastIndexOf('/')!=-1) {
-            if (remoteFile.length()>1) {
-                pwd=remoteFile.substring(0, remoteFile.lastIndexOf('/'));
+        String pwd = remoteFile;
+        if (remoteFile.lastIndexOf('/') != -1) {
+            if (remoteFile.length() > 1) {
+                pwd = remoteFile.substring(0, remoteFile.lastIndexOf('/'));
             }
         }
         channel.cd(pwd);
@@ -120,7 +115,7 @@
             localFile.mkdirs();
         }
         java.util.Vector files = channel.ls(remoteFile);
-        for(int i = 0; i < files.size(); i++){
+        for (int i = 0; i < files.size(); i++) {
             ChannelSftp.LsEntry le = (ChannelSftp.LsEntry) files.elementAt(i);
             String name = le.getFilename();
             if (le.getAttrs().isDir()) {
@@ -130,7 +125,7 @@
                 getDir(channel,
                        channel.pwd() + "/" + name + "/",
                        new File(localFile, le.getFilename()));
-            } else{
+            } else {
                 getFile(channel, le, localFile);
             }
         }
@@ -145,14 +140,14 @@
             String path = localFile.getAbsolutePath();
             int i = 0;
             if ((i = path.lastIndexOf(File.pathSeparator)) != -1) {
-                if (path.length()>File.pathSeparator.length()) {
+                if (path.length() > File.pathSeparator.length()) {
                     new File(path.substring(0, i)).mkdirs();
                 }
             }
         }
 
         if (localFile.isDirectory()) {
-            localFile=new File(localFile, remoteFile);
+            localFile = new File(localFile, remoteFile);
         }
 
         long startTime = System.currentTimeMillis();
@@ -160,15 +155,15 @@
 
         SftpProgressMonitor monitor = null;
         boolean trackProgress = getVerbose() && totalLength > 102400;
-        if (trackProgress){
+        if (trackProgress) {
             monitor = getProgressMonitor();
         }
-        try{
+        try {
             log("Receiving: " + remoteFile + " : " + le.getAttrs().getSize());
             channel.get(remoteFile, localFile.getAbsolutePath(), monitor);
-        } finally{
+        } finally {
             long endTime = System.currentTimeMillis();
-            logStats(startTime, endTime, (int)totalLength);
+            logStats(startTime, endTime, (int) totalLength);
         }
     }
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java?view=diff&rev=477342&r1=477341&r2=477342
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java Mon Nov 20 13:17:10 2006
@@ -18,19 +18,14 @@
 
 package org.apache.tools.ant.taskdefs.optional.ssh;
 
-import com.jcraft.jsch.Channel;
 import com.jcraft.jsch.Session;
 import com.jcraft.jsch.ChannelSftp;
 import com.jcraft.jsch.JSchException;
 import com.jcraft.jsch.SftpException;
 import com.jcraft.jsch.SftpProgressMonitor;
-import com.jcraft.jsch.SftpATTRS;
 
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.OutputStream;
 import java.util.List;
 import java.util.Iterator;
 
@@ -134,10 +129,9 @@
         ChannelSftp channel = openSftpChannel();
         try {
             channel.connect();
-            try{
+            try {
                 sendFileToRemote(channel, localFile, remotePath);
-            }
-            catch(SftpException e){
+            } catch (SftpException e) {
                 throw new JSchException(e.toString());
             }
         } finally {
@@ -152,14 +146,13 @@
         try {
             channel.connect();
 
-            try{
+            try {
                 channel.cd(remotePath);
                 for (Iterator i = directoryList.iterator(); i.hasNext();) {
                     Directory current = (Directory) i.next();
                     sendDirectory(channel, current);
                 }
-            }
-            catch(SftpException e){
+            } catch (SftpException e) {
                 throw new JSchException(e.toString());
             }
         } finally {
@@ -184,13 +177,12 @@
     private void sendDirectoryToRemote(ChannelSftp channel,
                                        Directory directory)
         throws IOException, SftpException {
-        String dir=directory.getDirectory().getName();
-        try{
+        String dir = directory.getDirectory().getName();
+        try {
             channel.stat(dir);
-        }
-        catch (SftpException e) {
+        } catch (SftpException e) {
             // dir does not exist.
-            if (e.id==ChannelSftp.SSH_FX_NO_SUCH_FILE) {
+            if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
                 channel.mkdir(dir);
             }
         }
@@ -205,8 +197,8 @@
         throws IOException, SftpException {
         long filesize = localFile.length();
 
-        if (remotePath==null) {
-            remotePath=localFile.getName();
+        if (remotePath == null) {
+            remotePath = localFile.getName();
         }
 
         long startTime = System.currentTimeMillis();
@@ -216,17 +208,16 @@
         boolean trackProgress = getVerbose() && filesize > 102400;
 
         SftpProgressMonitor monitor = null;
-        if (trackProgress){
+        if (trackProgress) {
             monitor = getProgressMonitor();
         }
 
-        try{
+        try {
             if (this.getVerbose()) {
                 log("Sending: " + localFile.getName() + " : " + filesize);
             }
             channel.put(localFile.getAbsolutePath(), remotePath, monitor);
-        }
-        finally {
+        } finally {
             if (this.getVerbose()) {
                 long endTime = System.currentTimeMillis();
                 logStats(startTime, endTime, (int) totalLength);
@@ -234,10 +225,18 @@
         }
     }
 
+    /**
+     * Get the local file.
+     * @return the local file.
+     */
     public File getLocalFile() {
         return localFile;
     }
 
+    /**
+     * Get the remote path.
+     * @return the remote path.
+     */
     public String getRemotePath() {
         return remotePath;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org