Package ch.ethz.ssh2

Examples of ch.ethz.ssh2.SFTPv3Client


    }
  }

  private void deleteCommandScript(String commandFile) throws Exception {
    try {
      SFTPv3Client sftpClient = new SFTPv3Client(this.getSshConnection());
      sftpClient.rm(commandFile);
      sftpClient.close();
    }
    catch (Exception e) {
      getLogger().warn("Failed to delete remote command script: " + e);
    }
  }
View Full Code Here


    }
  }

  private SFTPv3Client FtpClient() throws Exception {
    if (sftpClient == null) {
      sftpClient = new SFTPv3Client(this.getSshConnection());
    }
    return sftpClient;
  }
View Full Code Here

            if (!isAuthenticated) throw new Exception("authentication failed [host=" + this.getHost() + ", port=" + this.getPort() + ", user:" + this.getUser()
                    + ", auth_method=" + this.getAuthenticationMethod() + ", auth_file=" + this.getAuthenticationFilename());

           
            sftpClient = new SFTPv3Client(sshConnection);
            connected = true;
            reply = "OK";
        } catch (Exception e) {
          reply = e.toString();
            if (sshConnection != null) try { disconnect(); } catch (Exception ex) {} // gracefully ignore this error
View Full Code Here

  }

  private SFTPv3Client Client() {
    if (objFTPClient == null) {
      try {
        objFTPClient = new SFTPv3Client(sshConnection);
      }
      catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
View Full Code Here

   *
   * @see jSimMacs.logic.location.DataHandler#createDirectory(java.lang.String, boolean)
   */
  public boolean createDirectory(String dir, boolean absolutePath) throws IOException {
    boolean success = true;
    SFTPv3Client sftpConn = null;
    String directory = dir;
    if(!absolutePath)
      directory = rProject.getPath() + dir;
    try {

      sftpConn = new SFTPv3Client(conn);
      boolean createDir = true;
      try {
        sftpConn.lstat(directory);
        createDir = false;
      } catch (IOException e) {
        createDir = true;
      }
      if (createDir)
        sftpConn.mkdir(directory, standardPermission);
    } catch (IOException e) {
      success = false;
      throw e;
    } finally {
      if (sftpConn != null)
        sftpConn.close();
    }
    return success;
  }
View Full Code Here

   * @throws IOException
   */
  public SFTPv3DirectoryEntry getDirectoryEntry(String path)
      throws IOException {
    SFTPv3DirectoryEntry entry = new SFTPv3DirectoryEntry();
    SFTPv3Client sftpConn = null;
    try {
      sftpConn = new SFTPv3Client(conn);
      SFTPv3FileAttributes attribute = sftpConn.lstat(path);
      entry.attributes = attribute;
      entry.filename = path.substring(path.lastIndexOf("/") + 1);
    } catch (IOException e) {
      throw e;
    } finally {
      if (sftpConn != null)
        sftpConn.close();
    }
    return entry;
  }
View Full Code Here

   *
   * @see jSimMacs.logic.location.DataHandler#createFile(java.lang.String)
   */
  public boolean createFile(String fileDirectory) throws IOException {
    boolean success = true;
    SFTPv3Client sftpConn = null;
    try {
      sftpConn = new SFTPv3Client(conn);
      sftpConn.createFile(fileDirectory);
    } catch (IOException e) {
      success = false;
      throw new IOException();
    } finally {
      if (sftpConn != null)
        sftpConn.close();
    }
    return success;
  }
View Full Code Here

   * @return Vector of DirectoryEntries
   * @throws IOException
   */
  public Vector<SFTPv3DirectoryEntry> listFiles(String path)
      throws IOException {
    SFTPv3Client sftpConn = null;
    Vector<SFTPv3DirectoryEntry> nodes;
    try {
      sftpConn = new SFTPv3Client(conn);
      nodes = sftpConn.ls(path);
      filterNodes(nodes);
    } catch (IOException e) {
      throw e;
    } finally {
      if (sftpConn != null)
        sftpConn.close();
    }
    return nodes;

  }
View Full Code Here

   * (non-Javadoc)
   *
   * @see jSimMacs.logic.location.DataHandler#delete(java.lang.String)
   */
  public void delete(String pathString) throws IOException {
    SFTPv3Client sftpConn = null;
    try {
      sftpConn = new SFTPv3Client(conn);
      SFTPv3DirectoryEntry dirEntry = getDirectoryEntry(pathString);
      if (dirEntry.attributes.isDirectory()) {
        deleteDirectory(sftpConn, dirEntry, pathString);
      } else
        sftpConn.rm(pathString);
    } catch (IOException e) {
      throw e;
    } finally {
      if (sftpConn != null)
        sftpConn.close();
    }

  }
View Full Code Here

   * (non-Javadoc)
   *
   * @see jSimMacs.logic.location.DataHandler#deleteBackup(java.lang.String)
   */
  public void deleteBackup(String pathString) throws IOException {
    SFTPv3Client sftpConn = null;
    try {
      sftpConn = new SFTPv3Client(conn);
      SFTPv3DirectoryEntry dirEntry = getDirectoryEntry(pathString);
      if (dirEntry.attributes.isDirectory()) {
        deleteBackupDirectory(sftpConn, dirEntry, pathString);
      } else if (dirEntry.filename.startsWith("#")
          && dirEntry.filename.endsWith("#"))
        sftpConn.rm(pathString);
    } catch (IOException e) {
      throw e;
    } finally {
      if (sftpConn != null)
        sftpConn.close();
    }

  }
View Full Code Here

TOP

Related Classes of ch.ethz.ssh2.SFTPv3Client

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.