Package com.trilead.ssh2

Examples of com.trilead.ssh2.SFTPv3DirectoryEntry


            String loggingDir = getLoggingDirectoryForNode(instanceLogFileDirectory, node, sNode, instanceName);

            try {
                instanceLogFileNames = sftpClient.ls(loggingDir);
                for (int i = 0; i < instanceLogFileNames.size(); i++) {
                    SFTPv3DirectoryEntry file = (SFTPv3DirectoryEntry) instanceLogFileNames.get(i);
                    String fileName = file.filename;
                    // code to remove . and .. file which is return from sftpclient ls method
                    if (!file.attributes.isDirectory() && !fileName.equals(".") && !fileName.equals("..")
                            && fileName.contains(".log") && !fileName.contains(".log.")) {
                        instanceLogFileNamesAsString.add(fileName);
                        noFileFound = false;
                    }
                }
            } catch (Exception ex) {
                // if directory doesn't present or missing on remote machine. It happens due to bug 16451
                noFileFound = true;
            }

            if (noFileFound) {
                // this loop is used when user has changed value for server.log but not restarted the server.
                loggingDir = getLoggingDirectoryForNodeWhenNoFilesFound(instanceLogFileDirectory, node, sNode, instanceName);
                instanceLogFileNames = sftpClient.ls(loggingDir);


                for (int i = 0; i < instanceLogFileNames.size(); i++) {
                    SFTPv3DirectoryEntry file = (SFTPv3DirectoryEntry) instanceLogFileNames.get(i);
                    String fileName = file.filename;
                    // code to remove . and .. file which is return from sftpclient ls method
                    if (!file.attributes.isDirectory() && !fileName.equals(".") && !fileName.equals("..")
                            && fileName.contains(".log") && !fileName.contains(".log.")) {
                        instanceLogFileNamesAsString.add(fileName);
                    }
                }
            }

            sftpClient.close();
        } else if (node.getType().equals("DCOM")) {

            String loggingDir = getLoggingDirectoryForNode(instanceLogFileDirectory, node, sNode, instanceName);

            try {
                DcomInfo info = new DcomInfo(node);
                WindowsRemoteFileSystem wrfs = new WindowsRemoteFileSystem(info.getHost(), info.getUser(), info.getPassword());
                WindowsRemoteFile wrf = new WindowsRemoteFile(wrfs, loggingDir);
                String[] allLogFileNames = wrf.list();

                for (int i = 0; i < allLogFileNames.length; i++) {
                    File file = new File(allLogFileNames[i]);
                    String fileName = file.getName();
                    // code to remove . and .. file which is return
                    if (!fileName.equals(".") && !fileName.equals("..") && fileName.contains(".log")
                            && !fileName.contains(".log.")) {
                        instanceLogFileNamesAsString.add(fileName);
                    }
View Full Code Here


    } else if (es == openProject) {
      if (selectedNode instanceof RemoteProjectMutuableTreeNode) {
        RemoteProjectMutuableTreeNode rNode = (RemoteProjectMutuableTreeNode) selectedNode;
        RemoteProject rProject = rNode.getRemoteProject();
        JSimLogic.getInstance().openConnection(rProject);
        SFTPv3DirectoryEntry entry = JSimLogic.getInstance()
            .getDirectoryEntry(rProject,
                rProject.getPath() + rProject.getName());
        if (entry != null) {
          rNode.setJSimNode(entry);
          rNode.createNodes(true);
View Full Code Here

   * (non-Javadoc)
   *
   * @see javax.swing.ListModel#getElementAt(int)
   */
  public Object getElementAt(int index) {
    SFTPv3DirectoryEntry entry = files.get(index);
    return entry.filename;
  }
View Full Code Here

    files.addElement(entry);
    fireIntervalAdded(this, index, index);
  }
 
  public boolean isElementDirectory(int index){
    SFTPv3DirectoryEntry entry = files.get(index);
    return entry.attributes.isDirectory();
  }
View Full Code Here

   * @return SFTPv3DirectoryEntry
   * @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;
View Full Code Here

   * @param nodes
   */
  private void filterNodes(Vector<SFTPv3DirectoryEntry> nodes) {
    for (Iterator<SFTPv3DirectoryEntry> iterator = nodes.iterator(); iterator
        .hasNext();) {
      SFTPv3DirectoryEntry directoryEntry = iterator.next();
      if (directoryEntry.filename
          .equals(JSimConstants.DEFAULTDIRECTORY_1)
          || directoryEntry.filename
              .equals(JSimConstants.DEFAULTDIRECTORY_2))
        iterator.remove();
View Full Code Here

   */
  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) {
View Full Code Here

   * @see jSimMacs.logic.location.DataHandler#readFile(java.lang.String)
   */
  public File readFile(String pathString) throws IOException {
    File file = null;
    SCPClient scpClient = null;
    SFTPv3DirectoryEntry dirEntry = null;
    boolean noFile = false;
    try {
      dirEntry = getDirectoryEntry(pathString);
    } catch (IOException e) {
      if (e instanceof SFTPException) {
View Full Code Here

   * @param path where to copy file
   * @throws IOException
   */
  public void copyToServer(File file, String path) throws IOException {
    String serverPath = path;
    SFTPv3DirectoryEntry pathEntry = getDirectoryEntry(path);
    if (pathEntry.attributes.isRegularFile())
      serverPath = serverPath.substring(0, serverPath.lastIndexOf("/"));
    SCPClient scpClient = new SCPClient(conn);
    scpClient.put(file.getPath(), serverPath, standardFilePermission);
  }
View Full Code Here

   * @throws IOException
   */
  public void copy(String source, String destination) throws IOException {
    Session sess = createSession();
    String serverDestPath = destination;
    SFTPv3DirectoryEntry pathEntry = getDirectoryEntry(destination);
    if (pathEntry.attributes.isRegularFile())
      serverDestPath = serverDestPath.substring(0, serverDestPath
          .lastIndexOf("/"));

    SFTPv3DirectoryEntry pathEntrySource = getDirectoryEntry(source);
    if (pathEntrySource.attributes.isDirectory())
      return;

    String copyCommand = JSimConstants.COPYSSH;
    copyCommand = copyCommand.replace("%1", source);
View Full Code Here

TOP

Related Classes of com.trilead.ssh2.SFTPv3DirectoryEntry

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.