diff options
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java')
2 files changed, 264 insertions, 133 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java index dbe786a44b..aa9fc0a8cd 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.vendorlicense; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel; import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel; @@ -68,25 +69,21 @@ public interface VendorLicenseManager { LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version, String licenseAgreementId, String user); - void deleteLicenseAgreement(String vlmId, String licenseAgreementId, String user); + void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId, String user); - Collection<org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity> listFeatureGroups( - String vlmId, Version version, String user); + Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version, String user); - org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity createFeatureGroup( - org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity fg, String user); + FeatureGroupEntity createFeatureGroup(FeatureGroupEntity fg, String user); - void updateFeatureGroup(org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity featureGroup, + void updateFeatureGroup(FeatureGroupEntity featureGroup, Set<String> addedLicenseKeyGroups, Set<String> removedLicenseKeyGroups, Set<String> addedEntitlementPools, Set<String> removedEntitlementPools, String user); - FeatureGroupModel getFeatureGroupModel( - org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity featureGroup, String user); + FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user); - void deleteFeatureGroup(org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity featureGroup, - String user); + void deleteFeatureGroup(FeatureGroupEntity featureGroup, String user); Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version, diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java index b0b088c774..451415c5ea 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java @@ -20,22 +20,31 @@ package org.openecomp.sdc.vendorlicense.impl; -import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants - .VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE; - import org.openecomp.core.util.UniqueValueUtil; +import org.openecomp.sdc.activityLog.ActivityLogManager; +import org.openecomp.sdc.activityLog.ActivityLogManagerFactory; +import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; +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.VendorLicenseConstants; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao; import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory; import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao; import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory; +import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao; import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory; import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao; import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory; import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao; import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel; import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel; @@ -45,76 +54,109 @@ import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade; import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory; import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel; import org.openecomp.sdc.versioning.VersioningManager; +import org.openecomp.sdc.versioning.VersioningManagerFactory; import org.openecomp.sdc.versioning.VersioningUtil; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.dao.types.VersionStatus; import org.openecomp.sdc.versioning.types.VersionInfo; import org.openecomp.sdc.versioning.types.VersionableEntityAction; +import org.openecomp.sdcrests.activitylog.types.ActivityType; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Set; -public class VendorLicenseManagerImpl implements VendorLicenseManager { +import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE; +public class VendorLicenseManagerImpl implements VendorLicenseManager { private static final VersioningManager versioningManager = - org.openecomp.sdc.versioning.VersioningManagerFactory.getInstance().createInterface(); + VersioningManagerFactory.getInstance().createInterface(); private static final VendorLicenseFacade vendorLicenseFacade = VendorLicenseFacadeFactory.getInstance().createInterface(); - - private static final VendorLicenseModelDao - vendorLicenseModelDao = VendorLicenseModelDaoFactory.getInstance().createInterface(); - private static final org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao - licenseAgreementDao = LicenseAgreementDaoFactory.getInstance().createInterface(); + private static final VendorLicenseModelDao vendorLicenseModelDao = + VendorLicenseModelDaoFactory.getInstance().createInterface(); + private static final LicenseAgreementDao licenseAgreementDao = + LicenseAgreementDaoFactory.getInstance().createInterface(); private static final FeatureGroupDao featureGroupDao = FeatureGroupDaoFactory.getInstance().createInterface(); - private static final EntitlementPoolDao - entitlementPoolDao = EntitlementPoolDaoFactory.getInstance().createInterface(); - private static final LicenseKeyGroupDao - licenseKeyGroupDao = LicenseKeyGroupDaoFactory.getInstance().createInterface(); + private static final EntitlementPoolDao entitlementPoolDao = + EntitlementPoolDaoFactory.getInstance().createInterface(); + private static final LicenseKeyGroupDao licenseKeyGroupDao = + LicenseKeyGroupDaoFactory.getInstance().createInterface(); + private ActivityLogManager activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); private static void sortVlmListByModificationTimeDescOrder( List<VersionedVendorLicenseModel> vendorLicenseModels) { - Collections.sort(vendorLicenseModels, new Comparator<VersionedVendorLicenseModel>() { - @Override - public int compare(VersionedVendorLicenseModel o1, VersionedVendorLicenseModel o2) { - return o2.getVendorLicenseModel().getWritetimeMicroSeconds() - .compareTo(o1.getVendorLicenseModel().getWritetimeMicroSeconds()); - } - }); + vendorLicenseModels.sort((o1, o2) -> o2.getVendorLicenseModel().getWritetimeMicroSeconds() + .compareTo(o1.getVendorLicenseModel().getWritetimeMicroSeconds())); } @Override public void checkout(String vendorLicenseModelId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId); + Version newVersion = versioningManager .checkout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user); + + ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor()+1), + ActivityType.CHECKOUT.toString(), user, true, "", ""); + activityLogManager.addActionLog(activityLogEntity, user); + + newVersion.setStatus(VersionStatus.Locked); vendorLicenseFacade.updateVlmLastModificationTime(vendorLicenseModelId, newVersion); + + mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId); } @Override public void undoCheckout(String vendorLicenseModelId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId); + Version newVersion = versioningManager .undoCheckout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user); vendorLicenseFacade.updateVlmLastModificationTime(vendorLicenseModelId, newVersion); + + mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId); } @Override public void checkin(String vendorLicenseModelId, String user) { - vendorLicenseFacade.checkin(vendorLicenseModelId, user); + + mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId); + + Version newVersion = vendorLicenseFacade.checkin(vendorLicenseModelId, user); + + ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId, + String.valueOf(newVersion.getMajor()+1), ActivityType.CHECKIN.toString(), user, true, "", ""); + activityLogManager.addActionLog(activityLogEntity, user); + + mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId); } @Override public void submit(String vendorLicenseModelId, String user) { - vendorLicenseFacade.submit(vendorLicenseModelId, user); + + mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId); + + Version newVersion = vendorLicenseFacade.submit(vendorLicenseModelId, user); + + ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor()), + ActivityType.SUBMIT.toString(), user, true, "", ""); + activityLogManager.addActionLog(activityLogEntity, user); + + mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId); } @Override public Collection<VersionedVendorLicenseModel> listVendorLicenseModels(String versionFilter, String user) { + mdcDataDebugMessage.debugEntryMessage(null); + Map<String, VersionInfo> idToVersionsInfo = versioningManager .listEntitiesVersionInfo(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, user, VersionableEntityAction.Read); @@ -131,9 +173,13 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { versionInfo.setLockingUser(null); } - VendorLicenseModelEntity - vlm = vendorLicenseModelDao - .get(new VendorLicenseModelEntity(entry.getKey(), versionInfo.getActiveVersion())); + Version version = versionInfo.getActiveVersion(); + if (user.equals(versionInfo.getLockingUser())) { + version.setStatus(VersionStatus.Locked); + } + + VendorLicenseModelEntity vlm = + vendorLicenseModelDao.get(new VendorLicenseModelEntity(entry.getKey(), version)); if (vlm != null) { VersionedVendorLicenseModel versionedVlm = new VersionedVendorLicenseModel(); versionedVlm.setVendorLicenseModel(vlm); @@ -144,22 +190,32 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { sortVlmListByModificationTimeDescOrder(vendorLicenseModels); + mdcDataDebugMessage.debugExitMessage(null); return vendorLicenseModels; } @Override - public VendorLicenseModelEntity createVendorLicenseModel( - VendorLicenseModelEntity vendorLicenseModelEntity, String user) { - return vendorLicenseFacade.createVendorLicenseModel(vendorLicenseModelEntity, user); + public VendorLicenseModelEntity createVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity, String user) { + + VendorLicenseModelEntity vendorLicenseModelCreated = vendorLicenseFacade.createVendorLicenseModel(vendorLicenseModelEntity, user); + + ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelCreated.getId(), + String.valueOf(vendorLicenseModelCreated.getVersion().getMajor()+1), + ActivityType.CREATE_NEW.toString(), user, true, "", ""); + activityLogManager.addActionLog(activityLogEntity, user); + + return vendorLicenseModelCreated; } @Override public void updateVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity, String user) { - Version activeVersion = - getVersionInfo(vendorLicenseModelEntity.getId(), VersionableEntityAction.Write, user) - .getActiveVersion(); - vendorLicenseModelEntity.setVersion(activeVersion); + mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelEntity.getId()); + + Version version = VersioningUtil.resolveVersion(null, + getVersionInfo(vendorLicenseModelEntity.getId(), VersionableEntityAction.Write, user), + user); + vendorLicenseModelEntity.setVersion(version); String existingVendorName = vendorLicenseModelDao.get(vendorLicenseModelEntity).getVendorName(); UniqueValueUtil @@ -168,7 +224,9 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { vendorLicenseModelDao.update(vendorLicenseModelEntity); vendorLicenseFacade - .updateVlmLastModificationTime(vendorLicenseModelEntity.getId(), activeVersion); + .updateVlmLastModificationTime(vendorLicenseModelEntity.getId(), version); + + mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelEntity.getId()); } @Override @@ -179,28 +237,29 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { @Override public void deleteVendorLicenseModel(String vlmId, String user) { - throw new UnsupportedOperationException("Unsupported operation for 1607 release."); - - /* Version activeVersion = getVersionInfo(vlmId, VersionableEntityAction.Write, user) - .getActiveVersion(); - - vendorLicenseModelDao.delete(new VendorLicenseModelEntity(vlmId, activeVersion)); - licenseAgreementDao.deleteAll(new LicenseAgreementEntity(vlmId, activeVersion, null)); - featureGroupDao.deleteAll(new FeatureGroupEntity(vlmId, activeVersion, null)); - licenseKeyGroupDao.deleteAll(new LicenseKeyGroupEntity(vlmId, activeVersion, null)); - entitlementPoolDao.deleteAll(new EntitlementPoolEntity(vlmId, activeVersion, null));*/ + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.DELETE_ENTITY, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION); + throw new UnsupportedOperationException(VendorLicenseConstants.UNSUPPORTED_OPERATION_ERROR); } @Override public Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version, String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); return licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, VersioningUtil - .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user)), null)); + .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user), + null)); } @Override public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement, String user) { + mdcDataDebugMessage + .debugEntryMessage("VLM id", licenseAgreement.getVendorLicenseModelId()); + mdcDataDebugMessage + .debugExitMessage("VLM id", licenseAgreement.getVendorLicenseModelId()); return vendorLicenseFacade.createLicenseAgreement(licenseAgreement, user); } @@ -208,19 +267,20 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { public void updateLicenseAgreement(LicenseAgreementEntity licenseAgreement, Set<String> addedFeatureGroupIds, Set<String> removedFeatureGroupIds, String user) { - Version activeVersion = + mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", licenseAgreement + .getVendorLicenseModelId(), licenseAgreement.getId()); + + Version version = VersioningUtil.resolveVersion(licenseAgreement.getVersion(), getVersionInfo(licenseAgreement.getVendorLicenseModelId(), VersionableEntityAction.Write, - user).getActiveVersion(); - licenseAgreement.setVersion(activeVersion); + user), user); + licenseAgreement.setVersion(version); LicenseAgreementEntity retrieved = licenseAgreementDao.get(licenseAgreement); VersioningUtil .validateEntityExistence(retrieved, licenseAgreement, VendorLicenseModelEntity.ENTITY_TYPE); - VersioningUtil.validateContainedEntitiesExistence( - new org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity().getEntityType(), + VersioningUtil.validateContainedEntitiesExistence(new FeatureGroupEntity().getEntityType(), removedFeatureGroupIds, retrieved, retrieved.getFeatureGroupIds()); VersioningUtil.validateEntitiesExistence(addedFeatureGroupIds, - new org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity( - licenseAgreement.getVendorLicenseModelId(), activeVersion, null), + new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), version, null), featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE); UniqueValueUtil.updateUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME, @@ -233,21 +293,30 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { removeFeatureGroupsToLicenseAgreementRef(removedFeatureGroupIds, licenseAgreement); vendorLicenseFacade - .updateVlmLastModificationTime(licenseAgreement.getVendorLicenseModelId(), activeVersion); + .updateVlmLastModificationTime(licenseAgreement.getVendorLicenseModelId(), version); + + mdcDataDebugMessage.debugExitMessage("VLM id, LA id", licenseAgreement + .getVendorLicenseModelId(), licenseAgreement.getId()); } @Override public LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version, String licenseAgreementId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId); + mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId); return vendorLicenseFacade.getLicenseAgreementModel(vlmId, version, licenseAgreementId, user); } @Override - public void deleteLicenseAgreement(String vlmId, String licenseAgreementId, String user) { - Version activeVersion = - getVersionInfo(vlmId, VersionableEntityAction.Write, user).getActiveVersion(); + public void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId, + String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId); + + version = VersioningUtil + .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Write, user), user); LicenseAgreementEntity input = - new LicenseAgreementEntity(vlmId, activeVersion, licenseAgreementId); + new LicenseAgreementEntity(vlmId, version, licenseAgreementId); LicenseAgreementEntity retrieved = licenseAgreementDao.get(input); VersioningUtil.validateEntityExistence(retrieved, input, VendorLicenseModelEntity.ENTITY_TYPE); @@ -260,39 +329,44 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { vendorLicenseFacade .updateVlmLastModificationTime(input.getVendorLicenseModelId(), input.getVersion()); + + mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId); } @Override - public Collection<org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity> listFeatureGroups( - String vlmId, Version version, - String user) { - return featureGroupDao - .list(new org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity(vlmId, VersioningUtil - .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user)), - null)); + public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version, + String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); + return featureGroupDao.list(new FeatureGroupEntity(vlmId, VersioningUtil + .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user), + null)); } @Override - public org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity createFeatureGroup( - org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity featureGroup, String user) { + public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user) { + mdcDataDebugMessage + .debugEntryMessage("VLM id", featureGroup.getVendorLicenseModelId()); + mdcDataDebugMessage.debugExitMessage("VLM id", featureGroup.getId()); return vendorLicenseFacade.createFeatureGroup(featureGroup, user); } @Override - public void updateFeatureGroup( - org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity featureGroup, - Set<String> addedLicenseKeyGroups, - Set<String> removedLicenseKeyGroups, - Set<String> addedEntitlementPools, - Set<String> removedEntitlementPools, - String user) { - Version activeVersion = - getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write, user) - .getActiveVersion(); - featureGroup.setVersion(activeVersion); - - org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity retrieved = - featureGroupDao.get(featureGroup); + public void updateFeatureGroup(FeatureGroupEntity featureGroup, + Set<String> addedLicenseKeyGroups, + Set<String> removedLicenseKeyGroups, + Set<String> addedEntitlementPools, + Set<String> removedEntitlementPools, + String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id, FG id", featureGroup + .getVendorLicenseModelId(), featureGroup.getId()); + + Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(), + getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write, user), + user); + featureGroup.setVersion(version); + + FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup); VersioningUtil .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE); @@ -302,10 +376,10 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { removedEntitlementPools, retrieved, retrieved.getEntitlementPoolIds()); VersioningUtil.validateEntitiesExistence(addedLicenseKeyGroups, - new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), activeVersion, null), + new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), version, null), licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE); VersioningUtil.validateEntitiesExistence(addedEntitlementPools, - new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), activeVersion, null), + new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), version, null), entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE); UniqueValueUtil.updateUniqueValue(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME, retrieved.getName(), featureGroup.getName(), featureGroup.getVendorLicenseModelId(), @@ -320,24 +394,32 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { addedLicenseKeyGroups, removedLicenseKeyGroups); vendorLicenseFacade - .updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(), activeVersion); + .updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(), version); + + mdcDataDebugMessage.debugExitMessage("VLM id, FG id", featureGroup + .getVendorLicenseModelId(), featureGroup.getId()); } @Override - public FeatureGroupModel getFeatureGroupModel( - org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity featureGroup, String user) { + public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id, FG id", + featureGroup.getVendorLicenseModelId(), featureGroup.getId()); + + mdcDataDebugMessage.debugExitMessage("VLM id, FG id", + featureGroup.getVendorLicenseModelId(), featureGroup.getId()); return vendorLicenseFacade.getFeatureGroupModel(featureGroup, user); } @Override - public void deleteFeatureGroup( - org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity featureGroup, String user) { - Version activeVersion = - getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write, user) - .getActiveVersion(); - featureGroup.setVersion(activeVersion); - org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity retrieved = - featureGroupDao.get(featureGroup); + public void deleteFeatureGroup(FeatureGroupEntity featureGroup, String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id, FG id", + featureGroup.getVendorLicenseModelId(), featureGroup.getId()); + + Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(), + getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write, + user), user); + featureGroup.setVersion(version); + FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup); VersioningUtil .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE); @@ -346,7 +428,7 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { for (String licenceAgreementId : retrieved.getReferencingLicenseAgreements()) { licenseAgreementDao.removeFeatureGroup( - new LicenseAgreementEntity(featureGroup.getVendorLicenseModelId(), activeVersion, + new LicenseAgreementEntity(featureGroup.getVendorLicenseModelId(), version, licenceAgreementId), featureGroup.getId()); } @@ -357,49 +439,74 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { vendorLicenseFacade.updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion()); + + mdcDataDebugMessage + .debugExitMessage("VLM id, FG id", + featureGroup.getVendorLicenseModelId(), featureGroup.getId()); } @Override public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version, String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); return vendorLicenseFacade.listEntitlementPools(vlmId, version, user); } @Override public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool, String user) { + mdcDataDebugMessage + .debugEntryMessage("VLM id", entitlementPool.getVendorLicenseModelId()); + mdcDataDebugMessage + .debugExitMessage("VLM id", entitlementPool.getVendorLicenseModelId()); return vendorLicenseFacade.createEntitlementPool(entitlementPool, user); } @Override public void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user) { - Version activeVersion = + mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool + .getVendorLicenseModelId(), entitlementPool.getId()); + + Version version = VersioningUtil.resolveVersion(entitlementPool.getVersion(), getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write, - user).getActiveVersion(); + user), user); vendorLicenseFacade - .updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(), activeVersion); + .updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(), version); vendorLicenseFacade.updateEntitlementPool(entitlementPool, user); + + mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool + .getVendorLicenseModelId(), entitlementPool.getId()); } @Override public EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool, String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool + .getVendorLicenseModelId(), entitlementPool.getId()); + entitlementPool.setVersion(VersioningUtil.resolveVersion(entitlementPool.getVersion(), getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Read, - user))); + user), user)); EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool); VersioningUtil .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE); + + mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool + .getVendorLicenseModelId(), entitlementPool.getId()); return retrieved; } @Override public void deleteEntitlementPool(EntitlementPoolEntity entitlementPool, String user) { - Version activeVersion = + mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool + .getVendorLicenseModelId(), entitlementPool.getId()); + + Version version = VersioningUtil.resolveVersion(entitlementPool.getVersion(), getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write, - user).getActiveVersion(); - entitlementPool.setVersion(activeVersion); + user), user); + entitlementPool.setVersion(version); EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool); VersioningUtil @@ -407,80 +514,109 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) { featureGroupDao.removeEntitlementPool( - new org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity( - entitlementPool.getVendorLicenseModelId(), activeVersion, + new FeatureGroupEntity(entitlementPool.getVendorLicenseModelId(), version, referencingFeatureGroupId), entitlementPool.getId()); } entitlementPoolDao.delete(entitlementPool); + UniqueValueUtil.deleteUniqueValue(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME, retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(), retrieved.getName()); vendorLicenseFacade.updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion()); + + mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool + .getVendorLicenseModelId(), entitlementPool.getId()); } @Override public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version, String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); return vendorLicenseFacade.listLicenseKeyGroups(vlmId, version, user); } @Override public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) { + mdcDataDebugMessage + .debugEntryMessage("VLM id", licenseKeyGroup.getVendorLicenseModelId()); + + mdcDataDebugMessage.debugExitMessage("VLM id", licenseKeyGroup + .getVendorLicenseModelId()); return vendorLicenseFacade.createLicenseKeyGroup(licenseKeyGroup, user); } @Override public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) { - Version activeVersion = + mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup + .getVendorLicenseModelId(), licenseKeyGroup.getId()); + + Version version = VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(), getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write, - user).getActiveVersion(); + user), user); vendorLicenseFacade - .updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(), activeVersion); + .updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(), version); vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroup, user); + + mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup + .getVendorLicenseModelId(), licenseKeyGroup.getId()); } @Override public LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup + .getVendorLicenseModelId(), licenseKeyGroup.getId()); + licenseKeyGroup.setVersion(VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(), getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Read, - user))); + user), user)); LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup); VersioningUtil .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE); + + mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup + .getVendorLicenseModelId(), licenseKeyGroup.getId()); return retrieved; } @Override public void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) { - Version activeVersion = + mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup + .getVendorLicenseModelId(), licenseKeyGroup.getId()); + + Version version = VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(), getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write, - user).getActiveVersion(); - licenseKeyGroup.setVersion(activeVersion); + user), user); + licenseKeyGroup.setVersion(version); LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup); VersioningUtil .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE); - licenseKeyGroupDao.delete(licenseKeyGroup); for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) { featureGroupDao.removeLicenseKeyGroup( - new org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity( - licenseKeyGroup.getVendorLicenseModelId(), activeVersion, + new FeatureGroupEntity(licenseKeyGroup.getVendorLicenseModelId(), version, referencingFeatureGroupId), licenseKeyGroup.getId()); } + + licenseKeyGroupDao.delete(licenseKeyGroup); + UniqueValueUtil.deleteUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME, retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(), retrieved.getName()); vendorLicenseFacade.updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion()); + + mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup + .getVendorLicenseModelId(), licenseKeyGroup.getId()); } private void addFeatureGroupsToLicenseAgreementRef(Set<String> featureGroupIds, @@ -488,8 +624,7 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { if (featureGroupIds != null) { for (String featureGroupId : featureGroupIds) { featureGroupDao.addReferencingLicenseAgreement( - new org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity( - licenseAgreement.getVendorLicenseModelId(), + new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId()); } } @@ -500,15 +635,14 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { if (featureGroupIds != null) { for (String featureGroupId : featureGroupIds) { featureGroupDao.removeReferencingLicenseAgreement( - new org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity( - licenseAgreement.getVendorLicenseModelId(), + new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId()); } } } private void addLicenseKeyGroupsToFeatureGroupsRef(Set<String> licenseKeyGroupIds, - org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity featureGroup) { + FeatureGroupEntity featureGroup) { if (licenseKeyGroupIds != null) { for (String licenseKeyGroupId : licenseKeyGroupIds) { licenseKeyGroupDao.addReferencingFeatureGroup( @@ -519,7 +653,7 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { } private void removeLicenseKeyGroupsToFeatureGroupsRef(Set<String> licenseKeyGroupIds, - org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity featureGroup) { + FeatureGroupEntity featureGroup) { if (licenseKeyGroupIds != null) { for (String licenseKeyGroupId : licenseKeyGroupIds) { licenseKeyGroupDao.removeReferencingFeatureGroup( @@ -530,7 +664,7 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { } private void addEntitlementPoolsToFeatureGroupsRef(Set<String> entitlementPoolIds, - org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity featureGroup) { + FeatureGroupEntity featureGroup) { if (entitlementPoolIds != null) { for (String entitlementPoolId : entitlementPoolIds) { entitlementPoolDao.addReferencingFeatureGroup( @@ -541,7 +675,7 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { } private void removeEntitlementPoolsToFeatureGroupsRef(Set<String> entitlementPoolIds, - org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity featureGroup) { + FeatureGroupEntity featureGroup) { if (entitlementPoolIds != null) { for (String entitlementPoolId : entitlementPoolIds) { entitlementPoolDao.removeReferencingFeatureGroup( |