use of org.talend.designer.hdfsbrowse.model.HDFSPath in project tbd-studio-se by Talend.
the class FileSelectorTreeViewerProvider method getElements.
public Object[] getElements(Object inputElement) {
if (inputElement instanceof HDFSConnectionBean) {
try {
HDFSPath root = new HDFSFolder(this, (HDFSConnectionBean) inputElement);
root.setValue(ROOT_PATH);
root.setPath(ROOT_PATH);
return new Object[] { root };
} catch (Exception e) {
log.error(e);
}
}
return EMPTY_CONTENT;
}
use of org.talend.designer.hdfsbrowse.model.HDFSPath in project tbd-studio-se by Talend.
the class HadoopOperationManager method loadHDFSFolderChildren.
public void loadHDFSFolderChildren(HDFSConnectionBean connection, Object fileSystem, ClassLoader classLoader, HDFSPath parent, String path) throws HadoopServerException {
if (connection == null || fileSystem == null || classLoader == null || parent == null || path == null) {
return;
}
ClassLoader oldClassLoaderLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(classLoader);
Object pathObj = ReflectionUtils.newInstance("org.apache.hadoop.fs.Path", classLoader, new Object[] { path });
Object[] statusList = (Object[]) ReflectionUtils.invokeMethod(fileSystem, "listStatus", new Object[] { pathObj });
if (statusList == null) {
return;
}
for (Object status : statusList) {
HDFSPath content = null;
Object statusPath = ReflectionUtils.invokeMethod(status, "getPath", new Object[0]);
if (statusPath == null) {
continue;
}
String pathName = (String) ReflectionUtils.invokeMethod(statusPath, "getName", new Object[0]);
if (StringUtils.isBlank(pathName)) {
continue;
}
String absolutePath = ((URI) ReflectionUtils.invokeMethod(statusPath, "toUri", new Object[0])).toString();
if (StringUtils.isBlank(absolutePath)) {
continue;
}
String relativePath = URI.create(absolutePath).getPath();
if ((Boolean) ReflectionUtils.invokeMethod(status, "isDir", new Object[0])) {
content = new HDFSFolder(parent);
} else {
content = new HDFSFile(parent);
content.setTable(createTable(trimFileExtention(pathName)));
}
content.setPath(relativePath);
content.setValue(pathName);
parent.addChild(content);
}
} catch (Exception e) {
throw new HadoopServerException(e);
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoaderLoader);
}
}
Aggregations