diff options
author | niamhcore <niamh.core@est.tech> | 2021-10-07 10:38:50 +0100 |
---|---|---|
committer | niamhcore <niamh.core@est.tech> | 2021-10-08 11:43:13 +0100 |
commit | 6cfa5162ceb10cf14fe8cf870924c69eeac20885 (patch) | |
tree | 410bbf9923814b8447e2595e84de2b77d01972dc /cps-ncmp-service/src/main | |
parent | fdcb36fa9db642df3c47637d32f4e7ac5dd347e8 (diff) |
Update get yang resource response body
Issue-ID: CPS-706
Signed-off-by: niamhcore <niamh.core@est.tech>
Change-Id: Ic7045e873421ee5ce69e6e0400eeaa7a1d36eaf8
Diffstat (limited to 'cps-ncmp-service/src/main')
-rwxr-xr-x | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java index 291b0bf330..2395fb5db4 100755 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java @@ -59,7 +59,6 @@ import org.onap.cps.spi.exceptions.DataValidationException; import org.onap.cps.spi.model.DataNode; import org.onap.cps.spi.model.ModuleReference; import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -349,13 +348,13 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService cmHandleJsonData, NO_TIMESTAMP); for (final PersistenceCmHandle persistenceCmHandle : persistenceCmHandlesList.getPersistenceCmHandles()) { - createAnchorAndSyncModel(persistenceCmHandle); + syncModulesAndCreateAnchor(persistenceCmHandle); } } - protected void createAnchorAndSyncModel(final PersistenceCmHandle persistenceCmHandle) { - createAnchor(persistenceCmHandle); + protected void syncModulesAndCreateAnchor(final PersistenceCmHandle persistenceCmHandle) { fetchAndSyncModules(persistenceCmHandle); + createAnchor(persistenceCmHandle); } private static PersistenceCmHandle toPersistenceCmHandle(final String dmiPluginService, @@ -417,14 +416,13 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService private List<ModuleReference> fetchModuleReferencesFromDmi(final PersistenceCmHandle persistenceCmHandle, final Map<String, String> cmHandlePropertiesAsMap) { - final GenericRequestBody requestBodyObject = GenericRequestBody.builder() - .operation(GenericRequestBody.OperationEnum.READ) + final GenericRequestBody genericRequestBody = GenericRequestBody.builder() .cmHandleProperties(cmHandlePropertiesAsMap) .build(); - final String jsonBody = prepareOperationBody(requestBodyObject); + final String jsonBodyWithOnlyCmHandleProperties = prepareOperationBody(genericRequestBody); final ResponseEntity<String> dmiFetchModulesResponseEntity = dmiOperations.getResourceFromDmiWithJsonData(persistenceCmHandle.getDmiServiceName(), - jsonBody, persistenceCmHandle.getId(), "modules"); + jsonBodyWithOnlyCmHandleProperties, persistenceCmHandle.getId(), "modules"); return toModuleReferences(dmiFetchModulesResponseEntity); } @@ -437,13 +435,11 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService final JsonArray moduleReferencesAsJson = getModuleReferencesAsJson(unknownModuleReferences); final JsonObject data = new JsonObject(); data.add("modules", moduleReferencesAsJson); - final GenericRequestBody dmiRequestBodyObject = GenericRequestBody.builder() - .operation(GenericRequestBody.OperationEnum.READ) - .dataType(MediaType.APPLICATION_JSON_VALUE) - .data(data.toString()) - .cmHandleProperties(cmHandlePropertiesAsMap) - .build(); - return prepareOperationBody(dmiRequestBodyObject); + final JsonObject jsonRequestObject = new JsonObject(); + jsonRequestObject.add("data", data); + final Gson gson = new Gson(); + jsonRequestObject.add("cmHandleProperties", gson.toJsonTree(cmHandlePropertiesAsMap)); + return jsonRequestObject.toString(); } private static JsonArray getModuleReferencesAsJson(final List<ModuleReference> unknownModuleReferences) { @@ -461,12 +457,12 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService private Map<String, String> getNewYangResourcesFromDmi(final PersistenceCmHandle persistenceCmHandle, final List<ModuleReference> unknownModuleReferences, final Map<String, String> cmHandlePropertiesAsMap) { - final String jsonData = getRequestBodyToFetchYangResourceFromDmi( + final String jsonDataWithDataAndCmHandleProperties = getRequestBodyToFetchYangResourceFromDmi( unknownModuleReferences, cmHandlePropertiesAsMap); final ResponseEntity<String> moduleResourcesAsJsonString = dmiOperations.getResourceFromDmiWithJsonData( persistenceCmHandle.getDmiServiceName(), - jsonData, + jsonDataWithDataAndCmHandleProperties, persistenceCmHandle.getId(), "moduleResources"); |