summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service/src/main')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumer.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseConsumer.java)39
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionOutcomeMapper.java)16
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseMapper.java)10
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventConsumer.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventConsumer.java)38
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarder.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventForwarder.java)121
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventMapper.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventMapper.java)8
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/ClientSubscriptionEventMapper.java)11
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseOutcome.java)68
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/ResponseTimeoutTask.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/ResponseTimeoutTask.java)14
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/CmSubscriptionEventCloudMapper.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventCloudMapper.java)44
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventResponseCloudMapper.java18
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/SubscriptionOutcomeCloudMapper.java12
12 files changed, 200 insertions, 199 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseConsumer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumer.java
index b1c0a322dd..3a7e0c6cf5 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseConsumer.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumer.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.avcsubscription;
+package org.onap.cps.ncmp.api.impl.events.cmsubscription;
import com.hazelcast.map.IMap;
import io.cloudevents.CloudEvent;
@@ -35,7 +35,7 @@ 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.SubscriptionEventResponseCloudMapper;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionEventResponse;
+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;
import org.springframework.kafka.annotation.KafkaListener;
@@ -44,12 +44,13 @@ import org.springframework.stereotype.Component;
@Component
@Slf4j
@RequiredArgsConstructor
-public class SubscriptionEventResponseConsumer {
+public class CmSubscriptionDmiOutEventConsumer {
private final IMap<String, Set<String>> forwardedSubscriptionEventCache;
private final SubscriptionPersistence subscriptionPersistence;
- private final SubscriptionEventResponseMapper subscriptionEventResponseMapper;
- private final SubscriptionEventResponseOutcome subscriptionEventResponseOutcome;
+ private final CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper
+ cmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper;
+ private final CmSubscriptionNcmpOutEventPublisher cmSubscriptionNcmpOutEventPublisher;
private final SubscriptionEventResponseCloudMapper subscriptionEventResponseCloudMapper;
@Value("${notification.enabled:true}")
@@ -61,35 +62,35 @@ public class SubscriptionEventResponseConsumer {
/**
* Consume subscription response event.
*
- * @param subscriptionEventResponseConsumerRecord the event to be consumed
+ * @param cmSubscriptionDmiOutConsumerRecord the event to be consumed
*/
@KafkaListener(topics = "${app.ncmp.avc.subscription-response-topic}",
containerFactory = "cloudEventConcurrentKafkaListenerContainerFactory")
public void consumeSubscriptionEventResponse(
- final ConsumerRecord<String, CloudEvent> subscriptionEventResponseConsumerRecord) {
- final CloudEvent cloudEvent = subscriptionEventResponseConsumerRecord.value();
- final String eventType = subscriptionEventResponseConsumerRecord.value().getType();
- final SubscriptionEventResponse subscriptionEventResponse =
- subscriptionEventResponseCloudMapper.toSubscriptionEventResponse(cloudEvent);
- final String clientId = subscriptionEventResponse.getData().getClientId();
+ final ConsumerRecord<String, CloudEvent> cmSubscriptionDmiOutConsumerRecord) {
+ final CloudEvent cloudEvent = cmSubscriptionDmiOutConsumerRecord.value();
+ final String eventType = cmSubscriptionDmiOutConsumerRecord.value().getType();
+ final CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent =
+ subscriptionEventResponseCloudMapper.toCmSubscriptionDmiOutEvent(cloudEvent);
+ final String clientId = cmSubscriptionDmiOutEvent.getData().getClientId();
log.info("subscription event response of clientId: {} is received.", clientId);
- final String subscriptionName = subscriptionEventResponse.getData().getSubscriptionName();
+ final String subscriptionName = cmSubscriptionDmiOutEvent.getData().getSubscriptionName();
final String subscriptionEventId = clientId + subscriptionName;
boolean createOutcomeResponse = false;
if (forwardedSubscriptionEventCache.containsKey(subscriptionEventId)) {
final Set<String> dmiNames = forwardedSubscriptionEventCache.get(subscriptionEventId);
- dmiNames.remove(subscriptionEventResponse.getData().getDmiName());
+ dmiNames.remove(cmSubscriptionDmiOutEvent.getData().getDmiName());
forwardedSubscriptionEventCache.put(subscriptionEventId, dmiNames,
ForwardedSubscriptionEventCacheConfig.SUBSCRIPTION_FORWARD_STARTED_TTL_SECS, TimeUnit.SECONDS);
createOutcomeResponse = forwardedSubscriptionEventCache.get(subscriptionEventId).isEmpty();
}
if (subscriptionModelLoaderEnabled) {
- updateSubscriptionEvent(subscriptionEventResponse);
+ updateSubscriptionEvent(cmSubscriptionDmiOutEvent);
}
if (createOutcomeResponse
&& notificationFeatureEnabled
&& hasNoPendingCmHandles(clientId, subscriptionName)) {
- subscriptionEventResponseOutcome.sendResponse(subscriptionEventResponse, eventType);
+ cmSubscriptionNcmpOutEventPublisher.sendResponse(cmSubscriptionDmiOutEvent, eventType);
forwardedSubscriptionEventCache.remove(subscriptionEventId);
}
}
@@ -108,10 +109,10 @@ public class SubscriptionEventResponseConsumer {
return true;
}
- private void updateSubscriptionEvent(final SubscriptionEventResponse subscriptionEventResponse) {
+ private void updateSubscriptionEvent(final CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent) {
final YangModelSubscriptionEvent yangModelSubscriptionEvent =
- subscriptionEventResponseMapper
- .toYangModelSubscriptionEvent(subscriptionEventResponse);
+ cmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper
+ .toYangModelSubscriptionEvent(cmSubscriptionDmiOutEvent);
subscriptionPersistence.saveSubscriptionEvent(yangModelSubscriptionEvent);
}
} \ No newline at end of file
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionOutcomeMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper.java
index 7803b982f3..99452c6c24 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionOutcomeMapper.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.avcsubscription;
+package org.onap.cps.ncmp.api.impl.events.cmsubscription;
import java.util.List;
import java.util.Map;
@@ -26,19 +26,19 @@ import java.util.stream.Collectors;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionEventResponse;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionStatus;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_client.AdditionalInfo;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_client.AdditionalInfoDetail;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_client.SubscriptionEventOutcome;
+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.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 SubscriptionOutcomeMapper {
+public interface CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper {
@Mapping(source = "data.subscriptionStatus", target = "data.additionalInfo",
qualifiedByName = "mapListOfSubscriptionStatusToAdditionalInfo")
- SubscriptionEventOutcome toSubscriptionEventOutcome(SubscriptionEventResponse subscriptionEventResponse);
+ CmSubscriptionNcmpOutEvent toCmSubscriptionNcmpOutEvent(CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent);
/**
* Maps list of SubscriptionStatus to an AdditionalInfo.
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper.java
index dc122ee5d1..77eebe36f5 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseMapper.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.avcsubscription;
+package org.onap.cps.ncmp.api.impl.events.cmsubscription;
import java.util.List;
import java.util.stream.Collectors;
@@ -26,18 +26,18 @@ import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionEventResponse;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionStatus;
+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;
@Mapper(componentModel = "spring")
-public interface SubscriptionEventResponseMapper {
+public interface CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper {
@Mapping(source = "data.clientId", target = "clientId")
@Mapping(source = "data.subscriptionName", target = "subscriptionName")
@Mapping(source = "data.subscriptionStatus", target = "predicates.targetCmHandles",
qualifiedByName = "mapSubscriptionStatusToCmHandleTargets")
YangModelSubscriptionEvent toYangModelSubscriptionEvent(
- SubscriptionEventResponse subscriptionEventResponse);
+ CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent);
/**
* Maps SubscriptionStatus to list of TargetCmHandle.
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventConsumer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventConsumer.java
index 8dfdc3cd4e..c64ebacb01 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventConsumer.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventConsumer.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.avcsubscription;
+package org.onap.cps.ncmp.api.impl.events.cmsubscription;
import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_OPERATIONAL;
import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_RUNNING;
@@ -28,9 +28,9 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionPersistence;
-import org.onap.cps.ncmp.api.impl.utils.SubscriptionEventCloudMapper;
+import org.onap.cps.ncmp.api.impl.utils.CmSubscriptionEventCloudMapper;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.client_to_ncmp.SubscriptionEvent;
+import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
@@ -39,12 +39,12 @@ import org.springframework.stereotype.Component;
@Component
@Slf4j
@RequiredArgsConstructor
-public class SubscriptionEventConsumer {
+public class CmSubscriptionNcmpInEventConsumer {
- private final SubscriptionEventForwarder subscriptionEventForwarder;
- private final SubscriptionEventMapper subscriptionEventMapper;
+ private final CmSubscriptionNcmpInEventForwarder cmSubscriptionNcmpInEventForwarder;
+ private final CmSubscriptionNcmpInEventMapper cmSubscriptionNcmpInEventMapper;
private final SubscriptionPersistence subscriptionPersistence;
- private final SubscriptionEventCloudMapper subscriptionEventCloudMapper;
+ private final CmSubscriptionEventCloudMapper cmSubscriptionEventCloudMapper;
@Value("${notification.enabled:true}")
private boolean notificationFeatureEnabled;
@@ -62,23 +62,25 @@ public class SubscriptionEventConsumer {
public void consumeSubscriptionEvent(final ConsumerRecord<String, CloudEvent> subscriptionEventConsumerRecord) {
final CloudEvent cloudEvent = subscriptionEventConsumerRecord.value();
final String eventType = subscriptionEventConsumerRecord.value().getType();
- final SubscriptionEvent subscriptionEvent = subscriptionEventCloudMapper.toSubscriptionEvent(cloudEvent);
- final String eventDatastore = subscriptionEvent.getData().getPredicates().getDatastore();
- if (!eventDatastore.equals(PASSTHROUGH_RUNNING.getDatastoreName())
- || eventDatastore.equals(PASSTHROUGH_OPERATIONAL.getDatastoreName())) {
+ final CmSubscriptionNcmpInEvent cmSubscriptionNcmpInEvent =
+ cmSubscriptionEventCloudMapper.toCmSubscriptionNcmpInEvent(cloudEvent);
+ final String eventDatastore = cmSubscriptionNcmpInEvent.getData().getPredicates().getDatastore();
+ if (!eventDatastore.equals(PASSTHROUGH_RUNNING.getDatastoreName()) || eventDatastore.equals(
+ PASSTHROUGH_OPERATIONAL.getDatastoreName())) {
throw new UnsupportedOperationException(
"passthrough datastores are currently only supported for event subscriptions");
}
- if ("CM".equals(subscriptionEvent.getData().getDataType().getDataCategory())) {
+ if ("CM".equals(cmSubscriptionNcmpInEvent.getData().getDataType().getDataCategory())) {
if (subscriptionModelLoaderEnabled) {
- persistSubscriptionEvent(subscriptionEvent);
+ persistSubscriptionEvent(cmSubscriptionNcmpInEvent);
}
if ("subscriptionCreated".equals(cloudEvent.getType())) {
log.info("Subscription for ClientID {} with name {} ...",
- subscriptionEvent.getData().getSubscription().getClientID(),
- subscriptionEvent.getData().getSubscription().getName());
+ cmSubscriptionNcmpInEvent.getData().getSubscription().getClientID(),
+ cmSubscriptionNcmpInEvent.getData().getSubscription().getName());
if (notificationFeatureEnabled) {
- subscriptionEventForwarder.forwardCreateSubscriptionEvent(subscriptionEvent, eventType);
+ cmSubscriptionNcmpInEventForwarder.forwardCreateSubscriptionEvent(cmSubscriptionNcmpInEvent,
+ eventType);
}
}
} else {
@@ -86,9 +88,9 @@ public class SubscriptionEventConsumer {
}
}
- private void persistSubscriptionEvent(final SubscriptionEvent subscriptionEvent) {
+ private void persistSubscriptionEvent(final CmSubscriptionNcmpInEvent cmSubscriptionNcmpInEvent) {
final YangModelSubscriptionEvent yangModelSubscriptionEvent =
- subscriptionEventMapper.toYangModelSubscriptionEvent(subscriptionEvent);
+ cmSubscriptionNcmpInEventMapper.toYangModelSubscriptionEvent(cmSubscriptionNcmpInEvent);
subscriptionPersistence.saveSubscriptionEvent(yangModelSubscriptionEvent);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventForwarder.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarder.java
index d3bfe81e82..4a174954ea 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventForwarder.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarder.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.avcsubscription;
+package org.onap.cps.ncmp.api.impl.events.cmsubscription;
import com.hazelcast.map.IMap;
import io.cloudevents.CloudEvent;
@@ -38,15 +38,16 @@ import org.onap.cps.ncmp.api.impl.config.embeddedcache.ForwardedSubscriptionEven
import org.onap.cps.ncmp.api.impl.events.EventsPublisher;
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.CmSubscriptionEventCloudMapper;
import org.onap.cps.ncmp.api.impl.utils.DmiServiceNameOrganizer;
-import org.onap.cps.ncmp.api.impl.utils.SubscriptionEventCloudMapper;
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.events.avcsubscription1_0_0.client_to_ncmp.SubscriptionEvent;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.Data;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionEventResponse;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_dmi.CmHandle;
+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;
import org.springframework.stereotype.Component;
@@ -54,15 +55,16 @@ import org.springframework.stereotype.Component;
@Component
@Slf4j
@RequiredArgsConstructor
-public class SubscriptionEventForwarder {
+public class CmSubscriptionNcmpInEventForwarder {
private final InventoryPersistence inventoryPersistence;
private final EventsPublisher<CloudEvent> eventsPublisher;
private final IMap<String, Set<String>> forwardedSubscriptionEventCache;
- private final SubscriptionEventResponseOutcome subscriptionEventResponseOutcome;
- private final SubscriptionEventMapper subscriptionEventMapper;
- private final SubscriptionEventCloudMapper subscriptionEventCloudMapper;
- private final ClientSubscriptionEventMapper clientSubscriptionEventMapper;
+ private final CmSubscriptionNcmpOutEventPublisher cmSubscriptionNcmpOutEventPublisher;
+ private final CmSubscriptionNcmpInEventMapper cmSubscriptionNcmpInEventMapper;
+ private final CmSubscriptionEventCloudMapper cmSubscriptionEventCloudMapper;
+ private final CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper
+ cmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper;
private final SubscriptionPersistence subscriptionPersistence;
private final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
@Value("${app.ncmp.avc.subscription-forward-topic-prefix}")
@@ -74,34 +76,36 @@ public class SubscriptionEventForwarder {
/**
* Forward subscription event.
*
- * @param subscriptionEvent the event to be forwarded
+ * @param cmSubscriptionNcmpInEvent the event to be forwarded
*/
- public void forwardCreateSubscriptionEvent(final SubscriptionEvent subscriptionEvent, final String eventType) {
- final List<String> cmHandleTargets = subscriptionEvent.getData().getPredicates().getTargets();
- if (cmHandleTargets == null || cmHandleTargets.isEmpty()
- || cmHandleTargets.stream().anyMatch(id -> (id).contains("*"))) {
+ public void forwardCreateSubscriptionEvent(final CmSubscriptionNcmpInEvent cmSubscriptionNcmpInEvent,
+ final String eventType) {
+ final List<String> cmHandleTargets = cmSubscriptionNcmpInEvent.getData().getPredicates().getTargets();
+ if (cmHandleTargets == null || cmHandleTargets.isEmpty() || cmHandleTargets.stream()
+ .anyMatch(id -> (id).contains("*"))) {
throw new UnsupportedOperationException(
"CMHandle targets are required. \"Wildcard\" operations are not yet supported");
}
final Collection<YangModelCmHandle> yangModelCmHandles =
inventoryPersistence.getYangModelCmHandles(cmHandleTargets);
- final Map<String, Map<String, Map<String, String>>> dmiPropertiesPerCmHandleIdPerServiceName
- = DmiServiceNameOrganizer.getDmiPropertiesPerCmHandleIdPerServiceName(yangModelCmHandles);
- findDmisAndRespond(subscriptionEvent, eventType, cmHandleTargets, dmiPropertiesPerCmHandleIdPerServiceName);
+ final Map<String, Map<String, Map<String, String>>> dmiPropertiesPerCmHandleIdPerServiceName =
+ DmiServiceNameOrganizer.getDmiPropertiesPerCmHandleIdPerServiceName(yangModelCmHandles);
+ findDmisAndRespond(cmSubscriptionNcmpInEvent, eventType, cmHandleTargets,
+ dmiPropertiesPerCmHandleIdPerServiceName);
}
- private void findDmisAndRespond(final SubscriptionEvent subscriptionEvent, final String eventType,
- final List<String> cmHandleTargetsAsStrings,
- final Map<String, Map<String, Map<String, String>>>
- dmiPropertiesPerCmHandleIdPerServiceName) {
- final SubscriptionEventResponse emptySubscriptionEventResponse =
- new SubscriptionEventResponse().withData(new Data());
- emptySubscriptionEventResponse.getData().setSubscriptionName(
- subscriptionEvent.getData().getSubscription().getName());
- emptySubscriptionEventResponse.getData().setClientId(
- subscriptionEvent.getData().getSubscription().getClientID());
- final List<String> cmHandlesThatExistsInDb = dmiPropertiesPerCmHandleIdPerServiceName.entrySet().stream()
- .map(Map.Entry::getValue).map(Map::keySet).flatMap(Set::stream).collect(Collectors.toList());
+ 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 List<String> cmHandlesThatExistsInDb =
+ dmiPropertiesPerCmHandleIdPerServiceName.entrySet().stream().map(Map.Entry::getValue).map(Map::keySet)
+ .flatMap(Set::stream).collect(Collectors.toList());
final List<String> targetCmHandlesDoesNotExistInDb = new ArrayList<>(cmHandleTargetsAsStrings);
targetCmHandlesDoesNotExistInDb.removeAll(cmHandlesThatExistsInDb);
@@ -109,37 +113,38 @@ public class SubscriptionEventForwarder {
final Set<String> dmisToRespond = new HashSet<>(dmiPropertiesPerCmHandleIdPerServiceName.keySet());
if (dmisToRespond.isEmpty() || !targetCmHandlesDoesNotExistInDb.isEmpty()) {
- updatesCmHandlesToRejectedAndPersistSubscriptionEvent(subscriptionEvent, targetCmHandlesDoesNotExistInDb);
+ updatesCmHandlesToRejectedAndPersistSubscriptionEvent(cmSubscriptionNcmpInEvent,
+ targetCmHandlesDoesNotExistInDb);
}
if (dmisToRespond.isEmpty()) {
- subscriptionEventResponseOutcome.sendResponse(emptySubscriptionEventResponse,
+ cmSubscriptionNcmpOutEventPublisher.sendResponse(emptyCmSubscriptionDmiOutEvent,
"subscriptionCreatedStatus");
} else {
- startResponseTimeout(emptySubscriptionEventResponse, dmisToRespond);
- final org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_dmi.SubscriptionEvent ncmpSubscriptionEvent =
- clientSubscriptionEventMapper.toNcmpSubscriptionEvent(subscriptionEvent);
- forwardEventToDmis(dmiPropertiesPerCmHandleIdPerServiceName, ncmpSubscriptionEvent, eventType);
+ startResponseTimeout(emptyCmSubscriptionDmiOutEvent, dmisToRespond);
+ final CmSubscriptionDmiInEvent cmSubscriptionDmiInEvent =
+ cmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper.toCmSubscriptionDmiInEvent(
+ cmSubscriptionNcmpInEvent);
+ forwardEventToDmis(dmiPropertiesPerCmHandleIdPerServiceName, cmSubscriptionDmiInEvent, eventType);
}
}
- private void startResponseTimeout(final SubscriptionEventResponse emptySubscriptionEventResponse,
+ private void startResponseTimeout(final CmSubscriptionDmiOutEvent emptyCmSubscriptionDmiOutEvent,
final Set<String> dmisToRespond) {
- final String subscriptionClientId = emptySubscriptionEventResponse.getData().getClientId();
- final String subscriptionName = emptySubscriptionEventResponse.getData().getSubscriptionName();
+ final String subscriptionClientId = emptyCmSubscriptionDmiOutEvent.getData().getClientId();
+ final String subscriptionName = emptyCmSubscriptionDmiOutEvent.getData().getSubscriptionName();
final String subscriptionEventId = subscriptionClientId + subscriptionName;
forwardedSubscriptionEventCache.put(subscriptionEventId, dmisToRespond,
ForwardedSubscriptionEventCacheConfig.SUBSCRIPTION_FORWARD_STARTED_TTL_SECS, TimeUnit.SECONDS);
final ResponseTimeoutTask responseTimeoutTask =
- new ResponseTimeoutTask(forwardedSubscriptionEventCache, subscriptionEventResponseOutcome,
- emptySubscriptionEventResponse);
+ new ResponseTimeoutTask(forwardedSubscriptionEventCache, cmSubscriptionNcmpOutEventPublisher,
+ emptyCmSubscriptionDmiOutEvent);
executorService.schedule(responseTimeoutTask, dmiResponseTimeoutInMs, TimeUnit.MILLISECONDS);
}
private void forwardEventToDmis(final Map<String, Map<String, Map<String, String>>> dmiNameCmHandleMap,
- final org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_dmi.SubscriptionEvent
- ncmpSubscriptionEvent, final String eventType) {
+ final CmSubscriptionDmiInEvent cmSubscriptionDmiInEvent, final String eventType) {
dmiNameCmHandleMap.forEach((dmiName, cmHandlePropertiesMap) -> {
final List<CmHandle> cmHandleTargets = cmHandlePropertiesMap.entrySet().stream().map(
cmHandleAndProperties -> {
@@ -149,34 +154,28 @@ public class SubscriptionEventForwarder {
return cmHandle;
}).collect(Collectors.toList());
- ncmpSubscriptionEvent.getData().getPredicates().setTargets(cmHandleTargets);
- final String eventKey = createEventKey(ncmpSubscriptionEvent, dmiName);
+ cmSubscriptionDmiInEvent.getData().getPredicates().setTargets(cmHandleTargets);
+ final String eventKey = createEventKey(cmSubscriptionDmiInEvent, dmiName);
final String dmiAvcSubscriptionTopic = dmiAvcSubscriptionTopicPrefix + dmiName;
- final CloudEvent ncmpSubscriptionCloudEvent =
- subscriptionEventCloudMapper.toCloudEvent(ncmpSubscriptionEvent, eventKey, eventType);
- eventsPublisher.publishCloudEvent(dmiAvcSubscriptionTopic, eventKey, ncmpSubscriptionCloudEvent);
+ final CloudEvent cmSubscriptionDmiInCloudEvent =
+ cmSubscriptionEventCloudMapper.toCloudEvent(cmSubscriptionDmiInEvent, eventKey, eventType);
+ eventsPublisher.publishCloudEvent(dmiAvcSubscriptionTopic, eventKey, cmSubscriptionDmiInCloudEvent);
});
}
- private String createEventKey(
- final org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_dmi.SubscriptionEvent subscriptionEvent,
- final String dmiName) {
- return subscriptionEvent.getData().getSubscription().getClientID()
- + "-"
- + subscriptionEvent.getData().getSubscription().getName()
- + "-"
- + dmiName;
+ private String createEventKey(final CmSubscriptionDmiInEvent cmSubscriptionDmiInEvent, final String dmiName) {
+ return cmSubscriptionDmiInEvent.getData().getSubscription().getClientID() + "-"
+ + cmSubscriptionDmiInEvent.getData().getSubscription().getName() + "-" + dmiName;
}
private void updatesCmHandlesToRejectedAndPersistSubscriptionEvent(
- final SubscriptionEvent subscriptionEvent,
+ final CmSubscriptionNcmpInEvent cmSubscriptionNcmpInEvent,
final List<String> targetCmHandlesDoesNotExistInDb) {
final YangModelSubscriptionEvent yangModelSubscriptionEvent =
- subscriptionEventMapper.toYangModelSubscriptionEvent(subscriptionEvent);
+ cmSubscriptionNcmpInEventMapper.toYangModelSubscriptionEvent(cmSubscriptionNcmpInEvent);
yangModelSubscriptionEvent.getPredicates()
- .setTargetCmHandles(findRejectedCmHandles(targetCmHandlesDoesNotExistInDb,
- yangModelSubscriptionEvent));
+ .setTargetCmHandles(findRejectedCmHandles(targetCmHandlesDoesNotExistInDb, yangModelSubscriptionEvent));
subscriptionPersistence.saveSubscriptionEvent(yangModelSubscriptionEvent);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventMapper.java
index 35d94cc7a2..ab93f13a2c 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventMapper.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventMapper.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.avcsubscription;
+package org.onap.cps.ncmp.api.impl.events.cmsubscription;
import java.util.List;
import java.util.stream.Collectors;
@@ -26,17 +26,17 @@ import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.client_to_ncmp.SubscriptionEvent;
+import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent;
@Mapper(componentModel = "spring")
-public interface SubscriptionEventMapper {
+public interface CmSubscriptionNcmpInEventMapper {
@Mapping(source = "data.subscription.clientID", target = "clientId")
@Mapping(source = "data.subscription.name", target = "subscriptionName")
@Mapping(source = "data.predicates.targets", target = "predicates.targetCmHandles",
qualifiedByName = "mapTargetsToCmHandleTargets")
@Mapping(source = "data.predicates.datastore", target = "predicates.datastore")
- YangModelSubscriptionEvent toYangModelSubscriptionEvent(SubscriptionEvent subscriptionEvent);
+ YangModelSubscriptionEvent toYangModelSubscriptionEvent(CmSubscriptionNcmpInEvent cmSubscriptionNcmpInEvent);
/**
* Maps list of Targets to list of TargetCmHandle.
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/ClientSubscriptionEventMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper.java
index 59b1d09c7b..f1c1664537 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/ClientSubscriptionEventMapper.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper.java
@@ -18,17 +18,18 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.avcsubscription;
+package org.onap.cps.ncmp.api.impl.events.cmsubscription;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.client_to_ncmp.SubscriptionEvent;
+import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent;
+import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_dmi.CmSubscriptionDmiInEvent;
@Mapper(componentModel = "spring")
-public interface ClientSubscriptionEventMapper {
+public interface CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper {
@Mapping(target = "data.predicates.targets", ignore = true)
- org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_dmi.SubscriptionEvent toNcmpSubscriptionEvent(
- SubscriptionEvent subscriptionEvent);
+ CmSubscriptionDmiInEvent toCmSubscriptionDmiInEvent(
+ CmSubscriptionNcmpInEvent cmSubscriptionNcmpInEvent);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseOutcome.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java
index 822ca55091..38cc724be0 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseOutcome.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.avcsubscription;
+package org.onap.cps.ncmp.api.impl.events.cmsubscription;
import io.cloudevents.CloudEvent;
import java.util.List;
@@ -32,21 +32,22 @@ 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.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionEventResponse;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_client.SubscriptionEventOutcome;
+import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent;
+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;
@Component
@Slf4j
@RequiredArgsConstructor
-public class SubscriptionEventResponseOutcome {
+public class CmSubscriptionNcmpOutEventPublisher {
private final SubscriptionPersistence subscriptionPersistence;
private final EventsPublisher<CloudEvent> outcomeEventsPublisher;
- private final SubscriptionOutcomeMapper subscriptionOutcomeMapper;
+ private final CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper
+ cmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper;
private final SubscriptionOutcomeCloudMapper subscriptionOutcomeCloudMapper;
@@ -56,43 +57,43 @@ public class SubscriptionEventResponseOutcome {
/**
* This is for construction of outcome message to be published for client apps.
*
- * @param subscriptionEventResponse event produced by Dmi Plugin
+ * @param cmSubscriptionDmiOutEvent event produced by Dmi Plugin
*/
- public void sendResponse(final SubscriptionEventResponse subscriptionEventResponse, final String eventKey) {
- final SubscriptionEventOutcome subscriptionEventOutcome =
- formSubscriptionOutcomeMessage(subscriptionEventResponse);
- final String subscriptionClientId = subscriptionEventResponse.getData().getClientId();
- final String subscriptionName = subscriptionEventResponse.getData().getSubscriptionName();
+ public void sendResponse(final CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent, final String eventKey) {
+ final CmSubscriptionNcmpOutEvent cmSubscriptionNcmpOutEvent =
+ formCmSubscriptionNcmpOutEvent(cmSubscriptionDmiOutEvent);
+ final String subscriptionClientId = cmSubscriptionDmiOutEvent.getData().getClientId();
+ final String subscriptionName = cmSubscriptionDmiOutEvent.getData().getSubscriptionName();
final String subscriptionEventId = subscriptionClientId + subscriptionName;
final CloudEvent subscriptionOutcomeCloudEvent =
- subscriptionOutcomeCloudMapper.toCloudEvent(subscriptionEventOutcome,
+ subscriptionOutcomeCloudMapper.toCloudEvent(cmSubscriptionNcmpOutEvent,
subscriptionEventId, eventKey);
outcomeEventsPublisher.publishCloudEvent(subscriptionOutcomeEventTopic,
subscriptionEventId, subscriptionOutcomeCloudEvent);
}
- private SubscriptionEventOutcome formSubscriptionOutcomeMessage(
- final SubscriptionEventResponse subscriptionEventResponse) {
+ private CmSubscriptionNcmpOutEvent formCmSubscriptionNcmpOutEvent(
+ final CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent) {
final Map<String, Map<String, String>> cmHandleIdToStatusAndDetailsAsMap =
DataNodeHelper.cmHandleIdToStatusAndDetailsAsMapFromDataNode(
- subscriptionPersistence.getCmHandlesForSubscriptionEvent(
- subscriptionEventResponse.getData().getClientId(),
- subscriptionEventResponse.getData().getSubscriptionName()));
- final List<org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionStatus>
- subscriptionStatusList = mapCmHandleIdStatusDetailsMapToSubscriptionStatusList(
- cmHandleIdToStatusAndDetailsAsMap);
- subscriptionEventResponse.getData().setSubscriptionStatus(subscriptionStatusList);
- return fromSubscriptionEventResponse(subscriptionEventResponse,
+ subscriptionPersistence.getCmHandlesForSubscriptionEvent(
+ cmSubscriptionDmiOutEvent.getData().getClientId(),
+ cmSubscriptionDmiOutEvent.getData().getSubscriptionName()));
+ final List<org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.SubscriptionStatus>
+ subscriptionStatusList =
+ mapCmHandleIdStatusDetailsMapToSubscriptionStatusList(cmHandleIdToStatusAndDetailsAsMap);
+ cmSubscriptionDmiOutEvent.getData().setSubscriptionStatus(subscriptionStatusList);
+ return fromDmiOutEvent(cmSubscriptionDmiOutEvent,
decideOnNcmpEventResponseCodeForSubscription(cmHandleIdToStatusAndDetailsAsMap));
}
- private static List<org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionStatus>
+ private static List<org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.SubscriptionStatus>
mapCmHandleIdStatusDetailsMapToSubscriptionStatusList(
final Map<String, Map<String, String>> cmHandleIdToStatusAndDetailsAsMap) {
return cmHandleIdToStatusAndDetailsAsMap.entrySet()
.stream().map(entryset -> {
- final org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionStatus
- subscriptionStatus = new org.onap.cps.ncmp.events.avcsubscription1_0_0
+ 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 String cmHandleId = entryset.getKey();
final Map<String, String> statusAndDetailsMap = entryset.getValue();
@@ -100,7 +101,7 @@ public class SubscriptionEventResponseOutcome {
final String details = statusAndDetailsMap.get("details");
subscriptionStatus.setId(cmHandleId);
subscriptionStatus.setStatus(
- org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp
+ org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp
.SubscriptionStatus.Status.fromValue(status));
subscriptionStatus.setDetails(details);
return subscriptionStatus;
@@ -137,15 +138,16 @@ public class SubscriptionEventResponseOutcome {
.allMatch(entryset -> entryset.containsValue(subscriptionStatus.toString()));
}
- private SubscriptionEventOutcome fromSubscriptionEventResponse(
- final SubscriptionEventResponse subscriptionEventResponse,
+ private CmSubscriptionNcmpOutEvent fromDmiOutEvent(
+ final CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent,
final NcmpEventResponseCode ncmpEventResponseCode) {
- final SubscriptionEventOutcome subscriptionEventOutcome =
- subscriptionOutcomeMapper.toSubscriptionEventOutcome(subscriptionEventResponse);
- subscriptionEventOutcome.getData().setStatusCode(Integer.parseInt(ncmpEventResponseCode.getStatusCode()));
- subscriptionEventOutcome.getData().setStatusMessage(ncmpEventResponseCode.getStatusMessage());
+ final CmSubscriptionNcmpOutEvent cmSubscriptionNcmpOutEvent =
+ cmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper.toCmSubscriptionNcmpOutEvent(
+ cmSubscriptionDmiOutEvent);
+ cmSubscriptionNcmpOutEvent.getData().setStatusCode(Integer.parseInt(ncmpEventResponseCode.getStatusCode()));
+ cmSubscriptionNcmpOutEvent.getData().setStatusMessage(ncmpEventResponseCode.getStatusMessage());
- return subscriptionEventOutcome;
+ return cmSubscriptionNcmpOutEvent;
}
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/ResponseTimeoutTask.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/ResponseTimeoutTask.java
index e3f529787a..7f8cbf676e 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/avcsubscription/ResponseTimeoutTask.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/ResponseTimeoutTask.java
@@ -18,21 +18,21 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.avcsubscription;
+package org.onap.cps.ncmp.api.impl.events.cmsubscription;
import com.hazelcast.map.IMap;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionEventResponse;
+import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent;
@Slf4j
@RequiredArgsConstructor
public class ResponseTimeoutTask implements Runnable {
private final IMap<String, Set<String>> forwardedSubscriptionEventCache;
- private final SubscriptionEventResponseOutcome subscriptionEventResponseOutcome;
- private final SubscriptionEventResponse subscriptionEventResponse;
+ private final CmSubscriptionNcmpOutEventPublisher cmSubscriptionNcmpOutEventPublisher;
+ private final CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent;
@Override
public void run() {
@@ -40,11 +40,11 @@ public class ResponseTimeoutTask implements Runnable {
}
private void generateTimeoutResponse() {
- final String subscriptionClientId = subscriptionEventResponse.getData().getClientId();
- final String subscriptionName = subscriptionEventResponse.getData().getSubscriptionName();
+ final String subscriptionClientId = cmSubscriptionDmiOutEvent.getData().getClientId();
+ final String subscriptionName = cmSubscriptionDmiOutEvent.getData().getSubscriptionName();
final String subscriptionEventId = subscriptionClientId + subscriptionName;
if (forwardedSubscriptionEventCache.containsKey(subscriptionEventId)) {
- subscriptionEventResponseOutcome.sendResponse(subscriptionEventResponse,
+ cmSubscriptionNcmpOutEventPublisher.sendResponse(cmSubscriptionDmiOutEvent,
"subscriptionCreatedStatus");
forwardedSubscriptionEventCache.remove(subscriptionEventId);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventCloudMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/CmSubscriptionEventCloudMapper.java
index 1561edc448..5bc38e1dcd 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventCloudMapper.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/CmSubscriptionEventCloudMapper.java
@@ -31,57 +31,53 @@ import java.net.URI;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.client_to_ncmp.SubscriptionEvent;
+import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent;
+import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_dmi.CmSubscriptionDmiInEvent;
import org.springframework.stereotype.Component;
@Slf4j
@Component
@RequiredArgsConstructor
-public class SubscriptionEventCloudMapper {
+public class CmSubscriptionEventCloudMapper {
private final ObjectMapper objectMapper;
private static String randomId = UUID.randomUUID().toString();
/**
- * Maps CloudEvent object to SubscriptionEvent.
+ * Maps CloudEvent object to CmSubscriptionNcmpInEvent.
*
* @param cloudEvent object.
- * @return SubscriptionEvent deserialized.
+ * @return CmSubscriptionNcmpInEvent deserialized.
*/
- public SubscriptionEvent toSubscriptionEvent(final CloudEvent cloudEvent) {
- final PojoCloudEventData<SubscriptionEvent> deserializedCloudEvent = CloudEventUtils
- .mapData(cloudEvent, PojoCloudEventDataMapper.from(objectMapper, SubscriptionEvent.class));
+ public CmSubscriptionNcmpInEvent toCmSubscriptionNcmpInEvent(final CloudEvent cloudEvent) {
+ final PojoCloudEventData<CmSubscriptionNcmpInEvent> deserializedCloudEvent = CloudEventUtils
+ .mapData(cloudEvent, PojoCloudEventDataMapper.from(objectMapper, CmSubscriptionNcmpInEvent.class));
if (deserializedCloudEvent == null) {
log.debug("No data found in the consumed event");
return null;
} else {
- final SubscriptionEvent subscriptionEvent = deserializedCloudEvent.getValue();
- log.debug("Consuming event {}", subscriptionEvent);
- return subscriptionEvent;
+ final CmSubscriptionNcmpInEvent cmSubscriptionNcmpInEvent = deserializedCloudEvent.getValue();
+ log.debug("Consuming event {}", cmSubscriptionNcmpInEvent);
+ return cmSubscriptionNcmpInEvent;
}
}
/**
- * Maps SubscriptionEvent to a CloudEvent.
+ * Maps CmSubscriptionDmiInEvent to a CloudEvent.
*
- * @param ncmpSubscriptionEvent object.
+ * @param cmSubscriptionDmiInEvent object.
* @param eventKey as String.
* @return CloudEvent built.
*/
- public CloudEvent toCloudEvent(
- final org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_dmi.SubscriptionEvent ncmpSubscriptionEvent,
- final String eventKey, final String eventType) {
+ public CloudEvent toCloudEvent(final CmSubscriptionDmiInEvent cmSubscriptionDmiInEvent, final String eventKey,
+ final String eventType) {
try {
- return CloudEventBuilder.v1()
- .withId(randomId)
- .withSource(URI.create(ncmpSubscriptionEvent.getData().getSubscription().getClientID()))
- .withType(eventType)
- .withExtension("correlationid", eventKey)
- .withDataSchema(URI.create("urn:cps:"
- + org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_dmi
- .SubscriptionEvent.class.getName() + ":1.0.0"))
- .withData(objectMapper.writeValueAsBytes(ncmpSubscriptionEvent)).build();
+ return CloudEventBuilder.v1().withId(randomId)
+ .withSource(URI.create(cmSubscriptionDmiInEvent.getData().getSubscription().getClientID()))
+ .withType(eventType).withExtension("correlationid", eventKey)
+ .withDataSchema(URI.create("urn:cps:" + CmSubscriptionDmiInEvent.class.getName() + ":1.0.0"))
+ .withData(objectMapper.writeValueAsBytes(cmSubscriptionDmiInEvent)).build();
} catch (final JsonProcessingException jsonProcessingException) {
log.error("The Cloud Event could not be constructed", jsonProcessingException);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventResponseCloudMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventResponseCloudMapper.java
index e00bb16b93..0721d1d569 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventResponseCloudMapper.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventResponseCloudMapper.java
@@ -27,7 +27,7 @@ import io.cloudevents.core.data.PojoCloudEventData;
import io.cloudevents.jackson.PojoCloudEventDataMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionEventResponse;
+import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent;
import org.springframework.stereotype.Component;
@Slf4j
@@ -38,21 +38,21 @@ public class SubscriptionEventResponseCloudMapper {
private final ObjectMapper objectMapper;
/**
- * Maps CloudEvent object to SubscriptionEventResponse.
+ * Maps CloudEvent object to CmSubscriptionDmiOutEvent.
*
* @param cloudEvent object
- * @return SubscriptionEventResponse deserialized
+ * @return CmSubscriptionDmiOutEvent deserialized
*/
- public SubscriptionEventResponse toSubscriptionEventResponse(final CloudEvent cloudEvent) {
- final PojoCloudEventData<SubscriptionEventResponse> deserializedCloudEvent = CloudEventUtils
- .mapData(cloudEvent, PojoCloudEventDataMapper.from(objectMapper, SubscriptionEventResponse.class));
+ public CmSubscriptionDmiOutEvent toCmSubscriptionDmiOutEvent(final CloudEvent cloudEvent) {
+ final PojoCloudEventData<CmSubscriptionDmiOutEvent> deserializedCloudEvent = CloudEventUtils
+ .mapData(cloudEvent, PojoCloudEventDataMapper.from(objectMapper, CmSubscriptionDmiOutEvent.class));
if (deserializedCloudEvent == null) {
log.debug("No data found in the consumed subscription response event");
return null;
} else {
- final SubscriptionEventResponse subscriptionEventResponse = deserializedCloudEvent.getValue();
- log.debug("Consuming subscription response event {}", subscriptionEventResponse);
- return subscriptionEventResponse;
+ final CmSubscriptionDmiOutEvent cmSubscriptionDmiOutEvent = deserializedCloudEvent.getValue();
+ log.debug("Consuming subscription response event {}", cmSubscriptionDmiOutEvent);
+ return cmSubscriptionDmiOutEvent;
}
}
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/SubscriptionOutcomeCloudMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/SubscriptionOutcomeCloudMapper.java
index 9ea4487063..af629a6bd1 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/SubscriptionOutcomeCloudMapper.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/SubscriptionOutcomeCloudMapper.java
@@ -28,7 +28,7 @@ import java.net.URI;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_client.SubscriptionEventOutcome;
+import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_client.CmSubscriptionNcmpOutEvent;
import org.springframework.stereotype.Component;
@Slf4j
@@ -41,12 +41,12 @@ public class SubscriptionOutcomeCloudMapper {
private static String randomId = UUID.randomUUID().toString();
/**
- * Maps SubscriptionEventOutcome to a CloudEvent.
+ * Maps CmSubscriptionNcmpOutEvent to a CloudEvent.
*
- * @param subscriptionEventOutcome object
+ * @param cmSubscriptionNcmpOutEvent object
* @return CloudEvent
*/
- public CloudEvent toCloudEvent(final SubscriptionEventOutcome subscriptionEventOutcome,
+ public CloudEvent toCloudEvent(final CmSubscriptionNcmpOutEvent cmSubscriptionNcmpOutEvent,
final String eventKey, final String eventType) {
try {
return CloudEventBuilder.v1()
@@ -54,8 +54,8 @@ public class SubscriptionOutcomeCloudMapper {
.withSource(URI.create("NCMP"))
.withType(eventType)
.withExtension("correlationid", eventKey)
- .withDataSchema(URI.create("urn:cps:" + SubscriptionEventOutcome.class.getName() + ":1.0.0"))
- .withData(objectMapper.writeValueAsBytes(subscriptionEventOutcome)).build();
+ .withDataSchema(URI.create("urn:cps:" + CmSubscriptionNcmpOutEvent.class.getName() + ":1.0.0"))
+ .withData(objectMapper.writeValueAsBytes(cmSubscriptionNcmpOutEvent)).build();
} catch (final JsonProcessingException jsonProcessingException) {
log.error("The Cloud Event could not be constructed", jsonProcessingException);
}