aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-license-lib
diff options
context:
space:
mode:
authoravigaffa <avi.gaffa@amdocs.com>2017-09-10 08:58:51 +0300
committeravigaffa <avi.gaffa@amdocs.com>2017-09-10 10:07:00 +0300
commit00e935fc6b8baae4d9b9ffef2c748202a60b66b4 (patch)
tree56d7b608dbb5a53022db0350f04977da8cd960f5 /openecomp-be/lib/openecomp-sdc-vendor-license-lib
parent75c572279398dc2be7652263843c8802a9406c4f (diff)
Add latest bug fixes to master
Change-Id: Ieddc2330ad4e093984f14a69b52f2ca5cb465a10 Issue-ID: SDC-293 Signed-off-by: avigaffa <avi.gaffa@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-license-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java65
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/healing/impl/SimpleHealingServiceImpl.java21
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java118
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VendorLicenseArtifactsServiceUtils.java83
5 files changed, 186 insertions, 104 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java
index e40b2988b3..58ccd5e608 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java
@@ -20,6 +20,9 @@ public class LimitEntity implements VersionableEntity {
private String unit;
private AggregationFunction aggregationFunction;
private String time;
+ //Defined and used only to find parent(EP/LKG) of Limit. Not to be persisted in DB and License
+ // Xmls
+ private String parent;
public LimitEntity() {
}
@@ -44,7 +47,7 @@ public class LimitEntity implements VersionableEntity {
}
public void setAggregationFunction(
- AggregationFunction aggregationFunction) {
+ AggregationFunction aggregationFunction) {
this.aggregationFunction = aggregationFunction;
}
@@ -143,10 +146,20 @@ public class LimitEntity implements VersionableEntity {
this.value = value;
}
- @Override
+ //Defined and used only to find parent(EP/LKG) of Limit. Not to be persisted in DB and License
+ // Xmls
+ public String getParent() {
+ return parent;
+ }
+
+ public void setParent(String parent) {
+ this.parent = parent;
+ }
+
+ @Override
public int hashCode() {
return Objects.hash(vendorLicenseModelId, version, epLkgId, id, name, description, type,
- metric, unit, time, aggregationFunction, value);
+ metric, unit, time, aggregationFunction, value);
}
@Override
@@ -159,35 +172,35 @@ public class LimitEntity implements VersionableEntity {
}
LimitEntity that = (LimitEntity) obj;
return Objects.equals(that.unit, unit)
- && Objects.equals(that.value, value)
- && Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
- && Objects.equals(epLkgId, that.epLkgId)
- && Objects.equals(id, that.id)
- && Objects.equals(name, that.name)
- && Objects.equals(description, that.description)
- && Objects.equals(type, that.type)
- && Objects.equals(metric, that.metric)
- && Objects.equals(aggregationFunction, that.aggregationFunction);
+ && Objects.equals(that.value, value)
+ && Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
+ && Objects.equals(epLkgId, that.epLkgId)
+ && Objects.equals(id, that.id)
+ && Objects.equals(name, that.name)
+ && Objects.equals(description, that.description)
+ && Objects.equals(type, that.type)
+ && Objects.equals(metric, that.metric)
+ && Objects.equals(aggregationFunction, that.aggregationFunction);
}
@Override
public String toString() {
return "LimitEntity{"
- + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
- + ", version=" + version
- + ", epLkgId=" + epLkgId
- + ", id='" + id + '\''
- + ", name='" + name + '\''
- + ", description='" + description + '\''
- + ", type=" + type
- + ", metric=" + metric
- + ", value='" + value + '\''
- + ", unit='" + unit + '\''
- + ", aggregationFunction=" + aggregationFunction
- + ", time=" + time
-
- + '}';
+ + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
+ + ", version=" + version
+ + ", epLkgId=" + epLkgId
+ + ", id='" + id + '\''
+ + ", name='" + name + '\''
+ + ", description='" + description + '\''
+ + ", type=" + type
+ + ", metric=" + metric
+ + ", value='" + value + '\''
+ + ", unit='" + unit + '\''
+ + ", aggregationFunction=" + aggregationFunction
+ + ", time=" + time
+
+ + '}';
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java
index 027cb1e5be..6ae2de1a63 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java
@@ -24,8 +24,9 @@ import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
public interface HealingService {
- // VersionableEntity heal(VersionableEntity toHeal, String user);
VersionableEntity heal(VersionableEntity toHeal, String user);
+
+ void persistNoHealing(VersionableEntity alreadyHealed);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/healing/impl/SimpleHealingServiceImpl.java b/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 eeed3b069d..7cb3e2e844 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/healing/impl/SimpleHealingServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/healing/impl/SimpleHealingServiceImpl.java
@@ -20,7 +20,6 @@
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;
@@ -41,9 +40,9 @@ import java.util.UUID;
public class SimpleHealingServiceImpl implements HealingService {
private static final EntitlementPoolDao entitlementPoolDao =
- EntitlementPoolDaoFactory.getInstance().createInterface();
+ EntitlementPoolDaoFactory.getInstance().createInterface();
private static final LicenseKeyGroupDao licenseKeyGroupDao =
- LicenseKeyGroupDaoFactory.getInstance().createInterface();
+ LicenseKeyGroupDaoFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
@Override
@@ -51,6 +50,15 @@ public class SimpleHealingServiceImpl implements HealingService {
return handleMissingVersionId(toHeal, user);
}
+ @Override
+ public void persistNoHealing(VersionableEntity alreadyHealed) {
+ if (alreadyHealed instanceof EntitlementPoolEntity) {
+ entitlementPoolDao.update((EntitlementPoolEntity) alreadyHealed);
+ } else if (alreadyHealed instanceof LicenseKeyGroupEntity) {
+ licenseKeyGroupDao.update((LicenseKeyGroupEntity) alreadyHealed);
+ }
+ }
+
private VersionableEntity handleMissingVersionId(VersionableEntity toHeal, String user) {
@@ -68,11 +76,10 @@ public class SimpleHealingServiceImpl implements HealingService {
licenseKeyGroupDao.update((LicenseKeyGroupEntity) toHeal);
} else {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION);
+ 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?
+ "Unsupported operation for 1610 release/1607->1610 migration.");
}
mdcDataDebugMessage.debugExitMessage(null, null);
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 7d2cdc5474..282b4e6743 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
@@ -22,21 +22,18 @@ package org.openecomp.sdc.vendorlicense.licenseartifacts.impl;
import org.apache.commons.collections.CollectionUtils;
import org.openecomp.core.utilities.file.FileContentHandler;
-import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.vendorlicense.HealingServiceFactory;
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.LicenseKeyGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
import org.openecomp.sdc.vendorlicense.healing.HealingService;
import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService;
import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.VendorLicenseArtifact;
import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.VnfLicenseArtifact;
-import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.util.VendorLicenseArtifactsServiceUtils;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
@@ -48,18 +45,25 @@ import java.util.stream.Collectors;
import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH;
import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VNF_ARTIFACT_NAME_WITH_PATH;
+import static org.openecomp.sdc.vendorlicense.licenseartifacts.impl.util.VendorLicenseArtifactsServiceUtils.filterChangedEntities;
+import static org.openecomp.sdc.vendorlicense.licenseartifacts.impl.util.VendorLicenseArtifactsServiceUtils.getFinalVersionsForVlm;
+import static org.openecomp.sdc.vendorlicense.licenseartifacts.impl.util.VendorLicenseArtifactsServiceUtils.getVendorName;
+import static org.openecomp.sdc.vendorlicense.licenseartifacts.impl.util.VendorLicenseArtifactsServiceUtils.healEPs;
+import static org.openecomp.sdc.vendorlicense.licenseartifacts.impl.util.VendorLicenseArtifactsServiceUtils.healLkgs;
+import static org.openecomp.sdc.vendorlicense.licenseartifacts.impl.util.VendorLicenseArtifactsServiceUtils.prepareForFiltering;
public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifactsService {
public static final VendorLicenseFacade vendorLicenseFacade =
- VendorLicenseFacadeFactory.getInstance().createInterface();
+ VendorLicenseFacadeFactory.getInstance().createInterface();
public static final HealingService healingService =
- HealingServiceFactory.getInstance().createInterface();
+ HealingServiceFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- static byte[] createVnfArtifact(String vspId, String vlmId, Version vlmVersion, String vendorName,
- List<String> featureGroups, String user) {
+ private static byte[] createVnfArtifact(String vspId, String vlmId, Version vlmVersion,
+ String vendorName,
+ List<String> featureGroups, String user) {
mdcDataDebugMessage.debugEntryMessage("VLM name", vendorName);
@@ -68,31 +72,33 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts
artifact.setVspId(vspId);
artifact.setVendorName(vendorName);
- if(featureGroups != null) {
+ if (featureGroups != null) {
for (String featureGroupId : featureGroups) {
FeatureGroupModel featureGroupModel = vendorLicenseFacade
- .getFeatureGroupModel(new FeatureGroupEntity(vlmId, vlmVersion, featureGroupId), user);
- Set<EntitlementPoolEntity> entitlementPoolEntities = featureGroupModel.getEntitlementPools();
- for(EntitlementPoolEntity entitlementPoolEntity : entitlementPoolEntities){
+ .getFeatureGroupModel(new FeatureGroupEntity(vlmId, vlmVersion, featureGroupId), user);
+ Set<EntitlementPoolEntity> entitlementPoolEntities =
+ featureGroupModel.getEntitlementPools();
+ for (EntitlementPoolEntity entitlementPoolEntity : entitlementPoolEntities) {
entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
- entitlementPoolEntity.getId(), user));
+ entitlementPoolEntity.getId(), user));
entitlementPoolEntity.setManufacturerReferenceNumber(featureGroupModel.
- getEntityManufacturerReferenceNumber());
+ getEntityManufacturerReferenceNumber());
}
- Set<LicenseKeyGroupEntity> licenseKeyGroupEntities = featureGroupModel.getLicenseKeyGroups();
- for(LicenseKeyGroupEntity licenseKeyGroupEntity : licenseKeyGroupEntities){
+ Set<LicenseKeyGroupEntity> licenseKeyGroupEntities =
+ featureGroupModel.getLicenseKeyGroups();
+ for (LicenseKeyGroupEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
- licenseKeyGroupEntity.getId(), user));
+ licenseKeyGroupEntity.getId(), user));
licenseKeyGroupEntity.setManufacturerReferenceNumber(featureGroupModel.
- getEntityManufacturerReferenceNumber());
+ getEntityManufacturerReferenceNumber());
}
featureGroupModel.setEntitlementPools(entitlementPoolEntities.stream().map(
- entitlementPoolEntity -> (EntitlementPoolEntity) healingService
- .heal(entitlementPoolEntity, user)).collect(Collectors.toSet()));
+ entitlementPoolEntity -> (EntitlementPoolEntity) healingService
+ .heal(entitlementPoolEntity, user)).collect(Collectors.toSet()));
featureGroupModel.setLicenseKeyGroups(licenseKeyGroupEntities.stream().map(
- licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService
- .heal(licenseKeyGroupEntity, user)).collect(Collectors.toSet()));
+ licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService
+ .heal(licenseKeyGroupEntity, user)).collect(Collectors.toSet()));
artifact.getFeatureGroups().add(featureGroupModel);
}
}
@@ -101,7 +107,7 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts
return artifact.toXml().getBytes();
}
- static byte[] createVendorLicenseArtifact(String vlmId, String vendorName, String user) {
+ private static byte[] createVendorLicenseArtifact(String vlmId, String vendorName, String user) {
mdcDataDebugMessage.debugEntryMessage("VLM name", vendorName);
@@ -111,43 +117,42 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts
Set<EntitlementPoolEntity> entitlementPoolEntities = new HashSet<>();
Set<LicenseKeyGroupEntity> licenseKeyGroupEntities = new HashSet<>();
- List<Version> finalVersions = VendorLicenseArtifactsServiceUtils.getFinalVersionsForVlm(vlmId);
+ List<Version> finalVersions = getFinalVersionsForVlm(vlmId);
for (Version finalVersion : finalVersions) {
Collection<EntitlementPoolEntity> coll = vendorLicenseFacade.listEntitlementPools(vlmId,
- finalVersion, user);
- coll.stream().forEach( entitlementPoolEntity -> {
+ finalVersion, user);
+ coll.stream().forEach(entitlementPoolEntity -> {
entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, finalVersion,
- entitlementPoolEntity.getId(), user));
+ entitlementPoolEntity.getId(), user));
Optional<String> manufacturerReferenceNumber = getFeatureGroupManufactureRefNumber
- (entitlementPoolEntity.getReferencingFeatureGroups(), vlmId, finalVersion, user);
- manufacturerReferenceNumber.ifPresent(mrn -> entitlementPoolEntity
- .setManufacturerReferenceNumber(mrn));
+ (entitlementPoolEntity.getReferencingFeatureGroups(), vlmId, finalVersion, user);
+ manufacturerReferenceNumber
+ .ifPresent(entitlementPoolEntity::setManufacturerReferenceNumber);
});
entitlementPoolEntities.addAll(coll);
Collection<LicenseKeyGroupEntity> coll2 = vendorLicenseFacade.listLicenseKeyGroups(vlmId,
- finalVersion, user);
+ finalVersion, user);
- coll2.stream().forEach( licenseKeyGroupEntity -> {
+ coll2.stream().forEach(licenseKeyGroupEntity -> {
licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, finalVersion,
- licenseKeyGroupEntity.getId(), user));
+ licenseKeyGroupEntity.getId(), user));
Optional<String> manufacturerReferenceNumber = getFeatureGroupManufactureRefNumber
- (licenseKeyGroupEntity.getReferencingFeatureGroups(), vlmId, finalVersion, user);
- manufacturerReferenceNumber.ifPresent(mrn -> licenseKeyGroupEntity
- .setManufacturerReferenceNumber(mrn));
+ (licenseKeyGroupEntity.getReferencingFeatureGroups(), vlmId, finalVersion, user);
+ manufacturerReferenceNumber
+ .ifPresent(licenseKeyGroupEntity::setManufacturerReferenceNumber);
});
licenseKeyGroupEntities.addAll(coll2);
}
- entitlementPoolEntities = VendorLicenseArtifactsServiceUtils
- .healEPs(user,
- VendorLicenseArtifactsServiceUtils.filterChangedEntities(entitlementPoolEntities));
- licenseKeyGroupEntities = VendorLicenseArtifactsServiceUtils
- .healLkgs(user,
- VendorLicenseArtifactsServiceUtils.filterChangedEntities(licenseKeyGroupEntities));
-
+ entitlementPoolEntities =
+ healEPs(user, filterChangedEntities(prepareForFiltering(entitlementPoolEntities, user,
+ true)));
+ licenseKeyGroupEntities =
+ healLkgs(user, filterChangedEntities(prepareForFiltering(licenseKeyGroupEntities, user,
+ false)));
vendorLicenseArtifact.setEntitlementPoolEntities(entitlementPoolEntities);
vendorLicenseArtifact.setLicenseKeyGroupEntities(licenseKeyGroupEntities);
@@ -156,30 +161,33 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts
}
private static Optional<String> getFeatureGroupManufactureRefNumber(Set<String> featureGroupIds,
- String vlmId, Version finalVersion, String user) {
+ String vlmId,
+ Version finalVersion,
+ String user) {
String manufactureReferenceNumber = null;
if (CollectionUtils.isNotEmpty(featureGroupIds)) {
Object[] featureGroupIdsList = featureGroupIds.toArray();
- if (featureGroupIdsList != null && featureGroupIdsList.length > 0) {
+ if (featureGroupIdsList.length > 0) {
FeatureGroupEntity featureGroup =
- vendorLicenseFacade.getFeatureGroup(new FeatureGroupEntity(vlmId, finalVersion,
- featureGroupIdsList[0].toString()), user);
+ vendorLicenseFacade.getFeatureGroup(new FeatureGroupEntity(vlmId, finalVersion,
+ featureGroupIdsList[0].toString()), user);
manufactureReferenceNumber = featureGroup != null ? featureGroup
- .getManufacturerReferenceNumber() : null;
+ .getManufacturerReferenceNumber() : null;
}
}
return manufactureReferenceNumber != null ? Optional.of(manufactureReferenceNumber) :
- Optional.empty();
+ Optional.empty();
}
/**
* Create License Artifacts.
- * @param vspId vspId
- * @param vlmId vlmId
- * @param vlmVersion vlmVersion
+ *
+ * @param vspId vspId
+ * @param vlmId vlmId
+ * @param vlmVersion vlmVersion
* @param featureGroups featureGroups
- * @param user user
+ * @param user user
* @return FileContentHandler
*/
public FileContentHandler createLicenseArtifacts(String vspId, String vlmId, Version vlmVersion,
@@ -189,12 +197,12 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts
mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
FileContentHandler artifacts = new FileContentHandler();
- String vendorName = VendorLicenseArtifactsServiceUtils.getVendorName(vlmId, user);
+ String vendorName = getVendorName(vlmId, user);
artifacts.addFile(VNF_ARTIFACT_NAME_WITH_PATH,
- createVnfArtifact(vspId, vlmId, vlmVersion, vendorName, featureGroups, user));
+ createVnfArtifact(vspId, vlmId, vlmVersion, vendorName, featureGroups, user));
artifacts.addFile(VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH,
- createVendorLicenseArtifact(vlmId, vendorName, user));
+ createVendorLicenseArtifact(vlmId, vendorName, user));
mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
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/util/VendorLicenseArtifactsServiceUtils.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VendorLicenseArtifactsServiceUtils.java
index f3e09766db..502aa350b9 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VendorLicenseArtifactsServiceUtils.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VendorLicenseArtifactsServiceUtils.java
@@ -45,15 +45,15 @@ import java.util.Set;
public class VendorLicenseArtifactsServiceUtils {
private static final HealingService healingService =
- HealingServiceFactory.getInstance().createInterface();
+ HealingServiceFactory.getInstance().createInterface();
/**
* maps the entities by id
*
* @return a Map of id -> list of versionable entities with that id
*/
- static MultiValuedMap<String, VersionableEntity> mapById(
- Collection<? extends VersionableEntity> versionableEntities) {
+ private static MultiValuedMap<String, VersionableEntity> mapById(
+ Collection<? extends VersionableEntity> versionableEntities) {
MultiValuedMap<String, VersionableEntity> mappedById = new ArrayListValuedHashMap<>();
for (VersionableEntity ve : versionableEntities) {
mappedById.put(ve.getId(), ve);
@@ -64,16 +64,15 @@ public class VendorLicenseArtifactsServiceUtils {
/**
* For all entities with same id, only entities that differ from one another will be returned.
* If no change has occured, the entity with the earlier VLM version will be returned.
- * If only one version of said entitity exists it will be returned
- * @param versionableEntities
+ * If only one version of said entities exists it will be returned
* @return a list of entities that has been changed
*/
public static List<VersionableEntity> filterChangedEntities(
- Collection<? extends VersionableEntity> versionableEntities) {
+ Collection<? extends VersionableEntity> versionableEntities) {
MultiValuedMap<String, VersionableEntity> entitiesById = mapById(
- versionableEntities);
+ versionableEntities);
MultiValuedMap<String, VersionableEntity> entitiesByVersionUuId =
- new ArrayListValuedHashMap<>();
+ new ArrayListValuedHashMap<>();
List<VersionableEntity> changedOnly = new ArrayList<>();
for (String epId : entitiesById.keySet()) {
@@ -86,7 +85,7 @@ public class VendorLicenseArtifactsServiceUtils {
//for every list of eps which have the same uuid, get the one with the earliest vlm version.
for (String versionUid : entitiesByVersionUuId.keySet()) {
List<VersionableEntity> versionableEntitiesForUuid =
- (List<VersionableEntity>) entitiesByVersionUuId.get(versionUid);
+ (List<VersionableEntity>) entitiesByVersionUuId.get(versionUid);
versionableEntitiesForUuid.sort(new VersionableEntitySortByVlmMajorVersion());
changedOnly.add(versionableEntitiesForUuid.get(0));
}
@@ -99,7 +98,7 @@ public class VendorLicenseArtifactsServiceUtils {
Set<LicenseKeyGroupEntity> healed = new HashSet<>();
for (VersionableEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
healed.add((LicenseKeyGroupEntity) VendorLicenseArtifactsServiceImpl.healingService
- .heal(licenseKeyGroupEntity, user));
+ .heal(licenseKeyGroupEntity, user));
}
return healed;
@@ -110,7 +109,7 @@ public class VendorLicenseArtifactsServiceUtils {
Set<EntitlementPoolEntity> healed = new HashSet<>();
for (VersionableEntity entitlementPoolEntity : entitlementPoolEntities) {
healed.add((EntitlementPoolEntity) VendorLicenseArtifactsServiceImpl.healingService
- .heal(entitlementPoolEntity, user));
+ .heal(entitlementPoolEntity, user));
}
return healed;
@@ -118,15 +117,69 @@ public class VendorLicenseArtifactsServiceUtils {
public static List<Version> getFinalVersionsForVlm(String vlmId) {
VersionInfo versionInfo =
- VendorLicenseArtifactsServiceImpl.vendorLicenseFacade
- .getVersionInfo(vlmId, VersionableEntityAction.Read, "");
+ VendorLicenseArtifactsServiceImpl.vendorLicenseFacade
+ .getVersionInfo(vlmId, VersionableEntityAction.Read, "");
return versionInfo.getFinalVersions();
}
public static String getVendorName(String vendorLicenseModelId, String user) {
return VendorLicenseArtifactsServiceImpl.vendorLicenseFacade
- .getVendorLicenseModel(vendorLicenseModelId, null, user)
- .getVendorLicenseModel().getVendorName();
+ .getVendorLicenseModel(vendorLicenseModelId, null, user)
+ .getVendorLicenseModel().getVendorName();
}
+
+
+ /**
+ * Written to handle the consequences of ATTASDC-4780 where version_uuid was not saved or
+ * retrieved correctly by DAO for EPs and LKGs. Performs a healing of sorts according to the
+ * following : 1. all versions of a specific entity (EP or LKG that have the same invariant_uuid)
+ * are ordered by their VLM version 2. first element is sent to healing (which will set a
+ * versionUUID for it IF it doesnt exist) 3. each subsequent element is compared to previous . If
+ * same, UUID is copied from the previous element , if they differ - the current element is sent
+ * to healing as before. For VLMs created post-bugfix this code should not update any element
+ */
+ public static Collection<? extends VersionableEntity> prepareForFiltering(Collection<? extends
+ VersionableEntity> versionableEntities, String user, boolean isEP) {
+ MultiValuedMap<String, VersionableEntity> entitiesById = mapById(
+ versionableEntities);
+
+ for (String epId : entitiesById.keySet()) {
+ List<VersionableEntity> versionableEntitiesForId = new ArrayList<>();
+ versionableEntitiesForId.addAll(entitiesById.get(epId));
+ versionableEntitiesForId.sort(new VersionableEntitySortByVlmMajorVersion());
+ healingService.heal(versionableEntitiesForId.get(0), user);
+ for (int i = 1; i < versionableEntitiesForId.size(); i++) {
+ if (isEP) {
+ EntitlementPoolEntity current = (EntitlementPoolEntity) versionableEntitiesForId.get(i);
+ EntitlementPoolEntity previous = (EntitlementPoolEntity) versionableEntitiesForId
+ .get(i - 1);
+ if (current.equals(previous) && current.getVersionUuId() == null) {
+ current.setVersionUuId(previous.getVersionUuId());
+ healingService.persistNoHealing(current);
+ } else {
+ versionableEntitiesForId.set(i, healingService.heal(versionableEntitiesForId.get(i),
+ user));
+ }
+
+ } else {
+ LicenseKeyGroupEntity current = (LicenseKeyGroupEntity) versionableEntitiesForId.get(i);
+ LicenseKeyGroupEntity previous = (LicenseKeyGroupEntity) versionableEntitiesForId
+ .get(i - 1);
+ if (current.equals(previous) && current.getVersionUuId() == null) {
+ current.setVersionUuId(previous.getVersionUuId());
+ healingService.persistNoHealing(current);
+ } else {
+ versionableEntitiesForId.set(i, healingService.heal(versionableEntitiesForId.get(i),
+ user));
+ }
+
+
+ }
+ }
+ }
+ return versionableEntities;
+ }
+
+
}