Merge "Add withTrustLevel condition to CmHandle Query API"
[cps.git] / cps-ncmp-service / src / main / java / org / onap / cps / ncmp / api / impl / inventory / CmHandleQueriesImpl.java
index f684f2e..e5cf8ed 100644 (file)
@@ -72,15 +72,21 @@ public class CmHandleQueriesImpl implements CmHandleQueries {
 
     @Override
     public List<DataNode> queryCmHandlesByState(final CmHandleState cmHandleState) {
-        return queryCmHandleDataNodesByCpsPath("//state[@cm-handle-state=\"" + cmHandleState + "\"]",
+        return queryCmHandleAncestorsByCpsPath("//state[@cm-handle-state=\"" + cmHandleState + "\"]",
             INCLUDE_ALL_DESCENDANTS);
     }
 
     @Override
-    public List<DataNode> queryCmHandleDataNodesByCpsPath(final String cpsPath,
-            final FetchDescendantsOption fetchDescendantsOption) {
+    public List<DataNode> queryNcmpRegistryByCpsPath(final String cpsPath,
+                                                     final FetchDescendantsOption fetchDescendantsOption) {
         return cpsDataPersistenceService.queryDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,
-            cpsPath + ANCESTOR_CM_HANDLES, fetchDescendantsOption);
+                cpsPath, fetchDescendantsOption);
+    }
+
+    @Override
+    public List<DataNode> queryCmHandleAncestorsByCpsPath(final String cpsPath,
+                                                          final FetchDescendantsOption fetchDescendantsOption) {
+        return queryNcmpRegistryByCpsPath(cpsPath + ANCESTOR_CM_HANDLES, fetchDescendantsOption);
     }
 
     @Override
@@ -92,7 +98,7 @@ public class CmHandleQueriesImpl implements CmHandleQueries {
 
     @Override
     public List<DataNode> queryCmHandlesByOperationalSyncState(final DataStoreSyncState dataStoreSyncState) {
-        return queryCmHandleDataNodesByCpsPath("//state/datastores" + "/operational[@sync-state=\""
+        return queryCmHandleAncestorsByCpsPath("//state/datastores" + "/operational[@sync-state=\""
                 + dataStoreSyncState + "\"]", FetchDescendantsOption.OMIT_DESCENDANTS);
     }
 
@@ -125,7 +131,8 @@ public class CmHandleQueriesImpl implements CmHandleQueries {
                 + publicPropertyQueryPair.getKey()
                 + "\" and @value=\"" + publicPropertyQueryPair.getValue() + "\"]";
 
-            final Collection<DataNode> dataNodes = queryCmHandleDataNodesByCpsPath(cpsPath, OMIT_DESCENDANTS);
+            final Collection<DataNode> dataNodes = queryCmHandleAncestorsByCpsPath(cpsPath,
+                    OMIT_DESCENDANTS);
             if (cmHandleIds == null) {
                 cmHandleIds = collectCmHandleIdsFromDataNodes(dataNodes);
             } else {