diff options
author | Luke Gleeson <luke.gleeson@est.tech> | 2023-08-21 10:20:09 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2023-08-21 10:20:09 +0000 |
commit | 9f8ddd047943525bebf8a49599f22dbe530b4361 (patch) | |
tree | ec974af9697f1b5223673ea6db9457ea242c447f /cps-ncmp-service/src/main/java | |
parent | 7d486385a46b8dfa3a72db27dc4f31bf74d035bb (diff) | |
parent | 2640b91a98fae9867a0f45b7b20e26f5c0eb0f9a (diff) |
Merge "Cm Subscription: PENDING logic handling in NCMP"
Diffstat (limited to 'cps-ncmp-service/src/main/java')
7 files changed, 171 insertions, 77 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumer.java index 1ac4044114..9459778fd7 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumer.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumer.java @@ -36,6 +36,7 @@ import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionPersistence; import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus; import org.onap.cps.ncmp.api.impl.utils.DataNodeHelper; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent; +import org.onap.cps.ncmp.api.models.CmSubscriptionEvent; import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent; import org.onap.cps.spi.model.DataNode; import org.springframework.beans.factory.annotation.Value; @@ -66,7 +67,7 @@ public class CmSubscriptionDmiOutEventConsumer { */ @KafkaListener(topics = "${app.ncmp.avc.subscription-response-topic}", containerFactory = "cloudEventConcurrentKafkaListenerContainerFactory") - public void consumeSubscriptionEventResponse( + public void consumeDmiOutEvent( final ConsumerRecord<String, CloudEvent> cmSubscriptionDmiOutConsumerRecord) { final CloudEvent cloudEvent = cmSubscriptionDmiOutConsumerRecord.value(); final String eventType = cmSubscriptionDmiOutConsumerRecord.value().getType(); @@ -90,7 +91,12 @@ public class CmSubscriptionDmiOutEventConsumer { if (createOutcomeResponse && notificationFeatureEnabled && hasNoPendingCmHandles(clientId, subscriptionName)) { - cmSubscriptionNcmpOutEventPublisher.sendResponse(cmSubscriptionDmiOutEvent, eventType); + + final CmSubscriptionEvent cmSubscriptionEvent = new CmSubscriptionEvent(); + cmSubscriptionEvent.setClientId(cmSubscriptionDmiOutEvent.getData().getClientId()); + cmSubscriptionEvent.setSubscriptionName(cmSubscriptionDmiOutEvent.getData().getSubscriptionName()); + + cmSubscriptionNcmpOutEventPublisher.sendResponse(cmSubscriptionEvent, eventType); forwardedSubscriptionEventCache.remove(subscriptionEventId); } } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper.java index 99452c6c24..0fe2c9ae5d 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper.java @@ -26,43 +26,43 @@ import java.util.stream.Collectors; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Named; -import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent; -import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.SubscriptionStatus; +import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus; +import org.onap.cps.ncmp.api.models.CmSubscriptionEvent; +import org.onap.cps.ncmp.api.models.CmSubscriptionStatus; import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_client.AdditionalInfo; import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_client.AdditionalInfoDetail; import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_client.CmSubscriptionNcmpOutEvent; import org.onap.cps.spi.exceptions.DataValidationException; @Mapper(componentModel = "spring") -public interface CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper { +public interface CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper { - @Mapping(source = "data.subscriptionStatus", target = "data.additionalInfo", - qualifiedByName = "mapListOfSubscriptionStatusToAdditionalInfo") - CmSubscriptionNcmpOutEvent toCmSubscriptionNcmpOutEvent(CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent); + @Mapping(source = "cmSubscriptionStatus", target = "data.additionalInfo", + qualifiedByName = "mapCmSubscriptionStatusToAdditionalInfo") + CmSubscriptionNcmpOutEvent toCmSubscriptionNcmpOutEvent(CmSubscriptionEvent cmSubscriptionEvent); /** * Maps list of SubscriptionStatus to an AdditionalInfo. * - * @param subscriptionStatusList containing details + * @param cmSubscriptionStatusList containing details * @return an AdditionalInfo */ - @Named("mapListOfSubscriptionStatusToAdditionalInfo") - default AdditionalInfo mapListOfSubscriptionStatusToAdditionalInfo( - final List<SubscriptionStatus> subscriptionStatusList) { - if (subscriptionStatusList == null || subscriptionStatusList.isEmpty()) { - throw new DataValidationException("Invalid subscriptionStatusList", - "SubscriptionStatus list cannot be null or empty"); + @Named("mapCmSubscriptionStatusToAdditionalInfo") + default AdditionalInfo mapCmSubscriptionStatusToAdditionalInfo( + final List<CmSubscriptionStatus> cmSubscriptionStatusList) { + if (cmSubscriptionStatusList == null || cmSubscriptionStatusList.isEmpty()) { + throw new DataValidationException("Invalid cmSubscriptionStatusList", + "CmSubscriptionStatus list cannot be null or empty"); } - final Map<String, List<SubscriptionStatus>> rejectedSubscriptionsPerDetails = getSubscriptionsPerDetails( - subscriptionStatusList, SubscriptionStatus.Status.REJECTED); + final Map<String, List<CmSubscriptionStatus>> rejectedSubscriptionsPerDetails = + getSubscriptionsPerDetails(cmSubscriptionStatusList, SubscriptionStatus.REJECTED); final Map<String, List<String>> rejectedCmHandlesPerDetails = getCmHandlesPerDetails(rejectedSubscriptionsPerDetails); final List<AdditionalInfoDetail> rejectedCmHandles = getAdditionalInfoDetailList(rejectedCmHandlesPerDetails); - - final Map<String, List<SubscriptionStatus>> pendingSubscriptionsPerDetails = getSubscriptionsPerDetails( - subscriptionStatusList, SubscriptionStatus.Status.PENDING); + final Map<String, List<CmSubscriptionStatus>> pendingSubscriptionsPerDetails = + getSubscriptionsPerDetails(cmSubscriptionStatusList, SubscriptionStatus.PENDING); final Map<String, List<String>> pendingCmHandlesPerDetails = getCmHandlesPerDetails(pendingSubscriptionsPerDetails); final List<AdditionalInfoDetail> pendingCmHandles = getAdditionalInfoDetailList(pendingCmHandlesPerDetails); @@ -74,20 +74,20 @@ public interface CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper { return additionalInfo; } - private static Map<String, List<SubscriptionStatus>> getSubscriptionsPerDetails( - final List<SubscriptionStatus> subscriptionStatusList, final SubscriptionStatus.Status status) { - return subscriptionStatusList.stream() + private static Map<String, List<CmSubscriptionStatus>> getSubscriptionsPerDetails( + final List<CmSubscriptionStatus> cmSubscriptionStatusList, final SubscriptionStatus status) { + return cmSubscriptionStatusList.stream() .filter(subscriptionStatus -> subscriptionStatus.getStatus() == status) - .collect(Collectors.groupingBy(SubscriptionStatus::getDetails)); + .collect(Collectors.groupingBy(CmSubscriptionStatus::getDetails)); } private static Map<String, List<String>> getCmHandlesPerDetails( - final Map<String, List<SubscriptionStatus>> subscriptionsPerDetails) { - return subscriptionsPerDetails.entrySet().stream() + final Map<String, List<CmSubscriptionStatus>> cmSubscriptionsPerDetails) { + return cmSubscriptionsPerDetails.entrySet().stream() .collect(Collectors.toMap( Map.Entry::getKey, entry -> entry.getValue().stream() - .map(SubscriptionStatus::getId) + .map(CmSubscriptionStatus::getId) .collect(Collectors.toList()) )); } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarder.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarder.java index 4a174954ea..ea2d17d3a7 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarder.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarder.java @@ -43,9 +43,8 @@ import org.onap.cps.ncmp.api.impl.utils.DmiServiceNameOrganizer; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent; import org.onap.cps.ncmp.api.inventory.InventoryPersistence; +import org.onap.cps.ncmp.api.models.CmSubscriptionEvent; import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent; -import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent; -import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.Data; import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_dmi.CmHandle; import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_dmi.CmSubscriptionDmiInEvent; import org.springframework.beans.factory.annotation.Value; @@ -97,12 +96,11 @@ public class CmSubscriptionNcmpInEventForwarder { private void findDmisAndRespond(final CmSubscriptionNcmpInEvent cmSubscriptionNcmpInEvent, final String eventType, final List<String> cmHandleTargetsAsStrings, final Map<String, Map<String, Map<String, String>>> dmiPropertiesPerCmHandleIdPerServiceName) { - final CmSubscriptionDmiOutEvent emptyCmSubscriptionDmiOutEvent = - new CmSubscriptionDmiOutEvent().withData(new Data()); - emptyCmSubscriptionDmiOutEvent.getData() - .setSubscriptionName(cmSubscriptionNcmpInEvent.getData().getSubscription().getName()); - emptyCmSubscriptionDmiOutEvent.getData() - .setClientId(cmSubscriptionNcmpInEvent.getData().getSubscription().getClientID()); + + final CmSubscriptionEvent cmSubscriptionEvent = new CmSubscriptionEvent(); + cmSubscriptionEvent.setSubscriptionName(cmSubscriptionNcmpInEvent.getData().getSubscription().getName()); + cmSubscriptionEvent.setClientId(cmSubscriptionNcmpInEvent.getData().getSubscription().getClientID()); + final List<String> cmHandlesThatExistsInDb = dmiPropertiesPerCmHandleIdPerServiceName.entrySet().stream().map(Map.Entry::getValue).map(Map::keySet) .flatMap(Set::stream).collect(Collectors.toList()); @@ -117,10 +115,10 @@ public class CmSubscriptionNcmpInEventForwarder { targetCmHandlesDoesNotExistInDb); } if (dmisToRespond.isEmpty()) { - cmSubscriptionNcmpOutEventPublisher.sendResponse(emptyCmSubscriptionDmiOutEvent, + cmSubscriptionNcmpOutEventPublisher.sendResponse(cmSubscriptionEvent, "subscriptionCreatedStatus"); } else { - startResponseTimeout(emptyCmSubscriptionDmiOutEvent, dmisToRespond); + startResponseTimeout(cmSubscriptionEvent, dmisToRespond); final CmSubscriptionDmiInEvent cmSubscriptionDmiInEvent = cmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper.toCmSubscriptionDmiInEvent( cmSubscriptionNcmpInEvent); @@ -128,17 +126,17 @@ public class CmSubscriptionNcmpInEventForwarder { } } - private void startResponseTimeout(final CmSubscriptionDmiOutEvent emptyCmSubscriptionDmiOutEvent, + private void startResponseTimeout(final CmSubscriptionEvent cmSubscriptionEvent, final Set<String> dmisToRespond) { - final String subscriptionClientId = emptyCmSubscriptionDmiOutEvent.getData().getClientId(); - final String subscriptionName = emptyCmSubscriptionDmiOutEvent.getData().getSubscriptionName(); + final String subscriptionClientId = cmSubscriptionEvent.getClientId(); + final String subscriptionName = cmSubscriptionEvent.getSubscriptionName(); final String subscriptionEventId = subscriptionClientId + subscriptionName; forwardedSubscriptionEventCache.put(subscriptionEventId, dmisToRespond, ForwardedSubscriptionEventCacheConfig.SUBSCRIPTION_FORWARD_STARTED_TTL_SECS, TimeUnit.SECONDS); final ResponseTimeoutTask responseTimeoutTask = new ResponseTimeoutTask(forwardedSubscriptionEventCache, cmSubscriptionNcmpOutEventPublisher, - emptyCmSubscriptionDmiOutEvent); + cmSubscriptionEvent); executorService.schedule(responseTimeoutTask, dmiResponseTimeoutInMs, TimeUnit.MILLISECONDS); } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java index 38cc724be0..473538c93e 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java @@ -32,7 +32,8 @@ import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionPersistence; import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus; import org.onap.cps.ncmp.api.impl.utils.DataNodeHelper; import org.onap.cps.ncmp.api.impl.utils.SubscriptionOutcomeCloudMapper; -import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent; +import org.onap.cps.ncmp.api.models.CmSubscriptionEvent; +import org.onap.cps.ncmp.api.models.CmSubscriptionStatus; import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_client.CmSubscriptionNcmpOutEvent; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -46,8 +47,8 @@ public class CmSubscriptionNcmpOutEventPublisher { private final EventsPublisher<CloudEvent> outcomeEventsPublisher; - private final CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper - cmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper; + private final CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper + cmSubscriptionEventToCmSubscriptionNcmpOutEventMapper; private final SubscriptionOutcomeCloudMapper subscriptionOutcomeCloudMapper; @@ -57,54 +58,48 @@ public class CmSubscriptionNcmpOutEventPublisher { /** * This is for construction of outcome message to be published for client apps. * - * @param cmSubscriptionDmiOutEvent event produced by Dmi Plugin + * @param cmSubscriptionEvent event produced by Dmi Plugin */ - public void sendResponse(final CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent, final String eventKey) { + public void sendResponse(final CmSubscriptionEvent cmSubscriptionEvent, final String eventType) { final CmSubscriptionNcmpOutEvent cmSubscriptionNcmpOutEvent = - formCmSubscriptionNcmpOutEvent(cmSubscriptionDmiOutEvent); - final String subscriptionClientId = cmSubscriptionDmiOutEvent.getData().getClientId(); - final String subscriptionName = cmSubscriptionDmiOutEvent.getData().getSubscriptionName(); + formCmSubscriptionNcmpOutEvent(cmSubscriptionEvent); + final String subscriptionClientId = cmSubscriptionEvent.getClientId(); + final String subscriptionName = cmSubscriptionEvent.getSubscriptionName(); final String subscriptionEventId = subscriptionClientId + subscriptionName; final CloudEvent subscriptionOutcomeCloudEvent = subscriptionOutcomeCloudMapper.toCloudEvent(cmSubscriptionNcmpOutEvent, - subscriptionEventId, eventKey); + subscriptionEventId, eventType); outcomeEventsPublisher.publishCloudEvent(subscriptionOutcomeEventTopic, subscriptionEventId, subscriptionOutcomeCloudEvent); } private CmSubscriptionNcmpOutEvent formCmSubscriptionNcmpOutEvent( - final CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent) { + final CmSubscriptionEvent cmSubscriptionEvent) { final Map<String, Map<String, String>> cmHandleIdToStatusAndDetailsAsMap = DataNodeHelper.cmHandleIdToStatusAndDetailsAsMapFromDataNode( subscriptionPersistence.getCmHandlesForSubscriptionEvent( - cmSubscriptionDmiOutEvent.getData().getClientId(), - cmSubscriptionDmiOutEvent.getData().getSubscriptionName())); - final List<org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.SubscriptionStatus> - subscriptionStatusList = + cmSubscriptionEvent.getClientId(), + cmSubscriptionEvent.getSubscriptionName())); + final List<CmSubscriptionStatus> cmSubscriptionStatusList = mapCmHandleIdStatusDetailsMapToSubscriptionStatusList(cmHandleIdToStatusAndDetailsAsMap); - cmSubscriptionDmiOutEvent.getData().setSubscriptionStatus(subscriptionStatusList); - return fromDmiOutEvent(cmSubscriptionDmiOutEvent, + cmSubscriptionEvent.setCmSubscriptionStatus(cmSubscriptionStatusList); + return fromCmSubscriptionEvent(cmSubscriptionEvent, decideOnNcmpEventResponseCodeForSubscription(cmHandleIdToStatusAndDetailsAsMap)); } - private static List<org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.SubscriptionStatus> - mapCmHandleIdStatusDetailsMapToSubscriptionStatusList( + private static List<CmSubscriptionStatus> mapCmHandleIdStatusDetailsMapToSubscriptionStatusList( final Map<String, Map<String, String>> cmHandleIdToStatusAndDetailsAsMap) { return cmHandleIdToStatusAndDetailsAsMap.entrySet() .stream().map(entryset -> { - final org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.SubscriptionStatus - subscriptionStatus = new org.onap.cps.ncmp.events.cmsubscription1_0_0 - .dmi_to_ncmp.SubscriptionStatus(); + final CmSubscriptionStatus cmSubscriptionStatus = new CmSubscriptionStatus(); final String cmHandleId = entryset.getKey(); final Map<String, String> statusAndDetailsMap = entryset.getValue(); final String status = statusAndDetailsMap.get("status"); final String details = statusAndDetailsMap.get("details"); - subscriptionStatus.setId(cmHandleId); - subscriptionStatus.setStatus( - org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp - .SubscriptionStatus.Status.fromValue(status)); - subscriptionStatus.setDetails(details); - return subscriptionStatus; + cmSubscriptionStatus.setId(cmHandleId); + cmSubscriptionStatus.setStatus(SubscriptionStatus.fromString(status)); + cmSubscriptionStatus.setDetails(details); + return cmSubscriptionStatus; }).collect(Collectors.toList()); } @@ -138,13 +133,13 @@ public class CmSubscriptionNcmpOutEventPublisher { .allMatch(entryset -> entryset.containsValue(subscriptionStatus.toString())); } - private CmSubscriptionNcmpOutEvent fromDmiOutEvent( - final CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent, + private CmSubscriptionNcmpOutEvent fromCmSubscriptionEvent( + final CmSubscriptionEvent cmSubscriptionEvent, final NcmpEventResponseCode ncmpEventResponseCode) { final CmSubscriptionNcmpOutEvent cmSubscriptionNcmpOutEvent = - cmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper.toCmSubscriptionNcmpOutEvent( - cmSubscriptionDmiOutEvent); + cmSubscriptionEventToCmSubscriptionNcmpOutEventMapper.toCmSubscriptionNcmpOutEvent( + cmSubscriptionEvent); cmSubscriptionNcmpOutEvent.getData().setStatusCode(Integer.parseInt(ncmpEventResponseCode.getStatusCode())); cmSubscriptionNcmpOutEvent.getData().setStatusMessage(ncmpEventResponseCode.getStatusMessage()); diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/ResponseTimeoutTask.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/ResponseTimeoutTask.java index 7f8cbf676e..78b000dae6 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/ResponseTimeoutTask.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/ResponseTimeoutTask.java @@ -24,7 +24,7 @@ import com.hazelcast.map.IMap; import java.util.Set; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent; +import org.onap.cps.ncmp.api.models.CmSubscriptionEvent; @Slf4j @RequiredArgsConstructor @@ -32,7 +32,7 @@ public class ResponseTimeoutTask implements Runnable { private final IMap<String, Set<String>> forwardedSubscriptionEventCache; private final CmSubscriptionNcmpOutEventPublisher cmSubscriptionNcmpOutEventPublisher; - private final CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent; + private final CmSubscriptionEvent cmSubscriptionEvent; @Override public void run() { @@ -40,11 +40,11 @@ public class ResponseTimeoutTask implements Runnable { } private void generateTimeoutResponse() { - final String subscriptionClientId = cmSubscriptionDmiOutEvent.getData().getClientId(); - final String subscriptionName = cmSubscriptionDmiOutEvent.getData().getSubscriptionName(); + final String subscriptionClientId = cmSubscriptionEvent.getClientId(); + final String subscriptionName = cmSubscriptionEvent.getSubscriptionName(); final String subscriptionEventId = subscriptionClientId + subscriptionName; if (forwardedSubscriptionEventCache.containsKey(subscriptionEventId)) { - cmSubscriptionNcmpOutEventPublisher.sendResponse(cmSubscriptionDmiOutEvent, + cmSubscriptionNcmpOutEventPublisher.sendResponse(cmSubscriptionEvent, "subscriptionCreatedStatus"); forwardedSubscriptionEventCache.remove(subscriptionEventId); } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmSubscriptionEvent.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmSubscriptionEvent.java new file mode 100644 index 0000000000..2a60b2ab16 --- /dev/null +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmSubscriptionEvent.java @@ -0,0 +1,50 @@ +/* + * ============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.models; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; + + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Getter +@Setter +public class CmSubscriptionEvent { + + @JsonProperty("clientId") + @NotNull + private String clientId; + + @JsonProperty("subscriptionName") + @NotNull + private String subscriptionName; + + @JsonProperty("cmSubscriptionStatus") + @Valid + @NotNull + private List<CmSubscriptionStatus> cmSubscriptionStatus = new ArrayList<>(); +} diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmSubscriptionStatus.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmSubscriptionStatus.java new file mode 100644 index 0000000000..bba560785d --- /dev/null +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmSubscriptionStatus.java @@ -0,0 +1,45 @@ +/* + * ============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.models; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; +import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Getter +@Setter +public class CmSubscriptionStatus { + + @JsonProperty("id") + @NotNull + private String id; + + @JsonProperty("status") + @NotNull + private SubscriptionStatus status; + + @JsonProperty("details") + private String details; +} |