diff options
Diffstat (limited to 'openecomp-be/lib')
5 files changed, 34 insertions, 88 deletions
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(); } |