summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java/org
diff options
context:
space:
mode:
authorPriyank Maheshwari <priyank.maheshwari@est.tech>2024-02-21 15:10:02 +0000
committerGerrit Code Review <gerrit@onap.org>2024-02-21 15:10:02 +0000
commit3c8eaa8624c2bac85745f8d547d7aac8a9164c6e (patch)
tree484d3da444dd94f6d0905f5e5f8792ee2924a1ce /cps-ncmp-service/src/main/java/org
parenta1ab76467ce2d096e3d51eaf144cfe043ef1c241 (diff)
parent48716d684b665e0e6c4013f8a3fd60e82cf6d19c (diff)
Merge "adding isUniqueSubscriptionId method"
Diffstat (limited to 'cps-ncmp-service/src/main/java/org')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceService.java8
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceServiceImpl.java11
2 files changed, 19 insertions, 0 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceService.java
index 189fbb53d9..38f3db98de 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceService.java
@@ -40,6 +40,14 @@ public interface CmNotificationSubscriptionPersistenceService {
final String xpath);
/**
+ * Check if the subscription ID is unique against ongoing subscriptions.
+ *
+ * @param subscriptionId subscription ID
+ * @return true if subscriptionId is not used in active subscriptions, otherwise false
+ */
+ boolean isUniqueSubscriptionId(final String subscriptionId);
+
+ /**
* Get all ongoing cm notification subscription based on the parameters.
*
* @param datastoreType valid datastore type
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceServiceImpl.java
index 63f12ad623..6e4997a4dd 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionPersistenceServiceImpl.java
@@ -36,9 +36,13 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor
public class CmNotificationSubscriptionPersistenceServiceImpl implements CmNotificationSubscriptionPersistenceService {
+ private static final String SUBSCRIPTION_ANCHOR_NAME = "cm-data-subscriptions";
private static final String IS_ONGOING_CM_SUBSCRIPTION_CPS_PATH_QUERY = """
/datastores/datastore[@name='%s']/cm-handles/cm-handle[@id='%s']/filters/filter[@xpath='%s']
""".trim();
+ private static final String SUBSCRIPTION_IDS_CPS_PATH_QUERY = """
+ //filter/subscriptionIds[text()='%s']
+ """.trim();
private final CpsQueryService cpsQueryService;
@@ -49,6 +53,13 @@ public class CmNotificationSubscriptionPersistenceServiceImpl implements CmNotif
}
@Override
+ public boolean isUniqueSubscriptionId(final String subscriptionId) {
+ return cpsQueryService.queryDataNodes(NCMP_DATASPACE_NAME, SUBSCRIPTION_ANCHOR_NAME,
+ SUBSCRIPTION_IDS_CPS_PATH_QUERY.formatted(subscriptionId),
+ FetchDescendantsOption.OMIT_DESCENDANTS).isEmpty();
+ }
+
+ @Override
public Collection<String> getOngoingCmNotificationSubscriptionIds(final DatastoreType datastoreType,
final String cmHandleId, final String xpath) {