public ArrayList<FtpFileInfo> getFileList(String resPath)
{
ArrayList<FtpFileInfo> files = new ArrayList<FtpFileInfo>();
FtpFileInfo fi = new FtpFileInfoImpl();
fi.setName(".");
files.add(fi);
fi = new FtpFileInfoImpl();
fi.setName("..");
files.add(fi);
ArrayList<String> newPath = clientSession().getFullPath(resPath);
try
{
if (newPath.size() == 0)
{
if (clientSession().getFtpServer().getRepository() == null)
{
throw new RepositoryException("Repository can not be retrieved.");
}
String[] workspaces = clientSession().getFtpServer().getRepository().getWorkspaceNames();
for (int i = 0; i < workspaces.length; i++)
{
FtpFileInfo fileInfo = new FtpFileInfoImpl();
fileInfo.setName(workspaces[i]);
files.add(fileInfo);
}
}
else
{
String repoPath = clientSession().getRepoPath(newPath);
Session curSession = clientSession().getSession(newPath.get(0));
Node parentNode = (Node)curSession.getItem(repoPath);
if (parentNode.isNodeType(FtpConst.NodeTypes.NT_FILE))
{
files.clear();
FtpFileInfoImpl fileInfo = new FtpFileInfoImpl();
fileInfo.initFromNode(parentNode);
files.add(fileInfo);
}
else
{
NodeIterator nodeIter = parentNode.getNodes();
while (nodeIter.hasNext())
{
Node curNode = nodeIter.nextNode();
FtpFileInfoImpl fileInfo = new FtpFileInfoImpl();
fileInfo.initFromNode(curNode);
files.add(fileInfo);
}
}
}
}