use of org.pentaho.di.connections.vfs.VFSConnectionProvider in project pentaho-kettle by pentaho.
the class VFSFileProvider method getRoot.
/**
* @param file
* @return
*/
private List<VFSFile> getRoot(VFSFile file) throws FileException {
if (this.roots.containsKey(file.getConnection())) {
return this.roots.get(file.getConnection());
}
List<VFSFile> files = new ArrayList<>();
VFSConnectionDetails vfsConnectionDetails = (VFSConnectionDetails) ConnectionManager.getInstance().getConnectionDetails(file.getConnection());
@SuppressWarnings("unchecked") VFSConnectionProvider<VFSConnectionDetails> vfsConnectionProvider = (VFSConnectionProvider<VFSConnectionDetails>) ConnectionManager.getInstance().getConnectionProvider(vfsConnectionDetails.getType());
List<VFSRoot> vfsRoots = vfsConnectionProvider.getLocations(vfsConnectionDetails);
if (vfsRoots.isEmpty()) {
throw new FileNotFoundException(file.getPath(), file.getProvider());
}
String scheme = vfsConnectionProvider.getProtocol(vfsConnectionDetails);
for (VFSRoot root : vfsRoots) {
VFSDirectory vfsDirectory = new VFSDirectory();
vfsDirectory.setName(root.getName());
vfsDirectory.setDate(root.getModifiedDate());
vfsDirectory.setHasChildren(true);
vfsDirectory.setCanAddChildren(true);
vfsDirectory.setParent(scheme + "://");
vfsDirectory.setDomain(vfsConnectionDetails.getDomain());
vfsDirectory.setConnection(vfsConnectionDetails.getName());
vfsDirectory.setPath(scheme + "://" + root.getName());
vfsDirectory.setRoot(NAME);
files.add(vfsDirectory);
}
this.roots.put(file.getConnection(), files);
return files;
}
Aggregations