diff options
Diffstat (limited to 'components')
-rw-r--r-- | components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt | 13 | ||||
-rwxr-xr-x | components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt | 41 | ||||
-rwxr-xr-x | components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt | 65 | ||||
-rw-r--r-- | components/model-catalog/api-definition/proto/BluePrintManagement.proto | 56 | ||||
-rw-r--r-- | components/model-catalog/proto-definition/pom.xml | 81 | ||||
-rw-r--r-- | components/model-catalog/proto-definition/proto/BluePrintManagement.proto | 38 | ||||
-rw-r--r-- | components/model-catalog/proto-definition/proto/BluePrintProcessing.proto (renamed from components/model-catalog/api-definition/proto/BluePrintProcessing.proto) | 2 | ||||
-rw-r--r-- | components/parent/pom.xml | 12 | ||||
-rw-r--r-- | components/pom.xml | 4 |
9 files changed, 191 insertions, 121 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 68037387..4ef0e82b 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -27,12 +27,13 @@ object BluePrintConstants { const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID"
const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion"
const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion"
- const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion"
-
- const val STATUS_SUCCESS: String = "success"
- const val STATUS_FAILURE: String = "failure"
-
- const val TYPE_DEFAULT: String = "default"
+ const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" + + const val STATUS_SUCCESS: String = "success" + const val STATUS_PROCESSING: String = "processing" + const val STATUS_FAILURE: String = "failure" + + const val TYPE_DEFAULT: String = "default" const val DATA_TYPE_STRING: String = "string"
const val DATA_TYPE_INTEGER: String = "integer"
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 9186635e..c99cdf74 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 @@ -16,25 +16,44 @@ package org.onap.ccsdk.apps.controllerblueprints.core.interfaces -interface BluePrintCatalogService { +import org.jetbrains.annotations.NotNull +import org.jetbrains.annotations.Nullable +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import java.io.File +import java.nio.file.Path - /** - * Upload the CBA Zip fle to data base and return the Database identifier - */ - fun uploadToDataBase(file: String, validate : Boolean): String +interface BluePrintCatalogService { /** - * Download the CBA zip file from the data base and place it in a path and return the CBA zip absolute path + * Save the CBA to database. + * @param blueprintFile Either a directory, or an archive + * @param validate whether to validate blueprint content. Default true. + * @return The unique blueprint identifier + * @throws BluePrintException if process failed */ - fun downloadFromDataBase(name: String, version: String, path: String): String + @NotNull + @Throws(BluePrintException::class) + fun saveToDatabase(@NotNull blueprintFile: File, @Nullable validate: Boolean = true): String /** - * Get the Blueprint from Data Base and Download it under working directory and return the path path + * Retrieve the CBA from database either archived or extracted. + * @param name Name of the blueprint + * @param version Version of the blueprint + * @param extract true to extract the content, false for archived content. Default to true + * @return Path where CBA is located + * @throws BluePrintException if process failed */ - fun prepareBluePrint(name: String, version: String): String + @NotNull + @Throws(BluePrintException::class) + fun getFromDatabase(@NotNull name: String, @NotNull version: String, @Nullable extract: Boolean = true): Path /** - * Get blueprint archive with zip file from Data Base + * Delete the CBA from database. + * @param name Name of the blueprint + * @param version Version of the blueprint + * @throws BluePrintException if process failed */ - fun downloadFromDataBase(uuid: String, path: String): String + @NotNull + @Throws(BluePrintException::class) + fun deleteFromDatabase(@NotNull name: String, @NotNull version: 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 ab5175de..fe7929e8 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 @@ -24,13 +24,18 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream import org.apache.commons.io.IOUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import java.io.* +import org.slf4j.LoggerFactory +import java.io.BufferedInputStream +import java.io.File +import java.io.FileInputStream +import java.io.IOException import java.nio.charset.Charset import java.util.zip.ZipFile class BluePrintArchiveUtils { companion object { + private val log = LoggerFactory.getLogger(BluePrintArchiveUtils::class.java) fun getFileContent(fileName: String): String = runBlocking { async { @@ -51,50 +56,20 @@ class BluePrintArchiveUtils { /** * Create a new Zip from a root directory * - * @param directory the base directory - * @param filename the output filename + * @param source the base directory + * @param destination the output filename * @param absolute store absolute filepath (from directory) or only filename * @return True if OK */ fun compress(source: File, destination: File, absolute: Boolean): Boolean { - // recursive call - val zaos: ZipArchiveOutputStream try { - zaos = ZipArchiveOutputStream(FileOutputStream(destination)) - } catch (e: FileNotFoundException) { - return false - } - - try { - recurseFiles(source, source, zaos, absolute) - } catch (e2: IOException) { - try { - zaos.close() - } catch (e: IOException) { - // ignore + ZipArchiveOutputStream(destination).use { + recurseFiles(source, source, it, absolute) } - + } catch (e: Exception) { + log.error("Fail to compress folder(:$source) to path(${destination.path}", e) return false } - - try { - zaos.finish() - } catch (e1: IOException) { - // ignore - } - - try { - zaos.flush() - } catch (e: IOException) { - // ignore - } - - try { - zaos.close() - } catch (e: IOException) { - // ignore - } - return true } @@ -113,21 +88,19 @@ class BluePrintArchiveUtils { if (file.isDirectory) { // recursive call val files = file.listFiles() - for (file2 in files!!) { - recurseFiles(root, file2, zaos, absolute) + for (fileChild in files!!) { + recurseFiles(root, fileChild, zaos, absolute) } } else if (!file.name.endsWith(".zip") && !file.name.endsWith(".ZIP")) { - var filename: String? = null - if (absolute) { - filename = file.absolutePath.substring(root.absolutePath.length) + val filename = if (absolute) { + file.absolutePath.substring(root.absolutePath.length) } else { - filename = file.name + file.name } val zae = ZipArchiveEntry(filename) - zae.setSize(file.length()) + zae.size = file.length() zaos.putArchiveEntry(zae) - val fis = FileInputStream(file) - IOUtils.copy(fis, zaos) + FileInputStream(file).use { IOUtils.copy(it, zaos) } zaos.closeArchiveEntry() } } diff --git a/components/model-catalog/api-definition/proto/BluePrintManagement.proto b/components/model-catalog/api-definition/proto/BluePrintManagement.proto deleted file mode 100644 index 55f9466e..00000000 --- a/components/model-catalog/api-definition/proto/BluePrintManagement.proto +++ /dev/null @@ -1,56 +0,0 @@ -syntax = "proto3"; -option java_multiple_files = true; -package org.onap.ccsdk.apps.controllerblueprints.management.api; - -message BluePrintUploadInput { - CommonHeader commonHeader = 1; - string blueprintName = 2; - string blueprintVersion = 3; - FileChunk fileChunk = 4; -} - -message FileChunk { - bytes chunk = 1; -} - -message BluePrintUploadOutput { - CommonHeader commonHeader = 1; - Status status = 3; -} - -message BluePrintRemoveInput { - CommonHeader commonHeader = 1; - string blueprintName = 2; - string blueprintVersion = 3; -} - -message BluePrintRemoveOutput { - CommonHeader commonHeader = 1; - Status status = 3; -} - -message CommonHeader { - string timestamp = 1; - string originatorId = 23; - string requestId = 3; - string subRequestId = 4; -} - -message ActionIdentifiers { - string blueprintName = 1; - string blueprintVersion = 2; - string actionName = 3; - string mode = 4; -} - -message Status { - string timestamp = 1; - int32 code = 2; - string message = 3; - string errorMessage = 4; -} - -service BluePrintManagementService { - rpc uploadBlueprint (BluePrintUploadInput) returns (BluePrintUploadOutput); - rpc removeBlueprint (BluePrintRemoveInput) returns (BluePrintRemoveOutput); -} diff --git a/components/model-catalog/proto-definition/pom.xml b/components/model-catalog/proto-definition/pom.xml new file mode 100644 index 00000000..c1f77922 --- /dev/null +++ b/components/model-catalog/proto-definition/pom.xml @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (C) 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> + <artifactId>modules</artifactId> + <version>0.4.1-SNAPSHOT</version> + </parent> + + <artifactId>proto-definition</artifactId> + <packaging>jar</packaging> + + <name>Controller Blueprints Proto Definition</name> + <description>Controller Blueprints Proto Definition</description> + + <dependencies> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-protobuf</artifactId> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-stub</artifactId> + </dependency> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protobuf-java-util</artifactId> + </dependency> + </dependencies> + + <build> + <extensions> + <extension> + <groupId>kr.motd.maven</groupId> + <artifactId>os-maven-plugin</artifactId> + <version>1.6.1</version> + </extension> + </extensions> + <plugins> + <plugin> + <groupId>org.xolstice.maven.plugins</groupId> + <artifactId>protobuf-maven-plugin</artifactId> + <version>0.6.1</version> + <configuration> + <protocArtifact> + com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier} + </protocArtifact> + <pluginId>grpc-java</pluginId> + <pluginArtifact> + io.grpc:protoc-gen-grpc-java:1.16.1:exe:${os.detected.classifier} + </pluginArtifact> + <protoSourceRoot>proto</protoSourceRoot> + </configuration> + <executions> + <execution> + <goals> + <goal>compile</goal> + <goal>compile-custom</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project>
\ No newline at end of file diff --git a/components/model-catalog/proto-definition/proto/BluePrintManagement.proto b/components/model-catalog/proto-definition/proto/BluePrintManagement.proto new file mode 100644 index 00000000..dc0680d5 --- /dev/null +++ b/components/model-catalog/proto-definition/proto/BluePrintManagement.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; +option java_multiple_files = true; +package org.onap.ccsdk.apps.controllerblueprints.management.api; + +message BluePrintManagementInput { + CommonHeader commonHeader = 1; + string blueprintName = 2; + string blueprintVersion = 3; + FileChunk fileChunk = 4; +} + +message BluePrintManagementOutput { + CommonHeader commonHeader = 1; + Status status = 3; +} + +message FileChunk { + bytes chunk = 1; +} + +message CommonHeader { + string timestamp = 1; + string originatorId = 23; + string requestId = 3; + string subRequestId = 4; +} + +message Status { + string timestamp = 1; + int32 code = 2; + string message = 3; + string errorMessage = 4; +} + +service BluePrintManagementService { + rpc uploadBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput); + rpc removeBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput); +} diff --git a/components/model-catalog/api-definition/proto/BluePrintProcessing.proto b/components/model-catalog/proto-definition/proto/BluePrintProcessing.proto index 8fa4a13f..d8ad571b 100644 --- a/components/model-catalog/api-definition/proto/BluePrintProcessing.proto +++ b/components/model-catalog/proto-definition/proto/BluePrintProcessing.proto @@ -45,5 +45,5 @@ message Status { } service BluePrintProcessingService { - rpc process (ExecutionServiceInput) returns (stream ExecutionServiceOutput); + rpc process (stream ExecutionServiceInput) returns (stream ExecutionServiceOutput); } diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 8ecb2c1a..365515aa 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -304,7 +304,19 @@ </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-compiler-embeddable</artifactId> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-scripting-jvm-host</artifactId> + <!--Use kotlin-compiler-embeddable as koltin-compiler wrap--> + <!--guava dependency creating classpath issues at runtime--> + <exclusions> + <exclusion> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-compiler</artifactId> + </exclusion> + </exclusions> </dependency> <!-- GRPC Dependencies --> <dependency> diff --git a/components/pom.xml b/components/pom.xml index 5b8768ce..95ffd5c0 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -14,7 +14,8 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <parent> <groupId>org.onap.ccsdk.apps</groupId> <artifactId>ccsdk-apps</artifactId> @@ -37,5 +38,6 @@ <module>parent</module> <module>core</module> <module>resource-dict</module> + <module>model-catalog/proto-definition</module> </modules> </project> |