summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/db-lib
diff options
context:
space:
mode:
authorSteve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com>2019-01-09 14:34:06 -0500
committerBalazinski <bartosz.balazinski@ibm.com>2019-01-11 08:51:07 -0500
commit43f94784c8d33393ae12083f3518bbdcfa1a9bce (patch)
tree948e0bbcc08cb15315fcb2031f2d700eb7b6613f /ms/blueprintsprocessor/modules/commons/db-lib
parent3370454b30569f434a099973e1b63dc7142928f9 (diff)
Blueprint exception handler and REST responses
Change-Id: I5727238cd4c3f3f5475c3f3022e56f1acc0d73bf Issue-ID: CCSDK-418 Signed-off-by: Steve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com> Signed-off-by: Balazinski <bartosz.balazinski@ibm.com>
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/db-lib')
-rwxr-xr-xms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt11
1 files changed, 9 insertions, 2 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
index 7c0eb6b63..89b7f649f 100755
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
@@ -22,12 +22,15 @@ import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.domain.BlueprintProces
import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.repository.BlueprintProcessorModelContentRepository
import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.repository.BlueprintProcessorModelRepository
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.common.ApplicationConstants
import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ErrorCode
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintArchiveUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.db.resources.BlueprintCatalogServiceImpl
+import org.springframework.dao.DataIntegrityViolationException
import org.springframework.stereotype.Service
import java.io.File
import java.nio.file.Files
@@ -38,7 +41,6 @@ Similar/Duplicate implementation in [org.onap.ccsdk.apps.controllerblueprints.se
@Service
class BlueprintProcessorCatalogServiceImpl(bluePrintLoadConfiguration: BluePrintLoadConfiguration,
private val bluePrintValidatorService: BluePrintValidatorService,
- private val blueprintModelContentRepository: BlueprintProcessorModelContentRepository,
private val blueprintModelRepository: BlueprintProcessorModelRepository)
: BlueprintCatalogServiceImpl(bluePrintLoadConfiguration) {
@@ -80,7 +82,12 @@ class BlueprintProcessorCatalogServiceImpl(bluePrintLoadConfiguration: BluePrint
// Set the Blueprint Model Content into blueprintModel
blueprintModel.blueprintModelContent = blueprintModelContent
- blueprintModelRepository.saveAndFlush(blueprintModel)
+ try {
+ blueprintModelRepository.saveAndFlush(blueprintModel)
+ } catch (ex: DataIntegrityViolationException) {
+ throw BluePrintException(ErrorCode.CONFLICT_ADDING_RESOURCE.value, "The blueprint entry " +
+ "is already exist in database: ${ex.message}", ex)
+ }
}
}
} \ No newline at end of file