Merge "Adding logic to read response files from"
diff --git a/cps-dependencies/pom.xml b/cps-dependencies/pom.xml
index 8003d30..3eb2110 100755
--- a/cps-dependencies/pom.xml
+++ b/cps-dependencies/pom.xml
@@ -34,7 +34,7 @@
<description>This artifact contains dependencyManagement declarations of upstream versions.</description>
<properties>
- <groovy.version>3.0.8</groovy.version>
+ <groovy.version>3.0.9</groovy.version>
<nexusproxy>https://nexus.onap.org</nexusproxy>
<releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
<snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
@@ -99,7 +99,7 @@
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
- <version>2.1.4</version>
+ <version>2.2.10</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml
index d45b8da..818b2da 100644
--- a/cps-ncmp-rest/docs/openapi/components.yaml
+++ b/cps-ncmp-rest/docs/openapi/components.yaml
@@ -38,7 +38,7 @@
properties:
message:
type: string
- example: "Bad Gateway Error Message NCMP"
+ example: 'Bad Gateway Error Message NCMP'
dmi-response:
type: object
properties:
@@ -160,11 +160,11 @@
example: |
module stores {
yang-version 1.1;
- namespace "org:onap:ccsdk:sample";
+ namespace 'org:onap:ccsdk:sample';
prefix book-store;
- revision "2020-09-15" {
+ revision '2020-09-15' {
description
- "Sample Model";
+ 'Sample Model';
}
}
@@ -175,13 +175,11 @@
cmHandleQueryParameters:
type: array
items:
- type: object
$ref: '#/components/schemas/ConditionProperties'
conditions:
deprecated: true
type: array
items:
- type: object
$ref: '#/components/schemas/OldConditionProperties'
description: not necessary, it is just for backward compatibility
@@ -203,7 +201,6 @@
conditionParameters:
type: array
items:
- type: object
$ref: '#/components/schemas/ModuleNameAsJsonObject'
ModuleNameAsJsonObject:
properties:
@@ -293,7 +290,6 @@
operations:
type: array
items:
- type: object
$ref: '#/components/schemas/DataOperationDefinition'
description: contains group of data operation requests
DataOperationDefinition:
@@ -321,7 +317,7 @@
type: array
items:
type: string
- example: [ "da310eecdb8d44c2acc0ddaae01174b1","c748c58f8e0b438f9fd1f28370b17d47" ]
+ example: [ "da310eecdb8d44c2acc0ddaae01174b1","c748c58f8e0b438f9fd1f28370b17d47" ]
examples:
dataSampleRequest:
diff --git a/cps-ncmp-rest/docs/openapi/openapi-inventory.yml b/cps-ncmp-rest/docs/openapi/openapi-inventory.yml
index bd83dbf..b794082 100755
--- a/cps-ncmp-rest/docs/openapi/openapi-inventory.yml
+++ b/cps-ncmp-rest/docs/openapi/openapi-inventory.yml
@@ -1,6 +1,6 @@
# ============LICENSE_START=======================================================
# Copyright (C) 2021 Bell Canada
-# Modifications Copyright (C) 2022 Nordix Foundation
+# Modifications Copyright (C) 2022-2023 Nordix Foundation
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
-openapi: 3.0.1
+openapi: 3.0.3
info:
title: NCMP Inventory API
description: NCMP Inventory API
diff --git a/cps-ncmp-rest/docs/openapi/openapi.yml b/cps-ncmp-rest/docs/openapi/openapi.yml
index 84d86ff..7ceb4fe 100755
--- a/cps-ncmp-rest/docs/openapi/openapi.yml
+++ b/cps-ncmp-rest/docs/openapi/openapi.yml
@@ -18,7 +18,7 @@
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
-openapi: 3.0.1
+openapi: 3.0.3
info:
title: NCMP to CPS Proxy API
description: NCMP to CPS Proxy API
diff --git a/cps-ncmp-rest/pom.xml b/cps-ncmp-rest/pom.xml
index 8c84546..6679932 100644
--- a/cps-ncmp-rest/pom.xml
+++ b/cps-ncmp-rest/pom.xml
@@ -116,8 +116,9 @@
<plugins>
<!-- Swagger code generation. -->
<plugin>
- <groupId>io.swagger.codegen.v3</groupId>
- <artifactId>swagger-codegen-maven-plugin</artifactId>
+ <groupId>org.openapitools</groupId>
+ <artifactId>openapi-generator-maven-plugin</artifactId>
+ <version>6.6.0</version>
<executions>
<execution>
<id>ncmp-code-gen</id>
@@ -129,13 +130,16 @@
<invokerPackage>org.onap.cps.ncmp.rest.controller</invokerPackage>
<modelPackage>org.onap.cps.ncmp.rest.model</modelPackage>
<apiPackage>org.onap.cps.ncmp.rest.api</apiPackage>
- <language>spring</language>
+ <generatorName>spring</generatorName>
<generateSupportingFiles>false</generateSupportingFiles>
+ <generateAliasAsModel>true</generateAliasAsModel>
<configOptions>
<sourceFolder>src/gen/java</sourceFolder>
<dateLibrary>java11</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useTags>true</useTags>
+ <openApiNullable>false</openApiNullable>
+ <skipDefaultInterface>true</skipDefaultInterface>
</configOptions>
</configuration>
</execution>
@@ -149,13 +153,15 @@
<invokerPackage>org.onap.cps.ncmp.rest.controller</invokerPackage>
<modelPackage>org.onap.cps.ncmp.rest.model</modelPackage>
<apiPackage>org.onap.cps.ncmp.rest.api</apiPackage>
- <language>spring</language>
+ <generatorName>spring</generatorName>
<generateSupportingFiles>false</generateSupportingFiles>
<configOptions>
<sourceFolder>src/gen/java</sourceFolder>
<dateLibrary>java11</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useTags>true</useTags>
+ <openApiNullable>false</openApiNullable>
+ <skipDefaultInterface>true</skipDefaultInterface>
</configOptions>
</configuration>
</execution>
@@ -167,7 +173,7 @@
<phase>compile</phase>
<configuration>
<inputSpec>${project.basedir}/docs/openapi/openapi-inventory.yml</inputSpec>
- <language>openapi-yaml</language>
+ <generatorName>openapi-yaml</generatorName>
<configOptions>
<outputFile>openapi-inventory.yaml</outputFile>
</configOptions>
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index 3c22b81..b81378d 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -138,18 +138,18 @@
/**
* Patch resource data from passthrough-running.
*
- * @param resourceIdentifier resource identifier
* @param datastoreName name of the datastore
* @param cmHandle cm handle identifier
+ * @param resourceIdentifier resource identifier
* @param requestBody the request body
* @param contentType content type of body
* @return {@code ResponseEntity} response from dmi plugin
*/
@Override
- public ResponseEntity<Object> patchResourceDataRunningForCmHandle(final String resourceIdentifier,
- final String datastoreName,
+ public ResponseEntity<Object> patchResourceDataRunningForCmHandle(final String datastoreName,
final String cmHandle,
+ final String resourceIdentifier,
final Object requestBody,
final String contentType) {
@@ -165,17 +165,17 @@
/**
* Create resource data in datastore pass-through running for given cm-handle.
*
- * @param resourceIdentifier resource identifier
* @param datastoreName name of the datastore
* @param cmHandle cm handle identifier
+ * @param resourceIdentifier resource identifier
* @param requestBody the request body
* @param contentType content type of body
* @return {@code ResponseEntity} response from dmi plugin
*/
@Override
- public ResponseEntity<Void> createResourceDataRunningForCmHandle(final String resourceIdentifier,
- final String datastoreName,
+ public ResponseEntity<Void> createResourceDataRunningForCmHandle(final String datastoreName,
final String cmHandle,
+ final String resourceIdentifier,
final Object requestBody,
final String contentType) {
@@ -189,18 +189,18 @@
/**
* Update resource data in datastore pass-through running for given cm-handle.
*
- * @param resourceIdentifier resource identifier
* @param datastoreName name of the datastore
* @param cmHandle cm handle identifier
+ * @param resourceIdentifier resource identifier
* @param requestBody the request body
* @param contentType content type of the body
* @return response entity
*/
@Override
- public ResponseEntity<Object> updateResourceDataRunningForCmHandle(final String resourceIdentifier,
- final String datastoreName,
+ public ResponseEntity<Object> updateResourceDataRunningForCmHandle(final String datastoreName,
final String cmHandle,
+ final String resourceIdentifier,
final Object requestBody,
final String contentType) {
validateDataStore(PASSTHROUGH_RUNNING, datastoreName);
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java
index f459ace..fac9489 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Pantheon.tech
- * Modifications Copyright (C) 2021-2022 Nordix Foundation
+ * Modifications Copyright (C) 2021-2023 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@
import org.onap.cps.ncmp.rest.controller.NetworkCmProxyController;
import org.onap.cps.ncmp.rest.controller.NetworkCmProxyInventoryController;
import org.onap.cps.ncmp.rest.model.DmiErrorMessage;
-import org.onap.cps.ncmp.rest.model.DmiErrorMessageDmiresponse;
+import org.onap.cps.ncmp.rest.model.DmiErrorMessageDmiResponse;
import org.onap.cps.ncmp.rest.model.ErrorMessage;
import org.onap.cps.spi.exceptions.AlreadyDefinedException;
import org.onap.cps.spi.exceptions.AlreadyDefinedExceptionBatch;
@@ -116,7 +116,7 @@
final HttpStatus httpStatus,
final HttpClientRequestException httpClientRequestException) {
final var dmiErrorMessage = new DmiErrorMessage();
- final var dmiErrorResponse = new DmiErrorMessageDmiresponse();
+ final var dmiErrorResponse = new DmiErrorMessageDmiResponse();
dmiErrorResponse.setHttpCode(httpClientRequestException.getHttpStatus());
dmiErrorResponse.setBody(httpClientRequestException.getDetails());
dmiErrorMessage.setMessage(httpClientRequestException.getMessage());
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
index e20780b..a65e3c4 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
@@ -86,11 +86,10 @@
* Execute (async) data operation for group of cm handles using dmi.
*
* @param topicParamInQuery topic name for (triggering) async responses
- * @param dataOperationRequest cm handle identifiers
+ * @param dataOperationRequest contains a list of operation definitions(multiple operations)
*/
void executeDataOperationForCmHandles(String topicParamInQuery,
- DataOperationRequest
- dataOperationRequest,
+ DataOperationRequest dataOperationRequest,
String requestId);
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiBatchOperation.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperation.java
similarity index 93%
rename from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiBatchOperation.java
rename to cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperation.java
index 512c3bc..6346379 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiBatchOperation.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperation.java
@@ -33,7 +33,7 @@
@Getter
@Builder
@JsonPropertyOrder({"operation", "operationId", "datastore", "options", "resourceIdentifier", "cmHandles"})
-public class DmiBatchOperation {
+public class DmiDataOperation {
@JsonProperty("operation")
private OperationType operationType;
@@ -50,10 +50,10 @@
* @param dataOperationDefinition definition of incoming of dataOperation request
* @return mapped dmi operation details
*/
- public static DmiBatchOperation buildDmiBatchRequestBodyWithoutCmHandles(
+ public static DmiDataOperation buildDmiDataOperationRequestBodyWithoutCmHandles(
final DataOperationDefinition dataOperationDefinition) {
- return DmiBatchOperation.builder()
+ return DmiDataOperation.builder()
.operationType(OperationType.fromOperationName(dataOperationDefinition.getOperation()))
.operationId(dataOperationDefinition.getOperationId())
.datastore(DatastoreType.fromDatastoreName(dataOperationDefinition.getDatastore()).getDatastoreName())
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
index adf634d..8596c56 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
@@ -34,7 +34,7 @@
import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration;
import org.onap.cps.ncmp.api.impl.executor.TaskExecutor;
import org.onap.cps.ncmp.api.impl.utils.DmiServiceUrlBuilder;
-import org.onap.cps.ncmp.api.impl.utils.ResourceDataBatchRequestUtils;
+import org.onap.cps.ncmp.api.impl.utils.ResourceDataOperationRequestUtils;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
import org.onap.cps.ncmp.api.inventory.CmHandleState;
import org.onap.cps.ncmp.api.inventory.InventoryPersistence;
@@ -131,11 +131,11 @@
final Collection<YangModelCmHandle> yangModelCmHandles
= getYangModelCmHandlesInReadyState(cmHandlesIds);
- final Map<String, List<DmiBatchOperation>> operationsOutPerDmiServiceName
- = ResourceDataBatchRequestUtils.processPerOperationInBatchRequest(dataOperationRequest,
+ final Map<String, List<DmiDataOperation>> operationsOutPerDmiServiceName
+ = ResourceDataOperationRequestUtils.processPerDefinitionInDataOperationsRequest(dataOperationRequest,
yangModelCmHandles);
- buildBatchRequestUrlAndSendToDmiService(topicParamInQuery, requestId, operationsOutPerDmiServiceName);
+ buildDataOperationRequestUrlAndSendToDmiService(topicParamInQuery, requestId, operationsOutPerDmiServiceName);
}
/**
@@ -196,13 +196,13 @@
cmHandleId));
}
- private String getDmiServiceBatchRequestUrl(final String dmiServiceName,
- final String topicParamInQuery,
- final String requestId) {
- final MultiValueMap<String, String> batchRequestQueryParams = dmiServiceUrlBuilder
- .getBatchRequestQueryParams(topicParamInQuery, requestId);
- return dmiServiceUrlBuilder.getBatchRequestUrl(batchRequestQueryParams,
- dmiServiceUrlBuilder.populateBatchUriVariables(dmiServiceName));
+ private String getDmiServiceDataOperationRequestUrl(final String dmiServiceName,
+ final String topicParamInQuery,
+ final String requestId) {
+ final MultiValueMap<String, String> dataOperationRequestQueryParams = dmiServiceUrlBuilder
+ .getDataOperationRequestQueryParams(topicParamInQuery, requestId);
+ return dmiServiceUrlBuilder.getDataOperationRequestUrl(dataOperationRequestQueryParams,
+ dmiServiceUrlBuilder.populateDataOperationRequestUriVariables(dmiServiceName));
}
private void validateIfCmHandleStateReady(final YangModelCmHandle yangModelCmHandle,
@@ -230,25 +230,27 @@
== CmHandleState.READY).collect(Collectors.toList());
}
- private void buildBatchRequestUrlAndSendToDmiService(final String topicParamInQuery,
- final String requestId,
- final Map<String, List<DmiBatchOperation>>
+ private void buildDataOperationRequestUrlAndSendToDmiService(final String topicParamInQuery,
+ final String requestId,
+ final Map<String, List<DmiDataOperation>>
groupsOutPerDmiServiceName) {
groupsOutPerDmiServiceName.entrySet().forEach(groupsOutPerDmiServiceNameEntry -> {
final String dmiServiceName = groupsOutPerDmiServiceNameEntry.getKey();
- final List<DmiBatchOperation> dmiBatchRequestBodies = groupsOutPerDmiServiceNameEntry.getValue();
- final String dmiBatchResourceDataUrl = getDmiServiceBatchRequestUrl(dmiServiceName, topicParamInQuery,
- requestId);
- sendBatchRequestToDmiService(dmiBatchResourceDataUrl, dmiBatchRequestBodies);
+ final List<DmiDataOperation> dmiDataOperationRequestBodies = groupsOutPerDmiServiceNameEntry.getValue();
+ final String dmiDataOperationResourceUrl =
+ getDmiServiceDataOperationRequestUrl(dmiServiceName, topicParamInQuery, requestId);
+ sendDataOperationRequestToDmiService(dmiDataOperationResourceUrl, dmiDataOperationRequestBodies);
});
}
- private void sendBatchRequestToDmiService(final String batchResourceDataUrl,
- final List<DmiBatchOperation> dmiBatchRequestBodies) {
- final String batchRequestBodiesAsJsonString = jsonObjectMapper.asJsonString(dmiBatchRequestBodies);
- TaskExecutor.executeTask(() -> dmiRestClient.postOperationWithJsonData(batchResourceDataUrl,
- batchRequestBodiesAsJsonString, READ), DEFAULT_ASYNC_TASK_EXECUTOR_TIMEOUT_IN_MILLISECONDS)
+ private void sendDataOperationRequestToDmiService(final String dataOperationResourceUrl,
+ final List<DmiDataOperation> dmiDataOperationRequestBodies) {
+ final String dataOperationRequestBodiesAsJsonString =
+ jsonObjectMapper.asJsonString(dmiDataOperationRequestBodies);
+ TaskExecutor.executeTask(() -> dmiRestClient.postOperationWithJsonData(dataOperationResourceUrl,
+ dataOperationRequestBodiesAsJsonString, READ),
+ DEFAULT_ASYNC_TASK_EXECUTOR_TIMEOUT_IN_MILLISECONDS)
.whenCompleteAsync(this::handleTaskCompletion);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilder.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilder.java
index 5c6fa9f..d855442 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilder.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilder.java
@@ -53,17 +53,17 @@
}
/**
- * This method builds batch request url.
+ * This method builds data operation request url.
*
- * @param batchRequestQueryParams query param map as key, value pair
- * @param batchRequestUriVariables uri param map as key (placeholder), value pair
- * @return {@code String} batch request url as string
+ * @param dataoperationRequestQueryParams query param map as key, value pair
+ * @param dataoperationRequestUriVariables uri param map as key (placeholder), value pair
+ * @return {@code String} data operation request url as string
*/
- public String getBatchRequestUrl(final MultiValueMap<String, String> batchRequestQueryParams,
- final Map<String, Object> batchRequestUriVariables) {
- return getBatchResourceDataBasePathUriBuilder()
- .queryParams(batchRequestQueryParams)
- .uriVariables(batchRequestUriVariables)
+ public String getDataOperationRequestUrl(final MultiValueMap<String, String> dataoperationRequestQueryParams,
+ final Map<String, Object> dataoperationRequestUriVariables) {
+ return getDataOperationResourceDataBasePathUriBuilder()
+ .queryParams(dataoperationRequestQueryParams)
+ .uriVariables(dataoperationRequestUriVariables)
.buildAndExpand().toUriString();
}
@@ -82,11 +82,11 @@
}
/**
- * This method creates the dmi service url builder object with path variables for batch of cm handles.
+ * This method creates the dmi service url builder object with path variables for data operation request.
*
* @return {@code UriComponentsBuilder} dmi service url builder object
*/
- public UriComponentsBuilder getBatchResourceDataBasePathUriBuilder() {
+ public UriComponentsBuilder getDataOperationResourceDataBasePathUriBuilder() {
return UriComponentsBuilder.newInstance()
.path("{dmiServiceName}")
.pathSegment("{dmiBasePath}")
@@ -116,12 +116,12 @@
}
/**
- * This method populates uri variables for batch request.
+ * This method populates uri variables for data operation request.
*
* @param dmiServiceName dmi service name
* @return {@code Map<String, Object>} uri variables as map
*/
- public Map<String, Object> populateBatchUriVariables(final String dmiServiceName) {
+ public Map<String, Object> populateDataOperationRequestUriVariables(final String dmiServiceName) {
final Map<String, Object> uriVariables = new HashMap<>();
final String dmiBasePath = dmiProperties.getDmiBasePath();
uriVariables.put("dmiServiceName", dmiServiceName);
@@ -151,14 +151,14 @@
}
/**
- * This method is used to populate map from query params for batch request.
+ * This method is used to populate map from query params for data operation request.
*
* @param topicParamInQuery topic into url param
* @param requestId unique id of response for valid topic
* @return all valid query params as map
*/
- public MultiValueMap<String, String> getBatchRequestQueryParams(final String topicParamInQuery,
- final String requestId) {
+ public MultiValueMap<String, String> getDataOperationRequestQueryParams(final String topicParamInQuery,
+ final String requestId) {
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
getQueryParamConsumer().accept("topic", topicParamInQuery, queryParams);
getQueryParamConsumer().accept("requestId", requestId, queryParams);
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/ResourceDataBatchRequestUtils.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/ResourceDataOperationRequestUtils.java
similarity index 71%
rename from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/ResourceDataBatchRequestUtils.java
rename to cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/ResourceDataOperationRequestUtils.java
index f0d0255..573f8b3 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/ResourceDataBatchRequestUtils.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/ResourceDataOperationRequestUtils.java
@@ -31,26 +31,27 @@
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.impl.operations.CmHandle;
-import org.onap.cps.ncmp.api.impl.operations.DmiBatchOperation;
+import org.onap.cps.ncmp.api.impl.operations.DmiDataOperation;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
import org.onap.cps.ncmp.api.models.DataOperationDefinition;
import org.onap.cps.ncmp.api.models.DataOperationRequest;
@Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public class ResourceDataBatchRequestUtils {
+public class ResourceDataOperationRequestUtils {
private static final String UNKNOWN_SERVICE_NAME = null;
/**
- * Create a list of DMI batch operation per DMI service (name).
+ * Create a list of DMI data operations per DMI service (name).
*
* @param dataOperationRequestIn incoming data operation request details
* @param yangModelCmHandles involved cm handles represented as YangModelCmHandle (incl. metadata)
*
- * @return {@code Map<String, List<DmiBatchOperation>>} Create a list of DMI batch operation per DMI service (name).
+ * @return {@code Map<String, List<DmiDataOperation>>} Create a list of DMI data operations operation
+ * per DMI service (name).
*/
- public static Map<String, List<DmiBatchOperation>> processPerOperationInBatchRequest(
+ public static Map<String, List<DmiDataOperation>> processPerDefinitionInDataOperationsRequest(
final DataOperationRequest dataOperationRequestIn,
final Collection<YangModelCmHandle> yangModelCmHandles) {
@@ -60,7 +61,7 @@
final Map<String, String> dmiServiceNamesPerCmHandleId =
getDmiServiceNamesPerCmHandleId(dmiPropertiesPerCmHandleIdPerServiceName);
- final Map<String, List<DmiBatchOperation>> dmiBatchOperationsOutPerDmiServiceName = new HashMap<>();
+ final Map<String, List<DmiDataOperation>> dmiDataOperationsOutPerDmiServiceName = new HashMap<>();
for (final DataOperationDefinition dataOperationDefinitionIn :
dataOperationRequestIn.getDataOperationDefinitions()) {
@@ -71,14 +72,14 @@
if (cmHandleIdProperties == null) {
publishErrorMessageToClientTopic(cmHandleId);
} else {
- final DmiBatchOperation dmiBatchOperationOut = getOrAddDmiBatchOperation(dmiServiceName,
- dataOperationDefinitionIn, dmiBatchOperationsOutPerDmiServiceName);
+ final DmiDataOperation dmiDataOperationOut = getOrAddDmiDataOperation(dmiServiceName,
+ dataOperationDefinitionIn, dmiDataOperationsOutPerDmiServiceName);
final CmHandle cmHandle = CmHandle.buildCmHandleWithProperties(cmHandleId, cmHandleIdProperties);
- dmiBatchOperationOut.getCmHandles().add(cmHandle);
+ dmiDataOperationOut.getCmHandles().add(cmHandle);
}
}
}
- return dmiBatchOperationsOutPerDmiServiceName;
+ return dmiDataOperationsOutPerDmiServiceName;
}
private static void publishErrorMessageToClientTopic(final String requestedCmHandleId) {
@@ -103,24 +104,24 @@
return dmiServiceNamesPerCmHandleId;
}
- private static DmiBatchOperation getOrAddDmiBatchOperation(final String dmiServiceName,
- final DataOperationDefinition
+ private static DmiDataOperation getOrAddDmiDataOperation(final String dmiServiceName,
+ final DataOperationDefinition
dataOperationDefinitionIn,
- final Map<String, List<DmiBatchOperation>>
- dmiBatchOperationsOutPerDmiServiceName) {
- dmiBatchOperationsOutPerDmiServiceName
+ final Map<String, List<DmiDataOperation>>
+ dmiDataOperationsOutPerDmiServiceName) {
+ dmiDataOperationsOutPerDmiServiceName
.computeIfAbsent(dmiServiceName, dmiServiceNameAsKey -> new ArrayList<>());
- final List<DmiBatchOperation> dmiBatchOperationsOut
- = dmiBatchOperationsOutPerDmiServiceName.get(dmiServiceName);
- final boolean isNewOperation = dmiBatchOperationsOut.isEmpty()
- || !dmiBatchOperationsOut.get(dmiBatchOperationsOut.size() - 1).getOperationId()
+ final List<DmiDataOperation> dmiDataOperationsOut
+ = dmiDataOperationsOutPerDmiServiceName.get(dmiServiceName);
+ final boolean isNewOperation = dmiDataOperationsOut.isEmpty()
+ || !dmiDataOperationsOut.get(dmiDataOperationsOut.size() - 1).getOperationId()
.equals(dataOperationDefinitionIn.getOperationId());
if (isNewOperation) {
- final DmiBatchOperation newDmiBatchOperationOut =
- DmiBatchOperation.buildDmiBatchRequestBodyWithoutCmHandles(dataOperationDefinitionIn);
- dmiBatchOperationsOut.add(newDmiBatchOperationOut);
- return newDmiBatchOperationOut;
+ final DmiDataOperation newDmiDataOperationOut =
+ DmiDataOperation.buildDmiDataOperationRequestBodyWithoutCmHandles(dataOperationDefinitionIn);
+ dmiDataOperationsOut.add(newDmiDataOperationOut);
+ return newDmiDataOperationOut;
}
- return dmiBatchOperationsOut.get(dmiBatchOperationsOut.size() - 1);
+ return dmiDataOperationsOut.get(dmiDataOperationsOut.size() - 1);
}
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
index be178e1..c7ee4e0 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
@@ -94,7 +94,7 @@
def expectedDmiBatchResourceDataUrl = "ncmp/v1/data/topic=my-topic-name"
def expectedBatchRequestAsJson = '[{"operation":"read","operationId":"operational-14","datastore":"ncmp-datastore:passthrough-operational","options":"some option","resourceIdentifier":"some resource identifier","cmHandles":[{"id":"some-cm-handle","cmHandleProperties":{"prop1":"val1"}}]}]'
mockDmiRestClient.postOperationWithJsonData(expectedDmiBatchResourceDataUrl, _, READ.operationName) >> responseFromDmi
- dmiServiceUrlBuilder.getBatchRequestUrl(_, _) >> expectedDmiBatchResourceDataUrl
+ dmiServiceUrlBuilder.getDataOperationRequestUrl(_, _) >> expectedDmiBatchResourceDataUrl
when: 'get resource data for group of cm handles are invoked'
objectUnderTest.requestResourceDataFromDmi('my-topic-name', dataOperationRequest, 'requestId')
then: 'wait a little to allow execution of service method by task executor (on separate thread)'
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataOperationRequestUtilsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataOperationRequestUtilsSpec.groovy
index af3841a..334b455 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataOperationRequestUtilsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataOperationRequestUtilsSpec.groovy
@@ -42,7 +42,7 @@
and: '4 known cm handles: ch1-dmi1, ch2-dmi1, ch3-dmi2, ch4-dmi2'
def yangModelCmHandles = getYangModelCmHandles()
when: 'data operation request is processed'
- def operationsOutPerDmiServiceName = ResourceDataBatchRequestUtils.processPerOperationInBatchRequest(dataOperationRequest, yangModelCmHandles)
+ def operationsOutPerDmiServiceName = ResourceDataOperationRequestUtils.processPerDefinitionInDataOperationsRequest(dataOperationRequest, yangModelCmHandles)
and: 'converted to a json node'
def dmiDataOperationRequestBody = jsonObjectMapper.asJsonString(operationsOutPerDmiServiceName.get(serviceName))
def dmiDataOperationRequestBodyAsJsonNode = jsonObjectMapper.convertToJsonNode(dmiDataOperationRequestBody).get(operationIndex)
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy
index b1a8e85..6c45755 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy
@@ -81,15 +81,15 @@
given: 'the required path parameters'
def batchRequestUriVariables = [dmiServiceName: 'some-service', dmiBasePath: 'testBase', cmHandleId: '123']
and: 'the relevant query parameters'
- def batchRequestQueryParams = objectUnderTest.getBatchRequestQueryParams('some topic', 'some id')
+ def batchRequestQueryParams = objectUnderTest.getDataOperationRequestQueryParams('some topic', 'some id')
when: 'a URL is created'
- def result = objectUnderTest.getBatchRequestUrl(batchRequestQueryParams, batchRequestUriVariables)
+ def result = objectUnderTest.getDataOperationRequestUrl(batchRequestQueryParams, batchRequestUriVariables)
then: 'it is formed correctly'
assert result.toString() == 'some-service/testBase/v1/data?topic=some topic&requestId=some id'
}
def 'Populate batch uri variables.'() {
expect: 'Populate batch uri variables returns a map with given service name and base path from setup'
- assert objectUnderTest.populateBatchUriVariables('some service') == [ dmiServiceName: 'some service',dmiBasePath: 'dmi' ]
+ assert objectUnderTest.populateDataOperationRequestUriVariables('some service') == [dmiServiceName: 'some service', dmiBasePath: 'dmi' ]
}
}
diff --git a/cps-rest/docs/openapi/openapi.yml b/cps-rest/docs/openapi/openapi.yml
index d5ba97a..4bbf9f0 100644
--- a/cps-rest/docs/openapi/openapi.yml
+++ b/cps-rest/docs/openapi/openapi.yml
@@ -1,5 +1,5 @@
# ============LICENSE_START=======================================================
-# Copyright (C) 2021 Nordix Foundation
+# Copyright (C) 2021-2023 Nordix Foundation
# Modifications Copyright (C) 2021 Pantheon.tech
# Modifications Copyright (C) 2021 Bell Canada.
# Modifications Copyright (C) 2022-2023 TechMahindra Ltd.
@@ -19,7 +19,7 @@
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
-openapi: 3.0.1
+openapi: 3.0.3
info:
title: ONAP Open API v3 Configuration Persistence Service
description: Configuration Persistence Service is a Model Driven Generic Database
diff --git a/cps-rest/pom.xml b/cps-rest/pom.xml
index f6f8100..c581b06 100755
--- a/cps-rest/pom.xml
+++ b/cps-rest/pom.xml
@@ -128,8 +128,9 @@
<plugins>
<!-- Swagger code generation. -->
<plugin>
- <groupId>io.swagger.codegen.v3</groupId>
- <artifactId>swagger-codegen-maven-plugin</artifactId>
+ <groupId>org.openapitools</groupId>
+ <artifactId>openapi-generator-maven-plugin</artifactId>
+ <version>6.6.0</version>
<executions>
<execution>
<id>code-gen</id>
@@ -141,13 +142,15 @@
<invokerPackage>org.onap.cps.rest.controller</invokerPackage>
<modelPackage>org.onap.cps.rest.model</modelPackage>
<apiPackage>org.onap.cps.rest.api</apiPackage>
- <language>spring</language>
+ <generatorName>spring</generatorName>
<generateSupportingFiles>false</generateSupportingFiles>
<configOptions>
<sourceFolder>src/gen/java</sourceFolder>
<dateLibrary>java11</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useTags>true</useTags>
+ <openApiNullable>false</openApiNullable>
+ <skipDefaultInterface>true</skipDefaultInterface>
</configOptions>
</configuration>
</execution>
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
index 993c5a3..369c94d 100755
--- a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
@@ -96,14 +96,15 @@
/**
* Create a {@link SchemaSet}.
*
- * @param multipartFile multipart file
- * @param schemaSetName schemaset name
* @param dataspaceName dataspace name
+ * @param schemaSetName schemaset name
+ * @param multipartFile multipart file
* @return a {@Link ResponseEntity} of created schemaset name & {@link HttpStatus} CREATED
*/
@Override
- public ResponseEntity<String> createSchemaSet(@NotNull @Valid final String schemaSetName,
- final String dataspaceName, @Valid final MultipartFile multipartFile) {
+ public ResponseEntity<String> createSchemaSet(final String dataspaceName,
+ @NotNull @Valid final String schemaSetName,
+ final MultipartFile multipartFile) {
cpsModuleService.createSchemaSet(dataspaceName, schemaSetName, extractYangResourcesMap(multipartFile));
return new ResponseEntity<>(schemaSetName, HttpStatus.CREATED);
}
@@ -111,16 +112,17 @@
/**
* Create a {@link SchemaSet}.
*
- * @param multipartFile multipart file
- * @param schemaSetName schemaset name
* @param dataspaceName dataspace name
+ * @param schemaSetName schemaset name
+ * @param multipartFile multipart file
* @return a {@Link ResponseEntity} of created schema set without any response body & {@link HttpStatus} CREATED
*/
@Override
@Timed(value = "cps.rest.admin.controller.schemaset.create",
description = "Time taken to create schemaset from controller")
- public ResponseEntity<Void> createSchemaSetV2(@NotNull @Valid final String schemaSetName,
- final String dataspaceName, @Valid final MultipartFile multipartFile) {
+ public ResponseEntity<Void> createSchemaSetV2(final String dataspaceName,
+ @NotNull @Valid final String schemaSetName,
+ final MultipartFile multipartFile) {
cpsModuleService.createSchemaSet(dataspaceName, schemaSetName, extractYangResourcesMap(multipartFile));
return new ResponseEntity<>(HttpStatus.CREATED);
}
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java
index edfeab3..6216332 100755
--- a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2020-2022 Bell Canada.
* Modifications Copyright (C) 2021 Pantheon.tech
- * Modifications Copyright (C) 2021-2022 Nordix Foundation
+ * Modifications Copyright (C) 2021-2023 Nordix Foundation
* Modifications Copyright (C) 2022-2023 TechMahindra Ltd.
* Modifications Copyright (C) 2022 Deutsche Telekom AG
* ================================================================================
@@ -63,9 +63,9 @@
private final PrefixResolver prefixResolver;
@Override
- public ResponseEntity<String> createNode(@RequestHeader(value = "Content-Type") final String contentTypeHeader,
- final String apiVersion,
+ public ResponseEntity<String> createNode(final String apiVersion,
final String dataspaceName, final String anchorName,
+ @RequestHeader(value = "Content-Type") final String contentTypeHeader,
final String nodeData, final String parentNodeXpath,
final String observedTimestamp) {
final ContentType contentType = contentTypeHeader.contains(MediaType.APPLICATION_XML_VALUE) ? ContentType.XML
@@ -90,8 +90,9 @@
}
@Override
- public ResponseEntity<String> addListElements(final String parentNodeXpath, final String apiVersion,
- final String dataspaceName, final String anchorName, final Object jsonData, final String observedTimestamp) {
+ public ResponseEntity<String> addListElements(final String apiVersion, final String dataspaceName,
+ final String anchorName, final String parentNodeXpath,
+ final Object jsonData, final String observedTimestamp) {
cpsDataService.saveListElements(dataspaceName, anchorName, parentNodeXpath,
jsonObjectMapper.asJsonString(jsonData), toOffsetDateTime(observedTimestamp));
return new ResponseEntity<>(HttpStatus.CREATED);
@@ -148,8 +149,9 @@
}
@Override
- public ResponseEntity<Object> replaceListContent(final String parentNodeXpath,
- final String apiVersion, final String dataspaceName, final String anchorName, final Object jsonData,
+ public ResponseEntity<Object> replaceListContent(final String apiVersion,
+ final String dataspaceName, final String anchorName,
+ final String parentNodeXpath, final Object jsonData,
final String observedTimestamp) {
cpsDataService.replaceListContent(dataspaceName, anchorName, parentNodeXpath,
jsonObjectMapper.asJsonString(jsonData), toOffsetDateTime(observedTimestamp));