diff options
Diffstat (limited to 'cps-ncmp-service/src/main/java/org')
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) { |