[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-be / lib / openecomp-sdc-vendor-license-lib / openecomp-sdc-vendor-license-core / src / main / java / org / openecomp / sdc / vendorlicense / healing / impl / SimpleHealingServiceImpl.java
index 8f8f34e..eeed3b0 100644 (file)
 
 package org.openecomp.sdc.vendorlicense.healing.impl;
 
+import org.openecomp.sdc.common.utils.CommonUtil;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerErrorDescription;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
 import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
 import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
 import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
@@ -29,11 +37,14 @@ import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
 import org.openecomp.sdc.vendorlicense.healing.HealingService;
 import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
 
+import java.util.UUID;
+
 public class SimpleHealingServiceImpl implements HealingService {
   private static final EntitlementPoolDao entitlementPoolDao =
       EntitlementPoolDaoFactory.getInstance().createInterface();
   private static final LicenseKeyGroupDao licenseKeyGroupDao =
       LicenseKeyGroupDaoFactory.getInstance().createInterface();
+  private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
 
   @Override
   public VersionableEntity heal(VersionableEntity toHeal, String user) {
@@ -41,23 +52,30 @@ public class SimpleHealingServiceImpl implements HealingService {
   }
 
   private VersionableEntity handleMissingVersionId(VersionableEntity toHeal, String user) {
-    if (toHeal.getVersionUuId() != null) {
+
+
+    mdcDataDebugMessage.debugEntryMessage(null, null);
+
+    if (toHeal != null && toHeal.getVersionUuId() != null) {
       return toHeal;
     }
 
-
     if (toHeal instanceof EntitlementPoolEntity) {
-      toHeal.setVersionUuId(toHeal.getId());
+      toHeal.setVersionUuId(UUID.randomUUID().toString());
       entitlementPoolDao.update((EntitlementPoolEntity) toHeal);
     } else if (toHeal instanceof LicenseKeyGroupEntity) {
-      toHeal.setVersionUuId(toHeal.getId());
+      toHeal.setVersionUuId(UUID.randomUUID().toString());
       licenseKeyGroupDao.update((LicenseKeyGroupEntity) toHeal);
     } else {
+      MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+          LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(),
+          LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION);
       throw new UnsupportedOperationException(
           "Unsupported operation for 1610 release/1607->1610 migration.");
       //todo maybe errorbuilder?
     }
+
+    mdcDataDebugMessage.debugExitMessage(null, null);
     return toHeal;
   }
-
 }