You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2012/07/16 18:01:24 UTC

svn commit: r1362107 - in /commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp: SftpClientFactory.java SftpFileObject.java SftpFileSystem.java

Author: ggregory
Date: Mon Jul 16 16:01:24 2012
New Revision: 1362107

URL: http://svn.apache.org/viewvc?rev=1362107&view=rev
Log:
Javadoc fixes. Clean ups.

Modified:
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java?rev=1362107&r1=1362106&r2=1362107&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java Mon Jul 16 16:01:24 2012
@@ -54,6 +54,7 @@ public final class SftpClientFactory
 
     /**
      * Creates a new connection to the server.
+     * 
      * @param hostname The name of the host to connect to.
      * @param port The port to use.
      * @param username The user's id.

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileObject.java?rev=1362107&r1=1362106&r2=1362107&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileObject.java Mon Jul 16 16:01:24 2012
@@ -147,9 +147,11 @@ public class SftpFileObject extends Abst
     }
 
     /**
-     * Fetches file attrs from server.
+     * Fetches file attributes from server.
+     * 
+     * @throws IOException 
      */
-    private void statSelf() throws Exception
+    private void statSelf() throws IOException
     {
         ChannelSftp channel = fileSystem.getChannel();
         try
@@ -173,7 +175,7 @@ public class SftpFileObject extends Abst
                     attrs = null;
                 }
             }
-            catch (final SftpException e2)
+            catch (final SftpException innerEx)
             {
                 // TODO - not strictly true, but jsch 0.1.2 does not give us
                 // enough info in the exception. Should be using:

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java?rev=1362107&r1=1362106&r2=1362107&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java Mon Jul 16 16:01:24 2012
@@ -39,6 +39,10 @@ public class SftpFileSystem
     extends AbstractFileSystem
     implements FileSystem
 {
+    private static final int SLEEP_MILLIS = 100;
+
+    private static final int EXEC_BUFFER_SIZE = 128;
+
     private static final long LAST_MOD_TIME_ACCURACY = 1000L;
 
     private Session session;
@@ -83,6 +87,9 @@ public class SftpFileSystem
 
     /**
      * Returns an SFTP channel to the server.
+     * 
+     * @throws FileSystemException if a session cannot be created.
+     * @throws IOException if an I/O error is detected.
      */
     protected ChannelSftp getChannel() throws IOException
     {
@@ -125,7 +132,9 @@ public class SftpFileSystem
     }
 
     /**
-     * Ensures that the session link is established
+     * Ensures that the session link is established.
+     * 
+     * @throws FileSystemException if a session cannot be created.
      */
     private void ensureSession() throws FileSystemException
     {
@@ -204,7 +213,7 @@ public class SftpFileSystem
     }
 
     /**
-     * Last mod time is only a int and in seconds, thus can be off by 999.
+     * Last modification time is only an int and in seconds, thus can be off by 999.
      *
      * @return 1000
      */
@@ -218,7 +227,9 @@ public class SftpFileSystem
      * Gets the (numeric) group IDs.
      * 
      * @return the (numeric) group IDs.
-     * @throws JSchException If a problem occurs while retrieving the groups ID
+     * @throws JSchException If a problem occurs while retrieving the group IDs.
+     * @throws IOException if an I/O error is detected.
+     * @since 2.1
      */
     public int[] getGroupsIds() throws JSchException, IOException
     {
@@ -245,8 +256,9 @@ public class SftpFileSystem
      * Get the (numeric) group IDs.
      * 
      * @return The numeric user ID
-     * @throws JSchException
-     * @throws IOException
+     * @throws JSchException If a problem occurs while retrieving the group ID.
+     * @throws IOException if an I/O error is detected.
+     * @since 2.1
      */
     public int getUId() throws JSchException, IOException
     {
@@ -255,7 +267,7 @@ public class SftpFileSystem
             StringBuilder output = new StringBuilder();
             int code = executeCommand("id -u", output);
             if (code != 0) {
-                throw new JSchException("Could not get the user id of the current user (error code: " + code  + ")");
+                throw new FileSystemException("Could not get the user id of the current user (error code: " + code  + ")");
             }
             uid = Integer.parseInt(output.toString().trim());
         }
@@ -268,8 +280,9 @@ public class SftpFileSystem
      * @param command The command
      * @param output The output
      * @return The exit code of the command
-     * @throws JSchException
-     * @throws IOException
+     * @throws JSchException if a JSch error is detected.
+     * @throws FileSystemException if a session cannot be created.
+     * @throws IOException if an I/O error is detected.
      */
     private int executeCommand(String command, StringBuilder output) throws JSchException, IOException
     {
@@ -283,7 +296,7 @@ public class SftpFileSystem
         channel.connect();
 
         // Read the stream
-        char[] buffer = new char[128];
+        char[] buffer = new char[EXEC_BUFFER_SIZE];
         int read;
         while ((read = stream.read(buffer, 0, buffer.length)) >= 0)
         {
@@ -296,7 +309,7 @@ public class SftpFileSystem
         {
             try
             {
-                Thread.sleep(100);
+                Thread.sleep(SLEEP_MILLIS);
             } catch (Exception ee)
             {
                 // TODO: swallow exception, really?