[ARVADOS-WORKBENCH2] updated: 1.1.4-587-g67a259f

Git user git at public.curoverse.com
Mon Aug 13 06:37:03 EDT 2018


Summary of changes:
 src/common/xml.ts                                  |  8 ++++++++
 .../collection-service/collection-service.ts       | 22 ++++++++--------------
 2 files changed, 16 insertions(+), 14 deletions(-)
 create mode 100644 src/common/xml.ts

       via  67a259f2d6b350fd694a140b646cc07c50182f6e (commit)
       via  9617303db6efc4ff82b0f46af9aa9080879cc553 (commit)
      from  812e47f58549b4801a8fc5279bcf6cc6eec7925b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 67a259f2d6b350fd694a140b646cc07c50182f6e
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Mon Aug 13 12:36:49 2018 +0200

    Apply getTagVlue function
    
    Feature #13990
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/services/collection-service/collection-service.ts b/src/services/collection-service/collection-service.ts
index 67c3686..7e4d804 100644
--- a/src/services/collection-service/collection-service.ts
+++ b/src/services/collection-service/collection-service.ts
@@ -49,7 +49,7 @@ export class CollectionService extends CommonResourceService<CollectionResource>
     extractFilesData(document: Document) {
         return Array
             .from(document.getElementsByTagName('D:response'))
-            .slice(1)
+            .slice(1) // omit first element which is collection itself
             .map(element => {
                 const name = getTagValue(element, 'D:displayname', '');
                 const size = parseInt(getTagValue(element, 'D:getcontentlength', '0') as string, 10);
@@ -64,10 +64,9 @@ export class CollectionService extends CommonResourceService<CollectionResource>
                     path: directory,
                 };
 
-                const [resourceTypeElement] = Array.from(element.getElementsByTagName('D:resourcetype'));
-                return resourceTypeElement && resourceTypeElement.innerHTML === ''
-                    ? createCollectionFile({ ...data, size })
-                    : createCollectionDirectory(data);
+                return getTagValue(element, 'D:resourcetype', '')
+                    ? createCollectionDirectory(data)
+                    : createCollectionFile({ ...data, size });
 
             });
     }

commit 9617303db6efc4ff82b0f46af9aa9080879cc553
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Mon Aug 13 12:31:55 2018 +0200

    Extract function for getting xml tag value
    
    Feature #13990
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/common/xml.ts b/src/common/xml.ts
new file mode 100644
index 0000000..c810de9
--- /dev/null
+++ b/src/common/xml.ts
@@ -0,0 +1,8 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+export const getTagValue = (document: Document | Element, tagName: string, defaultValue: string) => {
+    const [el] = Array.from(document.getElementsByTagName(tagName));
+    return el ? el.innerHTML : defaultValue;
+};
diff --git a/src/services/collection-service/collection-service.ts b/src/services/collection-service/collection-service.ts
index add7ba9..67c3686 100644
--- a/src/services/collection-service/collection-service.ts
+++ b/src/services/collection-service/collection-service.ts
@@ -14,6 +14,7 @@ import { KeepManifestStream } from "../../models/keep-manifest";
 import { WebDAV } from "../../common/webdav";
 import { AuthService } from "../auth-service/auth-service";
 import { mapTree, getNodeChildren, getNode, TreeNode } from "../../models/tree";
+import { getTagValue } from "../../common/xml";
 
 export type UploadProgress = (fileId: number, loaded: number, total: number, currentTime: number) => void;
 
@@ -50,16 +51,10 @@ export class CollectionService extends CommonResourceService<CollectionResource>
             .from(document.getElementsByTagName('D:response'))
             .slice(1)
             .map(element => {
-                const [displayNameElement] = Array.from(element.getElementsByTagName('D:displayname'));
-                const name = displayNameElement ? displayNameElement.innerHTML : undefined;
-
-                const [sizeElement] = Array.from(element.getElementsByTagName('D:getcontentlength'));
-                const size = sizeElement ? parseInt(sizeElement.innerHTML, 10) : 0;
-
-                const [hrefElement] = Array.from(element.getElementsByTagName('D:href'));
-                const pathname = hrefElement ? hrefElement.innerHTML : undefined;
+                const name = getTagValue(element, 'D:displayname', '');
+                const size = parseInt(getTagValue(element, 'D:getcontentlength', '0') as string, 10);
+                const pathname = getTagValue(element, 'D:href', '');
                 const directory = pathname && pathname.replace(/\/c=[0-9a-zA-Z\-]*/, '').replace(`/${name || ''}`, '');
-
                 const href = this.webdavClient.defaults.baseURL + pathname + '?api_token=' + this.authService.getApiToken();
 
                 const data = {

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list