summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2021-08-25 13:43:51 +0000
committerGerrit Code Review <gerrit@onap.org>2021-08-25 13:43:51 +0000
commit528022a0f33225f3eab6930ff27c3ab8d1638568 (patch)
tree87170d1b5354ad456ce8a37a04bffa6b3140e309 /src/main/java/org
parentb8f72560c6f29c49ee80672072d6a168351ce00a (diff)
parent79e41e0794035ea8dd3ae3064f8d368b5345df95 (diff)
Merge "Write data for cm handle passthrough:running"
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java99
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java70
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java76
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java18
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java63
5 files changed, 195 insertions, 131 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 79c11a4e..32651e4d 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
@@ -27,14 +27,16 @@ 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;
+import org.onap.cps.ncmp.dmi.model.DataAccessWriteRequest;
import org.onap.cps.ncmp.dmi.model.ModuleReference;
import org.onap.cps.ncmp.dmi.model.ModuleRequestParent;
import org.onap.cps.ncmp.dmi.model.ModuleSet;
-import org.onap.cps.ncmp.dmi.model.OperationalRequest;
import org.onap.cps.ncmp.dmi.rest.api.DmiPluginApi;
import org.onap.cps.ncmp.dmi.rest.api.DmiPluginInternalApi;
import org.onap.cps.ncmp.dmi.service.DmiService;
import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -61,7 +63,7 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
@Override
public ResponseEntity<Object> retrieveModuleResources(@Valid final ModuleRequestParent moduleRequestParent,
- final String cmHandle) {
+ final String cmHandle) {
if (moduleRequestParent.getOperation().toString().equals("read")) {
final var moduleReferenceList = convertRestObjectToJavaApiObject(moduleRequestParent);
final var response = dmiService.getModuleResources(cmHandle, moduleReferenceList);
@@ -74,6 +76,25 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
}
/**
+ * Write data using passthrough for the given cmHandle.
+ *
+ * @param dataAccessWriteRequest pass through request
+ * @param cmHandle cmHandle
+ * @param resourceIdentifier resource identifier
+ * @return (@ code ResponseEntity) response entity
+ */
+ @Override
+ public ResponseEntity<Object> writeDataByPassthroughRunningForCmHandle(
+ final DataAccessWriteRequest dataAccessWriteRequest,
+ final String cmHandle, final String resourceIdentifier) {
+ final String response = dmiService.writeResourceDataPassthroughForCmHandle(cmHandle,
+ resourceIdentifier,
+ MediaType.APPLICATION_JSON_VALUE,
+ dataAccessWriteRequest.getData());
+ return new ResponseEntity<>(response, HttpStatus.OK);
+ }
+
+ /**
* This method register given list of cm-handles to ncmp.
*
* @param cmHandles list of cm-handles
@@ -89,60 +110,58 @@ 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.
+ * 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.
*
- * @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
+ * @param cmHandle cm handle identifier
+ * @param resourceIdentifier resource identifier to fetch data
+ * @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
* @return {@code ResponseEntity} response entity
*/
@Override
public ResponseEntity<Object> getResourceDataOperationalForCmHandle(final String cmHandle,
- final String resourceIdentifier,
- final @Valid OperationalRequest body,
- final String accept,
- final @Valid String fields,
- final @Min(1) @Valid Integer depth) {
+ final String resourceIdentifier,
+ final @Valid DataAccessReadRequest dataAccessReadRequest,
+ final String accept,
+ final @Valid String fields,
+ final @Min(1) @Valid Integer depth) {
final var modulesListAsJson = dmiService.getResourceDataOperationalForCmHandle(cmHandle,
- resourceIdentifier,
- accept,
- fields,
- depth,
- body.getCmHandleProperties());
+ resourceIdentifier,
+ accept,
+ fields,
+ depth,
+ 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.
+ * 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
+ * @param cmHandle cm handle identifier
+ * @param resourceIdentifier resource identifier to fetch data
+ * @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
* @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 String resourceIdentifier,
+ final @Valid DataAccessReadRequest dataAccessReadRequest,
+ 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());
+ resourceIdentifier,
+ accept,
+ fields,
+ depth,
+ 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 83301270..f1446084 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
@@ -42,8 +42,8 @@ public interface DmiService {
ModuleSet getModulesForCmHandle(String cmHandle) throws DmiException;
/**
- * This method used to register the given {@code CmHandles}
- * which contains list of {@code CmHandle} to cps repository.
+ * This method used to register the given {@code CmHandles} which contains list of {@code CmHandle} to cps
+ * repository.
*
* @param cmHandles list of cm-handles
*/
@@ -53,50 +53,58 @@ public interface DmiService {
* Get module resources for the given cm handle and modules.
*
* @param cmHandle cmHandle
- * @param modules a list of module data
+ * @param modules a list of module data
* @return returns all module resources
*/
String getModuleResources(String cmHandle, List<ModuleReference> modules);
/**
- * 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.
+ * 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.
*
- * @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 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 getResourceDataOperationalForCmHandle(@NotNull String cmHandle,
- @NotNull String resourceIdentifier,
- String acceptParam,
- String fieldsQuery,
- Integer depthQuery,
- Map<String, String> cmHandlePropertyMap);
+ @NotNull String resourceIdentifier,
+ String acceptParam,
+ 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.
+ * 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 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);
+ @NotNull String resourceIdentifier,
+ String acceptParam,
+ String fieldsQuery,
+ Integer depthQuery,
+ Map<String, String> cmHandlePropertyMap);
+
+ /**
+ * Write resource data to sdnc using passthrough running.
+ *
+ * @param cmHandle cmHandle
+ * @param resourceIdentifier resource identifier
+ * @param dataType accept header parameter
+ * @param data request data
+ * @return response from sdnc
+ */
+ String writeResourceDataPassthroughForCmHandle(String cmHandle, String resourceIdentifier, String dataType,
+ Object data);
} \ 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 62f93e63..a139f7be 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
@@ -69,8 +69,8 @@ public class DmiServiceImpl implements DmiService {
* @param objectMapper objectMapper
*/
public DmiServiceImpl(final DmiPluginProperties dmiPluginProperties,
- final NcmpRestClient ncmpRestClient,
- final SdncOperations sdncOperations, final ObjectMapper objectMapper) {
+ final NcmpRestClient ncmpRestClient,
+ final SdncOperations sdncOperations, final ObjectMapper objectMapper) {
this.dmiPluginProperties = dmiPluginProperties;
this.ncmpRestClient = ncmpRestClient;
this.objectMapper = objectMapper;
@@ -88,7 +88,7 @@ public class DmiServiceImpl implements DmiService {
return createModuleSchema(responseBody);
} else {
throw new DmiException("SDNC is not able to process request.",
- "response code : " + responseEntity.getStatusCode() + " message : " + responseEntity.getBody());
+ "response code : " + responseEntity.getStatusCode() + " message : " + responseEntity.getBody());
}
}
@@ -103,7 +103,7 @@ public class DmiServiceImpl implements DmiService {
} else {
log.error("SDNC did not return a module resource for the given cmHandle {}", cmHandle);
throw new ModuleResourceNotFoundException(cmHandle,
- "SDNC did not return a module resource for the given cmHandle.");
+ "SDNC did not return a module resource for the given cmHandle.");
}
}
return getModuleResponses.toJSONString();
@@ -126,7 +126,7 @@ public class DmiServiceImpl implements DmiService {
} catch (final JsonProcessingException e) {
log.error("Parsing error occurred while converting cm-handles to JSON {}", cmHandles);
throw new DmiException("Internal Server Error.",
- "Parsing error occurred while converting given cm-handles object list to JSON ");
+ "Parsing error occurred while converting given cm-handles object list to JSON ");
}
final ResponseEntity<String> responseEntity = ncmpRestClient.registerCmHandlesWithNcmp(cmHandlesJson);
if ((responseEntity.getStatusCode() != HttpStatus.CREATED)) {
@@ -166,44 +166,66 @@ 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 Map<String, String> cmHandlePropertyMap) {
+ 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,
+ resourceIdentifier,
+ fieldsQuery,
+ depthQuery,
+ 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) {
+ 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);
+ resourceIdentifier,
+ fieldsQuery,
+ depthQuery,
+ acceptParam,
+ CONTENT_QUERY_PASSTHROUGH_RUNNING);
return prepareAndSendResponse(responseEntity, cmHandle);
}
+ @Override
+ public String writeResourceDataPassthroughForCmHandle(final String cmHandle, final String resourceIdentifier,
+ final String dataType, final Object data) {
+ final String jsonData;
+ try {
+ jsonData = objectMapper.writeValueAsString(data);
+ } catch (final JsonProcessingException e) {
+ log.error("JSON exception occurred when processing pass through request data for the given cmHandle {}",
+ cmHandle);
+ throw new DmiException("Unable to process incoming JSON from the request body.",
+ "JSON exception occurred when writing data for the given cmHandle " + cmHandle, e);
+ }
+ final ResponseEntity<String> responseEntity =
+ sdncOperations.writeResourceDataPassthroughRunning(cmHandle, resourceIdentifier, dataType, jsonData);
+ if (responseEntity.getStatusCode() == HttpStatus.CREATED) {
+ return responseEntity.getBody();
+ } else {
+ throw new DmiException(cmHandle,
+ "response code : " + responseEntity.getStatusCode() + " message : " + responseEntity.getBody());
+ }
+ }
+
private String prepareAndSendResponse(final ResponseEntity<String> responseEntity, final String cmHandle) {
if (responseEntity.getStatusCode() == HttpStatus.OK) {
return responseEntity.getBody();
} else {
throw new ResourceDataNotFound(cmHandle,
- "response code : " + responseEntity.getStatusCode() + " message : " + responseEntity.getBody());
+ "response code : " + responseEntity.getStatusCode() + " message : " + responseEntity.getBody());
}
}
@@ -217,9 +239,9 @@ public class DmiServiceImpl implements DmiService {
moduleRequest = writer.writeValueAsString(ietfNetconfModuleReferences);
} catch (final JsonProcessingException e) {
log.error("JSON exception occurred when creating the module request for the given module reference {}",
- moduleReference.getName());
+ moduleReference.getName());
throw new DmiException("Unable to process JSON.",
- "JSON exception occurred when creating the module request.", e);
+ "JSON exception occurred when creating the module request.", e);
}
return moduleRequest;
}
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java b/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
index 499033d3..fe13a38d 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClient.java
@@ -23,7 +23,6 @@ package org.onap.cps.ncmp.dmi.service.client;
import org.onap.cps.ncmp.dmi.config.DmiConfiguration.SdncProperties;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
@@ -43,7 +42,6 @@ public class SdncRestconfClient {
* restconf get operation on sdnc.
*
* @param getResourceUrl sdnc get url
- *
* @return the response entity
*/
public ResponseEntity<String> getOperation(final String getResourceUrl) {
@@ -54,8 +52,7 @@ public class SdncRestconfClient {
* Overloaded restconf get operation on sdnc with http headers.
*
* @param getResourceUrl sdnc get url
- * @param httpHeaders http headers
- *
+ * @param httpHeaders http headers
* @return the response entity
*/
public ResponseEntity<String> getOperation(final String getResourceUrl, final HttpHeaders httpHeaders) {
@@ -71,20 +68,15 @@ public class SdncRestconfClient {
*
* @param postResourceUrl sdnc post resource url
* @param jsonData json data
+ * @param httpHeaders HTTP headers
* @return the response entity
*/
public ResponseEntity<String> postOperationWithJsonData(final String postResourceUrl,
- final String jsonData) {
+ final String jsonData, final HttpHeaders httpHeaders) {
final var sdncBaseUrl = sdncProperties.getBaseUrl();
final var sdncRestconfUrl = sdncBaseUrl.concat(postResourceUrl);
- final var httpEntity = new HttpEntity<>(jsonData, configureHttpHeaders());
- return restTemplate.postForEntity(sdncRestconfUrl, httpEntity, String.class);
- }
-
- private HttpHeaders configureHttpHeaders() {
- final var httpHeaders = new HttpHeaders();
httpHeaders.setBasicAuth(sdncProperties.getAuthUsername(), sdncProperties.getAuthPassword());
- httpHeaders.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
- return httpHeaders;
+ final var httpEntity = new HttpEntity<>(jsonData, httpHeaders);
+ return restTemplate.postForEntity(sdncRestconfUrl, httpEntity, String.class);
}
} \ No newline at end of file
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 ab9c7e1d..73503d23 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
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull;
import org.onap.cps.ncmp.dmi.config.DmiConfiguration.SdncProperties;
import org.onap.cps.ncmp.dmi.service.client.SdncRestconfClient;
import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
@@ -34,9 +35,9 @@ import org.springframework.stereotype.Component;
public class SdncOperations {
private static final String TOPOLOGY_URL_TEMPLATE_DATA =
- "/rests/data/network-topology:network-topology/topology={topologyId}";
+ "/rests/data/network-topology:network-topology/topology={topologyId}";
private static final String TOPOLOGY_URL_TEMPLATE_OPERATIONAL =
- "/rests/operations/network-topology:network-topology/topology={topologyId}";
+ "/rests/operations/network-topology:network-topology/topology={topologyId}";
private static final String MOUNT_URL_TEMPLATE = "/node={nodeId}/yang-ext:mount";
private static final String GET_SCHEMA_URL = "/ietf-netconf-monitoring:netconf-state/schemas";
private static final String GET_SCHEMA_SOURCES_URL = "/ietf-netconf-monitoring:get-schema";
@@ -56,7 +57,7 @@ public class SdncOperations {
this.sdncProperties = sdncProperties;
this.sdncRestconfClient = sdncRestconfClient;
topologyUrlOperational =
- TOPOLOGY_URL_TEMPLATE_OPERATIONAL.replace("{topologyId}", this.sdncProperties.getTopologyId());
+ TOPOLOGY_URL_TEMPLATE_OPERATIONAL.replace("{topologyId}", this.sdncProperties.getTopologyId());
topologyUrlData = TOPOLOGY_URL_TEMPLATE_DATA.replace("{topologyId}", this.sdncProperties.getTopologyId());
}
@@ -79,30 +80,32 @@ public class SdncOperations {
* @return response entity
*/
public ResponseEntity<String> getModuleResource(final String nodeId, final String moduleProperties) {
- final String getYangResourceUrl = prepareGetOperationSchemaUrl(nodeId);
- return sdncRestconfClient.postOperationWithJsonData(getYangResourceUrl, moduleProperties);
+ final var getYangResourceUrl = prepareGetOperationSchemaUrl(nodeId);
+ final var httpHeaders = new HttpHeaders();
+ httpHeaders.setContentType(MediaType.APPLICATION_JSON);
+ return sdncRestconfClient
+ .postOperationWithJsonData(getYangResourceUrl, moduleProperties, httpHeaders);
}
/**
- * This method fetches the resource data for given node identifier on given resource
- * using sdnc client.
+ * This method fetches the resource data for given node identifier on given resource using sdnc client.
*
- * @param nodeId network resource identifier
- * @param resourceId resource identifier
+ * @param nodeId network resource identifier
+ * @param resourceId resource identifier
* @param fieldsValue fields query
- * @param depthValue depth query
+ * @param depthValue depth query
* @param acceptParam accept parameter
* @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 resourceId,
+ final String fieldsValue,
+ final Integer depthValue,
+ final String acceptParam,
final String contentQuery) {
final String getResourceDataUrl = prepareResourceDataUrl(nodeId,
- resourceId,
- getQueryList(fieldsValue, depthValue, contentQuery));
+ resourceId,
+ getQueryList(fieldsValue, depthValue, contentQuery));
final HttpHeaders httpHeaders = new HttpHeaders();
if (!StringUtils.isEmpty(acceptParam)) {
httpHeaders.set(HttpHeaders.ACCEPT, acceptParam);
@@ -110,6 +113,23 @@ public class SdncOperations {
return sdncRestconfClient.getOperation(getResourceDataUrl, httpHeaders);
}
+ /**
+ * Write resource data using passthrough running.
+ *
+ * @param nodeId network resource identifier
+ * @param resourceId resource identifier
+ * @param contentType http content type
+ * @param requestData request data
+ * @return {@code ResponseEntity} response entity
+ */
+ public ResponseEntity<String> writeResourceDataPassthroughRunning(final String nodeId,
+ final String resourceId, final String contentType, final String requestData) {
+ final var getResourceDataUrl = preparePassthroughRunningUrl(nodeId, resourceId);
+ final var httpHeaders = new HttpHeaders();
+ httpHeaders.setContentType(MediaType.parseMediaType(contentType));
+ return sdncRestconfClient.postOperationWithJsonData(getResourceDataUrl, requestData, httpHeaders);
+ }
+
@NotNull
private List<String> getQueryList(final String fieldsValue, final Integer depthValue, final String contentQuery) {
final List<String> queryList = new LinkedList<>();
@@ -131,6 +151,10 @@ public class SdncOperations {
return addResource(addTopologyDataUrlwithNode(nodeId), GET_SCHEMA_URL);
}
+ private String preparePassthroughRunningUrl(final String nodeId, final String resourceId) {
+ return addResource(addTopologyDataUrlwithNode(nodeId), "/" + resourceId);
+ }
+
private String prepareGetOperationSchemaUrl(final String nodeId) {
final var topologyMountUrl = topologyUrlOperational + MOUNT_URL_TEMPLATE;
final var topologyMountUrlWithNodeId = topologyMountUrl.replace("{nodeId}", nodeId);
@@ -139,8 +163,8 @@ public class SdncOperations {
@NotNull
private String prepareResourceDataUrl(final String nodeId,
- final String resourceId,
- final List<String> queryList) {
+ final String resourceId,
+ final List<String> queryList) {
return addQuery(addResource(addTopologyDataUrlwithNode(nodeId), resourceId), queryList);
}
@@ -152,7 +176,7 @@ public class SdncOperations {
return url.concat("/" + resourceId);
}
}
-
+
@NotNull
private String addQuery(final String url, final List<String> queryList) {
if (queryList.isEmpty()) {
@@ -173,5 +197,4 @@ public class SdncOperations {
final String topologyMountUrl = topologyUrlData + MOUNT_URL_TEMPLATE;
return topologyMountUrl.replace("{nodeId}", nodeId);
}
-
} \ No newline at end of file