diff options
author | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-02-09 18:33:55 -0500 |
---|---|---|
committer | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-02-12 13:02:59 -0500 |
commit | a2fadaccbcdea04f3247b3abb5a2286c51341b5f (patch) | |
tree | 13894c69e192f4326ecf9f0cce9881cca39dd8bf /ms/controllerblueprints/modules | |
parent | c319fed9310f3e6d42202f1161040c5c7b709458 (diff) |
Multiple fixes & enhancement
- 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 <adetalhouet89@gmail.com>
Diffstat (limited to 'ms/controllerblueprints/modules')
3 files changed, 8 insertions, 30 deletions
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 fe7929e85..f6bde1cc5 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 diff --git a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt index 3ba729d1c..cfde86aac 100644 --- a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt +++ b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt @@ -41,7 +41,7 @@ abstract class BlueprintCatalogServiceImpl(private val blueprintValidator: BlueP if (blueprintFile.isDirectory) { extractedDirectory = blueprintFile - archivedDirectory = File(":$blueprintFile.zip") + archivedDirectory = File("$blueprintFile.zip") toDeleteDirectory = archivedDirectory if (!BluePrintArchiveUtils.compress(blueprintFile, archivedDirectory, true)) { diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoadService.kt index 4fd66ed57..948601cf4 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoadService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoadService.kt @@ -61,7 +61,7 @@ open class BluePrintCatalogLoadService(private val bluePrintCatalogService: Blue try { bluePrintCatalogService.saveToDatabase(file) } catch (e: Exception) { - errorBuilder.appendln("Couldn't load DataType(${file.name}: ${e.message}") + errorBuilder.appendln("Couldn't load BlueprintModel(${file.name}: ${e.message}") } } |