summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2020-09-22 12:16:46 -0400
committerSingal, Kapil (ks220y) <ks220y@att.com>2020-09-22 13:49:05 -0400
commit1072867dfac0df993cbd3e44bcc11a5cac7465fd (patch)
tree4a821659cf3b50cf946cbb535d528be8508e9fff /ms/blueprintsprocessor/modules/inbounds/resource-api/src/main
parentd97021cd756d63402545fdc2e14ac7611c3da118 (diff)
Enabling Code Formatter
Code Formatter was turned off due to java 11 migation Issue-ID: CCSDK-2852 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com> Change-Id: I3d02ed3cc7a93d7551fe25356512cfe8db1517d8
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/resource-api/src/main')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ErrorHandling.kt1
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt73
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceExceptionHandler.kt2
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt70
4 files changed, 82 insertions, 64 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ErrorHandling.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ErrorHandling.kt
index b37cd0eda..76e0346f4 100644
--- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ErrorHandling.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ErrorHandling.kt
@@ -17,6 +17,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.resource.api
object ResourceApiDomains {
+
// Resource Api Domains Constants
const val RESOURCE_API = "org.onap.ccsdk.cds.blueprintsprocessor.resource.api"
}
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 1aae8aa1c..e7c11e306 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
@@ -61,7 +61,7 @@ open class ResourceController(private var resourceResolutionDBService: ResourceR
@ApiOperation(
value = "Get all resolved resources using the resolution key. ",
notes = "Retrieve all stored resolved resources using the blueprint name, blueprint version, " +
- "artifact name and the resolution-key.",
+ "artifact name and the resolution-key.",
response = ResourceResolution::class,
responseContainer = "List",
produces = MediaType.APPLICATION_JSON_VALUE
@@ -82,37 +82,43 @@ open class ResourceController(private var resourceResolutionDBService: ResourceR
@ApiParam(value = "Resource Id associated with the resolution.", required = false)
@RequestParam(value = "resourceId", required = false, defaultValue = "") resourceId: String
):
- ResponseEntity<List<ResourceResolution>> = runBlocking {
+ ResponseEntity<List<ResourceResolution>> = runBlocking {
- if ((resolutionKey.isNotEmpty() || artifactName.isNotEmpty()) && (resourceId.isNotEmpty() || resourceType.isNotEmpty())) {
- throw httpProcessorException(ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API,
- "Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type.")
- } else if (resolutionKey.isNotEmpty() && artifactName.isNotEmpty()) {
- ResponseEntity.ok()
- .body(resourceResolutionDBService.readWithResolutionKey(bpName, bpVersion, artifactName, resolutionKey))
- } else if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) {
- ResponseEntity.ok()
- .body(
- resourceResolutionDBService.readWithResourceIdAndResourceType(
- bpName,
- bpVersion,
- resourceId,
- resourceType
+ if ((resolutionKey.isNotEmpty() || artifactName.isNotEmpty()) && (resourceId.isNotEmpty() || resourceType.isNotEmpty())) {
+ throw httpProcessorException(
+ ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API,
+ "Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type."
+ )
+ } else if (resolutionKey.isNotEmpty() && artifactName.isNotEmpty()) {
+ ResponseEntity.ok()
+ .body(resourceResolutionDBService.readWithResolutionKey(bpName, bpVersion, artifactName, resolutionKey))
+ } else if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) {
+ ResponseEntity.ok()
+ .body(
+ resourceResolutionDBService.readWithResourceIdAndResourceType(
+ bpName,
+ bpVersion,
+ resourceId,
+ resourceType
+ )
)
+ } else {
+ throw httpProcessorException(
+ ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API,
+ "Missing param. Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type."
)
- } else {
- throw httpProcessorException(ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API,
- "Missing param. Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type.")
+ }
}
- }
@RequestMapping(
- path = [""],
- method = [RequestMethod.DELETE], produces = [MediaType.APPLICATION_JSON_VALUE]
+ path = [""],
+ method = [RequestMethod.DELETE], produces = [MediaType.APPLICATION_JSON_VALUE]
+ )
+ @ApiOperation(
+ value = "Delete resources using resolution key",
+ notes = "Delete all the resources associated to a resolution-key using blueprint metadata, artifact name and the resolution-key.",
+ produces = MediaType.APPLICATION_JSON_VALUE
)
- @ApiOperation(value = "Delete resources using resolution key",
- notes = "Delete all the resources associated to a resolution-key using blueprint metadata, artifact name and the resolution-key.",
- produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('USER')")
fun deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(
@ApiParam(value = "Name of the CBA.", required = true)
@@ -125,7 +131,14 @@ open class ResourceController(private var resourceResolutionDBService: ResourceR
@RequestParam(value = "resolutionKey", required = true) resolutionKey: String
) = runBlocking {
ResponseEntity.ok()
- .body(resourceResolutionDBService.deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(bpName, bpVersion, artifactName, resolutionKey))
+ .body(
+ resourceResolutionDBService.deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(
+ bpName,
+ bpVersion,
+ artifactName,
+ resolutionKey
+ )
+ )
}
@RequestMapping(
@@ -152,9 +165,9 @@ 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<ResourceResolution> = runBlocking {
- ResponseEntity.ok()
- .body(resourceResolutionDBService.readValue(bpName, bpVersion, artifactName, resolutionKey, name))
- }
+ ResponseEntity.ok()
+ .body(resourceResolutionDBService.readValue(bpName, bpVersion, artifactName, resolutionKey, name))
+ }
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceExceptionHandler.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceExceptionHandler.kt
index 9c09bd819..baaa858d1 100644
--- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceExceptionHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceExceptionHandler.kt
@@ -27,4 +27,4 @@ import org.springframework.web.bind.annotation.RestControllerAdvice
*/
@RestControllerAdvice("org.onap.ccsdk.cds.blueprintsprocessor.resource.api")
open class ResourceExceptionHandler(private val errorCatalogService: ErrorCatalogService) :
- ErrorCatalogExceptionHandler(errorCatalogService)
+ ErrorCatalogExceptionHandler(errorCatalogService)
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 bd52bfee6..b56a63b17 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
@@ -71,8 +71,8 @@ open class TemplateController(private val templateResolutionService: TemplateRes
@ApiOperation(
value = "Retrieve a resolved template.",
notes = "Retrieve a config template for a given CBA's action, identified by its blueprint name, blueprint version, " +
- "artifact name and resolution key. An extra 'format' parameter can be passed to tell what content-type" +
- " to expect in return"
+ "artifact name and resolution key. An extra 'format' parameter can be passed to tell what content-type" +
+ " to expect in return"
)
@ResponseBody
@PreAuthorize("hasRole('USER')")
@@ -98,50 +98,54 @@ open class TemplateController(private val templateResolutionService: TemplateRes
@ApiParam(value = "Occurrence of the template resolution (1-n).", required = false)
@RequestParam(value = "occurrence", required = false, defaultValue = "1") occurrence: Int = 1
):
- ResponseEntity<String> = runBlocking {
+ ResponseEntity<String> = runBlocking {
- var result = ""
+ var result = ""
- if ((resolutionKey.isNotEmpty() || artifactName.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.")
- } else if (resolutionKey.isNotEmpty() && artifactName.isNotEmpty()) {
- result = templateResolutionService.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
- bpName,
- bpVersion,
- artifactName,
- resolutionKey,
- occurrence
- )
- } else if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) {
- result =
- templateResolutionService.findByResoureIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactName(
+ if ((resolutionKey.isNotEmpty() || artifactName.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."
+ )
+ } else if (resolutionKey.isNotEmpty() && artifactName.isNotEmpty()) {
+ result = templateResolutionService.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
bpName,
bpVersion,
artifactName,
- resourceId,
- resourceType,
+ resolutionKey,
occurrence
)
- } else {
- throw httpProcessorException(ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API,
- "Missing param. Either retrieve resolved template using artifact name and resolution-key OR using resource-id and resource-type.")
- }
+ } else if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) {
+ result =
+ templateResolutionService.findByResoureIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactName(
+ bpName,
+ bpVersion,
+ artifactName,
+ resourceId,
+ resourceType,
+ occurrence
+ )
+ } else {
+ throw httpProcessorException(
+ ErrorCatalogCodes.REQUEST_NOT_FOUND, ResourceApiDomains.RESOURCE_API,
+ "Missing param. Either retrieve resolved template using artifact name and resolution-key OR using resource-id and resource-type."
+ )
+ }
- var expectedContentType = format
- if (expectedContentType.indexOf('/') < 0) {
- expectedContentType = "application/$expectedContentType"
- }
- val expectedMediaType: MediaType = MediaType.valueOf(expectedContentType)
+ var expectedContentType = format
+ if (expectedContentType.indexOf('/') < 0) {
+ expectedContentType = "application/$expectedContentType"
+ }
+ val expectedMediaType: MediaType = MediaType.valueOf(expectedContentType)
- ResponseEntity.ok().contentType(expectedMediaType).body(result)
- }
+ ResponseEntity.ok().contentType(expectedMediaType).body(result)
+ }
@PostMapping("/{bpName}/{bpVersion}/{artifactName}/{resolutionKey}", produces = [MediaType.APPLICATION_JSON_VALUE])
@ApiOperation(
value = "Store a resolved template w/ resolution-key",
notes = "Store a template for a given CBA's action, identified by its blueprint name, blueprint version, " +
- "artifact name and resolution key.",
+ "artifact name and resolution key.",
response = TemplateResolution::class,
produces = MediaType.APPLICATION_JSON_VALUE
)
@@ -173,7 +177,7 @@ open class TemplateController(private val templateResolutionService: TemplateRes
@ApiOperation(
value = "Store a resolved template w/ resourceId and resourceType",
notes = "Store a template for a given CBA's action, identified by its blueprint name, blueprint version, " +
- "artifact name, resourceId and resourceType.",
+ "artifact name, resourceId and resourceType.",
response = TemplateResolution::class,
produces = MediaType.APPLICATION_JSON_VALUE
)