public void disconnect() { if ( c != null ) { c.disconnect(); } if ( s != null ) { s.disconnect(); } }
public synchronized void close() throws IOException { if (closed) { return; } super.close(); closed = true; if (!channel.isConnected()) { throw new IOException(E_CLIENT_NOTCONNECTED); } try { Session session = channel.getSession(); channel.disconnect(); session.disconnect(); } catch (JSchException e) { throw new IOException(StringUtils.stringifyException(e)); } } }
@Override public List<String> ls(String path) throws FileBasedHelperException { try { List<String> list = new ArrayList<>(); ChannelSftp channel = getSftpChannel(); Vector<LsEntry> vector = channel.ls(path); for (LsEntry entry : vector) { list.add(entry.getFilename()); } channel.disconnect(); return list; } catch (SftpException e) { throw new FileBasedHelperException("Cannot execute ls command on sftp connection", e); } }
void disconnect(ChannelSftp channel) throws IOException { if (channel != null) { // close connection if too many active connections boolean closeConnection = false; synchronized (this) { if (liveConnectionCount > maxConnection) { --liveConnectionCount; con2infoMap.remove(channel); closeConnection = true; } } if (closeConnection) { if (channel.isConnected()) { try { Session session = channel.getSession(); channel.disconnect(); session.disconnect(); } catch (JSchException e) { throw new IOException(StringUtils.stringifyException(e)); } } } else { returnToPool(channel); } } }
@Override public long getFileSize(String filePath) throws FileBasedHelperException { try { ChannelSftp channelSftp = getSftpChannel(); long fileSize = channelSftp.lstat(filePath).getSize(); channelSftp.disconnect(); return fileSize; } catch (SftpException e) { throw new FileBasedHelperException( String.format("Failed to get size for file at path %s due to error %s", filePath, e.getMessage()), e); } }
@Override public long getFileMTime(String filePath) throws FileBasedHelperException { ChannelSftp channelSftp = null; try { channelSftp = getSftpChannel(); int modificationTime = channelSftp.lstat(filePath).getMTime(); return modificationTime; } catch (SftpException e) { throw new FileBasedHelperException( String.format("Failed to get modified timestamp for file at path %s due to error %s", filePath, e.getMessage()), e); } finally { if (channelSftp != null) { channelSftp.disconnect(); } } }
@Override public void disconnect() { ftp.disconnect(); ftp = null; }
@Override public void close() throws Exception { sftp.getSession().disconnect(); sftp.disconnect(); }
@Override public void close() { this.closed = true; if (this.wrapper != null) { if (this.channel != null) { this.channel.disconnect(); } this.wrapper.close(); } else { if (this.jschSession.isConnected()) { this.jschSession.disconnect(); } } }
@Override public void clear() { if (sftp != null) sftp.disconnect(); }
@Override public void clear() { if (sftp != null) sftp.disconnect(); }
@Override public void clear() { if (sftp != null) sftp.disconnect(); }
@Override public void close() throws IOException { super.close(); if (sftp != null) sftp.disconnect(); } }
@Override public void logoutFtpServer() { if (channelSftp != null) { channelSftp.disconnect(); } if (session != null) { session.disconnect(); } }
@Override protected void doCloseCommunicationLink() { if (idleChannel != null) { idleChannel.disconnect(); idleChannel = null; } if (session != null) { session.disconnect(); session = null; } }
@Override public void close() throws IOException { super.close(); if (sftp != null) sftp.disconnect(); } }
/** * Disconnect. * * @throws IOException Signals that an I/O exception has occurred. */ public void disconnect() throws IOException { if (m_channel != null) m_channel.disconnect(); if (m_session != null) m_session.disconnect(); }
@Override public void close() throws IOException { super.close(); if (sftp != null) sftp.disconnect(); } }
private void closeChannel() { if (channel != null) { channel.disconnect(); try { channel.getSession().disconnect(); } catch (JSchException ex) { // Ignore possible exception thrown by getSession() } } channel = null; }
public final boolean createFolder(String folder) throws JSchException, SftpException { ChannelSftp channel = (ChannelSftp) sesConnection.openChannel("sftp"); channel.connect(); channel.mkdir(folder); channel.disconnect(); return true; }