aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpriyank <priyank.maheshwari@est.tech>2024-08-20 13:36:26 +0100
committerPriyank Maheshwari <priyank.maheshwari@est.tech>2024-08-27 12:54:30 +0000
commitae5fe19e0d8620326aa7be7068b1ab02361c5c40 (patch)
tree0ae1ff37401e61d142aa29fc3ecb8d7d59e26f2d
parent9718417885caa9581a9115ba07e2060bd38ec9b8 (diff)
Support for alternate-id for CPS-E-05 i/f
- Added support for alternateId for CREATE , UPDATE, DELETE and PATCH operation for CPS-E05 passthrough running datastores Issue-ID: CPS-2362 Change-Id: Ie4db1d84dba795e9650949cab3374e0b2570beba Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java24
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java5
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/NetworkCmProxyFacade.java6
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/AlternateIdMatcher.java2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy5
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiOperationsBaseSpec.groovy2
6 files changed, 27 insertions, 17 deletions
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 c339a05c71..6a2e9a1541 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
@@ -148,7 +148,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
* Patch resource data.
*
* @param datastoreName name of the datastore (currently only supports "ncmp-datastore:passthrough-running")
- * @param cmHandle cm handle identifier
+ * @param cmHandleReference cm handle or alternate identifier
* @param resourceIdentifier resource identifier
* @param requestBody the request body
* @param contentType content type of body
@@ -158,7 +158,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
@Override
public ResponseEntity<Object> patchResourceDataRunningForCmHandle(final String datastoreName,
- final String cmHandle,
+ final String cmHandleReference,
final String resourceIdentifier,
final Object requestBody,
final String contentType,
@@ -168,7 +168,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
final Object responseObject = networkCmProxyFacade
.writeResourceDataPassThroughRunningForCmHandle(
- cmHandle, resourceIdentifier, PATCH,
+ cmHandleReference, resourceIdentifier, PATCH,
jsonObjectMapper.asJsonString(requestBody), contentType, authorization);
return ResponseEntity.ok(responseObject);
}
@@ -177,7 +177,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
* Create resource data for given cm-handle.
*
* @param datastoreName name of the datastore (currently only supports "ncmp-datastore:passthrough-running")
- * @param cmHandle cm handle identifier
+ * @param cmHandleReference cm handle or alternate identifier
* @param resourceIdentifier resource identifier
* @param requestBody the request body
* @param contentType content type of body
@@ -186,14 +186,14 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
*/
@Override
public ResponseEntity<Void> createResourceDataRunningForCmHandle(final String datastoreName,
- final String cmHandle,
+ final String cmHandleReference,
final String resourceIdentifier,
final Object requestBody,
final String contentType,
final String authorization) {
validateDataStore(PASSTHROUGH_RUNNING, datastoreName);
- networkCmProxyFacade.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
+ networkCmProxyFacade.writeResourceDataPassThroughRunningForCmHandle(cmHandleReference,
resourceIdentifier, CREATE, jsonObjectMapper.asJsonString(requestBody), contentType, authorization);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@@ -202,7 +202,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
* Update resource data for given cm-handle.
*
* @param datastoreName name of the datastore (currently only supports "ncmp-datastore:passthrough-running")
- * @param cmHandle cm handle identifier
+ * @param cmHandleReference cm handle or alternate identifier
* @param resourceIdentifier resource identifier
* @param requestBody the request body
* @param contentType content type of the body
@@ -212,14 +212,14 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
@Override
public ResponseEntity<Object> updateResourceDataRunningForCmHandle(final String datastoreName,
- final String cmHandle,
+ final String cmHandleReference,
final String resourceIdentifier,
final Object requestBody,
final String contentType,
final String authorization) {
validateDataStore(PASSTHROUGH_RUNNING, datastoreName);
- networkCmProxyFacade.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
+ networkCmProxyFacade.writeResourceDataPassThroughRunningForCmHandle(cmHandleReference,
resourceIdentifier, UPDATE, jsonObjectMapper.asJsonString(requestBody), contentType, authorization);
return new ResponseEntity<>(HttpStatus.OK);
}
@@ -228,7 +228,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
* Delete resource data for a given cm-handle.
*
* @param datastoreName name of the datastore (currently only supports "ncmp-datastore:passthrough-running")
- * @param cmHandle cm handle identifier
+ * @param cmHandleReference cm handle or alternate identifier
* @param resourceIdentifier resource identifier
* @param contentType content type of the body
* @param authorization contents of Authorization header, or null if not present
@@ -236,14 +236,14 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
*/
@Override
public ResponseEntity<Void> deleteResourceDataRunningForCmHandle(final String datastoreName,
- final String cmHandle,
+ final String cmHandleReference,
final String resourceIdentifier,
final String contentType,
final String authorization) {
validateDataStore(PASSTHROUGH_RUNNING, datastoreName);
- networkCmProxyFacade.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
+ networkCmProxyFacade.writeResourceDataPassThroughRunningForCmHandle(cmHandleReference,
resourceIdentifier, DELETE, NO_BODY, contentType, authorization);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java
index 0cedeae0a4..6b813a6f69 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/DmiDataOperations.java
@@ -171,7 +171,10 @@ public class DmiDataOperations {
final String requestData,
final String dataType,
final String authorization) {
- final YangModelCmHandle yangModelCmHandle = getYangModelCmHandle(cmHandleId);
+ final CmResourceAddress cmResourceAddress =
+ new CmResourceAddress(PASSTHROUGH_RUNNING.getDatastoreName(), cmHandleId, resourceId);
+
+ final YangModelCmHandle yangModelCmHandle = getYangModelCmHandle(cmResourceAddress.getResolvedCmHandleId());
policyExecutor.checkPermission(yangModelCmHandle, operationType, authorization, resourceId, requestData);
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/NetworkCmProxyFacade.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/NetworkCmProxyFacade.java
index b97088a5e0..5343a2e131 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/NetworkCmProxyFacade.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/data/NetworkCmProxyFacade.java
@@ -101,7 +101,7 @@ public class NetworkCmProxyFacade {
/**
* Write resource data for data store pass-through running using dmi for given cm-handle.
*
- * @param cmHandleId cm handle identifier
+ * @param cmHandleReference cm handle or alternate identifier
* @param resourceIdentifier resource identifier
* @param operationType required operation type
* @param requestData request body to create resource
@@ -109,13 +109,13 @@ public class NetworkCmProxyFacade {
* @param authorization contents of Authorization header, or null if not present
* @return {@code Object} return data
*/
- public Object writeResourceDataPassThroughRunningForCmHandle(final String cmHandleId,
+ public Object writeResourceDataPassThroughRunningForCmHandle(final String cmHandleReference,
final String resourceIdentifier,
final OperationType operationType,
final String requestData,
final String dataType,
final String authorization) {
- return dmiDataOperations.writeResourceDataPassThroughRunningFromDmi(cmHandleId, resourceIdentifier,
+ return dmiDataOperations.writeResourceDataPassThroughRunningFromDmi(cmHandleReference, resourceIdentifier,
operationType, requestData, dataType, authorization);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/AlternateIdMatcher.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/AlternateIdMatcher.java
index c408ff9b13..c526dfb297 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/AlternateIdMatcher.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/AlternateIdMatcher.java
@@ -59,7 +59,7 @@ public class AlternateIdMatcher {
/**
* Get cm handle Id from given cmHandleReference.
*
- * @param cmHandleReference alternate ID
+ * @param cmHandleReference cm handle or alternate identifier
* @return cm handle id string
*/
public String getCmHandleId(final String cmHandleReference) {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy
index ec13aee4bb..fd76abb581 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy
@@ -49,6 +49,8 @@ import static org.onap.cps.ncmp.api.NcmpResponseStatus.UNKNOWN_ERROR
import static org.onap.cps.ncmp.api.data.models.DatastoreType.PASSTHROUGH_OPERATIONAL
import static org.onap.cps.ncmp.api.data.models.DatastoreType.PASSTHROUGH_RUNNING
import static org.onap.cps.ncmp.api.data.models.OperationType.CREATE
+import static org.onap.cps.ncmp.api.data.models.OperationType.DELETE
+import static org.onap.cps.ncmp.api.data.models.OperationType.PATCH
import static org.onap.cps.ncmp.api.data.models.OperationType.READ
import static org.onap.cps.ncmp.api.data.models.OperationType.UPDATE
import static org.onap.cps.ncmp.impl.models.RequiredDmiService.DATA
@@ -161,6 +163,7 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
def 'Write data for pass-through:running datastore in DMI.'() {
given: 'a cm handle for #cmHandleId'
mockYangModelCmHandleRetrieval([yangModelCmHandleProperty])
+ alternateIdMatcher.getCmHandleId(cmHandleId) >> cmHandleId
and: 'a positive response from DMI service when it is called with the expected parameters'
def expectedUrlTemplateParameters = new UrlTemplateParameters('myServiceName/dmi/v1/ch/{cmHandleId}/data/ds/{datastore}?resourceIdentifier={resourceIdentifier}', ['resourceIdentifier': resourceIdentifier, 'datastore': 'ncmp-datastore:passthrough-running', 'cmHandleId': cmHandleId])
def expectedJson = '{"operation":"' + expectedOperationInUrl + '","dataType":"some data type","data":"requestData","cmHandleProperties":{"prop1":"val1"},"moduleSetTag":""}'
@@ -176,6 +179,8 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
operation || expectedOperationInUrl
CREATE || 'create'
UPDATE || 'update'
+ DELETE || 'delete'
+ PATCH || 'patch'
}
def 'State Ready validation'() {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiOperationsBaseSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiOperationsBaseSpec.groovy
index affbf2aa4f..65fda8718c 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiOperationsBaseSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiOperationsBaseSpec.groovy
@@ -46,6 +46,7 @@ abstract class DmiOperationsBaseSpec extends Specification {
def yangModelCmHandle = new YangModelCmHandle()
def static dmiServiceName = 'myServiceName'
def static cmHandleId = 'some-cm-handle'
+ def static alternateId = 'alt-id-' + cmHandleId
def static resourceIdentifier = 'parent/child'
def mockYangModelCmHandleRetrieval(dmiProperties) {
@@ -68,6 +69,7 @@ abstract class DmiOperationsBaseSpec extends Specification {
yangModelCmHandle.dmiServiceName = dmiServiceName
yangModelCmHandle.dmiProperties = dmiProperties
yangModelCmHandle.id = cmHandleId
+ yangModelCmHandle.alternateId = alternateId
yangModelCmHandle.compositeState = new CompositeState()
yangModelCmHandle.compositeState.cmHandleState = CmHandleState.READY
yangModelCmHandle.moduleSetTag = moduleSetTag