Delete unused import
[arvados-workbench2.git] / src / services / ancestors-service / ancestors-service.ts
index 1cd42fb523945c3a6a5918b24b0474780dabe908..23e7729f7d0324f019de00f529c3dcd4d8022bb9 100644 (file)
@@ -14,17 +14,30 @@ export class AncestorService {
         private userService: UserService
     ) { }
 
-    async ancestors(uuid: string, rootUuid: string): Promise<Array<UserResource | GroupResource>> {
-        const service = this.getService(extractUuidObjectType(uuid));
+    async ancestors(startUuid: string, endUuid: string): Promise<Array<UserResource | GroupResource>> {
+        return this._ancestors(startUuid, endUuid);
+    }
+
+    private async _ancestors(startUuid: string, endUuid: string, previousUuid = ''): Promise<Array<UserResource | GroupResource>> {
+
+        if (startUuid === previousUuid) {
+            return [];
+        }
+
+        const service = this.getService(extractUuidObjectType(startUuid));
         if (service) {
-            const resource = await service.get(uuid);
-            if (uuid === rootUuid) {
-                return [resource];
-            } else {
-                return [
-                    ...await this.ancestors(resource.ownerUuid, rootUuid),
-                    resource
-                ];
+            try {
+                const resource = await service.get(startUuid);
+                if (startUuid === endUuid) {
+                    return [resource];
+                } else {
+                    return [
+                        ...await this._ancestors(resource.ownerUuid, endUuid, startUuid),
+                        resource
+                    ];
+                }
+            } catch (e) {
+                return [];
             }
         } else {
             return [];
@@ -41,4 +54,4 @@ export class AncestorService {
                 return undefined;
         }
     }
-}
\ No newline at end of file
+}