* @param localFile
* @throws GfacException
*/
public void downloadFile(URI destURI, GSSCredential gsCredential, File localFile) throws ToolsException {
GridFTPClient ftpClient = null;
GridFTPContactInfo contactInfo = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
try {
String remoteFile = destURI.getPath();
log.info("The local temp file is " + localFile);
log.info("the remote file is " + remoteFile);
log.debug("Setup GridFTP Client");
ftpClient = new GridFTPClient(contactInfo.hostName, contactInfo.port);
ftpClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
ftpClient.authenticate(gsCredential);
ftpClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
log.debug("Downloading file");
if (checkBinaryExtensions(remoteFile)) {
log.info("Transfer mode is set to Binary to download a file");
ftpClient.setType(Session.TYPE_IMAGE);
}
ftpClient.get(remoteFile, localFile);
log.info("Download file to:" + remoteFile + " is done");
} catch (ServerException e) {
throw new ToolsException("Cannot download file from GridFTP:" + contactInfo.toString(), e);
} catch (IOException e) {
throw new ToolsException("Cannot download file from GridFTP:" + contactInfo.toString(), e);
} catch (ClientException e) {
throw new ToolsException("Cannot download file from GridFTP:" + contactInfo.toString(), e);
} finally {
if (ftpClient != null) {
try {
ftpClient.close();
} catch (Exception e) {