summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authortragait <rahul.tyagi@est.tech>2021-08-19 11:19:54 +0100
committertragait <rahul.tyagi@est.tech>2021-08-19 11:19:59 +0100
commitf01d5674c738e1bc0e485a43f52e5cf19c9d81a7 (patch)
tree3c3b942445b556db4d531c31b20f7aa92b725e9e /src/main/java
parent577efb09a39282c608b53a3099b7edc95954f9c2 (diff)
Get resource data for pass-through running (dmi-impl)
Issue-ID: CPS-561 Signed-off-by: tragait <rahul.tyagi@est.tech> Change-Id: Ia92a97296e2c3e84d0b6f6d9d1d0daf1e8f46b55
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java34
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java23
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java26
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java13
4 files changed, 84 insertions, 12 deletions
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java b/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java
index 3d49b78e..79c11a4e 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.List;
import javax.validation.Valid;
+import javax.validation.constraints.Min;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.dmi.model.CmHandles;
import org.onap.cps.ncmp.dmi.model.ModuleReference;
@@ -89,7 +90,7 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
/**
* This method fetches the resource for given cm handle using pass
- * through option. It filters the response on the basis of depth and field
+ * through operational. It filters the response on the basis of depth and field
* query parameters and returns response.
*
* @param cmHandle cm handle identifier
@@ -106,7 +107,7 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
final @Valid OperationalRequest body,
final String accept,
final @Valid String fields,
- final @Valid Integer depth) {
+ final @Min(1) @Valid Integer depth) {
final var modulesListAsJson = dmiService.getResourceDataOperationalForCmHandle(cmHandle,
resourceIdentifier,
accept,
@@ -116,6 +117,35 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
return ResponseEntity.ok(modulesListAsJson);
}
+ /**
+ * This method fetches the resource for given cm handle using pass
+ * through running. It filters the response on the basis of depth and field
+ * query parameters and returns response.
+ *
+ * @param cmHandle cm handle identifier
+ * @param resourceIdentifier resource identifier to fetch data
+ * @param body operational body
+ * @param accept accept header parameter
+ * @param fields fields to filter the response data
+ * @param depth depth parameter for the response
+ * @return {@code ResponseEntity} response entity
+ */
+ @Override
+ public ResponseEntity<Object> getResourceDataPassthroughRunningForCmHandle(final String cmHandle,
+ final String resourceIdentifier,
+ final @Valid OperationalRequest body,
+ final String accept,
+ final @Valid String fields,
+ final @Min(1) @Valid Integer depth) {
+ final var modulesListAsJson = dmiService.getResourceDataPassThroughRunningForCmHandle(cmHandle,
+ resourceIdentifier,
+ accept,
+ fields,
+ depth,
+ body.getCmHandleProperties());
+ return ResponseEntity.ok(modulesListAsJson);
+ }
+
private List<ModuleReference> convertRestObjectToJavaApiObject(final ModuleRequestParent moduleRequestParent) {
return objectMapper
.convertValue(moduleRequestParent.getData().getModules(), new TypeReference<List<ModuleReference>>() {
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java
index a7c94349..83301270 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java
@@ -60,7 +60,7 @@ public interface DmiService {
/**
* This method use to fetch the resource data from cm handle
- * for given datasource and Identifier. Fields and depths query
+ * for datastore pass-through operational and resource Identifier. Fields and depths query
* parameter are used to filter the response from network resource.
*
* @param cmHandle cm handle identifier
@@ -78,4 +78,25 @@ public interface DmiService {
String fieldsQuery,
Integer depthQuery,
Map<String, String> cmHandlePropertyMap);
+
+ /**
+ * This method use to fetch the resource data from cm handle
+ * for datastore pass-through running and resource Identifier. Fields and depths query
+ * parameter are used to filter the response from network resource.
+ *
+ * @param cmHandle cm handle identifier
+ * @param resourceIdentifier resource identifier
+ * @param acceptParam accept header parameter
+ * @param fieldsQuery fields query parameter
+ * @param depthQuery depth query parameter
+ * @param cmHandlePropertyMap cm handle properties
+ *
+ * @return {@code Object} response from network function
+ */
+ Object getResourceDataPassThroughRunningForCmHandle(@NotNull String cmHandle,
+ @NotNull String resourceIdentifier,
+ String acceptParam,
+ String fieldsQuery,
+ Integer depthQuery,
+ Map<String, String> cmHandlePropertyMap);
} \ No newline at end of file
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java
index 94bd97d7..1ee5acf0 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java
@@ -26,10 +26,10 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import javax.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import net.minidev.json.JSONArray;
import org.apache.groovy.parser.antlr4.util.StringUtils;
-import org.jetbrains.annotations.NotNull;
import org.onap.cps.ncmp.dmi.config.DmiPluginConfig.DmiPluginProperties;
import org.onap.cps.ncmp.dmi.exception.CmHandleRegistrationException;
import org.onap.cps.ncmp.dmi.exception.DmiException;
@@ -57,6 +57,8 @@ public class DmiServiceImpl implements DmiService {
private NcmpRestClient ncmpRestClient;
private ObjectMapper objectMapper;
private DmiPluginProperties dmiPluginProperties;
+ private static final String CONTENT_QUERY_PASSTHROUGH_OPERATIONAL = "content=all";
+ private static final String CONTENT_QUERY_PASSTHROUGH_RUNNING = "content=config";
/**
* Constructor.
@@ -172,11 +174,29 @@ public class DmiServiceImpl implements DmiService {
final Integer depthQuery,
final Map<String, String> cmHandlePropertyMap) {
// not using cmHandlePropertyMap of onap dmi impl , other dmi impl might use this.
- final ResponseEntity<String> responseEntity = sdncOperations.getResouceDataForOperational(cmHandle,
+ final ResponseEntity<String> responseEntity = sdncOperations.getResouceDataForOperationalAndRunning(cmHandle,
resourceIdentifier,
fieldsQuery,
depthQuery,
- acceptParam);
+ acceptParam,
+ CONTENT_QUERY_PASSTHROUGH_OPERATIONAL);
+ return prepareAndSendResponse(responseEntity, cmHandle);
+ }
+
+ @Override
+ public Object getResourceDataPassThroughRunningForCmHandle(final @NotNull String cmHandle,
+ final @NotNull String resourceIdentifier,
+ final String acceptParam,
+ final String fieldsQuery,
+ final Integer depthQuery,
+ final Map<String, String> cmHandlePropertyMap) {
+ // not using cmHandlePropertyMap of onap dmi impl , other dmi impl might use this.
+ final ResponseEntity<String> responseEntity = sdncOperations.getResouceDataForOperationalAndRunning(cmHandle,
+ resourceIdentifier,
+ fieldsQuery,
+ depthQuery,
+ acceptParam,
+ CONTENT_QUERY_PASSTHROUGH_RUNNING);
return prepareAndSendResponse(responseEntity, cmHandle);
}
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java b/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java
index 358da590..2e1faf48 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java
@@ -94,14 +94,15 @@ public class SdncOperations {
* @param acceptParam accept parameter
* @return {@code ResponseEntity} response entity
*/
- public ResponseEntity<String> getResouceDataForOperational(final String nodeId,
- final String resourceId,
- final String fieldsValue,
- final Integer depthValue,
- final String acceptParam) {
+ public ResponseEntity<String> getResouceDataForOperationalAndRunning(final String nodeId,
+ final String resourceId,
+ final String fieldsValue,
+ final Integer depthValue,
+ final String acceptParam,
+ final String contentQuery) {
final String getResourceDataUrl = prepareResourceDataUrl(nodeId,
resourceId,
- getQueryList(fieldsValue, depthValue, "content=all"));
+ getQueryList(fieldsValue, depthValue, contentQuery));
final HttpHeaders httpHeaders = new HttpHeaders();
if (!StringUtils.isEmpty(acceptParam)) {
httpHeaders.set(HttpHeaders.ACCEPT, acceptParam);