Add getRepoFiles() finction

The function get list of files from artifactory repo

Change-Id: I2daba8f3b8d79c03ae8f8fc775c4c04c7321a7ec
Related-Prod: PRODX-1553
diff --git a/src/com/mirantis/mk/Artifactory.groovy b/src/com/mirantis/mk/Artifactory.groovy
index 824ba4f..9ac53bc 100644
--- a/src/com/mirantis/mk/Artifactory.groovy
+++ b/src/com/mirantis/mk/Artifactory.groovy
@@ -494,3 +494,30 @@
 def deleteArtifactoryHelmChart(art, repoName, chartName){
     return restDelete(art, "/repositories/${repoName}", "${chartName}")
 }
+
+/**
+ * Get (recursively) list of all files in repo
+ *
+ * @param art           Artifactory connection object
+ * @param repoName      Repository name
+ * @param path          Folder path
+ *
+ * @return              List of paths to files in given repo and folder
+ */
+def getRepoFiles(art, repoName, path = '') {
+  List result = []
+  def response = restGet(art, "/storage/${repoName}/${path}")
+  List children = response.get('children', [])
+  // remove '/' to form more safe-looking path
+  path = path.replaceAll('/$', '')
+  for (child in children) {
+    // remove '/' to form more safe-looking path
+    String childUri = child['uri'].replaceAll('^/', '')
+    if (child['folder'].toBoolean()) {
+      result += getRepoFiles(art, repoName, "${path}/${childUri}")
+    } else {
+      result.add("${path}/${childUri}")
+    }
+  }
+  return result
+}