diff options
author | mpriyank <priyank.maheshwari@est.tech> | 2024-05-03 10:48:04 +0100 |
---|---|---|
committer | mpriyank <priyank.maheshwari@est.tech> | 2024-05-03 10:48:09 +0100 |
commit | 6c35c5dd0dbfc417a57bad71c22b03f21cb71e5f (patch) | |
tree | 198a19f6587cbedec89dcb20d2331a98e04ffcb0 /cps-ncmp-service/src/main/java/org | |
parent | c5f6c45eb5cd94f76f1f39e5a4593996a9f25474 (diff) |
Schedule response to client
- Scheduling sending the response by reading whatever is present in the
cache for subscription after a pre-configured time.
- Also added test validation for the same
Issue-ID: CPS-2209
Change-Id: Ifacb0b12734a0529e671b0b63836189a243e453c
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
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/CmNotificationSubscriptionHandlerServiceImpl.java | 20 |
1 files changed, 13 insertions, 7 deletions
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 395c511af7..7872ba0a34 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 @@ -57,20 +57,26 @@ public class CmNotificationSubscriptionHandlerServiceImpl implements CmNotificat if (cmNotificationSubscriptionPersistenceService.isUniqueSubscriptionId(subscriptionId)) { dmiCmNotificationSubscriptionCacheHandler.add(subscriptionId, predicates); sendSubscriptionCreateRequestToDmi(subscriptionId); + scheduleCmNotificationSubscriptionNcmpOutEventResponse(subscriptionId); } else { - final Set<String> subscriptionTargetFilters = predicates.stream().flatMap( - predicate -> predicate.getTargetFilter().stream()).collect(Collectors.toSet()); rejectAndPublishCmNotificationSubscriptionCreateRequest(subscriptionId, - new ArrayList<>(subscriptionTargetFilters)); + predicates); } } + private void scheduleCmNotificationSubscriptionNcmpOutEventResponse(final String subscriptionId) { + cmNotificationSubscriptionEventsHandler.publishCmNotificationSubscriptionNcmpOutEvent(subscriptionId, + "subscriptionCreateResponse", null, true); + } + private void rejectAndPublishCmNotificationSubscriptionCreateRequest(final String subscriptionId, - final List<String> subscriptionTargetFilters) { + final List<Predicate> predicates) { + final Set<String> subscriptionTargetFilters = + predicates.stream().flatMap(predicate -> predicate.getTargetFilter().stream()) + .collect(Collectors.toSet()); final CmNotificationSubscriptionNcmpOutEvent cmNotificationSubscriptionNcmpOutEvent = - cmNotificationSubscriptionMappersHandler - .toCmNotificationSubscriptionNcmpOutEventForRejectedRequest(subscriptionId, - subscriptionTargetFilters); + cmNotificationSubscriptionMappersHandler.toCmNotificationSubscriptionNcmpOutEventForRejectedRequest( + subscriptionId, new ArrayList<>(subscriptionTargetFilters)); cmNotificationSubscriptionEventsHandler.publishCmNotificationSubscriptionNcmpOutEvent(subscriptionId, "subscriptionCreateResponse", cmNotificationSubscriptionNcmpOutEvent, false); } |