com.mindtree.techworks.insight.download
Class RemoteClient

java.lang.Object
  extended by com.mindtree.techworks.insight.download.RemoteClient
Direct Known Subclasses:
FTPRemoteClient, HTTPRemoteClient, SFTPRemoteClient

public abstract class RemoteClient
extends java.lang.Object

TODO

Version:
$Revision: 27 $ $Date: 2007-12-16 04:58:03 -0700 (Sun, 16 Dec 2007) $
Author:
Bindul Bhowmik

Field Summary
protected  java.io.File baseDownloadDirectory
          The base directory to which files are downloaded
protected  Insight insight
          The insight instance used for this class.
protected  boolean isBusy
          Is the instance of the client busy on an operation
protected  StatusBar statusBar
          The instance of status bar used for notifications.
 
Constructor Summary
RemoteClient()
          Creates an instance of the RemoteClient
 
Method Summary
protected abstract  void closeConnection()
          This method is to be called at the end of a transaction to complete any clean up operations on the connections, etc.
 java.lang.String[] downloadFile(Fileset fileset, java.lang.String file)
          Downloads a single file to the directory mentioned.
protected abstract  java.lang.String[] downloadFile(java.lang.String fileName)
          Downloads a single file to the default download directory, and returns the complete pathof the file.
 java.util.List downloadFiles(Fileset fileset, java.util.List files)
          Downloads a list of files from the remote host.
protected  java.io.File getDestinationFile(java.lang.String fileName, char seperatorChar)
          This method creates a destination temporary file and returns it to the calling method.
 void setBaseDownloadDirectory(java.lang.String directoryName)
          Set the base directory to which files are downloaded.
protected abstract  void setFileset(Fileset fileset)
          Sets the fileset.
 void setInsight(Insight insight)
          Sets the insight instance calling this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseDownloadDirectory

protected java.io.File baseDownloadDirectory
The base directory to which files are downloaded


isBusy

protected boolean isBusy
Is the instance of the client busy on an operation


statusBar

protected StatusBar statusBar
The instance of status bar used for notifications.


insight

protected Insight insight
The insight instance used for this class.

Constructor Detail

RemoteClient

public RemoteClient()
Creates an instance of the RemoteClient

Method Detail

setInsight

public void setInsight(Insight insight)
Sets the insight instance calling this class.

Parameters:
insight - The insight instance

setBaseDownloadDirectory

public void setBaseDownloadDirectory(java.lang.String directoryName)
                              throws java.io.IOException
Set the base directory to which files are downloaded.

Parameters:
directoryName - The name of the directory. It is created, if not present.
Throws:
java.io.IOException - If the directory cannot be created, or the path does not denote a directory or the application cannot write in this directory.

downloadFile

public java.lang.String[] downloadFile(Fileset fileset,
                                       java.lang.String file)
                                throws RemoteClientException
Downloads a single file to the directory mentioned. Returns the name of the file downloaded.

Parameters:
fileset - The fileset to get host information from.
file - The file to download on the host. The actual format is client dependent.
Returns:
The Complete path to the downloaded file.
Throws:
RemoteClientException - Remote exception if the client is busy or download fails.

downloadFiles

public java.util.List downloadFiles(Fileset fileset,
                                    java.util.List files)
                             throws RemoteClientException
Downloads a list of files from the remote host. Returns the names of the files downloaded.

Parameters:
fileset - The fileset to get host information from.
files - The list of files to download on the host. The actual format is client dependent.
Returns:
The list of complete path to the downloaded file.
Throws:
RemoteClientException - Remote exception if the client is busy or download fails.

setFileset

protected abstract void setFileset(Fileset fileset)
                            throws RemoteClientException
Sets the fileset. The actual implementation is client dependent, clients may extract information from the fileset. Most clients would check if the client instance created is compatible for the type of file being downloaded.

Parameters:
fileset - The fileset being set
Throws:
RemoteClientException - If the information is not correct or the client is incompatible for the fileset.

downloadFile

protected abstract java.lang.String[] downloadFile(java.lang.String fileName)
                                            throws RemoteClientException
Downloads a single file to the default download directory, and returns the complete pathof the file.

Parameters:
fileName - The file path and name on the remote system to download. The actual format is client dependent.
Returns:
The array of complete paths to the downloaded files.
Throws:
RemoteClientException - If the download fails.

closeConnection

protected abstract void closeConnection()
                                 throws RemoteClientException
This method is to be called at the end of a transaction to complete any clean up operations on the connections, etc.

Throws:
RemoteClientException - If there is any exception during the cleanup.

getDestinationFile

protected java.io.File getDestinationFile(java.lang.String fileName,
                                          char seperatorChar)
                                   throws java.io.IOException
This method creates a destination temporary file and returns it to the calling method.

Parameters:
fileName - The filename which is being downloaded, part of the destination filename is generated from this.
seperatorChar - The seperator character in the path specified in the fileName passed.
Returns:
A handle to the file where the source file is to be downloaded.
Throws:
java.io.IOException - If the file cannot be downloaded.
See Also:
Temporary File creation


Copyright © 2003-2008 MindTree Consulting Ltd.. All Rights Reserved.