diff options
author | shrikantawachar <shrikant.awachar@amdocs.com> | 2018-08-10 16:14:56 +0530 |
---|---|---|
committer | shrikantawachar <shrikant.awachar@amdocs.com> | 2018-08-10 19:05:17 +0530 |
commit | c15ef65197789965734fb3aa90e9ea50bda05045 (patch) | |
tree | 83d4b26b9926b0c43261f952b90b40c8008af4d5 | |
parent | 7e0f45ab7839fda19459f790e0384c3a6c98e2bf (diff) |
Inconsistent behavior in license model xmls
Removing toggle and fix for Inconsistent behavior in license model xmls
Change-Id: I2fd032f25afbdcc17547224beaecf626ed6322bb
Issue-ID: SDC-1625
Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
17 files changed, 40 insertions, 213 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java index 18435b3c71..d4526da1e5 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java @@ -20,7 +20,6 @@ package org.openecomp.sdcrests.vendorlicense.rest.mapping; -import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; @@ -47,8 +46,6 @@ public class MapEntitlementPoolEntityToEntitlementPoolEntityDto target.setStartDate(source.getStartDate()); target.setExpiryDate(source.getExpiryDate()); target.setVersionUUID(source.getVersionUuId()); - if (ToggleableFeature.MRN.isActive()) { - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - } + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java index bed7e696e7..69cd285cf7 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java @@ -20,7 +20,6 @@ package org.openecomp.sdcrests.vendorlicense.rest.mapping; -import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; @@ -31,9 +30,7 @@ public class MapEntitlementPoolRequestDtoToEntitlementPoolEntity @Override public void doMapping(EntitlementPoolRequestDto source, EntitlementPoolEntity target) { target.setName(source.getName()); - if (ToggleableFeature.MRN.isActive()) { - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - } + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); target.setDescription(source.getDescription()); target.setThresholdValue(source.getThresholdValue()); target.setThresholdUnit(source.getThresholdUnits()); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java index 232588779c..5dbf087e45 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java @@ -20,7 +20,6 @@ package org.openecomp.sdcrests.vendorlicense.rest.mapping; -import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto; @@ -32,8 +31,5 @@ public class MapFeatureGroupDescriptorDtoToFeatureGroupEntity target.setName(source.getName()); target.setDescription(source.getDescription()); target.setPartNumber(source.getPartNumber()); - if (!ToggleableFeature.MRN.isActive()) { - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - } } }
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java index e103b27687..70f5666bcb 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java @@ -20,7 +20,6 @@ package org.openecomp.sdcrests.vendorlicense.rest.mapping; -import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto; @@ -32,8 +31,5 @@ public class MapFeatureGroupEntityToFeatureGroupDescriptorDto target.setName(source.getName()); target.setDescription(source.getDescription()); target.setPartNumber(source.getPartNumber()); - if (!ToggleableFeature.MRN.isActive()) { - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - } } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java index a7d4b5bc42..c543cf402e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java @@ -20,7 +20,6 @@ package org.openecomp.sdcrests.vendorlicense.rest.mapping; -import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; @@ -43,8 +42,6 @@ public class MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto target.setThresholdValue(source.getThresholdValue()); target.setIncrements(source.getIncrements()); target.setVersionUUID(source.getVersionUuId()); - if (ToggleableFeature.MRN.isActive()) { - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - } + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java index 0eeda4a8b7..87eea4ba1e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java @@ -20,7 +20,6 @@ package org.openecomp.sdcrests.vendorlicense.rest.mapping; -import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; @@ -31,9 +30,7 @@ public class MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity @Override public void doMapping(LicenseKeyGroupRequestDto source, LicenseKeyGroupEntity target) { target.setName(source.getName()); - if (ToggleableFeature.MRN.isActive()) { - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - } + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); target.setDescription(source.getDescription()); target.setType(source.getType()); target.setOperationalScope(new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther() diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java index 292b4a0937..076ae45017 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java @@ -20,9 +20,6 @@ package org.openecomp.sdcrests.vendorlicense.rest.services; -import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.common.errors.ErrorCode; -import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; @@ -40,7 +37,6 @@ import org.springframework.stereotype.Service; import javax.inject.Named; import javax.ws.rs.core.Response; import java.util.Collection; -import java.util.Objects; @Named @Service("entitlementPools") @@ -80,12 +76,6 @@ public class EntitlementPoolsImpl implements EntitlementPools { */ public Response createEntitlementPool(EntitlementPoolRequestDto request, String vlmId, String versionId, String user) { - if (ToggleableFeature.MRN.isActive()) { - if (Objects.isNull(request.getManufacturerReferenceNumber())) { - throw new CoreException((new ErrorCode.ErrorCodeBuilder().withMessage("Field does not conform to " - + "predefined criteria : manufacturerReferenceNumber : is mandatory and should not be empty").build())); - } - } EntitlementPoolEntity entitlementPoolEntity = new MapEntitlementPoolRequestDtoToEntitlementPoolEntity() .applyMapping(request, EntitlementPoolEntity.class); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java index 65b2695b5e..8b62dc1843 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java @@ -21,9 +21,6 @@ package org.openecomp.sdcrests.vendorlicense.rest.services; import org.openecomp.core.utilities.CommonMethods; -import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.common.errors.ErrorCode; -import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; @@ -46,7 +43,6 @@ import javax.inject.Named; import javax.ws.rs.core.Response; import java.util.Collection; import java.util.HashSet; -import java.util.Objects; @Named @Service("featureGroups") @@ -79,15 +75,6 @@ public class FeatureGroupsImpl implements FeatureGroups { @Override public Response createFeatureGroup(FeatureGroupRequestDto request, String vlmId, String versionId, String user) { - //Below if block is introduced to have feature toggleable. This if block needs to remove when - // we remove toggle. - if (!ToggleableFeature.MRN.isActive()) { - if (Objects.isNull(request.getManufacturerReferenceNumber())) { - throw new CoreException((new ErrorCode.ErrorCodeBuilder().withMessage("Field does not " + - "conform to predefined criteria : manufacturerReferenceNumber : is mandatory and should not be empty").build())); - } - } - FeatureGroupEntity featureGroupEntity = new MapFeatureGroupDescriptorDtoToFeatureGroupEntity() .applyMapping(request, FeatureGroupEntity.class); featureGroupEntity.setVendorLicenseModelId(vlmId); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java index 8fa34b8579..6bc4f94b5f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java @@ -22,6 +22,7 @@ package org.openecomp.sdcrests.vendorlicense.types; import io.swagger.annotations.ApiModel; import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.hibernate.validator.constraints.NotBlank; import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope; import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit; @@ -37,6 +38,7 @@ public class EntitlementPoolRequestDto { @Size(max = 120) private String name; + @NotBlank(message = "is mandatory and should not be empty") @Size(max = 100) private String manufacturerReferenceNumber; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java index 4270ffee9e..919fdb21c2 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java @@ -34,10 +34,6 @@ public class FeatureGroupDescriptorDto { @NotNull private String partNumber; - - @Size(max = 100) - private String manufacturerReferenceNumber; - public String getName() { return name; } @@ -62,11 +58,4 @@ public class FeatureGroupDescriptorDto { this.partNumber = partNumber; } - public String getManufacturerReferenceNumber() { - return manufacturerReferenceNumber; - } - - public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) { - this.manufacturerReferenceNumber = manufacturerReferenceNumber; - } } 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 d1ff5387ca..3a635de1ee 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 @@ -16,10 +16,8 @@ package org.openecomp.sdc.vendorlicense.impl; -import org.apache.commons.collections.CollectionUtils; import org.openecomp.core.dao.UniqueValueDao; import org.openecomp.core.util.UniqueValueUtil; -import org.openecomp.core.utilities.CommonMethods; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.vendorlicense.VendorLicenseConstants; @@ -35,7 +33,6 @@ import org.openecomp.sdc.versioning.dao.types.Version; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.Collection; -import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -213,61 +210,6 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager { featureGroupDao.updateFeatureGroup(featureGroup, addedEntitlementPools, removedEntitlementPools, addedLicenseKeyGroups, removedLicenseKeyGroups); - updateEpLkgOnMrnChange(featureGroup, addedLicenseKeyGroups, addedEntitlementPools, retrieved); - } - - /** - * If MRN is updated in feature group then update all linked EPs and Lkgs with new versionUuId - * @param featureGroup - Feature Group entity which is requested for update - * @param addedLicenseKeyGroups - LicenseKeyGroups added with Feature Group - * @param addedEntitlementPools - EntitlementPools added with Feature Group - * @param retrieved - Feature Group entity fetched from database - */ - private void updateEpLkgOnMrnChange(FeatureGroupEntity featureGroup, - Set<String> addedLicenseKeyGroups, - Set<String> addedEntitlementPools, - FeatureGroupEntity retrieved) { - if (Objects.nonNull(retrieved.getManufacturerReferenceNumber()) - && !retrieved.getManufacturerReferenceNumber().equals(featureGroup - .getManufacturerReferenceNumber())) { - if (CollectionUtils.isEmpty(addedEntitlementPools)) { - updateEntitlementPool(featureGroup, retrieved.getEntitlementPoolIds()); - } else { - updateEntitlementPool(featureGroup, addedEntitlementPools); - } - - if (CollectionUtils.isEmpty(addedLicenseKeyGroups)) { - updateLicenseKeyGroup(featureGroup, retrieved.getLicenseKeyGroupIds()); - } else { - updateLicenseKeyGroup(featureGroup, addedLicenseKeyGroups); - } - } - } - - private void updateEntitlementPool(FeatureGroupEntity featureGroup, - Set<String> entitlementPoolIds) { - for (String epId: entitlementPoolIds) { - final EntitlementPoolEntity entitlementPoolEntity = entitlementPoolDao - .get(new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), featureGroup - .getVersion(), epId)); - if (Objects.nonNull(entitlementPoolEntity)) { - entitlementPoolEntity.setVersionUuId(CommonMethods.nextUuId()); - entitlementPoolDao.update(entitlementPoolEntity); - } - } - } - - private void updateLicenseKeyGroup(FeatureGroupEntity featureGroup, - Set<String> licenseKeyGroupIds) { - for (String lkgId: licenseKeyGroupIds) { - final LicenseKeyGroupEntity licenseKeyGroupEntity = licenseKeyGroupDao - .get(new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), - featureGroup.getVersion(), lkgId)); - if (Objects.nonNull(licenseKeyGroupEntity)) { - licenseKeyGroupEntity.setVersionUuId(CommonMethods.nextUuId()); - licenseKeyGroupDao.update(licenseKeyGroupEntity); - } - } } @Override diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java index d4f66c61d2..b7636bb514 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java @@ -255,7 +255,6 @@ public class FeatureGroupTest { existingFG.setEntitlementPoolIds(new HashSet<String>()); existingFG.setLicenseKeyGroupIds(new HashSet<String>()); - existingFG.setManufacturerReferenceNumber("MRN"); doReturn(existingFG).when(featureGroupDao).get(anyObject()); @@ -283,7 +282,6 @@ public class FeatureGroupTest { anyObject(),anyObject(), anyObject()); FeatureGroupEntity fg = new FeatureGroupEntity(vlm1_id, VERSION01, fg1_id); - fg.setManufacturerReferenceNumber("MRN_UPD"); vendorLicenseManagerImpl.updateFeatureGroup(fg,addedLKGs,removedLKGs, addedEPs, removedEPs); @@ -298,9 +296,6 @@ public class FeatureGroupTest { verify(featureGroupDao) .updateFeatureGroup(fg,addedEPs,removedEPs, addedLKGs, removedLKGs); - - verify(entitlementPoolDao, times(2)).update(anyObject()); - verify(licenseKeyGroupDao,times(2)).update(anyObject()); } @Test @@ -311,7 +306,6 @@ public class FeatureGroupTest { HashSet<String> lkgSet = new HashSet<String>(); lkgSet.add(lkg1_id); existingFG.setEntitlementPoolIds(epSet); existingFG.setLicenseKeyGroupIds(lkgSet); - existingFG.setManufacturerReferenceNumber("MRN"); doReturn(existingFG).when(featureGroupDao).get(anyObject()); @@ -330,7 +324,6 @@ public class FeatureGroupTest { anyObject(),anyObject(), anyObject()); FeatureGroupEntity fg = new FeatureGroupEntity(vlm1_id, VERSION01, fg1_id); - fg.setManufacturerReferenceNumber("MRN_UPD"); vendorLicenseManagerImpl.updateFeatureGroup(fg,addedLKGs,removedLKGs, addedEPs, removedEPs); @@ -346,8 +339,6 @@ public class FeatureGroupTest { verify(featureGroupDao) .updateFeatureGroup(fg,addedEPs,removedEPs, addedLKGs, removedLKGs); - verify(entitlementPoolDao, times(1)).update(anyObject()); - verify(licenseKeyGroupDao,times(1)).update(anyObject()); } diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java index 0d900d2d30..4f4192805a 100644 --- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java +++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java @@ -1,13 +1,11 @@ package org.openecomp.sdc.common.togglz; import org.togglz.core.Feature; -import org.togglz.core.annotation.Label; import org.togglz.core.context.FeatureContext; public enum ToggleableFeature implements Feature { - @Label(("MRN")) - MRN; + ; public boolean isActive() { return FeatureContext.getFeatureManager().isActive(this); diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealer.java index 237e4bf55b..4bb5bc865a 100644 --- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealer.java +++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealer.java @@ -32,7 +32,7 @@ import java.util.Set; public class ManufacturerReferenceNumberHealer implements Healer { - private static final String manufacturerReferenceNumber = "MRN"; + private static final String MANUFACTURER_REFERENCE_NUMBER = "MRN"; private VendorLicenseFacade vendorLicenseFacade = VendorLicenseFacadeFactory.getInstance() .createInterface(); private static final FeatureGroupDao featureGroupDao = @@ -64,7 +64,7 @@ public class ManufacturerReferenceNumberHealer implements Healer { entitlementPoolEntity.setManufacturerReferenceNumber(getMRN(itemId, version, referencingFeatureGroup)); } else { - entitlementPoolEntity.setManufacturerReferenceNumber(manufacturerReferenceNumber); + entitlementPoolEntity.setManufacturerReferenceNumber(MANUFACTURER_REFERENCE_NUMBER); } vendorLicenseFacade.updateEntitlementPool(entitlementPoolEntity); } @@ -80,7 +80,7 @@ public class ManufacturerReferenceNumberHealer implements Healer { licenseKeyGroupEntity.setManufacturerReferenceNumber(getMRN(itemId, version, referencingFeatureGroup)); } else { - licenseKeyGroupEntity.setManufacturerReferenceNumber(manufacturerReferenceNumber); + licenseKeyGroupEntity.setManufacturerReferenceNumber(MANUFACTURER_REFERENCE_NUMBER); } vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroupEntity); } @@ -99,7 +99,7 @@ public class ManufacturerReferenceNumberHealer implements Healer { (itemId, version); for (FeatureGroupEntity featureGroupEntity : featureGroupEntities) { - featureGroupEntity.setManufacturerReferenceNumber(""); + featureGroupEntity.setManufacturerReferenceNumber(null); featureGroupDao.update(featureGroupEntity); } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/FeatureGroupDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/FeatureGroupDaoZusammenImpl.java index f1b9026cf6..13e41e2e88 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/FeatureGroupDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/FeatureGroupDaoZusammenImpl.java @@ -269,7 +269,6 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao { info.setDescription(featureGroup.getDescription()); info.addProperty(ElementPropertyName.elementType.name(), ElementType.FeatureGroup); info.addProperty("partNumber", featureGroup.getPartNumber()); - info.addProperty("manufacturerReferenceNumber", featureGroup.getManufacturerReferenceNumber()); featureGroupElement.setInfo(info); featureGroupElement.setRelations(new ArrayList<>()); diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java index 6770424101..a0173fa0ad 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java @@ -26,7 +26,6 @@ import org.openecomp.core.util.UniqueValueUtil; import org.openecomp.core.utilities.CommonMethods; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCode; -import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdc.vendorlicense.VendorLicenseConstants; import org.openecomp.sdc.vendorlicense.dao.*; import org.openecomp.sdc.vendorlicense.dao.types.*; @@ -41,7 +40,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; -import java.util.Objects; import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE; @@ -79,11 +77,7 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade { FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup); VersioningUtil .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE); - if (!ToggleableFeature.MRN.isActive()) { //Remove updateManufacturerNumberInFeatureGroup() while removing remove toggle - if (retrieved.getManufacturerReferenceNumber() == null) { - updateManufacturerNumberInFeatureGroup(retrieved); - } - } + return retrieved; } @@ -262,12 +256,7 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade { @Override public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version) { - Collection<FeatureGroupEntity> featureGroupEntities = - featureGroupDao.list(new FeatureGroupEntity(vlmId, version, null)); - featureGroupEntities.stream() - .filter(fgEntity -> Objects.isNull(fgEntity.getManufacturerReferenceNumber())) - .forEach(this::updateManufacturerNumberInFeatureGroup); - return featureGroupEntities; + return featureGroupDao.list(new FeatureGroupEntity(vlmId, version, null)); } @@ -329,22 +318,6 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade { limitDao.update(limit); } - private void updateManufacturerNumberInFeatureGroup(FeatureGroupEntity featureGroupEntity) { - if (CollectionUtils.isNotEmpty(featureGroupEntity.getEntitlementPoolIds())) { - Object[] entitlementPoolIdsList = featureGroupEntity.getEntitlementPoolIds().toArray(); - if (entitlementPoolIdsList.length > 0) { - String entitlementPoolId = entitlementPoolIdsList[0].toString(); - EntitlementPoolEntity entitlementPoolEntity = - new EntitlementPoolEntity(featureGroupEntity.getVendorLicenseModelId(), - featureGroupEntity.getVersion(), entitlementPoolId); - entitlementPoolEntity = entitlementPoolDao.get(entitlementPoolEntity); - featureGroupEntity.setManufacturerReferenceNumber( - entitlementPoolDao.getManufacturerReferenceNumber(entitlementPoolEntity)); - featureGroupDao.update(featureGroupEntity); - } - } - } - @Override public void validate(String vendorLicenseModelId, Version version) { Collection<String> allFeatureGroupEntities = new HashSet<>(); diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java index b9fd403db1..f0f8a6cb7c 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java @@ -17,8 +17,8 @@ package org.openecomp.sdc.vendorlicense.licenseartifacts.impl; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; import org.openecomp.core.utilities.file.FileContentHandler; -import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdc.vendorlicense.HealingServiceFactory; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; @@ -65,63 +65,39 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts for (String featureGroupId : featureGroups) { FeatureGroupModel featureGroupModel = vendorLicenseFacade .getFeatureGroupModel(new FeatureGroupEntity(vlmId, vlmVersion, featureGroupId)); + Set<EntitlementPoolEntity> entitlementPoolEntities = + featureGroupModel.getEntitlementPools(); + String manufacturerReferenceNumber = featureGroupModel.getEntityManufacturerReferenceNumber(); + for (EntitlementPoolEntity entitlementPoolEntity : entitlementPoolEntities) { + entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion, + entitlementPoolEntity.getId())); + if (Objects.nonNull(manufacturerReferenceNumber) && !manufacturerReferenceNumber.trim().isEmpty()) { + entitlementPoolEntity.setManufacturerReferenceNumber(manufacturerReferenceNumber); + } + } - updateEntitlementPools(vlmId, vlmVersion, featureGroupModel); - updateLicenseKeyGroupEntities(vlmId, vlmVersion, featureGroupModel); + Set<LicenseKeyGroupEntity> licenseKeyGroupEntities = + featureGroupModel.getLicenseKeyGroups(); + for (LicenseKeyGroupEntity licenseKeyGroupEntity : licenseKeyGroupEntities) { + licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion, + licenseKeyGroupEntity.getId())); + if (Objects.nonNull(manufacturerReferenceNumber) && !manufacturerReferenceNumber.trim().isEmpty()) { + licenseKeyGroupEntity.setManufacturerReferenceNumber(manufacturerReferenceNumber); + } + } + featureGroupModel.setEntitlementPools(entitlementPoolEntities.stream().map( + entitlementPoolEntity -> (EntitlementPoolEntity) healingService + .heal(entitlementPoolEntity)).collect(Collectors.toSet())); + featureGroupModel.setLicenseKeyGroups(licenseKeyGroupEntities.stream().map( + licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService + .heal(licenseKeyGroupEntity)).collect(Collectors.toSet())); artifact.getFeatureGroups().add(featureGroupModel); } } return artifact.toXml().getBytes(); } - private static void updateEntitlementPools(String vlmId, Version vlmVersion, FeatureGroupModel featureGroupModel) { - - Set<EntitlementPoolEntity> entitlementPoolEntities = - featureGroupModel.getEntitlementPools(); - - for (EntitlementPoolEntity entitlementPoolEntity : entitlementPoolEntities) { - entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion, - entitlementPoolEntity.getId())); - String manuFacturerReferenceNumber = featureGroupModel.getEntityManufacturerReferenceNumber(); - if (ToggleableFeature.MRN.isActive()) { - if (Objects.nonNull(manuFacturerReferenceNumber) - && !manuFacturerReferenceNumber.trim().isEmpty()) { - entitlementPoolEntity.setManufacturerReferenceNumber(manuFacturerReferenceNumber); - } - } else { - entitlementPoolEntity.setManufacturerReferenceNumber(manuFacturerReferenceNumber); - } - } - featureGroupModel.setEntitlementPools(entitlementPoolEntities.stream().map( - entitlementPoolEntity -> (EntitlementPoolEntity) healingService - .heal(entitlementPoolEntity)).collect(Collectors.toSet())); - } - - private static void updateLicenseKeyGroupEntities(String vlmId, Version vlmVersion, FeatureGroupModel featureGroupModel) { - - Set<LicenseKeyGroupEntity> licenseKeyGroupEntities = - featureGroupModel.getLicenseKeyGroups(); - for (LicenseKeyGroupEntity licenseKeyGroupEntity : licenseKeyGroupEntities) { - licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion, - licenseKeyGroupEntity.getId())); - String manuFacturerReferenceNumber = featureGroupModel.getEntityManufacturerReferenceNumber(); - if (ToggleableFeature.MRN.isActive()) { - if (Objects.nonNull(manuFacturerReferenceNumber) - && !manuFacturerReferenceNumber.trim().isEmpty()) { - licenseKeyGroupEntity.setManufacturerReferenceNumber(manuFacturerReferenceNumber); - } - } else { - licenseKeyGroupEntity.setManufacturerReferenceNumber(manuFacturerReferenceNumber); - } - } - - featureGroupModel.setLicenseKeyGroups(licenseKeyGroupEntities.stream().map( - licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService - .heal(licenseKeyGroupEntity)).collect(Collectors.toSet())); - - } - private static byte[] createVendorLicenseArtifact(String vlmId, String vendorName) { VendorLicenseArtifact vendorLicenseArtifact = new VendorLicenseArtifact(); vendorLicenseArtifact.setVendorName(vendorName); @@ -180,7 +156,7 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts .getManufacturerReferenceNumber() : null; } } - return manufactureReferenceNumber != null ? Optional.of(manufactureReferenceNumber) : + return StringUtils.isNotEmpty(manufactureReferenceNumber) ? Optional.of(manufactureReferenceNumber) : Optional.empty(); } |