summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2022-07-01 08:08:14 +0000
committerGerrit Code Review <gerrit@onap.org>2022-07-01 08:08:14 +0000
commitb93d6df7f4304580e0f2029cbd449ba863d1ef02 (patch)
treeaf89db00274084686b4e4d695aa7ad0afd48cc72 /cps-ncmp-service/src/main
parent79dc74fd69086cf9937ed06241fed9a2772b0fba (diff)
parent884a5a0e8bf08cc47e0e0dbd7e20558212ca82b1 (diff)
Merge "Allow Module Re-Sync"
Diffstat (limited to 'cps-ncmp-service/src/main')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncService.java19
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java1
2 files changed, 20 insertions, 0 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncService.java
index 58e2bf3450..c574aa61d9 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncService.java
@@ -32,6 +32,8 @@ import org.onap.cps.api.CpsAdminService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.ncmp.api.impl.operations.DmiModelOperations;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
+import org.onap.cps.spi.CascadeDeleteAllowed;
+import org.onap.cps.spi.exceptions.SchemaSetNotFoundException;
import org.onap.cps.spi.model.ModuleReference;
import org.springframework.stereotype.Service;
@@ -83,4 +85,21 @@ public class ModuleSyncService {
schemaSetAndAnchorName);
}
+ /**
+ * Deletes the SchemaSet for provided cmHandle if the SchemaSet Exists.
+ *
+ * @param yangModelCmHandle the yang model of cm handle.
+ */
+ public void deleteSchemaSetIfExists(final YangModelCmHandle yangModelCmHandle) {
+ final String schemaSetAndAnchorName = yangModelCmHandle.getId();
+ try {
+ cpsModuleService.deleteSchemaSet(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, schemaSetAndAnchorName,
+ CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED);
+ log.debug("SchemaSet for {} has been deleted. Ready to be recreated.", schemaSetAndAnchorName);
+ } catch (final SchemaSetNotFoundException e) {
+ log.debug("No SchemaSet for {}. Assuming CmHandle has not been previously Module Synced.",
+ schemaSetAndAnchorName);
+ }
+ }
+
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java
index ac53d881c1..6ec44197d2 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java
@@ -55,6 +55,7 @@ public class ModuleSyncWatchdog {
final String cmHandleId = advisedCmHandle.getId();
final CompositeState compositeState = inventoryPersistence.getCmHandleState(cmHandleId);
try {
+ moduleSyncService.deleteSchemaSetIfExists(advisedCmHandle);
moduleSyncService.syncAndCreateSchemaSetAndAnchor(advisedCmHandle);
setCompositeStateToReadyWithInitialDataStoreSyncState().accept(compositeState);
} catch (final Exception e) {