More HDFS Manage Access dialog updates (#7692)

* Add support for default permissions on directories

(cherry picked from commit 4e81cceba142c6763c3447b4d2965cd75764f8f9)

* Remove unneeded import

(cherry picked from commit ffe5f357357e75e9290966e89768c699df2e1311)

* Add recursive apply and clean up webhdfs

(cherry picked from commit ae76df14f99e599df1cdfcc74ee22d3822f11a59)

* Final set of changes

* Undo changes to azdata/sqlops and few minor fixes

* Remove cast to fix build error

* Hide defaults checkbox for files and switch checkbox order
This commit is contained in:
Charles Gagnon
2019-10-11 15:18:17 -07:00
committed by GitHub
parent 888327f5bc
commit d02c680dab
9 changed files with 466 additions and 162 deletions

View File

@@ -17,7 +17,7 @@ import * as constants from '../constants';
import { WebHDFS, HdfsError } from '../hdfs/webhdfs';
import { AclEntry, PermissionStatus } from '../hdfs/aclEntry';
import { Mount, MountStatus } from '../hdfs/mount';
import { FileStatus } from '../hdfs/fileStatus';
import { FileStatus, HdfsFileType } from '../hdfs/fileStatus';
const localize = nls.loadMessageBundle();
@@ -87,6 +87,11 @@ export interface IFileSource {
* @param aclEntries The ACL entries to set
*/
setAcl(path: string, ownerEntry: AclEntry, groupEntry: AclEntry, otherEntry: AclEntry, aclEntries: AclEntry[]): Promise<void>;
/**
* Removes the default ACLs for the specified path
* @param path The path to remove the default ACLs for
*/
removeDefaultAcl(path: string): Promise<void>;
/**
* Sets the permission octal (sticky, owner, group & other) for a file/folder
* @param path The path to the file/folder to set the permission of
@@ -120,11 +125,6 @@ export interface IRequestParams {
headers?: {};
}
export interface IHdfsFileStatus {
type: 'FILE' | 'DIRECTORY';
pathSuffix: string;
}
export class FileSourceFactory {
private static _instance: FileSourceFactory;
@@ -181,7 +181,7 @@ export class HdfsFileSource implements IFileSource {
if (!this.mounts || refresh) {
await this.loadMounts();
}
return this.readdir(path);
return this.listStatus(path);
}
private loadMounts(): Promise<void> {
@@ -196,16 +196,15 @@ export class HdfsFileSource implements IFileSource {
});
}
private readdir(path: string): Promise<IFile[]> {
private listStatus(path: string): Promise<IFile[]> {
return new Promise((resolve, reject) => {
this.client.readdir(path, (error, files) => {
this.client.listStatus(path, (error, fileStatuses) => {
if (error) {
reject(error);
}
else {
let hdfsFiles: IFile[] = files.map(fileStat => {
let hdfsFile = <IHdfsFileStatus>fileStat;
let file = new File(File.createPath(path, hdfsFile.pathSuffix), hdfsFile.type === 'DIRECTORY');
let hdfsFiles: IFile[] = fileStatuses.map(fileStatus => {
let file = new File(File.createPath(path, fileStatus.pathSuffix), fileStatus.type === HdfsFileType.Directory);
if (this.mounts && this.mounts.has(file.path)) {
file.mountStatus = MountStatus.Mount;
}
@@ -403,6 +402,22 @@ export class HdfsFileSource implements IFileSource {
});
}
/**
* Removes the default ACLs for the specified path
* @param path The path to remove the default ACLs for
*/
public removeDefaultAcl(path: string): Promise<void> {
return new Promise((resolve, reject) => {
this.client.removeDefaultAcl(path, (error: HdfsError) => {
if (error) {
reject(error);
} else {
resolve();
}
});
});
}
/**
* Sets the permission octal (sticky, owner, group & other) for a file/folder
* @param path The path to the file/folder to set the permission of