Examples of SftpATTRS


Examples of com.jcraft.jsch.SftpATTRS

        }

        // easiest way to check if a file already exists is to do a file stat
        // this method will error out if the remote file does not exist!
        try {
            SftpATTRS attrs = channel.stat(filename);
            // if we get here, then file exists
            return true;
        } catch (SftpException e) {
            // map "no file" message to return correct result
            if (e.getMessage().toLowerCase().indexOf("no such file") >= 0) {
View Full Code Here

Examples of com.jcraft.jsch.SftpATTRS

            setLastModified(localFile);
        }
    }

    private void setLastModified(File localFile) throws JSchException {
        SftpATTRS fileAttributes = null;
        String remotePath = null;
        ChannelSftp channel = openSftpChannel();
        channel.connect();
        try {
            fileAttributes = channel.lstat(remoteDir(remoteFile)
                                           + localFile.getName());
        } catch (SftpException e) {
            throw new JSchException("failed to stat remote file", e);
        }
        FileUtils.getFileUtils().setFileLastModified(localFile,
                                                     ((long) fileAttributes
                                                      .getMTime())
                                                     * 1000);
    }
View Full Code Here

Examples of com.jcraft.jsch.SftpATTRS

    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

Examples of com.jcraft.jsch.SftpATTRS

    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

Examples of com.jcraft.jsch.SftpATTRS

            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 );
            }

            @SuppressWarnings( "unchecked" )
View Full Code Here

Examples of com.jcraft.jsch.SftpATTRS

            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

Examples of com.jcraft.jsch.SftpATTRS

    }

    @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

Examples of com.jcraft.jsch.SftpATTRS

  public boolean setDirectories(){
    boolean success = false;
    try{
      m_channel.lcd(m_details.getLocalRoot());
     
      SftpATTRS attrib = m_channel.stat(m_details.getSiteRoot());
      if(attrib.isDir() == false){
        m_channel.mkdir(m_details.getSiteRoot());
      }
      m_channel.cd(m_details.getSiteRoot());
      success = true;
    }catch(SftpException e){
View Full Code Here

Examples of com.jcraft.jsch.SftpATTRS

          //  Ignores anything with a . or .. in it
          if(entry.getFilename().endsWith(".")) continue;

          //  Get the attributes for this directory item
          SftpATTRS attrib = entry.getAttrs();
                   
          //  Is it a directory or file? add it to the appropriate array
          if(attrib.isDir() == true && m_details.getRecurse() == true){
            folders.add(directory+entry.getFilename()+"/");
          }else{
            files.add(directory+entry.getFilename());
          }
        }
View Full Code Here

Examples of com.jcraft.jsch.SftpATTRS

  }
 
  public boolean isDirectory(String dir) throws Exception{   
    try{
      //  Stat the requested site root
      SftpATTRS a = m_channel.stat(dir);
     
      //  If directory, great, otherwise, show warning
      if(a.isDir()) return true;
    }catch(SftpException e){
      throw new Exception();
    }
   
    return false;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.