aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2023-04-26 12:14:16 -0400
committerSingal, Kapil (ks220y) <ks220y@att.com>2023-04-27 09:38:55 -0400
commitddcc79f9968f65f34bb049e469acfafe0a0aa2e9 (patch)
tree13fab94982852aee0ab90a4a663073a398d8b527 /ms/blueprintsprocessor/modules/inbounds
parent6db73002faffaa35caed91c4d440f694ec074ea1 (diff)
Adding some minor features
* Adding proxy and ssl context to CloseableHttpClient * Adding paged capability to ResourceDictionary GET API, and adding POST APi to bulk load resource definitions * Adding more packages to swagger-maven-plugin to get more RestCOntroller generating swagger doc * Fixing maven artifact versions all places Issue-ID: CCSDK-3895 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com> Change-Id: I096f80a2326cd00068029330b241da209e46e31d (cherry picked from commit 2f4cc180555b1891fb749443449bd969db408d9c)
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt62
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt71
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BlueprintSortByOption.kt16
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/DictionarySortByOption.kt21
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt2
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt4
6 files changed, 142 insertions, 34 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt
index 8d69ccdde..a9a2e69f2 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt
@@ -21,10 +21,14 @@ import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.ResourceDictionaryHandler
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.DictionarySortByOption
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.mdcWebCoroutineScope
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceSourceMapping
+import org.springframework.data.domain.Page
+import org.springframework.data.domain.PageRequest
+import org.springframework.data.domain.Sort
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.GetMapping
@@ -32,13 +36,14 @@ import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping(value = ["/api/v1/dictionary"])
@Api(
- value = "Resource dictionary",
+ value = "Resource Dictionary",
description = "Interaction with stored dictionaries"
)
open class ResourceDictionaryController(private val resourceDictionaryHandler: ResourceDictionaryHandler) {
@@ -59,6 +64,26 @@ open class ResourceDictionaryController(private val resourceDictionaryHandler: R
resourceDictionaryHandler.getResourceDictionaryByName(name)
}
+ @GetMapping("/paged", produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ApiOperation(
+ value = "Get Blueprints Dictionary ordered",
+ notes = "Lists all blueprint Dictionary which are saved in CDS in an ordered mode.",
+ nickname = "BlueprintModelController_allBlueprintDictionaryPaged_GET.org.onap.ccsdk.cds.blueprintsprocessor.designer.api"
+ )
+ @ResponseBody
+ suspend fun allBlueprintModel(
+ @ApiParam(value = "Maximum number of returned blueprint dictionary") @RequestParam(defaultValue = "20") limit: Int,
+ @ApiParam(value = "Offset") @RequestParam(defaultValue = "0") offset: Int,
+ @ApiParam(value = "Order of returned blueprint dictionary") @RequestParam(defaultValue = "DATE") sort: DictionarySortByOption,
+ @ApiParam(value = "Ascend or descend ordering") @RequestParam(defaultValue = "ASC") sortType: String
+ ): Page<ResourceDictionary> {
+ val pageRequest = PageRequest.of(
+ offset, limit,
+ Sort.Direction.fromString(sortType), sort.columnName
+ )
+ return resourceDictionaryHandler.getAllDictionary(pageRequest)
+ }
+
@PostMapping(
produces = [MediaType.APPLICATION_JSON_VALUE],
consumes = [MediaType.APPLICATION_JSON_VALUE]
@@ -72,10 +97,10 @@ open class ResourceDictionaryController(private val resourceDictionaryHandler: R
@Throws(BluePrintException::class)
suspend fun saveResourceDictionary(
@ApiParam(value = "Resource dictionary to store", required = true)
- @RequestBody dataDictionary: ResourceDictionary
+ @RequestBody resourceDictionary: ResourceDictionary
): ResourceDictionary =
mdcWebCoroutineScope {
- resourceDictionaryHandler.saveResourceDictionary(dataDictionary)
+ resourceDictionaryHandler.saveResourceDictionary(resourceDictionary)
}
@PostMapping(
@@ -85,20 +110,41 @@ open class ResourceDictionaryController(private val resourceDictionaryHandler: R
)
@ApiOperation(
value = "Save a resource dictionary",
- notes = "Save a resource dictionary by resource definition provided.",
+ notes = "Save a resource dictionary by provided resource definition json.",
nickname = "ResourceDictionaryController_saveResourceDictionary_1_POST.org.onap.ccsdk.cds.blueprintsprocessor.designer.api",
- response = ResourceDefinition::class
+ response = ResourceDictionary::class
)
@ResponseBody
@Throws(BluePrintException::class)
- suspend fun saveResourceDictionary(
- @ApiParam(value = "Resource definition to generate", required = true)
+ suspend fun saveResourceDefinition(
+ @ApiParam(value = "Resource definition to generate Resource Dictionary", required = true)
@RequestBody resourceDefinition: ResourceDefinition
- ): ResourceDefinition =
+ ): ResourceDictionary =
mdcWebCoroutineScope {
resourceDictionaryHandler.saveResourceDefinition(resourceDefinition)
}
+ @PostMapping(
+ path = ["/definition-bulk"],
+ produces = [MediaType.APPLICATION_JSON_VALUE],
+ consumes = [MediaType.APPLICATION_JSON_VALUE]
+ )
+ @ApiOperation(
+ value = "Save multiple resource dictionaries",
+ notes = "Save multiple resource dictionaries by provided resource definition json array.",
+ nickname = "ResourceDictionaryController_saveAllResourceDictionary_1_POST.org.onap.ccsdk.cds.blueprintsprocessor.designer.api",
+ response = ResourceDictionary::class
+ )
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ suspend fun saveAllResourceDictionary(
+ @ApiParam(value = "Resource definition json array to generate Resource Dictionaries", required = true)
+ @RequestBody resourceDefinition: List<ResourceDefinition>
+ ): MutableList<ResourceDictionary> =
+ mdcWebCoroutineScope {
+ resourceDictionaryHandler.saveAllResourceDefinition(resourceDefinition)
+ }
+
@DeleteMapping(path = ["/{name}"])
@ApiOperation(
value = "Remove a resource dictionary",
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt
index 3f06a4a98..0af1e1586 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt
@@ -31,15 +31,17 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceSourceMappi
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogCodes
import org.springframework.stereotype.Service
+import org.springframework.data.domain.Page
+import org.springframework.data.domain.Pageable
@Service
class ResourceDictionaryHandler(private val resourceDictionaryRepository: ResourceDictionaryRepository) {
/**
- * This is a getDataDictionaryByName service
+ * This is a getResourceDictionaryByName service
*
* @param name name
- * @return DataDictionary
+ * @return ResourceDictionary
* @throws BluePrintException BluePrintException
*/
@Throws(BluePrintException::class)
@@ -61,7 +63,7 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
*
* @param names names
* @return List<ResourceDictionary>
- </ResourceDictionary> */
+ */
suspend fun searchResourceDictionaryByNames(names: List<String>): List<ResourceDictionary> {
Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide")
return resourceDictionaryRepository.findByNameIn(names)
@@ -72,17 +74,17 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
*
* @param tags tags
* @return List<ResourceDictionary>
- </ResourceDictionary> */
+ */
suspend fun searchResourceDictionaryByTags(tags: String): List<ResourceDictionary> {
Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide")
return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags)
}
/**
- * This is a saveDataDictionary service
+ * This is a saveResourceDictionary service
*
* @param resourceDictionary resourceDictionary
- * @return DataDictionary
+ * @return ResourceDictionary
*/
@Throws(BluePrintException::class)
suspend fun saveResourceDictionary(resourceDictionary: ResourceDictionary): ResourceDictionary {
@@ -128,33 +130,49 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
}
/**
- * This is a saveDataDictionary service
+ * This is to save single ResourceDictionary from json content
*
* @param resourceDefinition ResourceDefinition
- * @return ResourceDefinition
+ * @return ResourceDictionary
+ */
+ @Throws(BluePrintException::class)
+ suspend fun saveResourceDefinition(resourceDefinition: ResourceDefinition): ResourceDictionary {
+ return resourceDictionaryRepository.save(enrichResourceDictionary(resourceDefinition))
+ }
+
+ /**
+ * This is to save multiple ResourceDictionaries from json array content
+ *
+ * @param resourceDefinitionList List<ResourceDefinition>
+ * @return MutableList<ResourceDictionary>
*/
@Throws(BluePrintException::class)
- suspend fun saveResourceDefinition(resourceDefinition: ResourceDefinition): ResourceDefinition {
+ suspend fun saveAllResourceDefinition(resourceDefinitionList: List<ResourceDefinition>): MutableList<ResourceDictionary> {
+ val dictionaryList: MutableList<ResourceDictionary> = mutableListOf()
+ resourceDefinitionList.forEach {
+ dictionaryList.add(enrichResourceDictionary(it))
+ }
+ return resourceDictionaryRepository.saveAll(dictionaryList)
+ }
+
+ private fun enrichResourceDictionary(resourceDefinition: ResourceDefinition): ResourceDictionary {
val resourceDictionary = ResourceDictionary()
resourceDictionary.name = resourceDefinition.name
resourceDictionary.updatedBy = resourceDefinition.updatedBy
resourceDictionary.resourceDictionaryGroup = resourceDefinition.group
resourceDictionary.entrySchema = resourceDefinition.property.entrySchema?.type
+ resourceDictionary.description = resourceDefinition.property.description!!
+ resourceDictionary.dataType = resourceDefinition.property.type
+ resourceDictionary.definition = resourceDefinition
+
if (StringUtils.isBlank(resourceDefinition.tags)) {
- resourceDictionary.tags = (
- resourceDefinition.name + ", " + resourceDefinition.updatedBy +
- ", " + resourceDefinition.updatedBy
- )
+ resourceDictionary.tags = resourceDefinition.name + ", " + resourceDefinition.updatedBy
} else {
resourceDictionary.tags = resourceDefinition.tags!!
}
- resourceDictionary.description = resourceDefinition.property.description!!
- resourceDictionary.dataType = resourceDefinition.property.type
- resourceDictionary.definition = resourceDefinition
validateResourceDictionary(resourceDictionary)
-
- return resourceDictionaryRepository.save(resourceDictionary).definition
+ return resourceDictionary
}
/**
@@ -174,12 +192,19 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
return ResourceSourceMappingFactory.getRegisterSourceMapping()
}
+ /**
+ * This is a getResourceDirectories service
+ */
+ suspend fun getAllDictionary(pageRequest: Pageable): Page<ResourceDictionary> {
+ return resourceDictionaryRepository.findAll(pageRequest)
+ }
+
private fun validateResourceDictionary(resourceDictionary: ResourceDictionary): Boolean {
- checkNotEmpty(resourceDictionary.name) { "DataDictionary Definition name is missing." }
- checkNotNull(resourceDictionary.definition) { "DataDictionary Definition Information is missing." }
- checkNotEmpty(resourceDictionary.description) { "DataDictionary Definition Information is missing." }
- checkNotEmpty(resourceDictionary.tags) { "DataDictionary Definition tags is missing." }
- checkNotEmpty(resourceDictionary.updatedBy) { "DataDictionary Definition updatedBy is missing." }
+ checkNotEmpty(resourceDictionary.name) { "ResourceDictionary Definition name is missing." }
+ checkNotNull(resourceDictionary.definition) { "ResourceDictionary Definition Information is missing." }
+ checkNotEmpty(resourceDictionary.description) { "ResourceDictionary Definition Information is missing." }
+ checkNotEmpty(resourceDictionary.tags) { "ResourceDictionary Definition tags is missing." }
+ checkNotEmpty(resourceDictionary.updatedBy) { "ResourceDictionary Definition updatedBy is missing." }
return true
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BlueprintSortByOption.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BlueprintSortByOption.kt
index ff12efdda..846bd0af2 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BlueprintSortByOption.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BlueprintSortByOption.kt
@@ -1,3 +1,19 @@
+/*
+ * Copyright © 2017-2023 AT&T Intellectual Property.
+ *
+ * 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.designer.api.utils
enum class BlueprintSortByOption(val columnName: String) {
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/DictionarySortByOption.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/DictionarySortByOption.kt
new file mode 100644
index 000000000..c0df4d72c
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/DictionarySortByOption.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright © 2017-2023 AT&T Intellectual Property.
+ *
+ * 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.designer.api.utils
+
+enum class DictionarySortByOption(val columnName: String) {
+ DATE("creationDate")
+}
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 49e03137b..26badcc08 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
@@ -47,7 +47,7 @@ import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("/api/v1/template")
@Api(
- value = "Resource template",
+ value = "Resource Template",
description = "Interaction with resolved templates"
)
open class TemplateController(private val templateResolutionService: TemplateResolutionService) {
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
index bed8b80e9..7c0672f65 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
@@ -50,8 +50,8 @@ import javax.annotation.PreDestroy
@RestController
@RequestMapping("/api/v1/execution-service")
@Api(
- value = "/api/v1/execution-service",
- description = "Interaction with CBA."
+ value = "Execution Service Catalog",
+ description = "Interaction with CBA which are available in CDS"
)
open class ExecutionServiceController {