summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rwxr-xr-x[-rw-r--r--]components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt46
-rwxr-xr-xcomponents/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zipbin0 -> 5382 bytes
-rw-r--r--components/parent/pom.xml9
3 files changed, 55 insertions, 0 deletions
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 67ae3987..2be9f19c 100644..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
@@ -20,6 +20,7 @@ import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import kotlinx.coroutines.runBlocking
import org.apache.commons.io.FileUtils
+import org.apache.commons.lang3.StringUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.data.ImportDefinition
@@ -28,7 +29,16 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import java.io.File
import java.io.FileFilter
import java.nio.file.Files
+import java.nio.file.Path
+import java.nio.file.Paths
import java.nio.file.StandardOpenOption
+import java.text.MessageFormat
+import java.time.Instant
+import java.time.temporal.ChronoUnit
+import java.time.ZoneId
+import java.time.format.DateTimeFormatter
+
+
class BluePrintFileUtils {
companion object {
@@ -196,6 +206,42 @@ class BluePrintFileUtils {
"\nEntry-Definitions: Definitions/<BLUEPRINT_NAME>.json" +
"\nTemplate-Tags: <TAGS>"
}
+
+ fun getBluePrintFile(fileName: String, targetPath: Path) : File {
+ val filePath = targetPath.resolve(fileName).toString()
+ val file = File(filePath)
+ check(file.exists()) {
+ throw BluePrintException("couldn't get definition file under path(${file.absolutePath})")
+ }
+ return file
+ }
+
+ fun getCBAGeneratedFileName(fileName: String, prefix: String): String {
+ val DATE_FORMAT = "yyyyMMddHHmmss"
+ val formatter = DateTimeFormatter.ofPattern(DATE_FORMAT)
+ val datePrefix = Instant.now().atZone(ZoneId.systemDefault()).toLocalDateTime().format(formatter)
+ return MessageFormat.format(prefix, datePrefix, fileName)
+ }
+
+ fun getCbaStorageDirectory(path: String): Path {
+ check(StringUtils.isNotBlank(path)) {
+ throw BluePrintException("CBA Path is missing.")
+ }
+
+ val fileStorageLocation = Paths.get(path).toAbsolutePath().normalize()
+
+ if (!Files.exists(fileStorageLocation))
+ Files.createDirectories(fileStorageLocation)
+
+ return fileStorageLocation
+ }
+
+ fun stripFileExtension(fileName: String): String {
+ val dotIndexe = fileName.lastIndexOf('.')
+
+ // In case dot is in first position, we are dealing with a hidden file rather than an extension
+ return if (dotIndexe > 0) fileName.substring(0, dotIndexe) else fileName
+ }
}
} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip b/components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip
new file mode 100755
index 00000000..77882ef1
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip
Binary files differ
diff --git a/components/parent/pom.xml b/components/parent/pom.xml
index 03656ebd..1330279e 100644
--- a/components/parent/pom.xml
+++ b/components/parent/pom.xml
@@ -120,6 +120,11 @@
<version>${kotlin.couroutines.version}</version>
</dependency>
<dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-reactor</artifactId>
+ <version>${kotlin.couroutines.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
@@ -259,6 +264,10 @@
<artifactId>kotlinx-coroutines-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-reactor</artifactId>
+ </dependency>
+ <dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>