summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main
diff options
context:
space:
mode:
authorBrinda Santh <brindasanth@in.ibm.com>2019-09-04 11:14:39 -0400
committerBrinda Santh <brindasanth@in.ibm.com>2019-09-04 11:14:39 -0400
commitb8afed63dea50e0833a820bd15bbeafc1a08412e (patch)
treec734aa01a8e9a28cb58870bdfb6a85afeac511e6 /ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main
parentf58ffbbdac2800a6828d072223883e52714460b6 (diff)
Add draft and publish grpc upload options.
Change-Id: Id1476f1cb449c4070a7ef53a918b62d26da26391 Issue-ID: CCSDK-1682 Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt51
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt2
2 files changed, 41 insertions, 12 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
index 451f827b6..0116680cf 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
@@ -24,21 +24,19 @@ import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.currentTimestamp
import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader
import org.onap.ccsdk.cds.controllerblueprints.common.api.Status
+import org.onap.ccsdk.cds.controllerblueprints.core.*
import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
-import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
-import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
-import org.onap.ccsdk.cds.controllerblueprints.core.reCreateDirs
-import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementOutput
-import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementServiceGrpc
-import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintRemoveInput
-import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput
+import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils
+import org.onap.ccsdk.cds.controllerblueprints.management.api.*
import org.slf4j.LoggerFactory
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.stereotype.Service
import java.io.File
import java.util.*
+// TODO("move to management-api or designer-api module")
@Service
open class BluePrintManagementGRPCHandler(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
private val blueprintsProcessorCatalogService: BluePrintCatalogService)
@@ -53,19 +51,48 @@ open class BluePrintManagementGRPCHandler(private val bluePrintLoadConfiguration
log.info("request(${request.commonHeader.requestId})")
val uploadId = UUID.randomUUID().toString()
+ val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, uploadId)
+ val blueprintWorking = normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, uploadId)
try {
- val cbaFile = normalizedFile(bluePrintLoadConfiguration.blueprintArchivePath, uploadId, "cba-zip")
+ val cbaFile = normalizedFile(blueprintArchive, "cba.zip")
saveToDisk(request, cbaFile)
- val blueprintId = blueprintsProcessorCatalogService.saveToDatabase(uploadId, cbaFile)
- responseObserver.onNext(successStatus("Successfully uploaded CBA($blueprintId)...", request.commonHeader))
+ val uploadAction = request.actionIdentifiers?.actionName.emptyTONull()
+ ?: UploadAction.DRAFT.toString()
+
+ when (uploadAction) {
+ UploadAction.DRAFT.toString() -> {
+ val blueprintId = blueprintsProcessorCatalogService.saveToDatabase(uploadId, cbaFile, false)
+ responseObserver.onNext(successStatus("Successfully uploaded CBA($blueprintId)...",
+ request.commonHeader))
+ }
+ UploadAction.PUBLISH.toString() -> {
+ val blueprintId = blueprintsProcessorCatalogService.saveToDatabase(uploadId, cbaFile, true)
+ responseObserver.onNext(successStatus("Successfully uploaded CBA($blueprintId)...",
+ request.commonHeader))
+ }
+ UploadAction.VALIDATE.toString() -> {
+ //TODO("Not Implemented")
+ responseObserver.onError(failStatus("Not Implemented",
+ BluePrintProcessorException("Not Implemented")))
+ }
+ UploadAction.ENRICH.toString() -> {
+ //TODO("Not Implemented")
+ responseObserver.onError(failStatus("Not Implemented",
+ BluePrintProcessorException("Not Implemented")))
+ }
+ }
responseObserver.onCompleted()
} catch (e: Exception) {
responseObserver.onError(failStatus("request(${request.commonHeader.requestId}): Failed to upload CBA", e))
} finally {
- deleteDir(bluePrintLoadConfiguration.blueprintArchivePath, uploadId)
- deleteDir(bluePrintLoadConfiguration.blueprintWorkingPath, uploadId)
+ // Clean blueprint script cache
+ val cacheKey = BluePrintFileUtils
+ .compileCacheKey(normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, uploadId))
+ BluePrintCompileCache.cleanClassLoader(cacheKey)
+ deleteNBDir(blueprintArchive)
+ deleteNBDir(blueprintWorking)
}
}
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
index 9dd04bf95..2f8878034 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
@@ -49,6 +49,7 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL
private val log = LoggerFactory.getLogger(ExecutionServiceHandler::class.toString())
+ //TODO("Remove from self service api and move to designer api module")
suspend fun upload(filePart: FilePart): String {
val saveId = UUID.randomUUID().toString()
val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, saveId)
@@ -74,6 +75,7 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL
}
}
+ //TODO("Remove from self service api and move to designer api module")
suspend fun remove(name: String, version: String) {
blueprintsProcessorCatalogService.deleteFromDatabase(name, version)
}