Package com.jcraft.jsch

Examples of com.jcraft.jsch.SftpATTRS


          // TODO: avoid DFAs with Spring 4.1 (INT-3412)
          ChannelSftp channel = (ChannelSftp) new DirectFieldAccessor(new DirectFieldAccessor(session)
              .getPropertyValue("targetSession")).getPropertyValue("channel");
          for (int i = 0; i < fileNames.length; i++) {
            try {
              SftpATTRS stat = channel.stat("si.sftp.sample/" + fileNames[i]);
              if (stat == null) {
                System.out.println("stat returned null for " + fileNames[i]);
                return false;
              }
            }
View Full Code Here


            if (r != null) {
                for (Iterator iter = r.iterator(); iter.hasNext();) {
                    Object obj = iter.next();
                    if (obj instanceof LsEntry) {
                        LsEntry entry = (LsEntry) obj;
                        SftpATTRS attrs = entry.getAttrs();
                        return new BasicResource(path, true, attrs.getSize(), attrs.getMTime()
                                * MILLIS_PER_SECOND, false);
                    }
                }
            }
        } catch (Exception e) {
View Full Code Here

        }
    }

    private void mkdirs(String directory, ChannelSftp c) throws IOException, SftpException {
        try {
            SftpATTRS att = c.stat(directory);
            if (att != null) {
                if (att.isDir()) {
                    return;
                }
            }
        } catch (SftpException ex) {
            if (directory.indexOf('/') != -1) {
View Full Code Here

    public void execute() throws IOException, JSchException {
        ChannelSftp channel = openSftpChannel();
        try {
            channel.connect();
            try {
                SftpATTRS attrs = channel.stat(remoteFile);
                if (attrs.isDir() && !remoteFile.endsWith("/")) {
                    remoteFile = remoteFile + "/";
                }
            } catch (SftpException ee) {
                // Ignored
            }
View Full Code Here

    private void mkdir( String dir, int mode )
        throws TransferFailedException, SftpException
    {
        try
        {
            SftpATTRS attrs = channel.stat( dir );
            if ( ( attrs.getPermissions() & S_IFDIR ) == 0 )
            {
                throw new TransferFailedException( "Remote path is not a directory:" + dir );
            }
        }
        catch ( SftpException e )
View Full Code Here

    private SftpATTRS changeToRepositoryDirectory( String dir, String filename )
        throws ResourceDoesNotExistException, SftpException
    {
        // This must be called first to ensure that if the file doesn't exist it throws an exception
        SftpATTRS attrs;
        try
        {
            channel.cd( repository.getBasedir() );

            if ( dir.length() > 0 )
View Full Code Here

            dir = dir.substring( 1 );
        }

        try
        {
            SftpATTRS attrs = changeToRepositoryDirectory( dir, filename );
            if ( ( attrs.getPermissions() & S_IFDIR ) == 0 )
            {
                throw new TransferFailedException( "Remote path is not a directory:" + dir );
            }

            Vector fileList = channel.ls( filename );
View Full Code Here

            dir = dir.substring( 1 );
        }

        try
        {
            SftpATTRS attrs = changeToRepositoryDirectory( dir, filename );

            long lastModified = attrs.getMTime() * MILLIS_PER_SEC;
            resource.setContentLength( attrs.getSize() );

            resource.setLastModified( lastModified );
           
            inputData.setInputStream( channel.get( filename ) );
        }
View Full Code Here

    }

    @Override
    FileStream open(final String path) throws IOException {
      try {
        final SftpATTRS a = ftp.lstat(path);
        return new FileStream(ftp.get(path), a.getSize());
      } catch (SftpException je) {
        if (je.id == ChannelSftp.SSH_FX_NO_SUCH_FILE)
          throw new FileNotFoundException(path);
        throw new TransportException("Can't get " + objectsPath + "/"
            + path + ": " + je.getMessage(), je);
View Full Code Here

                        {
                                Object obj = vFileList.elementAt(i);
                               
                                if (obj instanceof LsEntry)
                                {
                                        SftpATTRS oSftAttr = ((LsEntry) obj).getAttrs();
                                        if (!oSftAttr.isDir())
                                        {
                                                lFileList.add(((LsEntry) obj).getFilename());
                                        }
                                }
                        }
View Full Code Here

TOP

Related Classes of com.jcraft.jsch.SftpATTRS

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.