use of com.microsoft.azure.hdinsight.sdk.common.errorresponse.ForbiddenHttpErrorStatus in project azure-tools-for-java by Microsoft.
the class ADLSGen2FileSystem method listFiles.
@NotNull
public VirtualFile[] listFiles(AdlsGen2VirtualFile vf) {
List<AdlsGen2VirtualFile> childrenList = new ArrayList<>();
if (vf.isDirectory()) {
// sample fileSystemRootPath: https://accountName.dfs.core.windows.net/fileSystem/
String fileSystemRootPath = rootPathUri.resolve("/").getUrl().toString();
// sample directoryParam: sub/path/to
String directoryParam = vf.getAbfsUri().getDirectoryParam();
childrenList = this.op.list(fileSystemRootPath, directoryParam).map(remoteFile -> new AdlsGen2VirtualFile((AbfsUri) AbfsUri.parse(fileSystemRootPath).resolveAsRoot(AzureStorageUri.encodeAndNormalizePath(remoteFile.getName())), remoteFile.isDirectory(), this)).doOnNext(file -> file.setParent(vf)).onErrorResumeNext(err -> {
String errorMessage = "Failed to list folders and files with error " + err.getMessage() + ". ";
if (err instanceof ForbiddenHttpErrorStatus) {
errorMessage += ADLSGen2Deploy.getForbiddenErrorHints(vf.toString());
}
return Observable.error(new IOException(errorMessage));
}).toList().toBlocking().lastOrDefault(new ArrayList<>());
}
return childrenList.toArray(new VirtualFile[0]);
}
Aggregations