use of com.trilead.ssh2.SFTPException in project COSMIC-CryoEM-Gateway by cianfrocco-lab.
the class SFTPFileHandler method getInputStream.
public InputStream getInputStream(String fileName) throws Exception {
Connection conn = getConnection();
SFTPv3Client client = null;
try {
client = new SFTPv3Client(conn);
return new SFTPInputStream(conn, client, fileName);
} catch (SFTPException sftpErr) {
if (client != null) {
client.close();
}
conn.close();
// we want to produce behavior consistent with the java.io package, so
// that consumers can have a uniform way of handling exceptions
m_log.debug("Filename=" + fileName + ", " + sftpErr.getServerErrorMessage() + ": " + sftpErr.getServerErrorCodeVerbose());
if (sftpErr.getServerErrorCode() == 2) {
throw new FileNotFoundException(fileName);
} else {
throw sftpErr;
}
} catch (IOException ioErr) {
if (client != null)
client.close();
conn.close();
throw ioErr;
}
}
Aggregations