diff options
author | mpriyank <priyank.maheshwari@est.tech> | 2024-05-24 11:38:06 +0100 |
---|---|---|
committer | mpriyank <priyank.maheshwari@est.tech> | 2024-05-27 10:46:34 +0100 |
commit | c69ce470ecabedc9df59b9a9d3888338850fd502 (patch) | |
tree | 50ec03712f781fdbc21ccf99d0d5220fe1df652e /cps-ncmp-service/src/main/java | |
parent | c628542edebf7b000bc8646455378ae076bdc9c5 (diff) |
CmSubscription overlapping case
- Directly ACCEPT the CmSubscription request in case of overlapping
scenario
- The confirmation will be sent out when the DMI timeout has happened
- No request sent out to DMI plugin in this scenario
Issue-ID: CPS-2237
Change-Id: Ic799801058e9c8e1c2db8780a42ab85ea306f45e
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/main/java')
2 files changed, 39 insertions, 13 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionDelta.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionDelta.java index 8a4beb9560..4e2062fed6 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionDelta.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionDelta.java @@ -64,12 +64,19 @@ public class CmNotificationSubscriptionDelta { } } - final DmiCmNotificationSubscriptionPredicate predicateDelta = - new DmiCmNotificationSubscriptionPredicate(targetCmHandleIds, datastoreType, xpaths); + populateValidDmiCmNotificationSubscriptionPredicateDelta(targetCmHandleIds, xpaths, datastoreType, delta); + } + return delta; + } + private void populateValidDmiCmNotificationSubscriptionPredicateDelta(final Set<String> targetCmHandleIds, + final Set<String> xpaths, final DatastoreType datastoreType, + final List<DmiCmNotificationSubscriptionPredicate> delta) { + if (!(targetCmHandleIds.isEmpty() || xpaths.isEmpty())) { + final DmiCmNotificationSubscriptionPredicate predicateDelta = + new DmiCmNotificationSubscriptionPredicate(targetCmHandleIds, datastoreType, xpaths); delta.add(predicateDelta); } - return delta; } } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImpl.java index 7872ba0a34..128c6751ce 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/service/CmNotificationSubscriptionHandlerServiceImpl.java @@ -30,6 +30,7 @@ import org.onap.cps.ncmp.api.impl.events.cmsubscription.CmNotificationSubscripti import org.onap.cps.ncmp.api.impl.events.cmsubscription.CmNotificationSubscriptionEventsHandler; import org.onap.cps.ncmp.api.impl.events.cmsubscription.CmNotificationSubscriptionMappersHandler; import org.onap.cps.ncmp.api.impl.events.cmsubscription.DmiCmNotificationSubscriptionCacheHandler; +import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.CmNotificationSubscriptionStatus; import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionDetails; import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionPredicate; import org.onap.cps.ncmp.events.cmnotificationsubscription_merge1_0_0.client_to_ncmp.CmNotificationSubscriptionNcmpInEvent; @@ -56,11 +57,10 @@ public class CmNotificationSubscriptionHandlerServiceImpl implements CmNotificat if (cmNotificationSubscriptionPersistenceService.isUniqueSubscriptionId(subscriptionId)) { dmiCmNotificationSubscriptionCacheHandler.add(subscriptionId, predicates); - sendSubscriptionCreateRequestToDmi(subscriptionId); + handleCmNotificationSubscriptionDelta(subscriptionId); scheduleCmNotificationSubscriptionNcmpOutEventResponse(subscriptionId); } else { - rejectAndPublishCmNotificationSubscriptionCreateRequest(subscriptionId, - predicates); + rejectAndPublishCmNotificationSubscriptionCreateRequest(subscriptionId, predicates); } } @@ -81,18 +81,37 @@ public class CmNotificationSubscriptionHandlerServiceImpl implements CmNotificat "subscriptionCreateResponse", cmNotificationSubscriptionNcmpOutEvent, false); } - private void sendSubscriptionCreateRequestToDmi(final String subscriptionId) { + private void handleCmNotificationSubscriptionDelta(final String subscriptionId) { final Map<String, DmiCmNotificationSubscriptionDetails> dmiCmNotificationSubscriptionDetailsMap = dmiCmNotificationSubscriptionCacheHandler.get(subscriptionId); dmiCmNotificationSubscriptionDetailsMap.forEach((dmiPluginName, dmiCmNotificationSubscriptionDetails) -> { final List<DmiCmNotificationSubscriptionPredicate> dmiCmNotificationSubscriptionPredicates = cmNotificationSubscriptionDelta.getDelta( dmiCmNotificationSubscriptionDetails.getDmiCmNotificationSubscriptionPredicates()); - final CmNotificationSubscriptionDmiInEvent cmNotificationSubscriptionDmiInEvent = - cmNotificationSubscriptionMappersHandler.toCmNotificationSubscriptionDmiInEvent( - dmiCmNotificationSubscriptionPredicates); - cmNotificationSubscriptionEventsHandler.publishCmNotificationSubscriptionDmiInEvent(subscriptionId, - dmiPluginName, "subscriptionCreateRequest", cmNotificationSubscriptionDmiInEvent); + + if (dmiCmNotificationSubscriptionPredicates.isEmpty()) { + acceptAndPublishCmNotificationSubscriptionNcmpOutEventPerDmi(subscriptionId, dmiPluginName); + } else { + publishCmNotificationSubscriptionDmiInEventPerDmi(subscriptionId, dmiPluginName, + dmiCmNotificationSubscriptionPredicates); + } }); } -}
\ No newline at end of file + + private void publishCmNotificationSubscriptionDmiInEventPerDmi(final String subscriptionId, + final String dmiPluginName, + final List<DmiCmNotificationSubscriptionPredicate> dmiCmNotificationSubscriptionPredicates) { + final CmNotificationSubscriptionDmiInEvent cmNotificationSubscriptionDmiInEvent = + cmNotificationSubscriptionMappersHandler.toCmNotificationSubscriptionDmiInEvent( + dmiCmNotificationSubscriptionPredicates); + cmNotificationSubscriptionEventsHandler.publishCmNotificationSubscriptionDmiInEvent(subscriptionId, + dmiPluginName, "subscriptionCreateRequest", cmNotificationSubscriptionDmiInEvent); + } + + private void acceptAndPublishCmNotificationSubscriptionNcmpOutEventPerDmi(final String subscriptionId, + final String dmiPluginName) { + dmiCmNotificationSubscriptionCacheHandler.updateDmiCmNotificationSubscriptionStatusPerDmi(subscriptionId, + dmiPluginName, CmNotificationSubscriptionStatus.ACCEPTED); + dmiCmNotificationSubscriptionCacheHandler.persistIntoDatabasePerDmi(subscriptionId, dmiPluginName); + } +} |