aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-license-lib
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2022-04-13 11:21:15 +0100
committerMichael Morris <michael.morris@est.tech>2022-04-21 09:48:05 +0000
commit30ff812c65389f5ca4c91d9774d425e81ef62049 (patch)
treeb7d293c23621df6c1084b9ff7dbde9c7d7d888ac /openecomp-be/lib/openecomp-sdc-vendor-license-lib
parent225dabdf0812d1a3d9eb3a96740507744bb2b807 (diff)
Check if VLM is used before deleting
Checks if the VLM is in use by any VSP before allowing to delete it. Add unit tests for the delete method, considering the restriction. Applies minor refactors with related code. Change-Id: I4ff6ddf3959a4ca92ab68b29c8913fc6f0ebdb3c Issue-ID: SDC-3966 Signed-off-by: andre.schmid <andre.schmid@est.tech>
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/errors/VendorLicenseErrorCodes.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VendorLicenseModelDaoZusammenImpl.java6
2 files changed, 10 insertions, 2 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseErrorCodes.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseErrorCodes.java
index 62ea84b48b..eecb597ab2 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseErrorCodes.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseErrorCodes.java
@@ -19,6 +19,10 @@
*/
package org.openecomp.sdc.vendorlicense.errors;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class VendorLicenseErrorCodes {
public static final String VENDOR_LICENSE_MODEL_NOT_FOUND = "VENDOR_LICENSE_MODEL_NOT_FOUND";
@@ -30,4 +34,6 @@ public class VendorLicenseErrorCodes {
public static final String LIMIT_INVALID_TIME = "LIMIT_INVALID_TIME";
public static final String DUPLICATE_LIMIT_NAME_NOT_ALLOWED = "DUPLICATE_LIMIT_NAME_NOT_ALLOWED";
public static final String DATE_RANGE_INVALID = "DATE_RANGE_INVALID";
+ public static final String VLM_IS_IN_USE_DELETE_ERROR = "VLM_IS_IN_USE_DELETE_ERROR";
+ public static final String VLM_IS_CERTIFIED_DELETE_ERROR = "VLM_IS_CERTIFIED_DELETE_ERROR";
}
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/VendorLicenseModelDaoZusammenImpl.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/VendorLicenseModelDaoZusammenImpl.java
index 2c4702aec1..8f974c4df8 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/VendorLicenseModelDaoZusammenImpl.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/VendorLicenseModelDaoZusammenImpl.java
@@ -15,6 +15,8 @@
*/
package org.openecomp.sdc.vendorlicense.dao.impl.zusammen;
+import static org.openecomp.sdc.versioning.dao.impl.zusammen.ItemZusammenDaoImpl.ItemInfoProperty.ITEM_TYPE;
+
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
@@ -34,7 +36,7 @@ import org.openecomp.sdc.versioning.types.VersionableEntityStoreType;
public class VendorLicenseModelDaoZusammenImpl implements VendorLicenseModelDao {
- private ZusammenAdaptor zusammenAdaptor;
+ private final ZusammenAdaptor zusammenAdaptor;
public VendorLicenseModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
this.zusammenAdaptor = zusammenAdaptor;
@@ -50,7 +52,7 @@ public class VendorLicenseModelDaoZusammenImpl implements VendorLicenseModelDao
public Collection<VendorLicenseModelEntity> list(VendorLicenseModelEntity vendorLicenseModelEntity) {
ElementToVLMGeneralConvertor convertor = new ElementToVLMGeneralConvertor();
return zusammenAdaptor.listItems(ZusammenUtil.createSessionContext()).stream()
- .filter(item -> "VendorLicenseModel".equals(item.getInfo().getProperty("item_type"))).map(item -> {
+ .filter(item -> "VendorLicenseModel".equals(item.getInfo().getProperty(ITEM_TYPE.getName()))).map(item -> {
VendorLicenseModelEntity entity = convertor.convert(item);
entity.setId(item.getId().getValue());
entity.setVersion(null);