From 5c658a23e4f8d739ef879f7efa708d89fbdf3d29 Mon Sep 17 00:00:00 2001 From: kuldipr Date: Fri, 17 Jun 2022 18:27:33 -0400 Subject: Fixed Template API (resourceId and resoourceType) input validation Validation was always checking for resolutionKey even when it is not required when using resourceId and resourceType. Also artifactName which is always required could not have been sent along with resourceId and resourceType. Issue-ID: CCSDK-3713 Signed-off-by: kuldipr Change-Id: I4a2945397f10bf5c57a698894df09ee4fc5891d0 --- .../cds/blueprintsprocessor/resource/api/TemplateController.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ms/blueprintsprocessor/modules/inbounds/resource-api/src') diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt index 2840f8016..03ba347fd 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt @@ -84,7 +84,7 @@ open class TemplateController(private val templateResolutionService: TemplateRes @ApiParam(value = "Artifact name for which to retrieve a resolved resource", required = true) @RequestParam(value = "artifactName") artifactName: String, @ApiParam(value = "Resolution Key associated with the resolution", required = false) - @RequestParam(value = "resolutionKey") resolutionKey: String, + @RequestParam(value = "resolutionKey", required = false, defaultValue = "") resolutionKey: String, @ApiParam(value = "Resource Type associated with the resolution", required = false) @RequestParam(value = "resourceType", required = false, defaultValue = "") resourceType: String, @ApiParam(value = "Resource Id associated with the resolution", required = false) @@ -102,10 +102,10 @@ open class TemplateController(private val templateResolutionService: TemplateRes var result = "" - if ((resolutionKey.isNotEmpty() || artifactName.isNotEmpty()) && (resourceId.isNotEmpty() || resourceType.isNotEmpty())) { + if (resolutionKey.isNotEmpty() && (resourceId.isNotEmpty() || resourceType.isNotEmpty())) { throw httpProcessorException( ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API, - "Either retrieve resolved template using artifact name and resolution-key OR using resource-id and resource-type." + "Either retrieve resolved template using resolution-key OR using resource-id and resource-type." ) } else if (resolutionKey.isNotEmpty() && artifactName.isNotEmpty()) { result = templateResolutionService.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName( @@ -115,7 +115,7 @@ open class TemplateController(private val templateResolutionService: TemplateRes resolutionKey, occurrence ) - } else if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) { + } else if (resourceType.isNotEmpty() && resourceId.isNotEmpty() && artifactName.isNotEmpty()) { result = templateResolutionService.findByResoureIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactName( bpName, -- cgit 1.2.3-korg