summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorNiamh Core <niamh.core@est.tech>2021-08-20 09:54:44 +0000
committerGerrit Code Review <gerrit@onap.org>2021-08-20 09:54:44 +0000
commit06b8c2414d694334066c15b7de9ecc9325a1e37e (patch)
treea677a7a2cb2bde18ef701fa29bc1ff36006bf55b /src/main/java
parenteeb7a94bc24f4458f134d9902b7c4e27fe2f6e76 (diff)
parentf01d5674c738e1bc0e485a43f52e5cf19c9d81a7 (diff)
Merge "Get resource data for pass-through running (dmi-impl)"
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 4c8e8ecb..62f93e63 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.
@@ -170,11 +172,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 d017714f..ab9c7e1d 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);