/**
* 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
* 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
/*
* 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.
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 {
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 ->
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