} else {
log.debug("children are present: " + kids.length);
children = new TreeMap<String, SrbGeneralFileFileObject>();
for (int i = 0; i < kids.length; i++) {
final GeneralFile child = kids[i];
if (child == null) {
continue;
}
String childname = child.getName();
if (childname != null && !".".equals(childname) && !"..".equals(childname) &&
!"./".equals(childname) && !"../".equals(childname)) {
// Resolves a name, relative to the "root" file name.
// Refer to NameScope for a description of how names are resolved.
//
// Parameters:
// root - the base filename
// name - The name to resolve.
// scope - The NameScope to use when resolving the name.
// update the child FileObjects GeneralFile.
FileName fn = getFileSystem().getFileSystemManager().
resolveName(getName(), UriParser.encode(childname), NameScope.CHILD);
//log.debug("childname: [" + childname + "] fnStr: [" + fn.toString() + "] fnBas: [" + fn.getBaseName() + "]");
/**
* VFS resolveName and Jargon GeneralFile.getName() bug.
* Refer to results of following debug statement in explanation:
* log.debug("childname: [" + childname + "] fnStr: [" + fn.toString() + "] fnBas: [" + fn.getBaseName() + "]");
*
* A) Output of SRB Sls:
* =====================
* [ngs0153@ngs ~]$ Sls /ngs/home
* C-/ngs/home/http://marc.theaimsgroup.com/?l=redhat-list&m=109219329520329&w=2.ngs
* C-/home/ngs/david-meredith.ngs
* ...
* Note, that the file listing above contains a collection whose name
* begins with a url "http;//marc.theaimsgroup.com.."
*
*
* B) Name retireved by Jargon (child.getName()):
* ==============================================
* childname: [?l=redhat-list&m=109219329520329&w=2.ngs]
*
* Note, that the child name does not include the url
* part of the file name ("http;//marc.theaimsgroup.com..").
*
*
* D) FileName resolved by VFS (fn above)
* ========================================
* fnStr: [srb://srb1.ngs.rl.ac.uk/ngs/home?l=redhat-list&m=109219329520329&w=2.ngs]
* fnBas: [home]
*
* Note that the fn.toString() does not include the url part of the file name and also drops the
* file separator betweeen the home dir and the file name ("/ngs/home?l=redhat...").
* As a result, the fn.getBaseName() returns 'home' which is wrong.
*/
// Due to above bug, need to check that childname == fn.getBaseName()
// otherwise, will not be able to resolveFile correctly which causes ex.
if (fn != null && childname != null && childname.equals(fn.getBaseName())) {
//&& !"srb://srb1.ngs.rl.ac.uk/ngs/home?l=redhat-list&m=109219329520329&w=2.ngs".equals(fn.toString())) {
SrbGeneralFileFileObject fo = (SrbGeneralFileFileObject) getFileSystem().resolveFile(fn);
// Could also pass string to resolveFile and this must be an absPath !
//SrbGeneralFileFileObject fo = (SrbGeneralFileFileObject) getFileSystem().resolveFile(getName().getPath() + getName().SEPARATOR + childname);
// update the child collection.
if (fo != null) {
//fo.file = FileFactory.newFile(client, filePath + "/" + name);
fo.file = child;
// set this FileObjects FileType by injection
if (child.isFile()) {
// instantiate fo.attribs, fo.fileAttributes ?
fo.injectType(FileType.FILE);
children.put(childname, fo);
} else if (child.isDirectory()) {
// instantiate fo.attribs, fo.fileAttributes ?
fo.injectType(FileType.FOLDER);
children.put(childname, fo);
}