public class FileTreeUpdater extends Object
FileTreeUpdater ftu = null; try { FileTreeUpdater ftu = new FileTreeUpdater("remote URL","local path"); List lis = ftu.scan(); // find changed files if(lis.size() >> 0) { // no changes if empty list returned ftu.downloadUpdates(); // download changed files ftu.copyUpdates(); // put changed files into place } } catch (IOException e) { e.printStackTrace(); }A URL example for the SFTP protocol is:
sftp://[ username[: password]@] hostname[: port][ absolute-path]Example:
sftp://myusername:mypassword@somehost/pub/downloads/somefile.tgzThis url is maintained in file
///AuvWorkbench/configuration/c_app.xml
Modifier and Type | Class and Description |
---|---|
static interface |
FileTreeUpdater.OpDone |
static interface |
FileTreeUpdater.StatusLineOut
Used to receive status updates from a FileTreeUpdater instance.
|
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.vfs.FileSystemManager |
fsManager |
protected String |
localPath |
protected org.apache.commons.vfs.FileObject |
root |
protected File |
tmpDir |
protected String |
url |
Constructor and Description |
---|
FileTreeUpdater(String _url,
String _localPath)
Construct this class and connect to remote machine.
|
FileTreeUpdater(String _url,
String _localPath,
FileTreeUpdater.StatusLineOut _slo)
Constructor with passed object to receive status and error messages
|
Modifier and Type | Method and Description |
---|---|
void |
_copyF(File src,
File dest) |
void |
addExcludedName(String name) |
void |
asyncCopyUpdates(FileTreeUpdater.OpDone od,
List<String> filteredList) |
void |
asyncDownloadUpdates(FileTreeUpdater.OpDone od,
List<String> filteredList) |
void |
asyncScan(FileTreeUpdater.OpDone od) |
void |
cancel()
For multi-threaded uses of this class, this will signal the processing loops to stop.
|
void |
clearDownloadCache() |
void |
close() |
void |
copyUpdates(List<String> filteredList)
Move the downloaded files into place, overwriting existing files.
|
void |
downloadUpdates(List<String> filteredList)
Download the changed files into a temporary directory in preparation for overwrite
of local tree.
|
File |
getDownloadCacheRoot() |
int |
getFileCount() |
int |
getScanListCount() |
List<String> |
scan()
Perform a scan of the remote machine.
|
protected String url
protected String localPath
protected File tmpDir
protected org.apache.commons.vfs.FileSystemManager fsManager
protected org.apache.commons.vfs.FileObject root
public FileTreeUpdater(String _url, String _localPath) throws Exception
_url
- URL string with scheme and user:password if required_localPath
- local path to updateException
- if network errorpublic FileTreeUpdater(String _url, String _localPath, FileTreeUpdater.StatusLineOut _slo) throws Exception
_url
- see FileTreeUpdater(String,String)
._localPath
- see FileTreeUpdater(String,String)
._slo
- see StatusLineOut interface.Exception
- see FileTreeUpdater(String,String)
.public int getFileCount()
public void cancel()
public void addExcludedName(String name)
public int getScanListCount()
public List<String> scan() throws IOException
IOException
public void asyncScan(FileTreeUpdater.OpDone od)
public void downloadUpdates(List<String> filteredList) throws IOException
filteredList
- IOException
- last error seenpublic void asyncDownloadUpdates(FileTreeUpdater.OpDone od, List<String> filteredList)
public void copyUpdates(List<String> filteredList) throws IOException
downloadUpdates(java.util.List<java.lang.String>)
.filteredList
- IOException
- last error seenpublic void clearDownloadCache()
public File getDownloadCacheRoot()
public void asyncCopyUpdates(FileTreeUpdater.OpDone od, List<String> filteredList)
public void close()
public void _copyF(File src, File dest) throws IOException
IOException