summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2022-05-20 14:53:51 +0000
committerGerrit Code Review <gerrit@onap.org>2022-05-20 14:53:51 +0000
commitc71ec674f81560753730ac39647d773600ecc418 (patch)
tree46afea2315e59a61d523cb482f538cd0e2d3f4f4 /ms/blueprintsprocessor/modules
parent0948c5b1bf6b9c4fcae9c794172ecb4e98db6831 (diff)
parenta1142669cd10f47d8178230500012e6421722c30 (diff)
Merge "Resource endpoint should support occurrences"
Diffstat (limited to 'ms/blueprintsprocessor/modules')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt13
1 files changed, 10 insertions, 3 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt
index 15c27a43b..4a2a55930 100644
--- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt
@@ -26,6 +26,8 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.R
import org.onap.ccsdk.cds.controllerblueprints.core.httpProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogCodes
+import org.onap.ccsdk.cds.error.catalog.core.ErrorPayload
+import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.access.prepost.PreAuthorize
@@ -161,9 +163,14 @@ open class ResourceController(private var resourceResolutionDBService: ResourceR
@ApiParam(value = "Name of the resource to retrieve", required = true)
@RequestParam(value = "name", required = true) name: String
):
- ResponseEntity<ResourceResolution> = runBlocking {
+ ResponseEntity<out Any>? = runBlocking {
- ResponseEntity.ok()
- .body(resourceResolutionDBService.readValue(bpName, bpVersion, artifactName, resolutionKey, name))
+ var result: ResourceResolution? = resourceResolutionDBService.readValue(bpName, bpVersion, artifactName, resolutionKey, name)
+ if (result != null) {
+ ResponseEntity.ok().body(result)
+ } else {
+ var errorPayload = ErrorPayload(HttpStatus.NOT_FOUND.value(), ErrorCatalogCodes.GENERIC_FAILURE, "No records found")
+ ResponseEntity.status(HttpStatus.NOT_FOUND).body(errorPayload)
+ }
}
}