Java Code Examples for com.jcraft.jsch.SftpException#getMessage()

The following examples show how to use com.jcraft.jsch.SftpException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SftpDistributor.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public void test(Destination destination) throws DistributionException {
	SftpDestination sftpDestination = (SftpDestination) destination;
	
	if (!isConnected()) {
		connect(sftpDestination);
	}
    try {
       	String folder = sftpDestination.getFolder();
		if (folder != null) {
			channelSftp.cd(folder);
		}
		channelSftp.pwd();
	} catch (SftpException e) {
		throw new DistributionException(e.getMessage());
       } finally {
       	disconnect();
       }
}
 
Example 2
Source File: DefaultFileSystemExceptionFactory.java    From sftp-fs with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * <p>
 * If the {@link SftpException#id id} of the {@link SftpException} is not {@link ChannelSftp#SSH_FX_NO_SUCH_FILE} or
 * {@link ChannelSftp#SSH_FX_PERMISSION_DENIED}, this default implementation does not return a {@link FileSystemException}, but a
 * {@link NotLinkException} instead.
 */
@Override
public FileSystemException createReadLinkException(String link, SftpException exception) {
    if (exception.id == ChannelSftp.SSH_FX_NO_SUCH_FILE || exception.id == ChannelSftp.SSH_FX_PERMISSION_DENIED) {
        return asFileSystemException(link, null, exception);
    }
    final FileSystemException result = new NotLinkException(link, null, exception.getMessage());
    result.initCause(exception);
    return result;
}
 
Example 3
Source File: SftpFsHelper.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * Executes a get SftpCommand and returns an input stream to the file
 * @param cmd is the command to execute
 * @param sftp is the channel to execute the command on
 * @throws SftpException
 */
@Override
public InputStream getFileStream(String file) throws FileBasedHelperException {
  SftpGetMonitor monitor = new SftpGetMonitor();
  try {
    ChannelSftp channel = getSftpChannel();
    return new SftpFsFileInputStream(channel.get(file, monitor), channel);
  } catch (SftpException e) {
    throw new FileBasedHelperException("Cannot download file " + file + " due to " + e.getMessage(), e);
  }
}
 
Example 4
Source File: SftpSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static SftpIOException decorateSftpException(SftpException e, String path) {
    return new SftpIOException(e.id, e.getMessage(), path, e);
}