agave-systems/systems-core/src/main/java/org/iplantc/service/transfer/sftp/MaverickSFTP.java
/**
     * Internal method to fetch and cache metadata for a remote file/folder.
     * This speeds up most operations as the logic of this adaptor heavily
     * relies on explicit metadata checking for each operation. Cached data
     * can by ignored by setting skipCache to true. Doing so will result in a
     * remote stat call every time. If unsure, use the {@link #stat(String)}
     * method.
     *
     * @param resolvedPath the remote absolute path to stat
     * @param skipCache if true, the local cache will not be checked prior to the request
     * @return file attributes for the remote file item
     * @throws FileNotFoundException if the remote path does not exist
     * @throws RemoteDataException if something went wrong with the request, permissions prevented the check, etc
     */
Internal method to fetch and cache metadata for a remote file/folder.
This speeds up most operations as the logic of this adaptor heavily
relies on explicit metadata checking for each operation. Cached data
can by ignored by setting skipCache to true. Doing so will result in a
remote stat call every time. If unsure, use the  #stat(String)
method.


Internal method to fetch and cache metadata for a remote file / folder . This speeds up most operations as the logic of this adaptor heavily relies on explicit metadata checking for each operation . Cached data can by ignored by setting skipCache to true . Doing so will result in a remote stat call every time . If unsure use the #stat ( String ) method .
protected SftpFileAttributes stat(String resolvedPath, boolean skipCache)
    throws FileNotFoundException, RemoteDataException {
        SftpFileAttributes atts = null;
        try {
            if (!skipCache) {
                atts = fileInfoCache.get(resolvedPath);
            }
            if (atts == null) {
                atts = getClient().stat(StringUtils.removeEnd(resolvedPath, "/"));
                if (atts != null && atts.isLink()) {
                    atts = getClient().statLink(resolvedPath);
                }
                if (atts != null) {
                    fileInfoCache.put(resolvedPath, atts);
                }
            }
            return atts;
        } catch (SftpStatusException e) {
            fileInfoCache.remove(resolvedPath);
            switch (e.getStatus()) {
                case SftpStatusException.SSH_FX_PERMISSION_DENIED:
                    throw new RemotePermissionException(e);
                case SftpStatusException.SSH_FX_NO_SUCH_FILE:
                case SftpStatusException.SSH_FX_NO_SUCH_PATH:
                    throw new FileNotFoundException(e.getMessage());
                default:
                    throw new RemoteDataException(e);
            }
        } catch (SshException e) {
            fileInfoCache.remove(resolvedPath);
            String msg = e.getMessage();
            if (msg != null && msg.contains(CONN_TIMEDOUT)) {
                throw new RemoteConnectionException(e);
            } else {
                msg = String.format("Failed to retrieve information about %s. %s", resolvedPath, msg);
                throw new RemoteDataException(e);
            }
        } catch (Throwable t) {
            String msg = String.format("Failed to retrieve information about %s. %s",
                    resolvedPath, t.getMessage());
            throw new RemoteDataException(t);
        }
    }
protected SftpFileAttributes stat ( String resolvedPath , boolean skipCache ) throws FileNotFoundException , RemoteDataException { SftpFileAttributes atts = null ; try { if ( ! skipCache ) { atts = fileInfoCache . get ( resolvedPath ) ; } if ( atts == null ) { atts = getClient ( ) . stat ( StringUtils . removeEnd ( resolvedPath , "/" ) ) ; if ( atts != null && atts . isLink ( ) ) { atts = getClient ( ) . statLink ( resolvedPath ) ; } if ( atts != null ) { fileInfoCache . put ( resolvedPath , atts ) ; } } return atts ; } catch ( SftpStatusException e ) { fileInfoCache . remove ( resolvedPath ) ; switch ( e . getStatus ( ) ) { case SftpStatusException . SSH_FX_PERMISSION_DENIED : throw new RemotePermissionException ( e ) ; case SftpStatusException . SSH_FX_NO_SUCH_FILE : case SftpStatusException . SSH_FX_NO_SUCH_PATH : throw new FileNotFoundException ( e . getMessage ( ) ) ; default : throw new RemoteDataException ( e ) ; } } catch ( SshException e ) { fileInfoCache . remove ( resolvedPath ) ; String msg = e . getMessage ( ) ; if ( msg != null && msg . contains ( CONN_TIMEDOUT ) ) { throw new RemoteConnectionException ( e ) ; } else { msg = String . format ( "Failed to retrieve information about %s. %s" , resolvedPath , msg ) ; throw new RemoteDataException ( e ) ; } } catch ( Throwable t ) { String msg = String . format ( "Failed to retrieve information about %s. %s" , resolvedPath , t . getMessage ( ) ) ; throw new RemoteDataException ( t ) ; } }
Internal method to fetch and cache metadata for a remote file/folder.
Internal method to fetch and cache metadata for a remote file / folder .
// adjust for links so we get info about the referenced file/folder