From 91162610de8efaa9c0bfd73ff99fcabe0ef23e8a Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Sat, 9 Feb 2019 18:33:55 -0500 Subject: Multiple fixes & enhancement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rework docker image build - Fix compress function - Fix node type name for source-primary-db Change-Id: Ide38e17036e76047d9f850b714ba0da4add5cd9d Issue-ID: CCSDK-414 Signed-off-by: Alexis de Talhouët --- .../core/utils/BluePrintArchiveUtils.kt | 34 ++++------------------ 1 file changed, 6 insertions(+), 28 deletions(-) (limited to 'ms/controllerblueprints/modules/blueprint-core') diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt index fe7929e8..f6bde1cc 100755 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt @@ -37,22 +37,6 @@ class BluePrintArchiveUtils { companion object { private val log = LoggerFactory.getLogger(BluePrintArchiveUtils::class.java) - fun getFileContent(fileName: String): String = runBlocking { - async { - try { - File(fileName).readText(Charsets.UTF_8) - } catch (e: Exception) { - throw BluePrintException("couldn't find file($fileName)") - } - }.await() - } - - fun compress(source: String, destination: String, absolute: Boolean): Boolean { - val rootDir = File(source) - val saveFile = File(destination) - return compress(rootDir, saveFile, absolute) - } - /** * Create a new Zip from a root directory * @@ -63,11 +47,12 @@ class BluePrintArchiveUtils { */ fun compress(source: File, destination: File, absolute: Boolean): Boolean { try { + destination.createNewFile() ZipArchiveOutputStream(destination).use { recurseFiles(source, source, it, absolute) } } catch (e: Exception) { - log.error("Fail to compress folder(:$source) to path(${destination.path}", e) + log.error("Fail to compress folder($source) to path(${destination.path}", e) return false } return true @@ -100,7 +85,10 @@ class BluePrintArchiveUtils { val zae = ZipArchiveEntry(filename) zae.size = file.length() zaos.putArchiveEntry(zae) - FileInputStream(file).use { IOUtils.copy(it, zaos) } + FileInputStream(file).use { + IOUtils.copy(it, zaos) + it.close() + } zaos.closeArchiveEntry() } } @@ -132,16 +120,6 @@ class BluePrintArchiveUtils { 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 -- cgit 1.2.3-korg