summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-license-lib
diff options
context:
space:
mode:
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/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
2 files changed, 20 insertions, 7 deletions
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