diff options
author | 2019-11-22 18:06:08 -0500 | |
---|---|---|
committer | 2019-11-26 21:32:38 +0000 | |
commit | 341db21b2ac0a14a1ed2b8bf7930914dda054bfe (patch) | |
tree | 113bba965b06cfe3a8af3a0a527d1a41c9faf0f9 /ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin | |
parent | d274e5fc552cf9ae25500f504f0434981cf3accf (diff) |
Formatting Code base with ktlint
No Business logic change, just the code format.
Competible with IntelliJ: https://github.com/pinterest/ktlint#option-3
To format run: mvn process-sources -P format
Issue-ID: CCSDK-1947
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Change-Id: Ic9e9209fb7023d77f434693ad5a01229f8d09331
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin')
36 files changed, 607 insertions, 403 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt index 5f2a6dfb6..bca77f275 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt @@ -30,31 +30,42 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.asJsonString import org.onap.ccsdk.cds.controllerblueprints.core.emptyTONull import org.onap.ccsdk.cds.controllerblueprints.core.utils.currentTimestamp -import org.onap.ccsdk.cds.controllerblueprints.management.api.* +import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintBootstrapInput +import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintDownloadInput +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.management.api.DownloadAction +import org.onap.ccsdk.cds.controllerblueprints.management.api.FileChunk +import org.onap.ccsdk.cds.controllerblueprints.management.api.RemoveAction +import org.onap.ccsdk.cds.controllerblueprints.management.api.UploadAction import org.slf4j.LoggerFactory import org.springframework.security.access.prepost.PreAuthorize import org.springframework.stereotype.Service -//TODO("Convert to coroutines handler") +// TODO("Convert to coroutines handler") @Service -open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: BluePrintModelHandler) - : BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase() { +open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: BluePrintModelHandler) : + BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase() { private val log = LoggerFactory.getLogger(BluePrintManagementGRPCHandler::class.java) @PreAuthorize("hasRole('USER')") - override fun uploadBlueprint(request: BluePrintUploadInput, responseObserver: - StreamObserver<BluePrintManagementOutput>) { + override fun uploadBlueprint( + request: BluePrintUploadInput, + responseObserver: StreamObserver<BluePrintManagementOutput> + ) { runBlocking { - //TODO("catch if request id is missing") + // TODO("catch if request id is missing") log.info("request(${request.commonHeader.requestId})") try { /** Get the file byte array */ val byteArray = request.fileChunk.chunk.toByteArray() /** Get the Upload Action */ val uploadAction = request.actionIdentifiers?.actionName.emptyTONull() - ?: UploadAction.DRAFT.toString() + ?: UploadAction.DRAFT.toString() when (uploadAction) { UploadAction.DRAFT.toString() -> { @@ -66,24 +77,36 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu responseObserver.onNext(successStatus(request.commonHeader, blueprintModel.asJsonString())) } UploadAction.VALIDATE.toString() -> { - //TODO("Not Implemented") - responseObserver.onNext(failStatus(request.commonHeader, + // TODO("Not Implemented") + responseObserver.onNext( + failStatus( + request.commonHeader, "Upload action($uploadAction) not implemented", - BluePrintProcessorException("Not Implemented"))) + BluePrintProcessorException("Not Implemented") + ) + ) } UploadAction.ENRICH.toString() -> { val enrichedByteArray = bluePrintModelHandler.enrichBlueprintFileSource(byteArray) responseObserver.onNext(outputWithFileBytes(request.commonHeader, enrichedByteArray)) } else -> { - responseObserver.onNext(failStatus(request.commonHeader, + responseObserver.onNext( + failStatus( + request.commonHeader, "Upload action($uploadAction) not implemented", - BluePrintProcessorException("Not implemented"))) + BluePrintProcessorException("Not implemented") + ) + ) } } } catch (e: Exception) { - responseObserver.onNext(failStatus(request.commonHeader, - "request(${request.commonHeader.requestId}): Failed to upload CBA", e)) + responseObserver.onNext( + failStatus( + request.commonHeader, + "request(${request.commonHeader.requestId}): Failed to upload CBA", e + ) + ) } finally { responseObserver.onCompleted() } @@ -91,8 +114,10 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu } @PreAuthorize("hasRole('USER')") - override fun downloadBlueprint(request: BluePrintDownloadInput, - responseObserver: StreamObserver<BluePrintManagementOutput>) { + override fun downloadBlueprint( + request: BluePrintDownloadInput, + responseObserver: StreamObserver<BluePrintManagementOutput> + ) { runBlocking { val blueprintName = request.actionIdentifiers.blueprintName val blueprintVersion = request.actionIdentifiers.blueprintVersion @@ -100,7 +125,7 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu /** Get the Search Action */ val searchAction = request.actionIdentifiers?.actionName.emptyTONull() - ?: DownloadAction.SEARCH.toString() + ?: DownloadAction.SEARCH.toString() log.info("request(${request.commonHeader.requestId}): Received download $blueprint") try { @@ -110,14 +135,22 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu responseObserver.onNext(outputWithFileBytes(request.commonHeader, downloadByteArray)) } else -> { - responseObserver.onNext(failStatus(request.commonHeader, + responseObserver.onNext( + failStatus( + request.commonHeader, "Search action($searchAction) not implemented", - BluePrintProcessorException("Not implemented"))) + BluePrintProcessorException("Not implemented") + ) + ) } } } catch (e: Exception) { - responseObserver.onNext(failStatus(request.commonHeader, - "request(${request.commonHeader.requestId}): Failed to delete $blueprint", e)) + responseObserver.onNext( + failStatus( + request.commonHeader, + "request(${request.commonHeader.requestId}): Failed to delete $blueprint", e + ) + ) } finally { responseObserver.onCompleted() } @@ -125,8 +158,11 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu } @PreAuthorize("hasRole('USER')") - override fun removeBlueprint(request: BluePrintRemoveInput, responseObserver: - StreamObserver<BluePrintManagementOutput>) { + override fun removeBlueprint( + request: BluePrintRemoveInput, + responseObserver: + StreamObserver<BluePrintManagementOutput> + ) { runBlocking { val blueprintName = request.actionIdentifiers.blueprintName @@ -137,7 +173,7 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu /** Get the Remove Action */ val removeAction = request.actionIdentifiers?.actionName.emptyTONull() - ?: RemoveAction.DEFAULT.toString() + ?: RemoveAction.DEFAULT.toString() try { when (removeAction) { @@ -146,22 +182,32 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu responseObserver.onNext(successStatus(request.commonHeader)) } else -> { - responseObserver.onNext(failStatus(request.commonHeader, + responseObserver.onNext( + failStatus( + request.commonHeader, "Remove action($removeAction) not implemented", - BluePrintProcessorException("Not implemented"))) + BluePrintProcessorException("Not implemented") + ) + ) } } } catch (e: Exception) { - responseObserver.onNext(failStatus(request.commonHeader, - "request(${request.commonHeader.requestId}): Failed to delete $blueprint", e)) + responseObserver.onNext( + failStatus( + request.commonHeader, + "request(${request.commonHeader.requestId}): Failed to delete $blueprint", e + ) + ) } finally { responseObserver.onCompleted() } } } - override fun bootstrapBlueprint(request: BluePrintBootstrapInput, - responseObserver: StreamObserver<BluePrintManagementOutput>) { + override fun bootstrapBlueprint( + request: BluePrintBootstrapInput, + responseObserver: StreamObserver<BluePrintManagementOutput> + ) { runBlocking { try { log.info("request(${request.commonHeader.requestId}): Received bootstrap request") @@ -173,10 +219,13 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu /** Perform bootstrap of Model Types, Resource Definitions and CBA */ bluePrintModelHandler.bootstrapBlueprint(bootstrapRequest) responseObserver.onNext(successStatus(request.commonHeader)) - } catch (e: Exception) { - responseObserver.onNext(failStatus(request.commonHeader, - "request(${request.commonHeader.requestId}): Failed to bootstrap", e)) + responseObserver.onNext( + failStatus( + request.commonHeader, + "request(${request.commonHeader.requestId}): Failed to bootstrap", e + ) + ) } finally { responseObserver.onCompleted() } @@ -184,15 +233,17 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu } private fun outputWithFileBytes(header: CommonHeader, byteArray: ByteArray): BluePrintManagementOutput = - BluePrintManagementOutput.newBuilder() - .setCommonHeader(header) - .setFileChunk(FileChunk.newBuilder().setChunk(ByteString.copyFrom(byteArray))) - .setStatus(Status.newBuilder() - .setTimestamp(currentTimestamp()) - .setMessage(BluePrintConstants.STATUS_SUCCESS) - .setCode(200) - .build()) + BluePrintManagementOutput.newBuilder() + .setCommonHeader(header) + .setFileChunk(FileChunk.newBuilder().setChunk(ByteString.copyFrom(byteArray))) + .setStatus( + Status.newBuilder() + .setTimestamp(currentTimestamp()) + .setMessage(BluePrintConstants.STATUS_SUCCESS) + .setCode(200) .build() + ) + .build() private fun successStatus(header: CommonHeader, propertyContent: String? = null): BluePrintManagementOutput { // Populate Response Payload @@ -201,30 +252,34 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu JsonFormat.parser().merge(propertyContent, propertiesBuilder) } return BluePrintManagementOutput.newBuilder() - .setCommonHeader(header) - .setProperties(propertiesBuilder.build()) - .setStatus(Status.newBuilder() - .setTimestamp(currentTimestamp()) - .setMessage(BluePrintConstants.STATUS_SUCCESS) - .setCode(200) - .build()) - .build() + .setCommonHeader(header) + .setProperties(propertiesBuilder.build()) + .setStatus( + Status.newBuilder() + .setTimestamp(currentTimestamp()) + .setMessage(BluePrintConstants.STATUS_SUCCESS) + .setCode(200) + .build() + ) + .build() } private fun failStatus(header: CommonHeader, message: String, e: Exception): BluePrintManagementOutput { log.error(message, e) return BluePrintManagementOutput.newBuilder() - .setCommonHeader(header) - .setStatus(Status.newBuilder() - .setTimestamp(currentTimestamp()) - .setMessage(BluePrintConstants.STATUS_FAILURE) - .setErrorMessage(message) - .setCode(500) - .build()) - .build() -// return io.grpc.Status.INTERNAL -// .withDescription(message) -// .withCause(e) -// .asException() + .setCommonHeader(header) + .setStatus( + Status.newBuilder() + .setTimestamp(currentTimestamp()) + .setMessage(BluePrintConstants.STATUS_FAILURE) + .setErrorMessage(message) + .setCode(500) + .build() + ) + .build() + // return io.grpc.Status.INTERNAL + // .withDescription(message) + // .withCause(e) + // .asException() } } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt index 5ef50b09f..f257157c8 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt @@ -34,7 +34,16 @@ import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.http.codec.multipart.FilePart import org.springframework.security.access.prepost.PreAuthorize -import org.springframework.web.bind.annotation.* +import org.springframework.web.bind.annotation.DeleteMapping +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RequestPart +import org.springframework.web.bind.annotation.ResponseBody +import org.springframework.web.bind.annotation.RestController import reactor.core.publisher.Mono /** @@ -47,8 +56,10 @@ import reactor.core.publisher.Mono @RequestMapping("/api/v1/blueprint-model") open class BlueprintModelController(private val bluePrintModelHandler: BluePrintModelHandler) { - @PostMapping(path = arrayOf("/bootstrap"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE), - consumes = arrayOf(MediaType.APPLICATION_JSON_VALUE)) + @PostMapping( + path = arrayOf("/bootstrap"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE), + consumes = arrayOf(MediaType.APPLICATION_JSON_VALUE) + ) @ResponseBody @Throws(BluePrintException::class) @PreAuthorize("hasRole('USER')") @@ -74,9 +85,11 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint @GetMapping("/paged", produces = [MediaType.APPLICATION_JSON_VALUE]) @ResponseBody @PreAuthorize("hasRole('USER')") - fun allBlueprintModel(@RequestParam(defaultValue = "20") limit: Int, - @RequestParam(defaultValue = "0") offset: Int, - @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption): Page<BlueprintModelSearch> { + fun allBlueprintModel( + @RequestParam(defaultValue = "20") limit: Int, + @RequestParam(defaultValue = "0") offset: Int, + @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption + ): Page<BlueprintModelSearch> { val pageRequest = PageRequest.of(offset, limit, Sort.Direction.ASC, sort.columnName) return this.bluePrintModelHandler.allBlueprintModel(pageRequest) } @@ -88,18 +101,17 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint return this.bluePrintModelHandler.searchBluePrintModelsByKeyWord(keyWord) } - @GetMapping("/paged/meta-data/{keyword}", produces = [MediaType.APPLICATION_JSON_VALUE]) @ResponseBody @PreAuthorize("hasRole('USER')") - fun allBlueprintModelMetaDataPaged(@NotNull @PathVariable(value = "keyword") keyWord: String, - @RequestParam(defaultValue = "20") limit: Int, - @RequestParam(defaultValue = "0") offset: Int, - @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption + fun allBlueprintModelMetaDataPaged( + @NotNull @PathVariable(value = "keyword") keyWord: String, + @RequestParam(defaultValue = "20") limit: Int, + @RequestParam(defaultValue = "0") offset: Int, + @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption ): Page<BlueprintModelSearch> { val pageRequest = PageRequest.of(offset, limit, Sort.Direction.ASC, sort.columnName) return this.bluePrintModelHandler.searchBluePrintModelsByKeyWordPaged(keyWord, pageRequest) - } @DeleteMapping("/{id}") @@ -113,9 +125,11 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint @ResponseBody @Throws(BluePrintException::class) @PreAuthorize("hasRole('USER')") - fun getBlueprintByNameAndVersion(@PathVariable(value = "name") name: String, - @PathVariable(value = "version") version: String) - : Mono<BlueprintModelSearch> = monoMdc { + fun getBlueprintByNameAndVersion( + @PathVariable(value = "name") name: String, + @PathVariable(value = "version") version: String + ): + Mono<BlueprintModelSearch> = monoMdc { bluePrintModelHandler.getBlueprintModelSearchByNameAndVersion(name, version) } @@ -123,9 +137,11 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint @ResponseBody @Throws(BluePrintException::class) @PreAuthorize("hasRole('USER')") - fun downloadBlueprintByNameAndVersion(@PathVariable(value = "name") name: String, - @PathVariable(value = "version") version: String) - : Mono<ResponseEntity<Resource>> = monoMdc { + fun downloadBlueprintByNameAndVersion( + @PathVariable(value = "name") name: String, + @PathVariable(value = "version") version: String + ): + Mono<ResponseEntity<Resource>> = monoMdc { bluePrintModelHandler.downloadBlueprintModelFileByNameAndVersion(name, version) } @@ -145,8 +161,10 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint bluePrintModelHandler.downloadBlueprintModelFile(id) } - @PostMapping("/enrich", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType - .MULTIPART_FORM_DATA_VALUE]) + @PostMapping( + "/enrich", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType + .MULTIPART_FORM_DATA_VALUE] + ) @ResponseBody @Throws(BluePrintException::class) @PreAuthorize("hasRole('USER')") @@ -170,14 +188,18 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint } @DeleteMapping("/name/{name}/version/{version}") - @ApiOperation(value = "Delete a CBA", - notes = "Delete the CBA package identified by its name and version.", - produces = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation( + value = "Delete a CBA", + notes = "Delete the CBA package identified by its name and version.", + produces = MediaType.APPLICATION_JSON_VALUE + ) @PreAuthorize("hasRole('USER')") - fun deleteBlueprint(@ApiParam(value = "Name of the CBA.", required = true) - @PathVariable(value = "name") name: String, - @ApiParam(value = "Version of the CBA.", required = true) - @PathVariable(value = "version") version: String) = monoMdc { + fun deleteBlueprint( + @ApiParam(value = "Name of the CBA.", required = true) + @PathVariable(value = "name") name: String, + @ApiParam(value = "Version of the CBA.", required = true) + @PathVariable(value = "version") version: String + ) = monoMdc { bluePrintModelHandler.deleteBlueprintModel(name, version) } } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiData.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiData.kt index 346015bc4..d0cb67315 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiData.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiData.kt @@ -24,8 +24,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment import java.io.Serializable -import java.util.* - +import java.util.Date class BootstrapRequest { var loadModelType: Boolean = false @@ -40,15 +39,16 @@ class BootstrapRequest { * @version 1.0 */ class AutoMapResponse { + var resourceAssignments: List<ResourceAssignment>? = null var dataDictionaries: List<ResourceDictionary>? = null } - @JsonInclude(JsonInclude.Include.NON_NULL) @JsonTypeName("errorMessage") @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME) class ErrorMessage(var message: String?, var code: Int?, var debugMessage: String?) : Serializable { + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") var timestamp = Date() -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt index bac281356..adeb3cf89 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt @@ -18,11 +18,18 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api import kotlinx.coroutines.runBlocking +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.ModelTypeHandler import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType import org.springframework.http.MediaType -import org.springframework.web.bind.annotation.* +import org.springframework.web.bind.annotation.DeleteMapping +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.ResponseBody +import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping(value = arrayOf("/api/v1/model-type")) @@ -55,4 +62,4 @@ open class ModelTypeController(private val modelTypeHandler: ModelTypeHandler) { fun deleteModelTypeByName(@PathVariable(value = "name") name: String) = runBlocking { modelTypeHandler.deleteByModelName(name) } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt index bae890a87..562932e23 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt @@ -22,7 +22,14 @@ import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.ResourceDicti import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceSourceMapping import org.springframework.http.MediaType -import org.springframework.web.bind.annotation.* +import org.springframework.web.bind.annotation.DeleteMapping +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.ResponseBody +import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping(value = ["/api/v1/dictionary"]) @@ -57,7 +64,6 @@ open class ResourceDictionaryController(private val resourceDictionaryHandler: R @ResponseBody fun searchResourceDictionaryByTags(@PathVariable(value = "tags") tags: String): List<ResourceDictionary> = runBlocking { resourceDictionaryHandler.searchResourceDictionaryByTags(tags) - } @GetMapping(path = ["/source-mapping"], produces = [MediaType.APPLICATION_JSON_VALUE]) @@ -65,5 +71,4 @@ open class ResourceDictionaryController(private val resourceDictionaryHandler: R fun getResourceSourceMapping(): ResourceSourceMapping = runBlocking { resourceDictionaryHandler.getResourceSourceMapping() } - } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaJsonNodeConverter.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaJsonNodeConverter.kt index 97c7ab6a6..4779ad340 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaJsonNodeConverter.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaJsonNodeConverter.kt @@ -18,7 +18,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain import com.fasterxml.jackson.databind.JsonNode import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils - import javax.persistence.AttributeConverter import javax.persistence.Converter @@ -35,4 +34,4 @@ class JpaJsonNodeConverter : AttributeConverter<JsonNode, String> { override fun convertToEntityAttribute(dbData: String): JsonNode { return JacksonUtils.jsonNode(dbData) } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaResourceDefinitionConverter.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaResourceDefinitionConverter.kt index 75cfede50..f0692cdd9 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaResourceDefinitionConverter.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaResourceDefinitionConverter.kt @@ -18,7 +18,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition - import javax.persistence.AttributeConverter import javax.persistence.Converter @@ -27,6 +26,7 @@ import javax.persistence.Converter */ @Converter class JpaResourceDefinitionConverter : AttributeConverter<ResourceDefinition, String> { + override fun convertToDatabaseColumn(resourceDefinition: ResourceDefinition): String { return JacksonUtils.getJson(resourceDefinition) } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ModelType.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ModelType.kt index a964e0416..6e277e5c8 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ModelType.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ModelType.kt @@ -22,8 +22,16 @@ import io.swagger.annotations.ApiModelProperty import org.springframework.data.annotation.LastModifiedDate import org.springframework.data.jpa.domain.support.AuditingEntityListener import java.io.Serializable -import java.util.* -import javax.persistence.* +import java.util.Date +import javax.persistence.Column +import javax.persistence.Convert +import javax.persistence.Entity +import javax.persistence.EntityListeners +import javax.persistence.Id +import javax.persistence.Lob +import javax.persistence.Table +import javax.persistence.Temporal +import javax.persistence.TemporalType /** * Provide ModelType Entity @@ -94,4 +102,4 @@ class ModelType : Serializable { companion object { private const val serialVersionUID = 1L } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ResourceDictionary.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ResourceDictionary.kt index ac5ea2070..209e2bbe8 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ResourceDictionary.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ResourceDictionary.kt @@ -22,8 +22,16 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition import org.springframework.data.annotation.LastModifiedDate import org.springframework.data.jpa.domain.support.AuditingEntityListener import java.io.Serializable -import java.util.* -import javax.persistence.* +import java.util.Date +import javax.persistence.Column +import javax.persistence.Convert +import javax.persistence.Entity +import javax.persistence.EntityListeners +import javax.persistence.Id +import javax.persistence.Lob +import javax.persistence.Table +import javax.persistence.Temporal +import javax.persistence.TemporalType /** * Provide ResourceDictionary Entity @@ -89,6 +97,4 @@ class ResourceDictionary : Serializable { companion object { private const val serialVersionUID = 1L } - - } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt index 552339be9..f954df7ac 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt @@ -32,22 +32,22 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment import org.springframework.stereotype.Service @Service -open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService, - private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, - private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService) - : BluePrintArtifactDefinitionEnhancer { +open class BluePrintArtifactDefinitionEnhancerImpl( + private val bluePrintRepoService: BluePrintRepoService, + private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, + private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService +) : + BluePrintArtifactDefinitionEnhancer { companion object { const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource" } - private val log = logger(BluePrintArtifactDefinitionEnhancerImpl::class) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var bluePrintContext: BluePrintContext - override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactDefinition: ArtifactDefinition) { log.info("enhancing ArtifactDefinition($name)") @@ -55,7 +55,7 @@ open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoServ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext() val artifactTypeName = artifactDefinition.type - ?: throw BluePrintException("artifact type is missing for ArtifactDefinition($name)") + ?: throw BluePrintException("artifact type is missing for ArtifactDefinition($name)") // Populate Artifact Type BluePrintEnhancerUtils.populateArtifactType(bluePrintContext, bluePrintRepoService, artifactTypeName) @@ -80,7 +80,7 @@ open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoServ if (!alreadyEnhanced) { val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromFile(artifactFilePath, ResourceAssignment::class.java) as? MutableList<ResourceAssignment> - ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($artifactFilePath)") + ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($artifactFilePath)") // Call Resource Assignment Enhancer resourceAssignmentEnhancerService.enhanceBluePrint(bluePrintTypeEnhancerService, bluePrintRuntimeService, resourceAssignments) @@ -88,5 +88,4 @@ open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoServ bluePrintRuntimeService.put(alreadyEnhancedKey, true.asJsonPrimitive()) } } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt index 0b64ed503..030fbe8ae 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt @@ -26,9 +26,11 @@ import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnha import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService -class BluePrintAttributeDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService, - private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) - : BluePrintAttributeDefinitionEnhancer { +class BluePrintAttributeDefinitionEnhancerImpl( + private val bluePrintRepoService: BluePrintRepoService, + private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService +) : + BluePrintAttributeDefinitionEnhancer { lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var bluePrintContext: BluePrintContext @@ -39,10 +41,9 @@ class BluePrintAttributeDefinitionEnhancerImpl(private val bluePrintRepoService: val propertyType = attributeDefinition.type if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { - } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { val entrySchema = attributeDefinition.entrySchema - ?: throw BluePrintException("Entry Schema is missing for collection property($name)") + ?: throw BluePrintException("Entry Schema is missing for collection property($name)") if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) { BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, entrySchema.type) @@ -51,5 +52,4 @@ class BluePrintAttributeDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, propertyType) } } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImpl.kt index b4d149e16..e99f49489 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImpl.kt @@ -26,11 +26,13 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils import org.springframework.stereotype.Service -import java.util.* +import java.util.UUID @Service -open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, - private val resourceDefinitionEnhancerService: ResourceDefinitionEnhancerService) : BluePrintEnhancerService { +open class BluePrintEnhancerServiceImpl( + private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, + private val resourceDefinitionEnhancerService: ResourceDefinitionEnhancerService +) : BluePrintEnhancerService { private val log = logger(BluePrintEnhancerServiceImpl::class) @@ -48,16 +50,20 @@ open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService log.info("Enhancing blueprint($basePath)") val blueprintRuntimeService = BluePrintMetadataUtils - .getBaseEnhancementBluePrintRuntime(UUID.randomUUID().toString(), basePath) + .getBaseEnhancementBluePrintRuntime(UUID.randomUUID().toString(), basePath) try { - bluePrintTypeEnhancerService.enhanceServiceTemplate(blueprintRuntimeService, "service_template", - blueprintRuntimeService.bluePrintContext().serviceTemplate) + bluePrintTypeEnhancerService.enhanceServiceTemplate( + blueprintRuntimeService, "service_template", + blueprintRuntimeService.bluePrintContext().serviceTemplate + ) log.info("##### Enhancing blueprint Resource Definitions") - val resourceDefinitions = resourceDefinitionEnhancerService.enhance(bluePrintTypeEnhancerService, - blueprintRuntimeService) + val resourceDefinitions = resourceDefinitionEnhancerService.enhance( + bluePrintTypeEnhancerService, + blueprintRuntimeService + ) // Write the Enhanced Blueprint Definitions BluePrintFileUtils.writeEnhancedBluePrint(blueprintRuntimeService.bluePrintContext()) @@ -68,12 +74,9 @@ open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService if (blueprintRuntimeService.getBluePrintError().errors.isNotEmpty()) { throw BluePrintException(blueprintRuntimeService.getBluePrintError().errors.toString()) } - } catch (e: Exception) { throw e } return blueprintRuntimeService.bluePrintContext() } - } - diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTemplateEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTemplateEnhancerImpl.kt index 723d7bb27..6ca0b2d14 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTemplateEnhancerImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTemplateEnhancerImpl.kt @@ -31,22 +31,22 @@ import org.springframework.stereotype.Service @Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService, - private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) - : BluePrintNodeTemplateEnhancer { +open class BluePrintNodeTemplateEnhancerImpl( + private val bluePrintRepoService: BluePrintRepoService, + private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService +) : + BluePrintNodeTemplateEnhancer { - private val log= logger(BluePrintNodeTemplateEnhancerImpl::class) + private val log = logger(BluePrintNodeTemplateEnhancerImpl::class) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var bluePrintContext: BluePrintContext - override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) { log.info("***** Enhancing NodeTemplate($name)") this.bluePrintRuntimeService = bluePrintRuntimeService this.bluePrintContext = bluePrintRuntimeService.bluePrintContext() - val nodeTypeName = nodeTemplate.type // Get NodeType from Repo and Update Service Template val nodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext, bluePrintRepoService, nodeTypeName) @@ -54,7 +54,7 @@ open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: B // Enrich NodeType bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType) - //Enrich Node Template Artifacts + // Enrich Node Template Artifacts enhanceNodeTemplateArtifactDefinition(name, nodeTemplate) } @@ -65,5 +65,4 @@ open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: B bluePrintTypeEnhancerService.enhanceArtifactDefinition(bluePrintRuntimeService, artifactDefinitionName, artifactDefinition) } } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTypeEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTypeEnhancerImpl.kt index efb695b22..d28084e40 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTypeEnhancerImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTypeEnhancerImpl.kt @@ -34,20 +34,20 @@ import org.springframework.stereotype.Service @Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService, - private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : BluePrintNodeTypeEnhancer { +open class BluePrintNodeTypeEnhancerImpl( + private val bluePrintRepoService: BluePrintRepoService, + private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService +) : BluePrintNodeTypeEnhancer { - private val log= logger(BluePrintNodeTypeEnhancerImpl::class) + private val log = logger(BluePrintNodeTypeEnhancerImpl::class) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var bluePrintContext: BluePrintContext - override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) { this.bluePrintRuntimeService = bluePrintRuntimeService this.bluePrintContext = bluePrintRuntimeService.bluePrintContext() - val derivedFrom = nodeType.derivedFrom if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { @@ -62,15 +62,14 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP // NodeType Property Definitions enrichNodeTypeProperties(name, nodeType) - //NodeType Requirement + // NodeType Requirement enrichNodeTypeRequirements(name, nodeType) - //NodeType Capability + // NodeType Capability enrichNodeTypeCapabilityProperties(name, nodeType) - //NodeType Interface + // NodeType Interface enrichNodeTypeInterfaces(name, nodeType) - } open fun enrichNodeTypeAttributes(nodeTypeName: String, nodeType: NodeType) { @@ -91,15 +90,19 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP // Populate Requirement Node requirementDefinition.node?.let { requirementNodeTypeName -> // Get Requirement NodeType from Repo and Update Service Template - val requirementNodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext, - bluePrintRepoService, requirementNodeTypeName) + val requirementNodeType = BluePrintEnhancerUtils.populateNodeType( + bluePrintContext, + bluePrintRepoService, requirementNodeTypeName + ) // Enhance Node Type enhance(bluePrintRuntimeService, requirementNodeTypeName, requirementNodeType) // Enhance Relationship Type val relationShipTypeName = requirementDefinition.relationship - ?: throw BluePrintException("couldn't get relationship name for the NodeType($nodeTypeName) " + - "Requirement($requirementName)") + ?: throw BluePrintException( + "couldn't get relationship name for the NodeType($nodeTypeName) " + + "Requirement($requirementName)" + ) enrichRelationShipType(relationShipTypeName) } } @@ -118,7 +121,6 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP // Populate Node type Interface Operation log.debug("Enriching NodeType({}) Interface({})", nodeTypeName, interfaceName) populateNodeTypeInterfaceOperation(nodeTypeName, interfaceName, interfaceObj) - } } @@ -136,8 +138,11 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP } } - open fun enrichNodeTypeInterfaceOperationOutputs(nodeTypeName: String, operationName: String, - operation: OperationDefinition) { + open fun enrichNodeTypeInterfaceOperationOutputs( + nodeTypeName: String, + operationName: String, + operation: OperationDefinition + ) { operation.outputs?.let { inputs -> bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs) } @@ -149,5 +154,4 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP open fun enrichRelationShipType(relationshipName: String) { BluePrintEnhancerUtils.populateRelationshipType(bluePrintContext, bluePrintRepoService, relationshipName) } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPolicyTypeEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPolicyTypeEnhancerImpl.kt index 83fd403e8..212dc440d 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPolicyTypeEnhancerImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPolicyTypeEnhancerImpl.kt @@ -27,17 +27,18 @@ import org.springframework.stereotype.Service @Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -class BluePrintPolicyTypeEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService, - private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) - : BluePrintPolicyTypeEnhancer { +class BluePrintPolicyTypeEnhancerImpl( + private val bluePrintRepoService: BluePrintRepoService, + private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService +) : + BluePrintPolicyTypeEnhancer { lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> - override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: PolicyType) { - this.bluePrintRuntimeService = bluePrintRuntimeService + this.bluePrintRuntimeService = bluePrintRuntimeService // TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt index b87cf9c6b..eb7443443 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt @@ -32,9 +32,11 @@ import org.springframework.stereotype.Service @Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -open class BluePrintPropertyDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService, - private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) - : BluePrintPropertyDefinitionEnhancer { +open class BluePrintPropertyDefinitionEnhancerImpl( + private val bluePrintRepoService: BluePrintRepoService, + private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService +) : + BluePrintPropertyDefinitionEnhancer { lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var bluePrintContext: BluePrintContext @@ -44,12 +46,13 @@ open class BluePrintPropertyDefinitionEnhancerImpl(private val bluePrintRepoServ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext() val propertyType = propertyDefinition.type - if (BluePrintTypes.validPrimitiveTypes().contains(propertyType) - || BluePrintTypes.validComplexTypes().contains(propertyType)) { + if (BluePrintTypes.validPrimitiveTypes().contains(propertyType) || + BluePrintTypes.validComplexTypes().contains(propertyType) + ) { // Do Nothing, } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { val entrySchema = propertyDefinition.entrySchema - ?: throw BluePrintException("Entry Schema is missing for collection property($name)") + ?: throw BluePrintException("Entry Schema is missing for collection property($name)") if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) { BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, entrySchema.type) @@ -58,5 +61,4 @@ open class BluePrintPropertyDefinitionEnhancerImpl(private val bluePrintRepoServ BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, propertyType) } } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintServiceTemplateEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintServiceTemplateEnhancerImpl.kt index 65e5ff9e1..9f4a4592a 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintServiceTemplateEnhancerImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintServiceTemplateEnhancerImpl.kt @@ -28,10 +28,10 @@ import org.springframework.stereotype.Service @Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) - : BluePrintServiceTemplateEnhancer { - private val log = logger(BluePrintServiceTemplateEnhancerImpl::class) +open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : + BluePrintServiceTemplateEnhancer { + private val log = logger(BluePrintServiceTemplateEnhancerImpl::class) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var bluePrintContext: BluePrintContext @@ -57,7 +57,6 @@ open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintTypeEnhance bluePrintContext.serviceTemplate.policyTypes = mutableMapOf() bluePrintContext.serviceTemplate.relationshipTypes = mutableMapOf() log.info("reinitialized all type definitions") - } open fun enhanceTopologyTemplate() { @@ -65,4 +64,4 @@ open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintTypeEnhance bluePrintTypeEnhancerService.enhanceTopologyTemplate(bluePrintRuntimeService, "topology_template", topologyTemplate) } } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt index c22370c33..c0100fbea 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt @@ -27,8 +27,11 @@ import org.springframework.stereotype.Service @Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -open class BluePrintTopologyTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService, - private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : BluePrintTopologyTemplateEnhancer { +open class BluePrintTopologyTemplateEnhancerImpl( + private val bluePrintRepoService: BluePrintRepoService, + private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService +) : + BluePrintTopologyTemplateEnhancer { lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> @@ -57,5 +60,4 @@ open class BluePrintTopologyTemplateEnhancerImpl(private val bluePrintRepoServic bluePrintTypeEnhancerService.enhanceWorkflow(bluePrintRuntimeService, workflowName, workflow) } } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTypeEnhancerServiceImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTypeEnhancerServiceImpl.kt index db361a248..5b7c6b2d0 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTypeEnhancerServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTypeEnhancerServiceImpl.kt @@ -16,7 +16,16 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.enhancer -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.* +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintArtifactDefinitionEnhancer +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionEnhancer +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintNodeTemplateEnhancer +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintNodeTypeEnhancer +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintPolicyTypeEnhancer +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionEnhancer +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintServiceTemplateEnhancer +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTopologyTemplateEnhancer +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowEnhancer import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.ApplicationContext import org.springframework.stereotype.Service @@ -62,4 +71,4 @@ open class BluePrintTypeEnhancerServiceImpl : BluePrintTypeEnhancerService { override fun getAttributeDefinitionEnhancers(): List<BluePrintAttributeDefinitionEnhancer> { return context.getBeansOfType(BluePrintAttributeDefinitionEnhancer::class.java).map { it.value } } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintWorkflowEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintWorkflowEnhancerImpl.kt index 394289ced..88127e3ca 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintWorkflowEnhancerImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintWorkflowEnhancerImpl.kt @@ -17,13 +17,17 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.enhancer -import org.onap.ccsdk.cds.controllerblueprints.core.* +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowEnhancer +import org.onap.ccsdk.cds.controllerblueprints.core.logger import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils @@ -34,11 +38,14 @@ import org.springframework.stereotype.Service @Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService, - private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, - private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService) - : BluePrintWorkflowEnhancer { - private val log= logger(BluePrintWorkflowEnhancerImpl::class) +open class BluePrintWorkflowEnhancerImpl( + private val bluePrintRepoService: BluePrintRepoService, + private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, + private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService +) : + BluePrintWorkflowEnhancer { + + private val log = logger(BluePrintWorkflowEnhancerImpl::class) companion object { const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource" @@ -70,8 +77,6 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP // Enrich Only for Resource Assignment and Dynamic Input Properties if any enhanceStepTargets(name, workflow) - - } open fun enhanceWorkflowInputs(name: String, workflow: Workflow) { @@ -102,11 +107,12 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP enhanceStepTargets(name, workflow, firstNodeTemplateName, true) } else -> { - throw BluePrintProcessorException("couldn't execute workflow($name) step mapped " + - "to node template($firstNodeTemplateName) derived from($derivedFrom)") + throw BluePrintProcessorException( + "couldn't execute workflow($name) step mapped " + + "to node template($firstNodeTemplateName) derived from($derivedFrom)" + ) } } - } private fun enhanceStepTargets(name: String, workflow: Workflow, nodeTemplateName: String, isDG: Boolean) { @@ -132,10 +138,10 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP log.info("identified workflow($name) targets($componentNodeTemplateName)") val resourceAssignmentArtifacts = bluePrintContext.nodeTemplateByName(componentNodeTemplateName) - .artifacts?.filter { + .artifacts?.filter { it.value.type == ARTIFACT_TYPE_MAPPING_SOURCE }?.map { - log.info("resource assignment artifacts(${it.key}) for NodeType(${componentNodeTemplateName})") + log.info("resource assignment artifacts(${it.key}) for NodeType($componentNodeTemplateName)") it.value.file } resourceAssignmentArtifacts @@ -162,13 +168,13 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP val filePath = "${bluePrintContext.rootPath}/$fileName" - log.info("enriching artifacts file(${filePath}") + log.info("enriching artifacts file($filePath") val resourceAssignmentProperties: MutableMap<String, PropertyDefinition> = hashMapOf() val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java) as? MutableList<ResourceAssignment> - ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)") + ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)") val alreadyEnhancedKey = "enhanced-$fileName" val alreadyEnhanced = bluePrintRuntimeService.check(alreadyEnhancedKey) @@ -215,7 +221,6 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP // Overwrite WorkFlow DataType bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, dynamicDataType) - } else { log.info("dynamic dataType($dataTypeName) already present for workflow($workflowName).") } @@ -224,4 +229,4 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP dynamicDataType.properties?.put(propertyName, propertyDefinition) } } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceAssignmentEnhancerService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceAssignmentEnhancerService.kt index 55eb42f89..94e183405 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceAssignmentEnhancerService.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceAssignmentEnhancerService.kt @@ -16,6 +16,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.enhancer +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.service.ResourceDefinitionRepoService import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService @@ -25,7 +26,6 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDictionaryConstants import org.onap.ccsdk.cds.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory -import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.service.ResourceDefinitionRepoService import org.springframework.beans.factory.config.ConfigurableBeanFactory import org.springframework.context.annotation.Scope import org.springframework.stereotype.Service @@ -38,9 +38,11 @@ import org.springframework.stereotype.Service interface ResourceAssignmentEnhancerService { @Throws(BluePrintException::class) - fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, - bluePrintRuntimeService: BluePrintRuntimeService<*>, - resourceAssignments: List<ResourceAssignment>) + fun enhanceBluePrint( + bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, + bluePrintRuntimeService: BluePrintRuntimeService<*>, + resourceAssignments: List<ResourceAssignment> + ) } /** @@ -50,17 +52,20 @@ interface ResourceAssignmentEnhancerService { */ @Service @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService) - : ResourceAssignmentEnhancerService { - private val log= logger(ResourceAssignmentEnhancerServiceImpl::class) +open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService) : + ResourceAssignmentEnhancerService { + + private val log = logger(ResourceAssignmentEnhancerServiceImpl::class) /** * Get the defined source instance from the ResourceAssignment, * then get the NodeType of the Sources assigned */ - override fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, - bluePrintRuntimeService: BluePrintRuntimeService<*>, - resourceAssignments: List<ResourceAssignment>) { + override fun enhanceBluePrint( + bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, + bluePrintRuntimeService: BluePrintRuntimeService<*>, + resourceAssignments: List<ResourceAssignment> + ) { val uniqueSourceNodeTypeNames = hashSetOf<String>() @@ -77,14 +82,16 @@ open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionR // TODO("Candidate for Optimisation") if (checkResourceDefinitionNeeded(resourceAssignment)) { - bluePrintTypeEnhancerService.enhancePropertyDefinition(bluePrintRuntimeService, resourceAssignment.name, - resourceAssignment.property!!); + bluePrintTypeEnhancerService.enhancePropertyDefinition( + bluePrintRuntimeService, resourceAssignment.name, + resourceAssignment.property!! + ) // Get the Resource Definition from Repo val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName) val sourceNodeTemplate = resourceDefinition.sources[dictionarySource] - ?: throw BluePrintException("failed to get assigned dictionarySource($dictionarySource) from resourceDefinition($dictionaryName)") + ?: throw BluePrintException("failed to get assigned dictionarySource($dictionarySource) from resourceDefinition($dictionaryName)") // Enrich as NodeTemplate bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintRuntimeService, dictionarySource, sourceNodeTemplate) @@ -95,16 +102,15 @@ open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionR val nodeType = resourceDefinitionRepoService.getNodeType(nodeTypeName) bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType) } - } private fun checkResourceDefinitionNeeded(resourceAssignment: ResourceAssignment): Boolean { - return !((resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_INPUT) - || resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_DEFAULT)) - && BluePrintTypes.validPrimitiveOrCollectionPrimitive(resourceAssignment.property!!)) + return !((resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_INPUT) || + resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_DEFAULT)) && + BluePrintTypes.validPrimitiveOrCollectionPrimitive(resourceAssignment.property!!)) } private fun getResourceDefinition(name: String): ResourceDefinition { return resourceDefinitionRepoService.getResourceDefinition(name) } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceDefinitionEnhancerService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceDefinitionEnhancerService.kt index c018664e4..042c76805 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceDefinitionEnhancerService.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceDefinitionEnhancerService.kt @@ -20,6 +20,8 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.enhancer import kotlinx.coroutines.Deferred import kotlinx.coroutines.async import kotlinx.coroutines.runBlocking +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.service.ResourceDefinitionRepoService +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService import org.onap.ccsdk.cds.controllerblueprints.core.logger @@ -28,20 +30,20 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeServ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils -import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.service.ResourceDefinitionRepoService -import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils import org.springframework.stereotype.Service interface ResourceDefinitionEnhancerService { @Throws(BluePrintException::class) - fun enhance(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, - bluePrintRuntimeService: BluePrintRuntimeService<*>): List<ResourceDefinition> + fun enhance( + bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, + bluePrintRuntimeService: BluePrintRuntimeService<*> + ): List<ResourceDefinition> } @Service class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService) : - ResourceDefinitionEnhancerService { + ResourceDefinitionEnhancerService { private val log = logger(ResourceDefinitionEnhancerService::class) @@ -54,8 +56,10 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe // 2. Get all the Unique Resource assignments from all mapping files // 3. Collect the Resource Definition for Resource Assignment names from database. // 4. Create the Resource Definition under blueprint base path. - override fun enhance(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, - bluePrintRuntimeService: BluePrintRuntimeService<*>): List<ResourceDefinition> { + override fun enhance( + bluePrintTypeEnhancerService: BluePrintTypeEnhancerService, + bluePrintRuntimeService: BluePrintRuntimeService<*> + ): List<ResourceDefinition> { var resourceDefinitions: List<ResourceDefinition> = mutableListOf() @@ -82,7 +86,6 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe }?.mapNotNull { artifactDefinitionMap -> artifactDefinitionMap.value.file } - }?.flatten()?.distinct() } @@ -104,33 +107,34 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe val distinctResourceAssignments = resourceAssignments.distinctBy { it.name } generateResourceDictionary(blueprintBasePath, distinctResourceAssignments) - //log.info("distinct Resource assignment ($distinctResourceAssignments)") + // log.info("distinct Resource assignment ($distinctResourceAssignments)") } - // Read the Resource Definitions from the Database and write to type file. - private fun generateResourceDictionary(blueprintBasePath: String, resourceAssignments: List<ResourceAssignment>) - : List<ResourceDefinition> { + private fun generateResourceDictionary(blueprintBasePath: String, resourceAssignments: List<ResourceAssignment>): + List<ResourceDefinition> { val resourceKeys = resourceAssignments.mapNotNull { it.dictionaryName }.distinct().sorted() log.info("distinct resource keys ($resourceKeys)") - //TODO("Optimise DB single Query to multiple Query") + // TODO("Optimise DB single Query to multiple Query") return resourceKeys.map { resourceKey -> getResourceDefinition(resourceKey) } } - private fun enrichResourceDefinitionSources(bluePrintContext: BluePrintContext, - resourceDefinitions: List<ResourceDefinition>) { + private fun enrichResourceDefinitionSources( + bluePrintContext: BluePrintContext, + resourceDefinitions: List<ResourceDefinition> + ) { val sources = resourceDefinitions - .map { it.sources } - .map { - it.values - .map { nodeTemplate -> - nodeTemplate.type - } - } - .flatten().distinct() + .map { it.sources } + .map { + it.values + .map { nodeTemplate -> + nodeTemplate.type + } + } + .flatten().distinct() log.info("Enriching Resource Definition sources Node Template: $sources") sources.forEach { BluePrintEnhancerUtils.populateNodeType(bluePrintContext, resourceDefinitionRepoService, it) @@ -141,4 +145,4 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe private fun getResourceDefinition(name: String): ResourceDefinition { return resourceDefinitionRepoService.getResourceDefinition(name) } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt index 5f7eacee8..392fa0bb4 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt @@ -27,11 +27,15 @@ import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintMod import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.BootstrapRequest import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.load.BluePrintDatabaseLoadService import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils -import org.onap.ccsdk.cds.controllerblueprints.core.* +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode +import org.onap.ccsdk.cds.controllerblueprints.core.deleteNBDir import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile +import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import org.springframework.core.io.ByteArrayResource @@ -46,8 +50,7 @@ import org.springframework.http.codec.multipart.FilePart import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import java.io.IOException -import java.util.* - +import java.util.UUID /** * BlueprintModelHandler Purpose: Handler service to handle the request from BlurPrintModelRest @@ -57,21 +60,24 @@ import java.util.* */ @Service -open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BluePrintDatabaseLoadService, - private val blueprintsProcessorCatalogService: BluePrintCatalogService, - private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, - private val blueprintModelSearchRepository: BlueprintModelSearchRepository, - private val blueprintModelRepository: BlueprintModelRepository, - private val blueprintModelContentRepository: BlueprintModelContentRepository, - private val bluePrintEnhancerService: BluePrintEnhancerService) { +open class BluePrintModelHandler( + private val bluePrintDatabaseLoadService: BluePrintDatabaseLoadService, + private val blueprintsProcessorCatalogService: BluePrintCatalogService, + private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, + private val blueprintModelSearchRepository: BlueprintModelSearchRepository, + private val blueprintModelRepository: BlueprintModelRepository, + private val blueprintModelContentRepository: BlueprintModelContentRepository, + private val bluePrintEnhancerService: BluePrintEnhancerService +) { private val log = logger(BluePrintModelHandler::class) - open suspend fun bootstrapBlueprint(bootstrapRequest: BootstrapRequest) { - log.info("Bootstrap request with type load(${bootstrapRequest.loadModelType}), " + - "resource dictionary load(${bootstrapRequest.loadResourceDictionary}) and " + - "cba load(${bootstrapRequest.loadCBA})") + log.info( + "Bootstrap request with type load(${bootstrapRequest.loadModelType}), " + + "resource dictionary load(${bootstrapRequest.loadResourceDictionary}) and " + + "cba load(${bootstrapRequest.loadCBA})" + ) if (bootstrapRequest.loadModelType) { bluePrintDatabaseLoadService.initModelTypes() } @@ -113,12 +119,13 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP try { return upload(filePart, false) } catch (e: IOException) { - throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value, - "Error in Save CBA: ${e.message}", e) + throw BluePrintException( + ErrorCode.IO_FILE_INTERRUPT.value, + "Error in Save CBA: ${e.message}", e + ) } } - /** * This is a searchBlueprintModels method * @@ -140,9 +147,10 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP @Throws(BluePrintException::class) open fun getBlueprintModelSearchByNameAndVersion(name: String, version: String): BlueprintModelSearch { return blueprintModelSearchRepository.findByArtifactNameAndArtifactVersion(name, version) - ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, - String.format(BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG, name, version)) - + ?: throw BluePrintException( + ErrorCode.RESOURCE_NOT_FOUND.value, + String.format(BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG, name, version) + ) } /** @@ -154,15 +162,19 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP * @throws BluePrintException BluePrintException </Resource> */ @Throws(BluePrintException::class) - open fun downloadBlueprintModelFileByNameAndVersion(name: String, - version: String): ResponseEntity<Resource> { + open fun downloadBlueprintModelFileByNameAndVersion( + name: String, + version: String + ): ResponseEntity<Resource> { try { val archiveByteArray = download(name, version) val fileName = "${name}_$version.zip" return prepareResourceEntity(fileName, archiveByteArray) } catch (e: BluePrintException) { - throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, - String.format("Error while " + "downloading the CBA file: %s", e.message), e) + throw BluePrintException( + ErrorCode.RESOURCE_NOT_FOUND.value, + String.format("Error while " + "downloading the CBA file: %s", e.message), e + ) } } @@ -183,8 +195,10 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP val fileName = "${blueprintModel.artifactName}_${blueprintModel.artifactVersion}.zip" val file = blueprintModel.blueprintModelContent?.content - ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, - String.format("Error while downloading the CBA file: couldn't get model content")) + ?: throw BluePrintException( + ErrorCode.RESOURCE_NOT_FOUND.value, + String.format("Error while downloading the CBA file: couldn't get model content") + ) return prepareResourceEntity(fileName, file) } @@ -193,9 +207,9 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP </Resource> */ private fun prepareResourceEntity(fileName: String, file: ByteArray): ResponseEntity<Resource> { return ResponseEntity.ok() - .contentType(MediaType.parseMediaType("text/plain")) - .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"$fileName\"") - .body(ByteArrayResource(file)) + .contentType(MediaType.parseMediaType("text/plain")) + .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"$fileName\"") + .body(ByteArrayResource(file)) } /** @@ -229,7 +243,7 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP @Throws(BluePrintException::class) open fun getBlueprintModelByNameAndVersion(name: String, version: String): BlueprintModel { val blueprintModel = blueprintModelRepository - .findByArtifactNameAndArtifactVersion(name, version) + .findByArtifactNameAndArtifactVersion(name, version) if (blueprintModel != null) { return blueprintModel } else { @@ -248,8 +262,10 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP @Throws(BluePrintException::class) open fun getBlueprintModelSearch(id: String): BlueprintModelSearch { return blueprintModelSearchRepository.findById(id) - ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, - String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id)) + ?: throw BluePrintException( + ErrorCode.RESOURCE_NOT_FOUND.value, + String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id) + ) } /** @@ -262,10 +278,10 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP </BlueprintModelSearch> */ open fun searchBluePrintModelsByKeyWord(keyWord: String): List<BlueprintModelSearch> { return blueprintModelSearchRepository.findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType( - keyWord, keyWord, keyWord, keyWord, keyWord) + keyWord, keyWord, keyWord, keyWord, keyWord + ) } - /** * This is a searchBluePrintModelsByKeyWordPagebale method to retrieve specific BlueprintModel in Database * where keyword equals updatedBy or tags or artifcat name or artifcat version or artifact type and pageable @@ -275,7 +291,14 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP * @return List<BlueprintModelSearch> list of the controller blueprint </BlueprintModelSearch> */ open fun searchBluePrintModelsByKeyWordPaged(keyWord: String, pageRequest: PageRequest): Page<BlueprintModelSearch> { - return blueprintModelSearchRepository.findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(keyWord, keyWord, keyWord, keyWord, keyWord, pageRequest) + return blueprintModelSearchRepository.findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType( + keyWord, + keyWord, + keyWord, + keyWord, + keyWord, + pageRequest + ) } /** @@ -319,8 +342,10 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP val enhancedByteArray = enrichBlueprintFileSource(filePart) return BluePrintEnhancerUtils.prepareResourceEntity("enhanced-cba.zip", enhancedByteArray) } catch (e: IOException) { - throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value, - "Error in Enriching CBA: ${e.message}", e) + throw BluePrintException( + ErrorCode.IO_FILE_INTERRUPT.value, + "Error in Enriching CBA: ${e.message}", e + ) } } @@ -336,8 +361,10 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP try { return upload(filePart, true) } catch (e: Exception) { - throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value, - "Error in Publishing CBA: ${e.message}", e) + throw BluePrintException( + ErrorCode.IO_FILE_INTERRUPT.value, + "Error in Publishing CBA: ${e.message}", e + ) } } @@ -357,16 +384,19 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP val blueprintId = blueprintsProcessorCatalogService.saveToDatabase(saveId, compressedFile, validate) return blueprintModelSearchRepository.findById(blueprintId) - ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, - String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, blueprintId)) - + ?: throw BluePrintException( + ErrorCode.RESOURCE_NOT_FOUND.value, + String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, blueprintId) + ) } catch (e: IOException) { - throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value, - "Error in Upload CBA: ${e.message}", e) + throw BluePrintException( + ErrorCode.IO_FILE_INTERRUPT.value, + "Error in Upload CBA: ${e.message}", e + ) } finally { // Clean blueprint script cache val cacheKey = BluePrintFileUtils - .compileCacheKey(normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, saveId)) + .compileCacheKey(normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, saveId)) BluePrintCompileCache.cleanClassLoader(cacheKey) deleteNBDir(blueprintArchive) deleteNBDir(blueprintWorking) @@ -379,11 +409,15 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP try { val blueprintModel = getBlueprintModelByNameAndVersion(name, version) return blueprintModel.blueprintModelContent?.content - ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, - String.format("Error while downloading the CBA file: couldn't get model content")) + ?: throw BluePrintException( + ErrorCode.RESOURCE_NOT_FOUND.value, + String.format("Error while downloading the CBA file: couldn't get model content") + ) } catch (e: BluePrintException) { - throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, - String.format("Error while " + "downloading the CBA file: %s", e.message), e) + throw BluePrintException( + ErrorCode.RESOURCE_NOT_FOUND.value, + String.format("Error while " + "downloading the CBA file: %s", e.message), e + ) } } @@ -396,17 +430,18 @@ open class BluePrintModelHandler(private val bluePrintDatabaseLoadService: BlueP try { when (fileSource) { is FilePart -> BluePrintEnhancerUtils - .copyFilePartToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir) + .copyFilePartToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir) is ByteArray -> BluePrintEnhancerUtils - .copyByteArrayToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir) - } // Enhance the Blue Prints + .copyByteArrayToEnhanceDir(fileSource, blueprintArchive, blueprintWorkingDir) + } // Enhance the Blue Prints bluePrintEnhancerService.enhance(blueprintWorkingDir) return BluePrintEnhancerUtils.compressEnhanceDirAndReturnByteArray(blueprintWorkingDir, blueprintArchive) - } catch (e: IOException) { - throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value, - "Error in Enriching CBA: ${e.message}", e) + throw BluePrintException( + ErrorCode.IO_FILE_INTERRUPT.value, + "Error in Enriching CBA: ${e.message}", e + ) } finally { BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintWorkingDir) } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeHandler.kt index 5c7ba275d..a364f3678 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeHandler.kt @@ -17,10 +17,10 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository.ModelTypeRepository import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.ModelTypeValidator import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -46,7 +46,6 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository } } - /** * This is a searchModelTypes service * @@ -66,7 +65,7 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository * @throws BluePrintException BluePrintException */ @Throws(BluePrintException::class) - suspend open fun saveModel(modelType: ModelType): ModelType { + open suspend fun saveModel(modelType: ModelType): ModelType { lateinit var dbModel: ModelType ModelTypeValidator.validateModelType(modelType) val dbModelType: ModelType? = modelTypeRepository.findByModelName(modelType.modelName) @@ -86,16 +85,14 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository return dbModel } - /** * This is a deleteByModelName service * * @param modelName modelName */ - suspend open fun deleteByModelName(modelName: String) { + open suspend fun deleteByModelName(modelName: String) { check(modelName.isNotBlank()) { "Model Name Information is missing." } modelTypeRepository.deleteByModelName(modelName) - } /** @@ -119,4 +116,4 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository check(derivedFrom.isNotBlank()) { "Model derivedFrom Information is missing." } return modelTypeRepository.findByDerivedFrom(derivedFrom) } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt index 8ba4c7b38..af40f56ed 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt @@ -31,7 +31,6 @@ import org.springframework.stereotype.Service @Service class ResourceDictionaryHandler(private val resourceDictionaryRepository: ResourceDictionaryRepository) { - /** * This is a getDataDictionaryByName service * @@ -85,8 +84,8 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour val resourceDefinition = resourceDictionary.definition Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content") // Validate the Resource Definitions - //TODO( Save Validator) - //validate(resourceDefinition) + // TODO( Save Validator) + // validate(resourceDefinition) resourceDictionary.tags = resourceDefinition.tags!! resourceDefinition.updatedBy = resourceDictionary.updatedBy @@ -137,11 +136,11 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour } private fun validateResourceDictionary(resourceDictionary: ResourceDictionary): Boolean { - checkNotEmpty(resourceDictionary.name){ "DataDictionary Definition name is missing."} + checkNotEmpty(resourceDictionary.name) { "DataDictionary Definition name is missing." } checkNotNull(resourceDictionary.definition) { "DataDictionary Definition Information is missing." } - checkNotEmpty(resourceDictionary.description){ "DataDictionary Definition Information is missing."} - checkNotEmpty(resourceDictionary.tags){ "DataDictionary Definition tags is missing."} - checkNotEmpty(resourceDictionary.updatedBy){ "DataDictionary Definition updatedBy is missing."} + checkNotEmpty(resourceDictionary.description) { "DataDictionary Definition Information is missing." } + checkNotEmpty(resourceDictionary.tags) { "DataDictionary Definition tags is missing." } + checkNotEmpty(resourceDictionary.updatedBy) { "DataDictionary Definition updatedBy is missing." } return true } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintCatalogLoadService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintCatalogLoadService.kt index 36df06909..8d209449c 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintCatalogLoadService.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintCatalogLoadService.kt @@ -25,7 +25,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogS import org.slf4j.LoggerFactory import org.springframework.stereotype.Service import java.io.File -import java.util.* +import java.util.UUID @Service open class BluePrintCatalogLoadService(private val controllerBlueprintsCatalogService: BluePrintCatalogService) { @@ -66,5 +66,4 @@ open class BluePrintCatalogLoadService(private val controllerBlueprintsCatalogSe errorBuilder.appendln("Couldn't load BlueprintModel(${file.name}: ${e.message}") } } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintDatabaseLoadService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintDatabaseLoadService.kt index 31bd2c953..02d6ad3c1 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintDatabaseLoadService.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintDatabaseLoadService.kt @@ -23,10 +23,12 @@ import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @Service -open class BluePrintDatabaseLoadService(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, - private val modelTypeLoadService: ModelTypeLoadService, - private val resourceDictionaryLoadService: ResourceDictionaryLoadService, - private val bluePrintCatalogLoadService: BluePrintCatalogLoadService) { +open class BluePrintDatabaseLoadService( + private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, + private val modelTypeLoadService: ModelTypeLoadService, + private val resourceDictionaryLoadService: ResourceDictionaryLoadService, + private val bluePrintCatalogLoadService: BluePrintCatalogLoadService +) { private val log = LoggerFactory.getLogger(BluePrintDatabaseLoadService::class.java) @@ -62,4 +64,4 @@ open class BluePrintDatabaseLoadService(private val bluePrintLoadConfiguration: bluePrintCatalogLoadService.loadPathsBluePrintModelCatalog(paths) } } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ModelTypeLoadService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ModelTypeLoadService.kt index 9f43740aa..e96daf9f0 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ModelTypeLoadService.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ModelTypeLoadService.kt @@ -26,7 +26,11 @@ import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.ModelTypeHandler import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.core.data.* +import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType +import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType +import org.onap.ccsdk.cds.controllerblueprints.core.data.EntityType +import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType +import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile import org.onap.ccsdk.cds.controllerblueprints.core.readNBText import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils @@ -108,7 +112,7 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler) val dataKey = FilenameUtils.getBaseName(file.name) val definitionContent = file.readNBText() val definition = JacksonUtils.readValue(definitionContent, classType) as EntityType - //checkNotNull(definition) { "failed to get data type from file : ${file.name}" } + // checkNotNull(definition) { "failed to get data type from file : ${file.name}" } val modelType = ModelType() val definitionType: String? @@ -143,4 +147,4 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler) errorBuilder.appendln("Couldn't load ${classType.name}(${file.name}: ${e.message}") } } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ResourceDictionaryLoadService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ResourceDictionaryLoadService.kt index 95073e99d..0350bc731 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ResourceDictionaryLoadService.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ResourceDictionaryLoadService.kt @@ -66,7 +66,6 @@ open class ResourceDictionaryLoadService(private val resourceDictionaryHandler: if (!errorBuilder.isEmpty) { log.error(errorBuilder.toString()) } - } private suspend fun loadResourceDictionary(errorBuilder: StrBuilder, file: File) { @@ -91,9 +90,8 @@ open class ResourceDictionaryLoadService(private val resourceDictionaryHandler: resourceDictionary.updatedBy = resourceDefinition.updatedBy if (StringUtils.isBlank(resourceDefinition.tags)) { - resourceDictionary.tags = (resourceDefinition.name + ", " + resourceDefinition.updatedBy - + ", " + resourceDefinition.updatedBy) - + resourceDictionary.tags = (resourceDefinition.name + ", " + resourceDefinition.updatedBy + + ", " + resourceDefinition.updatedBy) } else { resourceDictionary.tags = resourceDefinition.tags!! } @@ -107,5 +105,4 @@ open class ResourceDictionaryLoadService(private val resourceDictionaryHandler: errorBuilder.appendln("Couldn't load Resource dictionary (${file.name}: ${e.message}") } } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/BluePrintsReactRepository.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepository.kt index 1d69cd7cc..80aa6b49a 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/BluePrintsReactRepository.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepository.kt @@ -21,6 +21,7 @@ import org.springframework.stereotype.Service import reactor.core.publisher.Flux import reactor.core.publisher.Mono import reactor.core.scheduler.Schedulers + // TODO("Convert into coroutines") /** * ModelTypeReactRepository. @@ -40,37 +41,36 @@ open class ModelTypeReactRepository(private val modelTypeRepository: ModelTypeRe fun findByModelNameIn(modelNames: List<String>): Flux<ModelType> { return Flux.fromIterable(modelTypeRepository.findByModelNameIn(modelNames)) - .subscribeOn(Schedulers.elastic()) + .subscribeOn(Schedulers.elastic()) } fun findByDerivedFrom(derivedFrom: String): Flux<ModelType> { return Flux.fromIterable(modelTypeRepository.findByDerivedFrom(derivedFrom)) - .subscribeOn(Schedulers.elastic()) + .subscribeOn(Schedulers.elastic()) } fun findByDerivedFromIn(derivedFroms: List<String>): Flux<ModelType> { return Flux.fromIterable(modelTypeRepository.findByDerivedFromIn(derivedFroms)) - .subscribeOn(Schedulers.elastic()) + .subscribeOn(Schedulers.elastic()) } fun findByDefinitionType(definitionType: String): Flux<ModelType> { return Flux.fromIterable(modelTypeRepository.findByDefinitionType(definitionType)) - .subscribeOn(Schedulers.elastic()) + .subscribeOn(Schedulers.elastic()) } fun findByDefinitionTypeIn(definitionTypes: List<String>): Flux<ModelType> { return Flux.fromIterable(modelTypeRepository.findByDefinitionTypeIn(definitionTypes)) - .subscribeOn(Schedulers.elastic()) + .subscribeOn(Schedulers.elastic()) } fun findByTagsContainingIgnoreCase(tags: String): Flux<ModelType> { return Flux.fromIterable(modelTypeRepository.findByTagsContainingIgnoreCase(tags)) - .subscribeOn(Schedulers.elastic()) + .subscribeOn(Schedulers.elastic()) } fun deleteByModelName(modelName: String): Mono<Void> { modelTypeRepository.deleteByModelName(modelName) return Mono.empty() } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeRepository.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeRepository.kt index 3e36947a4..8beea7161 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeRepository.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeRepository.kt @@ -23,6 +23,7 @@ import javax.transaction.Transactional @Repository interface ModelTypeRepository : JpaRepository<ModelType, String> { + /** * This is a findByModelName method * @@ -30,6 +31,7 @@ interface ModelTypeRepository : JpaRepository<ModelType, String> { * @return Optional<ModelType> */ fun findByModelName(modelName: String): ModelType? + /** * This is a findByModelNameIn method * @@ -37,19 +39,21 @@ interface ModelTypeRepository : JpaRepository<ModelType, String> { * @return List<ModelType> */ fun findByModelNameIn(modelNames: List<String>): List<ModelType> + /** * This is a findByDerivedFrom method * * @param derivedFrom Derived From * @return List<ModelType> - */ + */ fun findByDerivedFrom(derivedFrom: String): List<ModelType> + /** * This is a findByDerivedFromIn method * * @param derivedFroms Derived Froms * @return List<ModelType> - */ + */ fun findByDerivedFromIn(derivedFroms: List<String>): List<ModelType> /** @@ -59,12 +63,13 @@ interface ModelTypeRepository : JpaRepository<ModelType, String> { * @return List<ModelType> */ fun findByDefinitionType(definitionType: String): List<ModelType> + /** * This is a findByDefinitionTypeIn method * * @param definitionTypes Definition Types * @return List<ModelType> - */ + */ fun findByDefinitionTypeIn(definitionTypes: List<String>): List<ModelType> /** diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepository.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepository.kt index 68db371c6..da7893861 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepository.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepository.kt @@ -20,7 +20,6 @@ import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictio import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository - /** * ResourceMappingRepository.java Purpose: Provide Configuration Generator ResourceMappingRepository * @@ -30,7 +29,6 @@ import org.springframework.stereotype.Repository @Repository interface ResourceDictionaryRepository : JpaRepository<ResourceDictionary, String> { - /** * This is a findByName method * @@ -61,6 +59,4 @@ interface ResourceDictionaryRepository : JpaRepository<ResourceDictionary, Strin * @param name name */ fun deleteByName(name: String) - - } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/BluePrintRepoServiceImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/BluePrintRepoServiceImpl.kt index f8e6163a5..420a9fcd7 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/BluePrintRepoServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/BluePrintRepoServiceImpl.kt @@ -23,7 +23,11 @@ import org.apache.commons.lang3.StringUtils import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository.ModelTypeRepository import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository.ResourceDictionaryRepository import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.cds.controllerblueprints.core.data.* +import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType +import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityDefinition +import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType +import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType +import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition @@ -36,37 +40,39 @@ interface ResourceDefinitionRepoService : BluePrintRepoService { } @Service -open class BluePrintRepoFileService(private val modelTypeRepository: ModelTypeRepository, - private val resourceDictionaryRepository: ResourceDictionaryRepository) : ResourceDefinitionRepoService { +open class BluePrintRepoFileService( + private val modelTypeRepository: ModelTypeRepository, + private val resourceDictionaryRepository: ResourceDictionaryRepository +) : ResourceDefinitionRepoService { @Throws(BluePrintException::class) override fun getNodeType(nodeTypeName: String): NodeType { return getModelType(nodeTypeName, NodeType::class.java) - ?: throw BluePrintException("couldn't get NodeType($nodeTypeName)") + ?: throw BluePrintException("couldn't get NodeType($nodeTypeName)") } @Throws(BluePrintException::class) override fun getDataType(dataTypeName: String): DataType { return getModelType(dataTypeName, DataType::class.java) - ?: throw BluePrintException("couldn't get DataType($dataTypeName)") + ?: throw BluePrintException("couldn't get DataType($dataTypeName)") } @Throws(BluePrintException::class) override fun getArtifactType(artifactTypeName: String): ArtifactType { return getModelType(artifactTypeName, ArtifactType::class.java) - ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName)") + ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName)") } @Throws(BluePrintException::class) override fun getRelationshipType(relationshipTypeName: String): RelationshipType { return getModelType(relationshipTypeName, RelationshipType::class.java) - ?: throw BluePrintException("couldn't get RelationshipType($relationshipTypeName)") + ?: throw BluePrintException("couldn't get RelationshipType($relationshipTypeName)") } @Throws(BluePrintException::class) override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition { return getModelType(capabilityDefinitionName, CapabilityDefinition::class.java) - ?: throw BluePrintException("couldn't get CapabilityDefinition($capabilityDefinitionName)") + ?: throw BluePrintException("couldn't get CapabilityDefinition($capabilityDefinitionName)") } @Throws(BluePrintException::class) @@ -81,12 +87,16 @@ open class BluePrintRepoFileService(private val modelTypeRepository: ModelTypeRe @Throws(BluePrintException::class) private fun <T> getModelType(modelName: String, valueClass: Class<T>): T? { - Preconditions.checkArgument(StringUtils.isNotBlank(modelName), - "Failed to get model from repo, model name is missing") + Preconditions.checkArgument( + StringUtils.isNotBlank(modelName), + "Failed to get model from repo, model name is missing" + ) val modelDefinition = getModelDefinition(modelName) - Preconditions.checkNotNull(modelDefinition, - String.format("Failed to get model content for model name (%s)", modelName)) + Preconditions.checkNotNull( + modelDefinition, + String.format("Failed to get model content for model name (%s)", modelName) + ) return JacksonUtils.readValue(modelDefinition, valueClass) } @@ -102,4 +112,4 @@ open class BluePrintRepoFileService(private val modelTypeRepository: ModelTypeRe } return modelDefinition } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtils.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtils.kt index c79d1b526..4d5ca36cf 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtils.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtils.kt @@ -19,12 +19,18 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils import kotlinx.coroutines.reactive.awaitSingle -import org.onap.ccsdk.cds.controllerblueprints.core.* +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType +import org.onap.ccsdk.cds.controllerblueprints.core.deCompress +import org.onap.ccsdk.cds.controllerblueprints.core.deleteNBDir import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile +import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName +import org.onap.ccsdk.cds.controllerblueprints.core.reCreateNBDirs import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils import org.springframework.core.io.ByteArrayResource @@ -36,47 +42,57 @@ import org.springframework.http.codec.multipart.FilePart import java.io.File import java.nio.file.Paths - class BluePrintEnhancerUtils { companion object { val log = logger(BluePrintEnhancerUtils) - fun populateDataTypes(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService, - dataTypeName: String): DataType { + fun populateDataTypes( + bluePrintContext: BluePrintContext, + bluePrintRepoService: BluePrintRepoService, + dataTypeName: String + ): DataType { val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName) - ?: bluePrintRepoService.getDataType(dataTypeName) - ?: throw BluePrintException("couldn't get DataType($dataTypeName) from repo.") + ?: bluePrintRepoService.getDataType(dataTypeName) + ?: throw BluePrintException("couldn't get DataType($dataTypeName) from repo.") bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, dataType) return dataType } - fun populateRelationshipType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService, - relationshipName: String): RelationshipType { + fun populateRelationshipType( + bluePrintContext: BluePrintContext, + bluePrintRepoService: BluePrintRepoService, + relationshipName: String + ): RelationshipType { val relationshipType = bluePrintContext.serviceTemplate.relationshipTypes?.get(relationshipName) - ?: bluePrintRepoService.getRelationshipType(relationshipName) - ?: throw BluePrintException("couldn't get RelationshipType($relationshipName) from repo.") + ?: bluePrintRepoService.getRelationshipType(relationshipName) + ?: throw BluePrintException("couldn't get RelationshipType($relationshipName) from repo.") bluePrintContext.serviceTemplate.relationshipTypes?.put(relationshipName, relationshipType) return relationshipType } - - fun populateNodeType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService, - nodeTypeName: String): NodeType { + fun populateNodeType( + bluePrintContext: BluePrintContext, + bluePrintRepoService: BluePrintRepoService, + nodeTypeName: String + ): NodeType { val nodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(nodeTypeName) - ?: bluePrintRepoService.getNodeType(nodeTypeName) - ?: throw BluePrintException("couldn't get NodeType($nodeTypeName) from repo.") + ?: bluePrintRepoService.getNodeType(nodeTypeName) + ?: throw BluePrintException("couldn't get NodeType($nodeTypeName) from repo.") bluePrintContext.serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType) return nodeType } - fun populateArtifactType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService, - artifactTypeName: String): ArtifactType { + fun populateArtifactType( + bluePrintContext: BluePrintContext, + bluePrintRepoService: BluePrintRepoService, + artifactTypeName: String + ): ArtifactType { val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName) - ?: bluePrintRepoService.getArtifactType(artifactTypeName) - ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName) from repo.") + ?: bluePrintRepoService.getArtifactType(artifactTypeName) + ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName) from repo.") bluePrintContext.serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType) return artifactType } @@ -90,17 +106,16 @@ class BluePrintEnhancerUtils { return targetFile } - suspend fun filePartAsFile(filePart: FilePart, targetFile: File): File { // Delete the Directory targetFile.parentFile.reCreateNBDirs() return filePart.transferTo(targetFile) - .thenReturn(targetFile) - .awaitSingle() + .thenReturn(targetFile) + .awaitSingle() } private suspend fun byteArrayAsArchiveFile(byteArray: ByteArray, archiveDir: String, enhanceDir: String): File { - //Recreate the Base Directories + // Recreate the Base Directories normalizedFile(archiveDir).reCreateNBDirs() normalizedFile(enhanceDir).reCreateNBDirs() val archiveFile = normalizedFile(archiveDir, "cba.zip") @@ -109,7 +124,7 @@ class BluePrintEnhancerUtils { } private suspend fun filePartAsArchiveFile(filePart: FilePart, archiveDir: String, enhanceDir: String): File { - //Recreate the Base Directories + // Recreate the Base Directories normalizedFile(archiveDir).reCreateNBDirs() normalizedFile(enhanceDir).reCreateNBDirs() val archiveFile = normalizedFile(archiveDir, "cba.zip") @@ -132,17 +147,23 @@ class BluePrintEnhancerUtils { } /** compress [enhanceDir] to [archiveDir] and return ByteArray */ - suspend fun compressEnhanceDirAndReturnByteArray(enhanceDir: String, archiveDir: String, - outputFileName: String = "enhanced-cba.zip"): ByteArray { + suspend fun compressEnhanceDirAndReturnByteArray( + enhanceDir: String, + archiveDir: String, + outputFileName: String = "enhanced-cba.zip" + ): ByteArray { val compressedFile = normalizedFile(archiveDir, outputFileName) BluePrintArchiveUtils.compress(Paths.get(enhanceDir).toFile(), compressedFile) return compressedFile.readBytes() } /** compress [enhanceDir] to [archiveDir] and return ResponseEntity */ - suspend fun compressEnhanceDirAndReturnFilePart(enhanceDir: String, archiveDir: String, - outputFileName: String = "enhanced-cba.zip") - : ResponseEntity<Resource> { + suspend fun compressEnhanceDirAndReturnFilePart( + enhanceDir: String, + archiveDir: String, + outputFileName: String = "enhanced-cba.zip" + ): + ResponseEntity<Resource> { val compressedFile = normalizedFile(archiveDir, outputFileName) BluePrintArchiveUtils.compress(Paths.get(enhanceDir).toFile(), compressedFile) return prepareResourceEntity(compressedFile) @@ -152,12 +173,13 @@ class BluePrintEnhancerUtils { suspend fun prepareResourceEntity(file: File): ResponseEntity<Resource> { return prepareResourceEntity(file.name, file.readBytes()) } + /** convert [byteArray] to ResourceEntity with [fileName]*/ fun prepareResourceEntity(fileName: String, byteArray: ByteArray): ResponseEntity<Resource> { return ResponseEntity.ok() - .contentType(MediaType.parseMediaType("text/plain")) - .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"$fileName\"") - .body(ByteArrayResource(byteArray)) + .contentType(MediaType.parseMediaType("text/plain")) + .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"$fileName\"") + .body(ByteArrayResource(byteArray)) } suspend fun cleanEnhancer(archiveLocation: String, enhancementLocation: String) { diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/SortByOptionsEnum.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BlueprintSortByOption.kt index 6f5636516..92573892a 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/SortByOptionsEnum.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BlueprintSortByOption.kt @@ -3,4 +3,4 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils enum class BlueprintSortByOption(val columnName: String) { DATE("createdDate"), NAME("artifactName") -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidator.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidator.kt index 8ec0b9bab..6b9ea28f0 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidator.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidator.kt @@ -21,7 +21,11 @@ import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.cds.controllerblueprints.core.data.* +import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType +import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityDefinition +import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType +import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType +import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils class ModelTypeValidator { @@ -38,23 +42,23 @@ class ModelTypeValidator { when (definitionType) { BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE -> { JacksonUtils.readValue(definitionContent, DataType::class.java) - ?: throw BluePrintException("Model type definition is not DataType valid content $definitionContent") + ?: throw BluePrintException("Model type definition is not DataType valid content $definitionContent") } BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE -> { JacksonUtils.readValue(definitionContent, NodeType::class.java) - ?: throw BluePrintException("Model type definition is not NodeType valid content $definitionContent") + ?: throw BluePrintException("Model type definition is not NodeType valid content $definitionContent") } BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE -> { JacksonUtils.readValue(definitionContent, ArtifactType::class.java) - ?: throw BluePrintException("Model type definition is not ArtifactType valid content $definitionContent") + ?: throw BluePrintException("Model type definition is not ArtifactType valid content $definitionContent") } BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE -> { JacksonUtils.readValue(definitionContent, CapabilityDefinition::class.java) - ?: throw BluePrintException("Model type definition is not CapabilityDefinition valid content $definitionContent") + ?: throw BluePrintException("Model type definition is not CapabilityDefinition valid content $definitionContent") } BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE -> { JacksonUtils.readValue(definitionContent, RelationshipType::class.java) - ?: throw BluePrintException("Model type definition is not RelationshipType valid content $definitionContent") + ?: throw BluePrintException("Model type definition is not RelationshipType valid content $definitionContent") } } return true @@ -79,5 +83,4 @@ class ModelTypeValidator { return true } } - } |