aboutsummaryrefslogtreecommitdiffstats
path: root/components/core/src/main
diff options
context:
space:
mode:
authorSteve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com>2018-12-28 14:58:27 -0500
committerSteve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com>2019-01-04 10:54:21 -0500
commitae235a33287834a5541c4914ab7f54e821d9731d (patch)
treeba5b046727c3e93cf329d5a46e29ff297ac0b61a /components/core/src/main
parent65691146cceb8ee483cd4003f5fcc6fda14c0f01 (diff)
1st drop integration with BluePrintCatalogService
Change-Id: I0824dcaf0a36e4616c12f3ac53530e6863bee290 Issue-ID: CCSDK-418 Signed-off-by: Steve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com>
Diffstat (limited to 'components/core/src/main')
-rwxr-xr-x[-rw-r--r--]components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt7
-rwxr-xr-x[-rw-r--r--]components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt17
-rwxr-xr-xcomponents/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt1
3 files changed, 24 insertions, 1 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt
index d07d4dab..9186635e 100644..100755
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt
@@ -21,7 +21,7 @@ interface BluePrintCatalogService {
/**
* Upload the CBA Zip fle to data base and return the Database identifier
*/
- fun uploadToDataBase(file: String): String
+ fun uploadToDataBase(file: String, validate : Boolean): String
/**
* Download the CBA zip file from the data base and place it in a path and return the CBA zip absolute path
@@ -32,4 +32,9 @@ interface BluePrintCatalogService {
* Get the Blueprint from Data Base and Download it under working directory and return the path path
*/
fun prepareBluePrint(name: String, version: String): String
+
+ /**
+ * Get blueprint archive with zip file from Data Base
+ */
+ fun downloadFromDataBase(uuid: String, path: String): String
} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt
index c1ab4fc6..beb64913 100644..100755
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Bell Canada.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,10 +22,13 @@ import kotlinx.coroutines.runBlocking
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
import org.apache.commons.io.IOUtils
+import org.apache.commons.io.filefilter.DirectoryFileFilter
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import reactor.core.publisher.zip
import java.io.*
import java.nio.charset.Charset
+import java.nio.file.Files
import java.util.zip.ZipFile
class BluePrintArchiveUtils {
@@ -139,8 +143,10 @@ class BluePrintArchiveUtils {
val entry = enumeration.nextElement()
val destFilePath = File(targetPath, entry.name)
destFilePath.parentFile.mkdirs()
+
if (entry.isDirectory)
continue
+
val bufferedIs = BufferedInputStream(zip.getInputStream(entry))
bufferedIs.use {
destFilePath.outputStream().buffered(1024).use { bos ->
@@ -153,8 +159,19 @@ class BluePrintArchiveUtils {
check(destinationDir.isDirectory && destinationDir.exists()) {
throw BluePrintProcessorException("failed to decompress blueprint(${zipFile.absolutePath}) to ($targetPath) ")
}
+
return destinationDir
}
+
+ /**
+ * Get the first item in directory
+ *
+ * @param zipFile
+ * @return string
+ */
+ fun getFirstItemInDirectory(dir: File): String {
+ return dir.walk().map { it.name }.elementAt(1)
+ }
}
} \ No newline at end of file
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
index 2be9f19c..18896f51 100755
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Bell Canada.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.