// parse property file
VirtualFileStructure vfs = propFileParser.parse(new FileInputStream(
propFile));
// determine RemoteSite
DownloadInfo di = dfi.getDownloadInfo();
if (!di.isAllowAliasOverride()
|| (remoteSite = vfs.getRemoteSite()) == null)
remoteSite = di.getRemoteSite();
// modify vfs to be root based if HOME directory based
if (!vfs.isRootBased()) {
String homeDirPath = frs.getHomeDir(remoteSite).getPath();
VirtualFile root = new VirtualFile(homeDirPath, true);
root.addChild(vfs.getRootVirtualFile());
vfs = new VirtualFileStructure(homeDirPath + "/"
+ vfs.getPathToRoot(), root.getRootDir());
frs.changeToHOME(remoteSite);
}
// initialize variables
final String initialCdPath = vfs.getPathToRoot();
final VirtualFile vf = vfs.getRootVirtualFile();
// change to initial directory (takes care of Linux auto-mounting)
frs.changeToDir(initialCdPath, remoteSite);
// add starting directory to stack
Stack<RemoteSiteFile> files = new Stack<RemoteSiteFile>();
files.add(new RemoteSiteFile(frs.getCurrentFile(remoteSite), remoteSite));
// start crawling
while (!files.isEmpty()) {
RemoteSiteFile file = files.peek();
try {
// if directory, then add its children to the crawl list
if (file.isDir()) {
// get next page worth of children
List<RemoteSiteFile> children = frs.getNextPage(file,
new ProtocolFileFilter() {
@Override
public boolean accept(ProtocolFile pFile) {
return FileRestrictions.isAllowed(new
ProtocolPath(pFile
.getPath(), pFile.isDir()), vf);
}
});
// if directory had more children then add them
if (children.size() > 0)
files.addAll(children);
// otherwise remove the directory from the crawl list
else
files.pop();
// if file, then download it
} else {
linker.addPropFileToDataFileLink(propFile, file);
if (!frs.addToDownloadQueue(files.pop(), di
.getRenamingConv(), di.getStagingArea(), dfi
.getQueryMetadataElementName(), di
.deleteFromServer()))
linker.eraseLinks(propFile);
}
} catch (ToManyFailedDownloadsException e) {