diff options
Diffstat (limited to 'cps-ncmp-service/src')
3 files changed, 50 insertions, 14 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java index cb2f78206c..e480a46e08 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java @@ -159,4 +159,13 @@ public interface NetworkCmProxyDataService { * @return a collection of modules names and revisions */ Collection<ModuleReference> getYangResourcesModuleReferences(@NotNull String cmHandle); + + /** + * Query cm handle identifiers for the given collection of module names. + * + * @param moduleNames module names. + * @return a collection of cm handle identifiers. The schema set for each cm handle must include all the + * given module names + */ + Collection<String> executeCmHandleHasAllModulesSearch(Collection<String> moduleNames); } 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 7020c74210..94544f389f 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 @@ -67,7 +67,7 @@ import org.springframework.util.StringUtils; @Service public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService { - private static final String NF_PROXY_DATASPACE_NAME = "NFP-Operational"; + private static final String NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME = "NFP-Operational"; private static final String NCMP_DATASPACE_NAME = "NCMP-Admin"; @@ -115,37 +115,44 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService @Override public DataNode getDataNode(final String cmHandle, final String xpath, final FetchDescendantsOption fetchDescendantsOption) { - return cpsDataService.getDataNode(NF_PROXY_DATASPACE_NAME, cmHandle, xpath, fetchDescendantsOption); + return cpsDataService + .getDataNode(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandle, xpath, fetchDescendantsOption); } @Override public Collection<DataNode> queryDataNodes(final String cmHandle, final String cpsPath, final FetchDescendantsOption fetchDescendantsOption) { - return cpsQueryService.queryDataNodes(NF_PROXY_DATASPACE_NAME, cmHandle, cpsPath, fetchDescendantsOption); + return cpsQueryService + .queryDataNodes(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandle, cpsPath, fetchDescendantsOption); } @Override public void createDataNode(final String cmHandle, final String parentNodeXpath, final String jsonData) { if (!StringUtils.hasText(parentNodeXpath) || "/".equals(parentNodeXpath)) { - cpsDataService.saveData(NF_PROXY_DATASPACE_NAME, cmHandle, jsonData, NO_TIMESTAMP); + cpsDataService.saveData(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandle, jsonData, NO_TIMESTAMP); } else { - cpsDataService.saveData(NF_PROXY_DATASPACE_NAME, cmHandle, parentNodeXpath, jsonData, NO_TIMESTAMP); + cpsDataService + .saveData(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandle, parentNodeXpath, jsonData, NO_TIMESTAMP); } } @Override public void addListNodeElements(final String cmHandle, final String parentNodeXpath, final String jsonData) { - cpsDataService.saveListElements(NF_PROXY_DATASPACE_NAME, cmHandle, parentNodeXpath, jsonData, NO_TIMESTAMP); + cpsDataService.saveListElements(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandle, parentNodeXpath, jsonData, + NO_TIMESTAMP); } @Override public void updateNodeLeaves(final String cmHandle, final String parentNodeXpath, final String jsonData) { - cpsDataService.updateNodeLeaves(NF_PROXY_DATASPACE_NAME, cmHandle, parentNodeXpath, jsonData, NO_TIMESTAMP); + cpsDataService + .updateNodeLeaves(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandle, parentNodeXpath, jsonData, + NO_TIMESTAMP); } @Override public void replaceNodeTree(final String cmHandle, final String parentNodeXpath, final String jsonData) { - cpsDataService.replaceNodeTree(NF_PROXY_DATASPACE_NAME, cmHandle, parentNodeXpath, jsonData, NO_TIMESTAMP); + cpsDataService.replaceNodeTree(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandle, parentNodeXpath, jsonData, + NO_TIMESTAMP); } @Override @@ -226,7 +233,18 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService @Override public Collection<ModuleReference> getYangResourcesModuleReferences(final String cmHandle) { - return cpsModuleService.getYangResourcesModuleReferences(NF_PROXY_DATASPACE_NAME, cmHandle); + return cpsModuleService.getYangResourcesModuleReferences(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandle); + } + + /** + * Retrieve cm handle identifiers for the given list of module names. + * + * @param moduleNames module names. + * @return a collection of anchor identifiers + */ + @Override + public Collection<String> executeCmHandleHasAllModulesSearch(final Collection<String> moduleNames) { + return cpsAdminService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, moduleNames); } private DataNode fetchDataNodeFromDmiRegistryForCmHandle(final String cmHandle) { @@ -379,7 +397,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService private void fetchAndSyncModules(final PersistenceCmHandle persistenceCmHandle) { final Map<String, String> cmHandlePropertiesAsMap = getCmHandlePropertiesAsMap( - persistenceCmHandle.getAdditionalProperties()); + persistenceCmHandle.getAdditionalProperties()); final List<ModuleReference> moduleReferencesFromCmHandle = fetchModuleReferencesFromDmi(persistenceCmHandle, cmHandlePropertiesAsMap); @@ -394,8 +412,9 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService newYangResourcesModuleNameToContentMap = getNewYangResourcesFromDmi(persistenceCmHandle, unknownModuleReferences, cmHandlePropertiesAsMap); } - cpsModuleService.createSchemaSetFromModules(NF_PROXY_DATASPACE_NAME, persistenceCmHandle.getId(), - newYangResourcesModuleNameToContentMap, existingModuleReferences); + cpsModuleService + .createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, persistenceCmHandle.getId(), + newYangResourcesModuleNameToContentMap, existingModuleReferences); } private void prepareModuleSubsets(final List<ModuleReference> moduleReferencesFromCmHandle, @@ -403,7 +422,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService final List<ModuleReference> unknownModuleReferences) { final Collection<ModuleReference> knownModuleReferencesInCps = - cpsModuleService.getYangResourceModuleReferences(NF_PROXY_DATASPACE_NAME); + cpsModuleService.getYangResourceModuleReferences(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME); for (final ModuleReference moduleReferenceFromDmiForCmHandle : moduleReferencesFromCmHandle) { if (knownModuleReferencesInCps.contains(moduleReferenceFromDmiForCmHandle)) { @@ -427,7 +446,8 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService } private void createAnchor(final PersistenceCmHandle persistenceCmHandle) { - cpsAdminService.createAnchor(NF_PROXY_DATASPACE_NAME, persistenceCmHandle.getId(), persistenceCmHandle.getId()); + cpsAdminService.createAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, persistenceCmHandle.getId(), + persistenceCmHandle.getId()); } private String getRequestBodyToFetchYangResourceFromDmi(final List<ModuleReference> unknownModuleReferences, diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy index ae252b870e..88277d3e97 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy @@ -450,6 +450,13 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { result == expectedRequestBody } + def 'Get cm handle identifiers for the given module names.'() { + when: 'execute a cm handle search for the given module names' + objectUnderTest.executeCmHandleHasAllModulesSearch(['some-module-name']) + then: 'get anchor identifiers is invoked with the expected parameters' + 1 * mockCpsAdminService.queryAnchorNames('NFP-Operational', ['some-module-name']) + } + def getObjectUnderTestWithModelSyncDisabled() { def objectUnderTest = Spy(new NetworkCmProxyDataServiceImpl(mockDmiOperations, mockCpsModuleService, mockCpsDataService, mockCpsQueryService, mockCpsAdminService, spyObjectMapper)) |