summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java/org/onap
diff options
context:
space:
mode:
authormpriyank <priyank.maheshwari@est.tech>2022-07-11 12:15:55 +0100
committermpriyank <priyank.maheshwari@est.tech>2022-07-14 09:05:31 +0100
commita6fa6c368f04c85bf553fce2cf89d25ec366116e (patch)
treecc69b8995470a7c4af0eaf4ce2a830ffea98b5a2 /cps-ncmp-service/src/main/java/org/onap
parent97c875cf3fea520563e1819209ab826f8c03fd5e (diff)
Code Refactoring Ncmp* to Lcm* as per new scope
- Refactored code to reflect the LcmEvents scope now. - Test cases updated and dependencies reviewed. - You can find few occurences of NcmpEvent for now but that will be cleaned up once we implement CPS-1104 which is for LcmEvent schema - UPCOMING: LcmEvent schema and then the code to publish the events on cmHandleStates - LATER : LcmEvents based on public properties update. Issue-ID: CPS-1137 Change-Id: I9f395ed733b4028e706205894c36a38412e3452e Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/main/java/org/onap')
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java4
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCmHandleStateHandler.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCmHandleStateHandler.java)6
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCmHandleStateHandlerImpl.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCmHandleStateHandlerImpl.java)24
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCreator.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCreator.java)20
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsPublisher.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsPublisher.java)16
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsService.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsService.java)12
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java10
7 files changed, 44 insertions, 48 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
index d827d465c0..16b9a66f4e 100755
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
@@ -290,9 +290,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
private CmHandleRegistrationResponse registerNewCmHandle(final YangModelCmHandle yangModelCmHandle) {
try {
- final String cmHandleJsonData = String.format("{\"cm-handles\":[%s]}",
- jsonObjectMapper.asJsonString(yangModelCmHandle));
- inventoryPersistence.saveListElements(cmHandleJsonData);
+ inventoryPersistence.saveCmHandle(yangModelCmHandle);
return CmHandleRegistrationResponse.createSuccessResponse(yangModelCmHandle.getId());
} catch (final AlreadyDefinedException alreadyDefinedException) {
return CmHandleRegistrationResponse.createFailureResponse(
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCmHandleStateHandler.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCmHandleStateHandler.java
index 7728b5f92d..8cab19405e 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCmHandleStateHandler.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCmHandleStateHandler.java
@@ -18,16 +18,16 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.event;
+package org.onap.cps.ncmp.api.impl.event.lcm;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
import org.onap.cps.ncmp.api.inventory.CmHandleState;
/**
* The implementation of it should handle the persisting of composite state and delegate the request to publish the
- * corresponding ncmp event.
+ * corresponding lcm event.
*/
-public interface NcmpEventsCmHandleStateHandler {
+public interface LcmEventsCmHandleStateHandler {
/**
* Updates the composite state of cmHandle based on cmHandleState.
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCmHandleStateHandlerImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCmHandleStateHandlerImpl.java
index 26a1c5bab9..111d5dcd58 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCmHandleStateHandlerImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCmHandleStateHandlerImpl.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.event;
+package org.onap.cps.ncmp.api.impl.event.lcm;
import static org.onap.cps.ncmp.api.inventory.CmHandleState.ADVISED;
import static org.onap.cps.ncmp.api.inventory.CmHandleState.LOCKED;
@@ -32,7 +32,6 @@ import org.onap.cps.ncmp.api.inventory.CmHandleState;
import org.onap.cps.ncmp.api.inventory.CompositeStateUtils;
import org.onap.cps.ncmp.api.inventory.InventoryPersistence;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
-import org.onap.cps.utils.JsonObjectMapper;
import org.onap.ncmp.cmhandle.lcm.event.NcmpEvent;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -40,12 +39,11 @@ import org.springframework.stereotype.Service;
@Slf4j
@Service
@RequiredArgsConstructor
-public class NcmpEventsCmHandleStateHandlerImpl implements NcmpEventsCmHandleStateHandler {
+public class LcmEventsCmHandleStateHandlerImpl implements LcmEventsCmHandleStateHandler {
private final InventoryPersistence inventoryPersistence;
- private final NcmpEventsCreator ncmpEventsCreator;
- private final JsonObjectMapper jsonObjectMapper;
- private final NcmpEventsService ncmpEventsService;
+ private final LcmEventsCreator lcmEventsCreator;
+ private final LcmEventsService lcmEventsService;
@Value("${data-sync.cache.enabled:false}")
private boolean isGlobalDataSyncCacheEnabled;
@@ -59,7 +57,7 @@ public class NcmpEventsCmHandleStateHandlerImpl implements NcmpEventsCmHandleSta
log.debug("CmHandle with id : {} already in state : {}", yangModelCmHandle.getId(), targetCmHandleState);
} else {
updateToSpecifiedCmHandleState(yangModelCmHandle, targetCmHandleState);
- publishNcmpEvent(yangModelCmHandle);
+ publishLcmEvent(yangModelCmHandle);
}
}
@@ -85,22 +83,20 @@ public class NcmpEventsCmHandleStateHandlerImpl implements NcmpEventsCmHandleSta
}
private void retryCmHandle(final YangModelCmHandle yangModelCmHandle) {
- CompositeStateUtils.setCompositeStateForRetry()
- .accept(yangModelCmHandle.getCompositeState());
+ CompositeStateUtils.setCompositeStateForRetry().accept(yangModelCmHandle.getCompositeState());
inventoryPersistence.saveCmHandleState(yangModelCmHandle.getId(), yangModelCmHandle.getCompositeState());
}
private void registerNewCmHandle(final YangModelCmHandle yangModelCmHandle) {
CompositeStateUtils.setCompositeState(ADVISED).accept(yangModelCmHandle.getCompositeState());
- inventoryPersistence.saveListElements(
- String.format("{\"cm-handles\":[%s]}", jsonObjectMapper.asJsonString(yangModelCmHandle)));
+ inventoryPersistence.saveCmHandle(yangModelCmHandle);
}
- private void publishNcmpEvent(final YangModelCmHandle yangModelCmHandle) {
+ private void publishLcmEvent(final YangModelCmHandle yangModelCmHandle) {
final NcmpServiceCmHandle ncmpServiceCmHandle =
YangDataConverter.convertYangModelCmHandleToNcmpServiceCmHandle(yangModelCmHandle);
final String cmHandleId = ncmpServiceCmHandle.getCmHandleId();
- final NcmpEvent ncmpEvent = ncmpEventsCreator.populateNcmpEvent(cmHandleId, ncmpServiceCmHandle);
- ncmpEventsService.publishNcmpEvent(cmHandleId, ncmpEvent);
+ final NcmpEvent ncmpEvent = lcmEventsCreator.populateLcmEvent(cmHandleId, ncmpServiceCmHandle);
+ lcmEventsService.publishLcmEvent(cmHandleId, ncmpEvent);
}
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCreator.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCreator.java
index df41eba8bd..783b299511 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsCreator.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsCreator.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.event;
+package org.onap.cps.ncmp.api.impl.event.lcm;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
@@ -32,11 +32,11 @@ import org.springframework.stereotype.Component;
/**
- * NcmpEventsCreator to create NcmpEvent based on relevant operation.
+ * LcmEventsCreator to create LcmEvent based on relevant operation.
*/
@Slf4j
@Component
-public class NcmpEventsCreator {
+public class LcmEventsCreator {
/**
@@ -46,17 +46,17 @@ public class NcmpEventsCreator {
* @param ncmpServiceCmHandle Ncmp CmHandle Data
* @return Populated NcmpEvent
*/
- public NcmpEvent populateNcmpEvent(final String cmHandleId, final NcmpServiceCmHandle ncmpServiceCmHandle) {
- return createNcmpEvent(cmHandleId, ncmpServiceCmHandle);
+ public NcmpEvent populateLcmEvent(final String cmHandleId, final NcmpServiceCmHandle ncmpServiceCmHandle) {
+ return createLcmEvent(cmHandleId, ncmpServiceCmHandle);
}
- private NcmpEvent createNcmpEvent(final String cmHandleId, final NcmpServiceCmHandle ncmpServiceCmHandle) {
- final NcmpEvent ncmpEvent = ncmpEventHeader(cmHandleId);
- ncmpEvent.setEvent(ncmpEventPayload(cmHandleId, ncmpServiceCmHandle));
+ private NcmpEvent createLcmEvent(final String cmHandleId, final NcmpServiceCmHandle ncmpServiceCmHandle) {
+ final NcmpEvent ncmpEvent = lcmEventHeader(cmHandleId);
+ ncmpEvent.setEvent(lcmEventPayload(cmHandleId, ncmpServiceCmHandle));
return ncmpEvent;
}
- private Event ncmpEventPayload(final String eventCorrelationId, final NcmpServiceCmHandle ncmpServiceCmHandle) {
+ private Event lcmEventPayload(final String eventCorrelationId, final NcmpServiceCmHandle ncmpServiceCmHandle) {
final Event event = new Event();
event.setCmHandleId(eventCorrelationId);
event.setCmhandleState(
@@ -65,7 +65,7 @@ public class NcmpEventsCreator {
return event;
}
- private NcmpEvent ncmpEventHeader(final String eventCorrelationId) {
+ private NcmpEvent lcmEventHeader(final String eventCorrelationId) {
final NcmpEvent ncmpEvent = new NcmpEvent();
ncmpEvent.setEventId(UUID.randomUUID().toString());
ncmpEvent.setEventCorrelationId(eventCorrelationId);
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsPublisher.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsPublisher.java
index 52ac4685e2..2a946b1008 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsPublisher.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsPublisher.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.event;
+package org.onap.cps.ncmp.api.impl.event.lcm;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -30,28 +30,28 @@ import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
/**
- * NcmpEventsPublisher to publish the NcmpEvents on event of CREATE, UPDATE and DELETE.
+ * LcmEventsPublisher to publish the LcmEvents on event of CREATE, UPDATE and DELETE.
*/
@Slf4j
@Service
@RequiredArgsConstructor
-public class NcmpEventsPublisher {
+public class LcmEventsPublisher {
- private final KafkaTemplate<String, NcmpEvent> ncmpEventKafkaTemplate;
+ private final KafkaTemplate<String, NcmpEvent> lcmEventKafkaTemplate;
/**
- * NCMP Event publisher.
+ * LCM Event publisher.
*
* @param topicName valid topic name
* @param eventKey message key
* @param ncmpEvent message payload
*/
public void publishEvent(final String topicName, final String eventKey, final NcmpEvent ncmpEvent) {
- final ListenableFuture<SendResult<String, NcmpEvent>> ncmpEventFuture =
- ncmpEventKafkaTemplate.send(topicName, eventKey, ncmpEvent);
+ final ListenableFuture<SendResult<String, NcmpEvent>> lcmEventFuture =
+ lcmEventKafkaTemplate.send(topicName, eventKey, ncmpEvent);
- ncmpEventFuture.addCallback(new ListenableFutureCallback<>() {
+ lcmEventFuture.addCallback(new ListenableFutureCallback<>() {
@Override
public void onFailure(final Throwable throwable) {
log.error("Unable to publish event to topic : {} due to {}", topicName, throwable.getMessage());
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsService.java
index 5e02e0d94f..d9c9b9a1ce 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/NcmpEventsService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/event/lcm/LcmEventsService.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.event;
+package org.onap.cps.ncmp.api.impl.event.lcm;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -33,11 +33,11 @@ import org.springframework.stereotype.Service;
@Slf4j
@Service
@RequiredArgsConstructor
-public class NcmpEventsService {
+public class LcmEventsService {
- private final NcmpEventsPublisher ncmpEventsPublisher;
+ private final LcmEventsPublisher lcmEventsPublisher;
- @Value("${app.ncmp.events.topic:ncmp-events}")
+ @Value("${app.lcm.events.topic:ncmp-events}")
private String topicName;
@Value("${notification.enabled:true}")
@@ -49,9 +49,9 @@ public class NcmpEventsService {
* @param cmHandleId Cm Handle Id
* @param ncmpEvent Ncmp Event
*/
- public void publishNcmpEvent(final String cmHandleId, final NcmpEvent ncmpEvent) {
+ public void publishLcmEvent(final String cmHandleId, final NcmpEvent ncmpEvent) {
if (notificationsEnabled) {
- ncmpEventsPublisher.publishEvent(topicName, cmHandleId, ncmpEvent);
+ lcmEventsPublisher.publishEvent(topicName, cmHandleId, ncmpEvent);
} else {
log.debug("Notifications disabled.");
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java
index af01fb4398..be26a58d58 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java
@@ -182,13 +182,15 @@ public class InventoryPersistence {
}
/**
- * Method to save list elements.
+ * Method to save cmHandle.
*
- * @param cmHandleJsonData cmHandle JSON data
+ * @param yangModelCmHandle cmHandle represented as Yang Model
*/
- public void saveListElements(final String cmHandleJsonData) {
+ public void saveCmHandle(final YangModelCmHandle yangModelCmHandle) {
+ final String cmHandleJsonData =
+ String.format("{\"cm-handles\":[%s]}", jsonObjectMapper.asJsonString(yangModelCmHandle));
cpsDataService.saveListElements(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, NCMP_DMI_REGISTRY_PARENT,
- cmHandleJsonData, NO_TIMESTAMP);
+ cmHandleJsonData, NO_TIMESTAMP);
}
/**