summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-09-04 15:44:00 +0000
committerGerrit Code Review <gerrit@onap.org>2019-09-04 15:44:00 +0000
commita006efcfacc3499615e835dae212c854826cfe7c (patch)
treecc2a88f838aa2515cc9ca6d635f28f82faf9cc87 /ms/blueprintsprocessor
parente736a5b6d322b9046656d86002e12f509acfad9a (diff)
parentd39c13bf2aff5f80029a4b8beb949f1f4a9ed189 (diff)
Merge "Refactor model entity and repository."
Diffstat (limited to 'ms/blueprintsprocessor')
-rwxr-xr-xms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt117
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt98
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt82
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelContentRepository.kt22
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelRepository.kt21
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelSearchRepository.kt62
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintModelHandler.kt59
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt2
-rwxr-xr-xms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ControllerBlueprintCatalogServiceImpl.kt6
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt2
10 files changed, 435 insertions, 36 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt
new file mode 100755
index 000000000..7bc88d8c2
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt
@@ -0,0 +1,117 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain
+
+import com.fasterxml.jackson.annotation.JsonFormat
+import io.swagger.annotations.ApiModelProperty
+import org.hibernate.annotations.Proxy
+import org.springframework.data.annotation.LastModifiedDate
+import org.springframework.data.jpa.domain.support.AuditingEntityListener
+import java.io.Serializable
+import java.util.*
+import javax.persistence.*
+
+/**
+ * Provide Configuration Generator BlueprintModel Entity
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@EntityListeners(AuditingEntityListener::class)
+@Entity
+@Table(name = "CONFIG_MODEL", uniqueConstraints = [UniqueConstraint(columnNames = ["artifact_name", "artifact_version"])])
+@Proxy(lazy = false)
+class BlueprintModel : Serializable {
+ @Id
+ @Column(name = "config_model_id")
+ var id: String? = null
+
+ @Column(name = "service_uuid")
+ var serviceUUID: String? = null
+
+ @Column(name = "distribution_id")
+ var distributionId: String? = null
+
+ @Column(name = "service_name")
+ var serviceName: String? = null
+
+ @Column(name = "service_description")
+ var serviceDescription: String? = null
+
+ @Column(name = "resource_uuid")
+ var resourceUUID: String? = null
+
+ @Column(name = "resource_instance_name")
+ var resourceInstanceName: String? = null
+
+ @Column(name = "resource_name")
+ var resourceName: String? = null
+
+ @Column(name = "resource_version")
+ var resourceVersion: String? = null
+
+ @Column(name = "resource_type")
+ var resourceType: String? = null
+
+ @Column(name = "artifact_uuid")
+ var artifactUUId: String? = null
+
+ @Column(name = "artifact_type")
+ var artifactType: String? = null
+
+ @Column(name = "artifact_version", nullable = false)
+ @ApiModelProperty(required = true)
+ var artifactVersion: String? = null
+
+ @Lob
+ @Column(name = "artifact_description")
+ var artifactDescription: String? = null
+
+ @Column(name = "internal_version")
+ var internalVersion: Int? = null
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ var createdDate = Date()
+
+ @Column(name = "artifact_name", nullable = false)
+ @ApiModelProperty(required = true)
+ var artifactName: String? = null
+
+ @Column(name = "published", nullable = false)
+ @ApiModelProperty(required = true)
+ var published: String? = null
+
+ @Column(name = "updated_by", nullable = false)
+ @ApiModelProperty(required = true)
+ var updatedBy: String? = null
+
+ @Lob
+ @Column(name = "tags", nullable = false)
+ @ApiModelProperty(required = true)
+ var tags: String? = null
+
+ @OneToOne(mappedBy = "blueprintModel", fetch = FetchType.EAGER, orphanRemoval = true, cascade = [CascadeType.ALL])
+ var blueprintModelContent: BlueprintModelContent? = null
+
+ companion object {
+ private const val serialVersionUID = 1L
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt
new file mode 100644
index 000000000..a3a42ff3d
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt
@@ -0,0 +1,98 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain
+
+import com.fasterxml.jackson.annotation.JsonFormat
+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.*
+
+/**
+ * Provide Blueprint Model Content Entity
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@EntityListeners(AuditingEntityListener::class)
+@Entity
+@Table(name = "CONFIG_MODEL_CONTENT")
+class BlueprintModelContent : Serializable {
+
+ @Id
+ @Column(name = "config_model_content_id")
+ var id: String? = null
+
+ @Column(name = "name", nullable = false)
+ @ApiModelProperty(required = true)
+ var name: String? = null
+
+ @Column(name = "content_type", nullable = false)
+ @ApiModelProperty(required = true)
+ var contentType: String? = null
+
+ @OneToOne
+ @JoinColumn(name = "config_model_id")
+ var blueprintModel: BlueprintModel? = null
+
+ @Lob
+ @Column(name = "description")
+ var description: String? = null
+
+ @Lob
+ @Column(name = "content", nullable = false)
+ @ApiModelProperty(required = true)
+ var content: ByteArray? = null
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "updated_date")
+ var creationDate = Date()
+
+ override fun toString(): String {
+ return "[" + "id = " + id +
+ ", name = " + name +
+ ", contentType = " + contentType +
+ "]"
+ }
+
+ override fun equals(o: Any?): Boolean {
+
+ if (o === this) {
+ return true
+ }
+ if (o !is BlueprintModelContent) {
+ return false
+ }
+ val blueprintModelContent = o as BlueprintModelContent?
+ return (id == blueprintModelContent!!.id && name == blueprintModelContent.name
+ && contentType == blueprintModelContent.contentType)
+ }
+
+ override fun hashCode(): Int {
+ return Objects.hash(id, name, contentType)
+ }
+
+ companion object {
+
+ private const val serialVersionUID = 1L
+ }
+
+}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt
new file mode 100644
index 000000000..f00d5cadf
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain
+
+import com.fasterxml.jackson.annotation.JsonFormat
+import com.fasterxml.jackson.annotation.JsonTypeInfo
+import com.fasterxml.jackson.annotation.JsonTypeName
+import org.springframework.data.annotation.LastModifiedDate
+import java.io.Serializable
+import java.util.*
+import javax.persistence.*
+
+/**
+ * Provide Blueprint Model Search Entity
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Entity
+@Table(name = "CONFIG_MODEL")
+@JsonTypeName("blueprintModel")
+@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
+class BlueprintModelSearch : Serializable {
+
+ @Id
+ @Column(name = "config_model_id")
+ var id: String? = null
+
+ @Column(name = "artifact_uuid")
+ var artifactUUId: String? = null
+
+ @Column(name = "artifact_type")
+ var artifactType: String? = null
+
+ @Column(name = "artifact_version", nullable = false)
+ var artifactVersion: String? = null
+
+ @Lob
+ @Column(name = "artifact_description")
+ var artifactDescription: String? = null
+
+ @Column(name = "internal_version")
+ var internalVersion: Int? = null
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ var createdDate = Date()
+
+ @Column(name = "artifact_name", nullable = false)
+ var artifactName: String? = null
+
+ @Column(name = "published", nullable = false)
+ var published: String? = null
+
+ @Column(name = "updated_by", nullable = false)
+ var updatedBy: String? = null
+
+ @Lob
+ @Column(name = "tags", nullable = false)
+ var tags: String? = null
+
+ companion object {
+ const val serialversionuid = 1L
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelContentRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelContentRepository.kt
new file mode 100644
index 000000000..59b82a3da
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelContentRepository.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository
+
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelContent
+import org.onap.ccsdk.cds.controllerblueprints.db.resources.repository.ModelContentRepository
+
+interface ControllerBlueprintModelContentRepository : ModelContentRepository<BlueprintModel, BlueprintModelContent>
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelRepository.kt
new file mode 100644
index 000000000..c26475b1d
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelRepository.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository
+
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
+import org.onap.ccsdk.cds.controllerblueprints.db.resources.repository.ModelRepository
+
+interface ControllerBlueprintModelRepository : ModelRepository<BlueprintModel>
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelSearchRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelSearchRepository.kt
new file mode 100644
index 000000000..0e0c5435b
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelSearchRepository.kt
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository
+
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch
+import org.springframework.data.jpa.repository.JpaRepository
+import org.springframework.stereotype.Repository
+
+/**
+ * Provide Configuration Generator AsdcArtifactsRepository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+interface ControllerBlueprintModelSearchRepository : JpaRepository<BlueprintModelSearch, Long> {
+
+ /**
+ * This is a findById method
+ *
+ * @param id id
+ * @return Optional<BlueprintModelSearch>
+ </BlueprintModelSearch> */
+ fun findById(id: String): BlueprintModelSearch?
+
+ /**
+ * This is a findAll method
+ * @return List<BlueprintModelSearch>
+ </BlueprintModelSearch> */
+ override fun findAll(): List<BlueprintModelSearch>
+
+ /**
+ * This is a findByArtifactNameAndArtifactVersion method
+ *
+ * @param artifactName artifactName
+ * @param artifactVersion artifactVersion
+ * @return Optional<AsdcArtifacts>
+ </AsdcArtifacts> */
+ fun findByArtifactNameAndArtifactVersion(artifactName: String, artifactVersion: String): BlueprintModelSearch?
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags
+ * @return Optional<BlueprintModelSearch>
+ </BlueprintModelSearch> */
+ fun findByTagsContainingIgnoreCase(tags: String): List<BlueprintModelSearch>
+} \ 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/BluePrintModelHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintModelHandler.kt
index d4bcd8e94..3a68951db 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintModelHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintModelHandler.kt
@@ -18,16 +18,16 @@
package org.onap.ccsdk.cds.blueprintsprocessor.designer.api
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.ControllerBlueprintModelContentRepository
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.ControllerBlueprintModelRepository
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.ControllerBlueprintModelSearchRepository
import org.onap.ccsdk.cds.controllerblueprints.core.*
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.interfaces.BluePrintCatalogService
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService
-import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModel
-import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelSearch
-import org.onap.ccsdk.cds.controllerblueprints.service.repository.ControllerBlueprintModelContentRepository
-import org.onap.ccsdk.cds.controllerblueprints.service.repository.ControllerBlueprintModelRepository
-import org.onap.ccsdk.cds.controllerblueprints.service.repository.ControllerBlueprintModelSearchRepository
import org.onap.ccsdk.cds.controllerblueprints.service.utils.BluePrintEnhancerUtils
import org.slf4j.LoggerFactory
import org.springframework.core.io.ByteArrayResource
@@ -88,7 +88,10 @@ open class BluePrintModelHandler(private val controllerBlueprintsCatalogService:
// Save the Copied file to Database
val blueprintId = controllerBlueprintsCatalogService.saveToDatabase(saveId, deCompressedFile, false)
// Check and Return the Saved File
- val blueprintModelSearch = blueprintModelSearchRepository.findById(blueprintId).get()
+ val blueprintModelSearch = blueprintModelSearchRepository.findById(blueprintId)
+ ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, blueprintId))
+
log.info("Save($saveId) successful for blueprint(${blueprintModelSearch.artifactName}) " +
"version(${blueprintModelSearch.artifactVersion})")
return blueprintModelSearch
@@ -121,16 +124,10 @@ open class BluePrintModelHandler(private val controllerBlueprintsCatalogService:
*/
@Throws(BluePrintException::class)
open fun getBlueprintModelSearchByNameAndVersion(name: String, version: String): BlueprintModelSearch {
- val blueprintModelSearch: BlueprintModelSearch
- val dbBlueprintModel = blueprintModelSearchRepository
- .findByArtifactNameAndArtifactVersion(name, version)
- if (dbBlueprintModel.isPresent) {
- blueprintModelSearch = dbBlueprintModel.get()
- } else {
- throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
- String.format(BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG, name, version))
- }
- return blueprintModelSearch
+ return blueprintModelSearchRepository.findByArtifactNameAndArtifactVersion(name, version)
+ ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format(BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG, name, version))
+
}
/**
@@ -148,11 +145,14 @@ open class BluePrintModelHandler(private val controllerBlueprintsCatalogService:
try {
blueprintModel = getBlueprintModelByNameAndVersion(name, version)
} 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)
}
val fileName = blueprintModel.id + ".zip"
- val file = blueprintModel.blueprintModelContent.content
+ 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"))
return prepareResourceEntity(fileName, file)
}
@@ -172,7 +172,9 @@ open class BluePrintModelHandler(private val controllerBlueprintsCatalogService:
}
val fileName = blueprintModel.id + ".zip"
- val file = blueprintModel.blueprintModelContent.content
+ 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"))
return prepareResourceEntity(fileName, file)
}
@@ -235,16 +237,9 @@ open class BluePrintModelHandler(private val controllerBlueprintsCatalogService:
*/
@Throws(BluePrintException::class)
open fun getBlueprintModelSearch(id: String): BlueprintModelSearch {
- val blueprintModelSearch: BlueprintModelSearch
- val dbBlueprintModel = blueprintModelSearchRepository.findById(id)
- if (dbBlueprintModel.isPresent) {
- blueprintModelSearch = dbBlueprintModel.get()
- } else {
- val msg = String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id)
- throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, msg)
- }
-
- return blueprintModelSearch
+ return blueprintModelSearchRepository.findById(id)
+ ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id))
}
/**
@@ -257,7 +252,7 @@ open class BluePrintModelHandler(private val controllerBlueprintsCatalogService:
@Throws(BluePrintException::class)
open fun deleteBlueprintModel(id: String) {
val dbBlueprintModel = blueprintModelRepository.findById(id)
- if (dbBlueprintModel.isPresent) {
+ if (dbBlueprintModel != null && dbBlueprintModel.isPresent) {
blueprintModelContentRepository.deleteByBlueprintModel(dbBlueprintModel.get())
blueprintModelRepository.delete(dbBlueprintModel.get())
} else {
@@ -317,7 +312,9 @@ open class BluePrintModelHandler(private val controllerBlueprintsCatalogService:
val blueprintId = controllerBlueprintsCatalogService.saveToDatabase(publishId, compressedFilePart, true)
- return blueprintModelSearchRepository.findById(blueprintId).get()
+ return blueprintModelSearchRepository.findById(blueprintId)
+ ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, blueprintId))
} catch (e: Exception) {
throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
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 98f521222..26420cc56 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
@@ -19,7 +19,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api
import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelSearch
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch
import org.springframework.core.io.Resource
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ControllerBlueprintCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ControllerBlueprintCatalogServiceImpl.kt
index f0252c815..e91f4918c 100755
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ControllerBlueprintCatalogServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ControllerBlueprintCatalogServiceImpl.kt
@@ -27,9 +27,9 @@ import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPath
import org.onap.ccsdk.cds.controllerblueprints.db.resources.BlueprintCatalogServiceImpl
-import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModel
-import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelContent
-import org.onap.ccsdk.cds.controllerblueprints.service.repository.ControllerBlueprintModelRepository
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelContent
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.ControllerBlueprintModelRepository
import org.slf4j.LoggerFactory
import org.springframework.dao.DataIntegrityViolationException
import org.springframework.stereotype.Service
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt
index cd49870ae..877584ed6 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt
@@ -29,9 +29,9 @@ import org.junit.runners.MethodSorters
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch
import org.onap.ccsdk.cds.controllerblueprints.core.*
import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
-import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelSearch
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest