summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java25
3 files changed, 21 insertions, 8 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index 56ea8daa53..df2e098be7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -499,7 +499,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private Collection<ErrorCode> validateLicensingData(VspDetails vspDetails) {
if (vspDetails.getVendorId() != null) {
- Optional<ErrorCode> errorCode = vendorLicenseFacade.validateVendorForUsage(vspDetails.getVendorId());
+ Optional<ErrorCode> errorCode = vendorLicenseFacade.validateVendorForUsage(vspDetails.getVendorId(),vspDetails.getVlmVersion());
if (errorCode.isPresent()) {
return Collections.singleton(errorCode.get());
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java
index 42a4699d96..d25a18909e 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java
@@ -70,7 +70,7 @@ public interface VendorLicenseFacade {
String licenseAgreementId,
Collection<String> featureGroupIds);
- Optional<ErrorCode> validateVendorForUsage(String vlmId);
+ Optional<ErrorCode> validateVendorForUsage(String vlmId, Version version);
void validate(String vendorLicenseModelId, Version version);
}
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 5b39a79c89..50772a3de3 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
@@ -64,6 +64,7 @@ import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.versioning.ItemManagerFactory;
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.errors.VersionableSubEntityNotFoundErrorBuilder;
import org.openecomp.sdc.versioning.types.Item;
import org.openecomp.sdc.versioning.types.ItemStatus;
@@ -89,6 +90,10 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
private static final ErrorCode USED_VLM_ARCHIVE_ERROR =
new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(FIELD_VALIDATION_ERROR_ERR_ID)
.withMessage("The supplied vendor is archived and therefore cannot be used").build();
+ private static final ErrorCode USED_VLM_IS_DRAFT_ERROR =
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(FIELD_VALIDATION_ERROR_ERR_ID)
+ .withMessage("The supplied vendor version is draft and therefor can not be used").build();
+
/**
* Instantiates a new Vendor license facade.
@@ -324,13 +329,21 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
}
@Override
- public Optional<ErrorCode> validateVendorForUsage(String vlmId) {
+ public Optional<ErrorCode> validateVendorForUsage(String vlmId, Version version) {
Item vlm = ItemManagerFactory.getInstance().createInterface().get(vlmId);
- return vlm == null
- ? Optional.of(USED_VLM_NOT_EXIST_ERROR)
- : ItemStatus.ARCHIVED == vlm.getStatus()
- ? Optional.of(USED_VLM_ARCHIVE_ERROR)
- : Optional.empty();
+ if(vlm == null) {
+ return Optional.of(USED_VLM_NOT_EXIST_ERROR);
+ }
+
+ if (ItemStatus.ARCHIVED == vlm.getStatus()){
+ return Optional.of(USED_VLM_ARCHIVE_ERROR);
+ }
+
+ if(VersionStatus.Draft.equals(version.getStatus())){
+ return Optional.of(USED_VLM_IS_DRAFT_ERROR);
+ }
+
+ return Optional.empty();
}
@Override