summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java35
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java24
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java29
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java47
4 files changed, 62 insertions, 73 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 2c2536ff..908ccbe2 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
@@ -26,7 +26,6 @@ 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.DataAccessReadRequest;
@@ -114,56 +113,50 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
/**
* This method fetches the resource for given cm handle using pass through operational. It filters the response on
- * the basis of depth and field query parameters and returns response.
+ * the basis of options query parameters and returns response.
*
* @param resourceIdentifier resource identifier to fetch data
* @param cmHandle cm handle identifier
* @param dataAccessReadRequest data Access Read Request
- * @param accept accept header parameter
- * @param fields fields to filter the response data
- * @param depth depth parameter for the response
+ * @param acceptParamInHeader accept header parameter
+ * @param optionsParamInQuery options query parameter
* @return {@code ResponseEntity} response entity
*/
@Override
public ResponseEntity<Object> getResourceDataOperationalForCmHandle(final String resourceIdentifier,
final String cmHandle,
final @Valid DataAccessReadRequest dataAccessReadRequest,
- final String accept,
- final @Valid String fields,
- final @Min(1) @Valid Integer depth) {
+ final String acceptParamInHeader,
+ final @Valid String optionsParamInQuery) {
final var modulesListAsJson = dmiService.getResourceDataOperationalForCmHandle(cmHandle,
resourceIdentifier,
- accept,
- fields,
- depth,
+ acceptParamInHeader,
+ optionsParamInQuery,
dataAccessReadRequest.getCmHandleProperties());
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.
+ * basis of options query parameters and returns response.
*
* @param resourceIdentifier resource identifier to fetch data
* @param cmHandle cm handle identifier
* @param dataAccessReadRequest data Access Read Request
- * @param accept accept header parameter
- * @param fields fields to filter the response data
- * @param depth depth parameter for the response
+ * @param acceptParamInHeader accept header parameter
+ * @param optionsParamInQuery options query parameter
* @return {@code ResponseEntity} response entity
*/
@Override
public ResponseEntity<Object> getResourceDataPassthroughRunningForCmHandle(final String resourceIdentifier,
final String cmHandle,
final @Valid DataAccessReadRequest dataAccessReadRequest,
- final String accept,
- final @Valid String fields,
- final @Min(1) @Valid Integer depth) {
+ final String acceptParamInHeader,
+ final @Valid String optionsParamInQuery) {
final var modulesListAsJson = dmiService.getResourceDataPassThroughRunningForCmHandle(cmHandle,
resourceIdentifier,
- accept,
- fields,
- depth,
+ acceptParamInHeader,
+ optionsParamInQuery,
dataAccessReadRequest.getCmHandleProperties());
return ResponseEntity.ok(modulesListAsJson);
}
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 753810a2..c6910399 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
@@ -61,40 +61,36 @@ public interface DmiService {
/**
* This method use to fetch the resource data from cm handle for datastore pass-through operational and resource
- * Identifier. Fields and depths query parameter are used to filter the response from network resource.
+ * Identifier. Options 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 acceptParamInHeader accept header parameter
+ * @param optionsParamInQuery options query parameter
* @param cmHandlePropertyMap cm handle properties
* @return {@code Object} response from network function
*/
Object getResourceDataOperationalForCmHandle(@NotNull String cmHandle,
@NotNull String resourceIdentifier,
- String acceptParam,
- String fieldsQuery,
- Integer depthQuery,
+ String acceptParamInHeader,
+ String optionsParamInQuery,
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.
+ * Identifier. Options 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 acceptParamInHeader accept header parameter
+ * @param optionsParamInQuery options 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,
+ String acceptParamInHeader,
+ String optionsParamInQuery,
Map<String, String> cmHandlePropertyMap);
/**
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 844cc4de..b66e5c1b 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
@@ -60,13 +60,12 @@ 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";
+ private static final String RESTCONF_CONTENT_PASSTHROUGH_OPERATIONAL_QUERY_PARAM = "content=all";
+ private static final String REST_CONF_CONTENT_PASSTHROUGH_RUNNING_QUERY_PARAM = "content=config";
private static final String RESPONSE_CODE = "response code : ";
private static final String MESSAGE = " message : ";
private static final String IETF_NETCONF_MONITORING_OUTPUT = "ietf-netconf-monitoring:output";
-
/**
* Constructor.
*
@@ -178,34 +177,30 @@ public class DmiServiceImpl implements DmiService {
@Override
public Object getResourceDataOperationalForCmHandle(final @NotNull String cmHandle,
final @NotNull String resourceIdentifier,
- final String acceptParam,
- final String fieldsQuery,
- final Integer depthQuery,
+ final String acceptParamInHeader,
+ final String optionsParamInQuery,
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_OPERATIONAL);
+ optionsParamInQuery,
+ acceptParamInHeader,
+ RESTCONF_CONTENT_PASSTHROUGH_OPERATIONAL_QUERY_PARAM);
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 String acceptParamInHeader,
+ final String optionsParamInQuery,
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);
+ optionsParamInQuery,
+ acceptParamInHeader,
+ REST_CONF_CONTENT_PASSTHROUGH_RUNNING_QUERY_PARAM);
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 73503d23..98371bf9 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
@@ -20,6 +20,7 @@
package org.onap.cps.ncmp.dmi.service.operation;
+import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.apache.groovy.parser.antlr4.util.StringUtils;
@@ -92,23 +93,22 @@ public class SdncOperations {
*
* @param nodeId network resource identifier
* @param resourceId resource identifier
- * @param fieldsValue fields query
- * @param depthValue depth query
- * @param acceptParam accept parameter
+ * @param optionsParamInQuery fields query
+ * @param acceptParamInHeader accept parameter
+ * @param restconfContentQueryParam restconf content query param
* @return {@code ResponseEntity} response entity
*/
public ResponseEntity<String> getResouceDataForOperationalAndRunning(final String nodeId,
final String resourceId,
- final String fieldsValue,
- final Integer depthValue,
- final String acceptParam,
- final String contentQuery) {
+ final String optionsParamInQuery,
+ final String acceptParamInHeader,
+ final String restconfContentQueryParam) {
final String getResourceDataUrl = prepareResourceDataUrl(nodeId,
resourceId,
- getQueryList(fieldsValue, depthValue, contentQuery));
+ buildQueryParamList(optionsParamInQuery, restconfContentQueryParam));
final HttpHeaders httpHeaders = new HttpHeaders();
- if (!StringUtils.isEmpty(acceptParam)) {
- httpHeaders.set(HttpHeaders.ACCEPT, acceptParam);
+ if (!StringUtils.isEmpty(acceptParamInHeader)) {
+ httpHeaders.set(HttpHeaders.ACCEPT, acceptParamInHeader);
}
return sdncRestconfClient.getOperation(getResourceDataUrl, httpHeaders);
}
@@ -131,20 +131,25 @@ public class SdncOperations {
}
@NotNull
- private List<String> getQueryList(final String fieldsValue, final Integer depthValue, final String contentQuery) {
- final List<String> queryList = new LinkedList<>();
- if (!StringUtils.isEmpty(fieldsValue)) {
- queryList.add("fields=" + fieldsValue);
- }
- if (depthValue != null) {
- queryList.add("depth=" + depthValue);
- }
- if (!StringUtils.isEmpty(contentQuery)) {
- queryList.add(contentQuery);
+ private List<String> buildQueryParamList(final String optionsParamInQuery, final String restconfContentQueryParam) {
+ final List<String> queryParamAsList = getOptionsParamAsList(optionsParamInQuery);
+ queryParamAsList.add(restconfContentQueryParam);
+ return queryParamAsList;
+ }
+
+ private List<String> getOptionsParamAsList(final String optionsParamInQuery) {
+ final List<String> queryParamAsList = new LinkedList<>();
+ if (!StringUtils.isEmpty(optionsParamInQuery)) {
+ final String tempQuery = stripParenthesisFromOptionsQuery(optionsParamInQuery);
+ queryParamAsList.addAll(Arrays.asList(tempQuery.split(",")));
}
- return queryList;
+ return queryParamAsList;
}
+ @NotNull
+ private String stripParenthesisFromOptionsQuery(final String optionsParamInQuery) {
+ return optionsParamInQuery.substring(1, optionsParamInQuery.length() - 1);
+ }
@NotNull
private String prepareGetSchemaUrl(final String nodeId) {