summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java
diff options
context:
space:
mode:
authorhalil.cakal <halil.cakal@est.tech>2023-09-26 15:07:08 +0100
committerhalil.cakal <halil.cakal@est.tech>2023-10-12 10:00:52 +0100
commit7aae9b8af2c82336882d0ae864b970b1885a63a8 (patch)
treea3165ff503592c17d91702e59855b5332806d9c1 /cps-ncmp-service/src/main/java
parent4bc19fe118ca7d81891c12d40719a569bc528a21 (diff)
Add withTrustLevel condition to CmHandle Query API
- Change untrustworthyCmHandleSet with trustLevelPerCmHandleMap - Change trust level cache config accordingly - Change device heartbet consumer accordingly - Add json schema for device trust level - Add with_trust_level enum into cm handle query conditions - Add query cm handle by trustlevel function to cm handle queries - Add query cm handle by trustlevel service to network cm proxy cm handle service - Add unit tests and fix code smells Issue-ID: CPS-1864 Change-Id: Ie214f0713cef779307d3379df81e2b95115b6d6d Signed-off-by: halil.cakal <halil.cakal@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/main/java')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandleQueryServiceImpl.java31
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java6
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfig.java20
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/mapper/CloudEventMapper.java5
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueries.java8
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImpl.java15
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/DeviceHeartbeatConsumer.java30
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/DeviceTrustLevel.java37
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/TrustLevel.java12
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/TrustLevelFilter.java58
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DMiPluginWatchDog.java4
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/CmHandleQueryConditions.java5
13 files changed, 145 insertions, 88 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandleQueryServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandleQueryServiceImpl.java
index 58732b207c..247d1c2961 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandleQueryServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandleQueryServiceImpl.java
@@ -24,6 +24,7 @@ import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DM
import static org.onap.cps.ncmp.api.impl.utils.CmHandleQueryConditions.HAS_ALL_MODULES;
import static org.onap.cps.ncmp.api.impl.utils.CmHandleQueryConditions.HAS_ALL_PROPERTIES;
import static org.onap.cps.ncmp.api.impl.utils.CmHandleQueryConditions.WITH_CPS_PATH;
+import static org.onap.cps.ncmp.api.impl.utils.CmHandleQueryConditions.WITH_TRUST_LEVEL;
import static org.onap.cps.ncmp.api.impl.utils.RestQueryParametersValidator.validateCpsPathConditionProperties;
import static org.onap.cps.ncmp.api.impl.utils.RestQueryParametersValidator.validateModuleNameConditionProperties;
import static org.onap.cps.ncmp.api.impl.utils.YangDataConverter.convertYangModelCmHandleToNcmpServiceCmHandle;
@@ -70,7 +71,8 @@ public class NetworkCmProxyCmHandleQueryServiceImpl implements NetworkCmProxyCmH
return executeQueries(cmHandleQueryServiceParameters,
this::executeCpsPathQuery,
this::queryCmHandlesByPublicProperties,
- this::executeModuleNameQuery);
+ this::executeModuleNameQuery,
+ this::queryCmHandlesByTrustLevel);
}
@Override
@@ -117,9 +119,10 @@ public class NetworkCmProxyCmHandleQueryServiceImpl implements NetworkCmProxyCmH
getPropertyPairs(cmHandleQueryServiceParameters.getCmHandleQueryParameters(),
InventoryQueryConditions.HAS_ALL_ADDITIONAL_PROPERTIES.getName());
- return privatePropertyQueryPairs.isEmpty()
- ? NO_QUERY_TO_EXECUTE
- : cmHandleQueries.queryCmHandleAdditionalProperties(privatePropertyQueryPairs);
+ if (privatePropertyQueryPairs.isEmpty()) {
+ return NO_QUERY_TO_EXECUTE;
+ }
+ return cmHandleQueries.queryCmHandleAdditionalProperties(privatePropertyQueryPairs);
}
private Collection<String> queryCmHandlesByPublicProperties(
@@ -129,9 +132,23 @@ public class NetworkCmProxyCmHandleQueryServiceImpl implements NetworkCmProxyCmH
getPropertyPairs(cmHandleQueryServiceParameters.getCmHandleQueryParameters(),
HAS_ALL_PROPERTIES.getConditionName());
- return publicPropertyQueryPairs.isEmpty()
- ? NO_QUERY_TO_EXECUTE
- : cmHandleQueries.queryCmHandlePublicProperties(publicPropertyQueryPairs);
+ if (publicPropertyQueryPairs.isEmpty()) {
+ return NO_QUERY_TO_EXECUTE;
+ }
+ return cmHandleQueries.queryCmHandlePublicProperties(publicPropertyQueryPairs);
+ }
+
+ private Collection<String> queryCmHandlesByTrustLevel(final CmHandleQueryServiceParameters
+ cmHandleQueryServiceParameters) {
+
+ final Map<String, String> trustLevelPropertyQueryPairs =
+ getPropertyPairs(cmHandleQueryServiceParameters.getCmHandleQueryParameters(),
+ WITH_TRUST_LEVEL.getConditionName());
+
+ if (trustLevelPropertyQueryPairs.isEmpty()) {
+ return NO_QUERY_TO_EXECUTE;
+ }
+ return cmHandleQueries.queryCmHandlesByTrustLevel(trustLevelPropertyQueryPairs);
}
private Collection<String> executeModuleNameQuery(
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 d34e2a3141..fa2fb6e8d1 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
@@ -94,7 +94,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
private final LcmEventsCmHandleStateHandler lcmEventsCmHandleStateHandler;
private final CpsDataService cpsDataService;
private final IMap<String, Object> moduleSyncStartedOnCmHandles;
- private final IMap<String, TrustLevel> trustLevelPerDmiPlugin;
+ private final Map<String, TrustLevel> trustLevelPerDmiPlugin;
@Override
public DmiPluginRegistrationResponse updateDmiRegistrationAndSyncModule(
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java
index 6a8310c207..e8ce050b2e 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java
@@ -75,10 +75,8 @@ public class DmiRestClient {
final HttpEntity<Object> httpHeaders = new HttpEntity<>(configureHttpHeaders(new HttpHeaders()));
final JsonNode dmiPluginHealthStatus = restTemplate.getForObject(dmiPluginBaseUrl + "/manage/health",
JsonNode.class, httpHeaders);
- if (dmiPluginHealthStatus != null) {
- if (dmiPluginHealthStatus.get("status").asText().equals("UP")) {
- return DmiPluginStatus.UP;
- }
+ if (dmiPluginHealthStatus != null && dmiPluginHealthStatus.get("status").asText().equals("UP")) {
+ return DmiPluginStatus.UP;
}
} catch (final Exception exception) {
log.warn("Could not send request for health check since {}", exception.getMessage());
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfig.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfig.java
index ebe99057d7..171db52998 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfig.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfig.java
@@ -20,10 +20,8 @@
package org.onap.cps.ncmp.api.impl.config.embeddedcache;
-import com.hazelcast.collection.ISet;
import com.hazelcast.config.MapConfig;
-import com.hazelcast.config.SetConfig;
-import com.hazelcast.map.IMap;
+import java.util.Map;
import org.onap.cps.cache.HazelcastCacheConfig;
import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel;
import org.springframework.context.annotation.Bean;
@@ -32,21 +30,21 @@ import org.springframework.context.annotation.Configuration;
@Configuration
public class TrustLevelCacheConfig extends HazelcastCacheConfig {
- private static final SetConfig untrustworthyCmHandlesSetConfig =
- createSetConfig("untrustworthyCmHandlesSetConfig");
+ private static final MapConfig trustLevelPerCmHandleCacheConfig =
+ createMapConfig("trustLevelPerCmHandleCacheConfig");
private static final MapConfig trustLevelPerDmiPluginCacheConfig =
createMapConfig("trustLevelPerDmiPluginCacheConfig");
/**
- * Distributed collection of untrustworthy cm handles.
+ * Distributed instance of trust level cache containing the trust level per cm handle.
*
- * @return instance of distributed set of untrustworthy cm handles.
+ * @return configured map of cm handle name as keys to trust-level for values.
*/
@Bean
- public ISet<String> untrustworthyCmHandlesSet() {
- return createHazelcastInstance("untrustworthyCmHandlesSet",
- untrustworthyCmHandlesSetConfig).getSet("untrustworthyCmHandlesSet");
+ public Map<String, TrustLevel> trustLevelPerCmHandle() {
+ return createHazelcastInstance("hazelcastInstanceTrustLevelPerCmHandleMap",
+ trustLevelPerCmHandleCacheConfig).getMap("trustLevelPerCmHandle");
}
/**
@@ -55,7 +53,7 @@ public class TrustLevelCacheConfig extends HazelcastCacheConfig {
* @return configured map of dmi-plugin name as keys to trust-level for values.
*/
@Bean
- public IMap<String, TrustLevel> trustLevelPerDmiPlugin() {
+ public Map<String, TrustLevel> trustLevelPerDmiPlugin() {
return createHazelcastInstance("hazelcastInstanceTrustLevelPerDmiPluginMap",
trustLevelPerDmiPluginCacheConfig).getMap("trustLevelPerDmiPlugin");
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/mapper/CloudEventMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/mapper/CloudEventMapper.java
index 98ba953864..4120970e52 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/mapper/CloudEventMapper.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/mapper/CloudEventMapper.java
@@ -25,7 +25,6 @@ import io.cloudevents.CloudEvent;
import io.cloudevents.core.CloudEventUtils;
import io.cloudevents.core.data.PojoCloudEventData;
import io.cloudevents.jackson.PojoCloudEventDataMapper;
-import io.cloudevents.rw.CloudEventRWException;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -51,9 +50,9 @@ public class CloudEventMapper {
mappedCloudEvent =
CloudEventUtils.mapData(cloudEvent, PojoCloudEventDataMapper.from(objectMapper, targetEventClass));
- } catch (final CloudEventRWException cloudEventRwException) {
+ } catch (final RuntimeException runtimeException) {
log.error("Unable to map cloud event to target event class type : {} with cause : {}", targetEventClass,
- cloudEventRwException.getMessage());
+ runtimeException.getMessage());
}
return mappedCloudEvent == null ? null : mappedCloudEvent.getValue();
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueries.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueries.java
index 4776788c84..d42fa17b5c 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueries.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueries.java
@@ -45,6 +45,14 @@ public interface CmHandleQueries {
Collection<String> queryCmHandlePublicProperties(Map<String, String> publicPropertyQueryPairs);
/**
+ * Query CmHandles based on Trust Level.
+ *
+ * @param trustLevelPropertyQueryPairs trust level properties for query
+ * @return CmHandles which have desired trust level
+ */
+ Collection<String> queryCmHandlesByTrustLevel(Map<String, String> trustLevelPropertyQueryPairs);
+
+ /**
* Method which returns cm handles by the cm handles state.
*
* @param cmHandleState cm handle state
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImpl.java
index b3ade4f1cf..f684f2ea64 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImpl.java
@@ -35,6 +35,8 @@ import java.util.Map;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.onap.cps.ncmp.api.impl.inventory.enums.PropertyType;
+import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel;
+import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevelFilter;
import org.onap.cps.spi.CpsDataPersistenceService;
import org.onap.cps.spi.FetchDescendantsOption;
import org.onap.cps.spi.model.DataNode;
@@ -45,9 +47,9 @@ import org.springframework.stereotype.Component;
public class CmHandleQueriesImpl implements CmHandleQueries {
private static final String DESCENDANT_PATH = "//";
-
- private final CpsDataPersistenceService cpsDataPersistenceService;
private static final String ANCESTOR_CM_HANDLES = "/ancestor::cm-handles";
+ private final CpsDataPersistenceService cpsDataPersistenceService;
+ private final Map<String, TrustLevel> trustLevelPerCmHandle;
@Override
public Collection<String> queryCmHandleAdditionalProperties(final Map<String, String> privatePropertyQueryPairs) {
@@ -60,6 +62,15 @@ public class CmHandleQueriesImpl implements CmHandleQueries {
}
@Override
+ public Collection<String> queryCmHandlesByTrustLevel(final Map<String, String> trustLevelPropertyQueryPairs) {
+ final String trustLevelProperty = trustLevelPropertyQueryPairs.values().iterator().next();
+ final TrustLevel targetTrustLevel = TrustLevel.valueOf(trustLevelProperty);
+
+ final TrustLevelFilter trustLevelFilter = new TrustLevelFilter(targetTrustLevel, trustLevelPerCmHandle);
+ return trustLevelFilter.getAllCmHandleIdsByTargetTrustLevel();
+ }
+
+ @Override
public List<DataNode> queryCmHandlesByState(final CmHandleState cmHandleState) {
return queryCmHandleDataNodesByCpsPath("//state[@cm-handle-state=\"" + cmHandleState + "\"]",
INCLUDE_ALL_DESCENDANTS);
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/DeviceHeartbeatConsumer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/DeviceHeartbeatConsumer.java
index 458c1b8518..b6d74d980f 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/DeviceHeartbeatConsumer.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/DeviceHeartbeatConsumer.java
@@ -20,14 +20,14 @@
package org.onap.cps.ncmp.api.impl.trustlevel;
-import static org.onap.cps.ncmp.api.impl.events.mapper.CloudEventMapper.toTargetEvent;
-
-import com.hazelcast.collection.ISet;
import io.cloudevents.CloudEvent;
import io.cloudevents.kafka.impl.KafkaHeaders;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.onap.cps.ncmp.api.impl.events.mapper.CloudEventMapper;
+import org.onap.cps.ncmp.events.trustlevel.DeviceTrustLevel;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
@@ -36,7 +36,8 @@ import org.springframework.stereotype.Component;
@RequiredArgsConstructor
public class DeviceHeartbeatConsumer {
- private final ISet<String> untrustworthyCmHandlesSet;
+ private static final String CLOUD_EVENT_ID_HEADER_NAME = "ce_id";
+ private final Map<String, TrustLevel> trustLevelPerCmHandle;
/**
* Listening the device heartbeats.
@@ -47,23 +48,16 @@ public class DeviceHeartbeatConsumer {
containerFactory = "cloudEventConcurrentKafkaListenerContainerFactory")
public void heartbeatListener(final ConsumerRecord<String, CloudEvent> deviceHeartbeatConsumerRecord) {
- final String cmHandleId = KafkaHeaders.getParsedKafkaHeader(deviceHeartbeatConsumerRecord.headers(), "ce_id");
+ final String cmHandleId = KafkaHeaders.getParsedKafkaHeader(deviceHeartbeatConsumerRecord.headers(),
+ CLOUD_EVENT_ID_HEADER_NAME);
final DeviceTrustLevel deviceTrustLevel =
- toTargetEvent(deviceHeartbeatConsumerRecord.value(), DeviceTrustLevel.class);
-
- if (deviceTrustLevel == null || deviceTrustLevel.getTrustLevel() == null) {
- log.warn("No or Invalid trust level defined");
- return;
- }
+ CloudEventMapper.toTargetEvent(deviceHeartbeatConsumerRecord.value(), DeviceTrustLevel.class);
- if (deviceTrustLevel.getTrustLevel().equals(TrustLevel.NONE)) {
- untrustworthyCmHandlesSet.add(cmHandleId);
- log.debug("Added cmHandleId to untrustworthy set : {}", cmHandleId);
- } else if (deviceTrustLevel.getTrustLevel().equals(TrustLevel.COMPLETE) && untrustworthyCmHandlesSet.contains(
- cmHandleId)) {
- untrustworthyCmHandlesSet.remove(cmHandleId);
- log.debug("Removed cmHandleId from untrustworthy set : {}", cmHandleId);
+ if (cmHandleId != null && deviceTrustLevel != null) {
+ final String trustLevel = deviceTrustLevel.getData().getTrustLevel();
+ trustLevelPerCmHandle.put(cmHandleId, TrustLevel.valueOf(trustLevel));
+ log.debug("Added cmHandleId to trustLevelPerCmHandle map as {}:{}", cmHandleId, trustLevel);
}
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/DeviceTrustLevel.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/DeviceTrustLevel.java
deleted file mode 100644
index 2ed4e45220..0000000000
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/DeviceTrustLevel.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.cps.ncmp.api.impl.trustlevel;
-
-import java.io.Serializable;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@AllArgsConstructor
-@Data
-@NoArgsConstructor
-class DeviceTrustLevel implements Serializable {
-
- private static final long serialVersionUID = -1705715024067165212L;
-
- private TrustLevel trustLevel;
-
-}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/TrustLevel.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/TrustLevel.java
index f4254bb473..8d1f8e90f6 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/TrustLevel.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/TrustLevel.java
@@ -20,6 +20,16 @@
package org.onap.cps.ncmp.api.impl.trustlevel;
+import lombok.Getter;
+
+@Getter
public enum TrustLevel {
- NONE, COMPLETE;
+ NONE(0), COMPLETE(99);
+
+ private final int value;
+
+ TrustLevel(final int value) {
+ this.value = value;
+ }
+
} \ No newline at end of file
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/TrustLevelFilter.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/TrustLevelFilter.java
new file mode 100644
index 0000000000..3b704ae4f5
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/TrustLevelFilter.java
@@ -0,0 +1,58 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.api.impl.trustlevel;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+import lombok.RequiredArgsConstructor;
+
+@RequiredArgsConstructor
+@EqualsAndHashCode(onlyExplicitlyIncluded = true)
+public class TrustLevelFilter implements Comparable<TrustLevel> {
+
+ @EqualsAndHashCode.Include
+ private final TrustLevel targetTrustLevel;
+ private final Map<String, TrustLevel> trustLevelPerCmHandle;
+
+ @Override
+ public int compareTo(@NonNull final TrustLevel other) {
+ return Integer.compare(this.targetTrustLevel.getValue(), other.getValue());
+ }
+
+ /**
+ * This method return cm handles that matches with given trust level.
+ *
+ * @return cm handle ids.
+ */
+ public Collection<String> getAllCmHandleIdsByTargetTrustLevel() {
+ final Collection<String> resultCmHandleIds = new HashSet<>();
+ trustLevelPerCmHandle.entrySet().forEach(cmHandleTrustLevelEntrySet -> {
+ if (compareTo(cmHandleTrustLevelEntrySet.getValue()) == 0) {
+ resultCmHandleIds.add(cmHandleTrustLevelEntrySet.getKey());
+ }
+ });
+ return resultCmHandleIds;
+ }
+
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DMiPluginWatchDog.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DMiPluginWatchDog.java
index d3b95eacbf..39f8802572 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DMiPluginWatchDog.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DMiPluginWatchDog.java
@@ -20,7 +20,7 @@
package org.onap.cps.ncmp.api.impl.trustlevel.dmiavailability;
-import com.hazelcast.map.IMap;
+import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.impl.client.DmiRestClient;
@@ -33,7 +33,7 @@ import org.springframework.stereotype.Service;
@Service
public class DMiPluginWatchDog {
- private final IMap<String, TrustLevel> trustLevelPerDmiPlugin;
+ private final Map<String, TrustLevel> trustLevelPerDmiPlugin;
private final DmiRestClient dmiRestClient;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/CmHandleQueryConditions.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/CmHandleQueryConditions.java
index b1bb7f767b..a59776036a 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/CmHandleQueryConditions.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/CmHandleQueryConditions.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation
+ * Copyright (C) 2022-2023 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,8 @@ import lombok.Getter;
public enum CmHandleQueryConditions {
HAS_ALL_PROPERTIES("hasAllProperties"),
HAS_ALL_MODULES("hasAllModules"),
- WITH_CPS_PATH("cmHandleWithCpsPath");
+ WITH_CPS_PATH("cmHandleWithCpsPath"),
+ WITH_TRUST_LEVEL("cmHandleWithTrustLevel");
public static final Collection<String> ALL_CONDITION_NAMES = Arrays.stream(CmHandleQueryConditions.values())
.map(CmHandleQueryConditions::getConditionName).collect(Collectors.toList());