当前位置: 首页>>代码示例>>Java>>正文


Java ChannelSftp.SSH_FX_NO_SUCH_FILE属性代码示例

本文整理汇总了Java中com.jcraft.jsch.ChannelSftp.SSH_FX_NO_SUCH_FILE属性的典型用法代码示例。如果您正苦于以下问题:Java ChannelSftp.SSH_FX_NO_SUCH_FILE属性的具体用法?Java ChannelSftp.SSH_FX_NO_SUCH_FILE怎么用?Java ChannelSftp.SSH_FX_NO_SUCH_FILE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.jcraft.jsch.ChannelSftp的用法示例。


在下文中一共展示了ChannelSftp.SSH_FX_NO_SUCH_FILE属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendDirectoryToRemote

private void sendDirectoryToRemote(final ChannelSftp channel,
                                   final Directory directory)
    throws IOException, SftpException {
    final String dir = directory.getDirectory().getName();
    try {
        channel.stat(dir);
    } catch (final SftpException e) {
        // dir does not exist.
        if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
            channel.mkdir(dir);
            channel.chmod(getDirMode(), dir);
        }
    }
    channel.cd(dir);
    sendDirectory(channel, directory);
    channel.cd("..");
}
 
开发者ID:apache,项目名称:ant,代码行数:17,代码来源:ScpToMessageBySftp.java

示例2: fastExistsFile

protected boolean fastExistsFile(String name) throws GenericFileOperationFailedException {
    LOG.trace("fastExistsFile({})", name);
    try {
        @SuppressWarnings("rawtypes")
        Vector files = channel.ls(name);
        if (files == null) {
            return false;
        }
        return files.size() >= 1;
    } catch (SftpException e) {
        // or an exception can be thrown with id 2 which means file does not exists
        if (ChannelSftp.SSH_FX_NO_SUCH_FILE == e.id) {
            return false;
        }
        // otherwise its a more serious error so rethrow
        throw new GenericFileOperationFailedException(e.getMessage(), e);
    }

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:SftpOperations.java

示例3: createRemotePath

private void createRemotePath(@NotNull final ChannelSftp channel,
                              @NotNull final String destination) throws SftpException {
  final int endIndex = destination.lastIndexOf('/');
  if (endIndex > 0) {
    createRemotePath(channel, destination.substring(0, endIndex));
  }
  try {
    channel.stat(destination);
  } catch (SftpException e) {
    // dir does not exist.
    if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
      channel.mkdir(destination);
    }
  }

}
 
开发者ID:JetBrains,项目名称:teamcity-deployer-plugin,代码行数:16,代码来源:SftpBuildProcessAdapter.java

示例4: getMetaData

public ExternalResourceMetaData getMetaData(URI uri, boolean revalidate) {
    LockableSftpClient sftpClient = sftpClientFactory.createSftpClient(uri, credentials);
    try {
        SftpATTRS attributes = sftpClient.getSftpClient().lstat(uri.getPath());
        return attributes != null ? toMetaData(uri, attributes) : null;
    } catch (com.jcraft.jsch.SftpException e) {
        if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
            return null;
        }
        throw ResourceExceptions.getFailed(uri, e);
    } finally {
        sftpClientFactory.releaseSftpClient(sftpClient);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:14,代码来源:SftpResourceAccessor.java

示例5: convertException

private Exception convertException(Exception e) {

		if (SftpException.class.isAssignableFrom(e.getClass()) )
		{
			SftpException sftpEx = (SftpException)e;
			if (sftpEx.id == ChannelSftp.SSH_FX_NO_SUCH_FILE)
				return new FileNotFoundException(sftpEx.getMessage());
		}
		
		return e;

	}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:12,代码来源:SftpStorage.java

示例6: existsFile

public synchronized boolean existsFile(String name) throws GenericFileOperationFailedException {
    LOG.trace("existsFile({})", name);
    if (endpoint.isFastExistsCheck()) {
        return fastExistsFile(name);
    }
    // check whether a file already exists
    String directory = FileUtil.onlyPath(name);
    if (directory == null) {
        // assume current dir if no path could be extracted
        directory = ".";
    }
    String onlyName = FileUtil.stripPath(name);

    try {
        @SuppressWarnings("rawtypes")
        Vector files = channel.ls(directory);
        // can return either null or an empty list depending on FTP servers
        if (files == null) {
            return false;
        }
        for (Object file : files) {
            ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) file;
            String existing = entry.getFilename();
            LOG.trace("Existing file: {}, target file: {}", existing, name);
            existing = FileUtil.stripPath(existing);
            if (existing != null && existing.equals(onlyName)) {
                return true;
            }
        }
        return false;
    } catch (SftpException e) {
        // or an exception can be thrown with id 2 which means file does not exists
        if (ChannelSftp.SSH_FX_NO_SUCH_FILE == e.id) {
            return false;
        }
        // otherwise its a more serious error so rethrow
        throw new GenericFileOperationFailedException(e.getMessage(), e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:39,代码来源:SftpOperations.java

示例7: ignoreCannotRetrieveFile

@Override
protected boolean ignoreCannotRetrieveFile(String name, Exchange exchange, Exception cause) {
    if (getEndpoint().getConfiguration().isIgnoreFileNotFoundOrPermissionError()) {
        SftpException sftp = ObjectHelper.getException(SftpException.class, cause);
        if (sftp != null) {
            return sftp.id == ChannelSftp.SSH_FX_NO_SUCH_FILE || sftp.id == ChannelSftp.SSH_FX_PERMISSION_DENIED;
        }
    }
    return super.ignoreCannotRetrieveFile(name, exchange, cause);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:SftpConsumer.java

示例8: getMetaData

public ExternalResourceMetaData getMetaData(URI uri) throws IOException {
    LockableSftpClient sftpClient = sftpClientFactory.createSftpClient(uri, credentials);
    try {
        SftpATTRS attributes = sftpClient.getSftpClient().lstat(uri.getPath());
        return attributes != null ? toMetaData(uri, attributes) : null;
    } catch (com.jcraft.jsch.SftpException e) {
        if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
            return null;
        }
        throw new SftpException(String.format("Could not get resource '%s'.", uri), e);
    } finally {
        sftpClientFactory.releaseSftpClient(sftpClient);
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:14,代码来源:SftpResourceAccessor.java

示例9: execute

@Override
protected void execute() throws SftpResult, JSchException {
    ChannelSftp ch = channel();
    try {
        ch.rm(path);
        throw new SftpResult(true);
    } catch (SftpException e) {
        if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
            throw new SftpResult(false);
        }
        throw new SftpError(e, "Error putting file[%s]", path);
    } finally {
        release(ch);
    }
}
 
开发者ID:osglworks,项目名称:java-sftp,代码行数:15,代码来源:Delete.java

示例10: execute

@Override
protected void execute() throws SftpResult, JSchException {
    ChannelSftp ch = channel();
    try {
        ch.mkdir(path);
        throw new SftpResult(true);
    } catch (SftpException e) {
        if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
            throw new SftpResult(false);
        }
        throw new SftpError(e, "Error putting file[%s]", path);
    } finally {
        release(ch);
    }
}
 
开发者ID:osglworks,项目名称:java-sftp,代码行数:15,代码来源:MkDir.java

示例11: execute

@Override
protected void execute() throws SftpResult, JSchException {
    ChannelSftp ch = channel();
    try {
        ch.rmdir(path);
        throw new SftpResult(true);
    } catch (SftpException e) {
        if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
            throw new SftpResult(false);
        }
        throw new SftpError(e, "Error putting file[%s]", path);
    } finally {
        release(ch);
    }
}
 
开发者ID:osglworks,项目名称:java-sftp,代码行数:15,代码来源:DeleteDir.java

示例12: statSelf

/**
 * Fetches file attrs from server.
 */
private void statSelf() throws Exception
{
    ChannelSftp channel = fileSystem.getChannel();
    try
    {
        setStat(channel.stat(relPath));
    }
    catch (final SftpException e)
    {
        try
        {
            // maybe the channel has some problems, so recreate the channel and retry
            if (e.id != ChannelSftp.SSH_FX_NO_SUCH_FILE)
            {
                channel.disconnect();
                channel = fileSystem.getChannel();
                setStat(channel.stat(relPath));
            }
            else
            {
                // Really does not exist
                attrs = null;
            }
        }
        catch (final SftpException e2)
        {
            // TODO - not strictly true, but jsch 0.1.2 does not give us
            // enough info in the exception. Should be using:
            // if ( e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE )
            // However, sometimes the exception has the correct id, and
            // sometimes
            // it does not. Need to look into why.

            // Does not exist
            attrs = null;
        }
    }
    finally
    {
        fileSystem.putChannel(channel);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:45,代码来源:SftpFileObject.java

示例13: doGetInputStream

/**
     * Creates an input stream to read the file content from.
     */
    @Override
    protected InputStream doGetInputStream() throws Exception
    {
        // VFS-113: avoid npe
        synchronized (fileSystem)
        {
            final ChannelSftp channel = fileSystem.getChannel();
            try
            {
                // return channel.get(getName().getPath());
                // hmmm - using the in memory method is soooo much faster ...

                // TODO - Don't read the entire file into memory. Use the
                // stream-based methods on ChannelSftp once they work properly

                /*
                final ByteArrayOutputStream outstr = new ByteArrayOutputStream();
                channel.get(relPath, outstr);
                outstr.close();
                return new ByteArrayInputStream(outstr.toByteArray());
                */

                InputStream is;
                try
                {
                    // VFS-210: sftp allows to gather an input stream even from a directory and will
                    // fail on first read. So we need to check the type anyway
                    if (!getType().hasContent())
                    {
                        throw new FileSystemException("vfs.provider/read-not-file.error", getName());
                    }

                    is = channel.get(relPath);
                }
                catch (SftpException e)
                {
                    if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE)
                    {
                        throw new FileNotFoundException(getName());
                    }

                    throw new FileSystemException(e);
                }

                return new SftpInputStream(channel, is);

            }
            finally
            {
//              fileSystem.putChannel(channel);
            }
        }
    }
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:56,代码来源:SftpFileObject.java

示例14: mightBrokeSftpChannel

/**
 * If an sftp exception occurs, a question arises, whether we should call ChannelSftp.quit().
 * On one hane, *not* calling quit can lead to infinite 4: errors.
 * On the other hand, there might be quite standard situations like file not exist or permission denied,
 * which do not require quitting the channel.
 * This method distinguishes the former and the latter cases.
 */
public static boolean mightBrokeSftpChannel(SftpException e) {
    // Or should it be just  return e.id == ChannelSftp.SSH_FX_FAILURE ?
    // well, let's be conservative
    return e.id != ChannelSftp.SSH_FX_NO_SUCH_FILE && e.id != ChannelSftp.SSH_FX_PERMISSION_DENIED;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:MiscUtils.java


注:本文中的com.jcraft.jsch.ChannelSftp.SSH_FX_NO_SUCH_FILE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。