summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service/src/main/java')
-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 402f9f6b4f..9383ac1ef7 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
@@ -53,6 +53,7 @@ public class ModuleSyncWatchdog {
final String cmHandleId = advisedCmHandle.getId();
final CompositeState compositeState = inventoryPersistence.getCmHandleState(cmHandleId);
try {
+ moduleSyncService.deleteSchemaSetIfExists(advisedCmHandle);
moduleSyncService.syncAndCreateSchemaSetAndAnchor(advisedCmHandle);
compositeState.setCmHandleState(CmHandleState.READY);
} catch (final Exception e) {