aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java4
-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.java34
2 files changed, 22 insertions, 16 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
index 36e076083f..582bf473d7 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
@@ -497,7 +497,9 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
String user) throws IOException {
VspDetails vspDetails = vendorSoftwareProductManager.getVsp(vspId, version);
- vspDetails.setVlmVersion(versioningManager.get(vspDetails.getVendorId(),vspDetails.getVlmVersion()));
+ if (vspDetails.getVlmVersion() != null) {
+ vspDetails.setVlmVersion(versioningManager.get(vspDetails.getVendorId(), vspDetails.getVlmVersion()));
+ }
ValidationResponse validationResponse = vendorSoftwareProductManager.validate(vspDetails);
Map<String, List<ErrorMessage>> compilationErrors =
vendorSoftwareProductManager.compile(vspId, 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 50772a3de3..818d772db4 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
@@ -92,7 +92,7 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
.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();
+ .withMessage("The supplied vendor version is draft and therefore can not be used").build();
/**
@@ -328,25 +328,29 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
return errorMessages;
}
- @Override
- public Optional<ErrorCode> validateVendorForUsage(String vlmId, Version version) {
- Item vlm = ItemManagerFactory.getInstance().createInterface().get(vlmId);
- if(vlm == null) {
- return Optional.of(USED_VLM_NOT_EXIST_ERROR);
+ @Override
+ 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)
+ : isDraftVlm(vlm, version)
+ ? Optional.of(USED_VLM_IS_DRAFT_ERROR)
+ : Optional.empty();
}
- if (ItemStatus.ARCHIVED == vlm.getStatus()){
- return Optional.of(USED_VLM_ARCHIVE_ERROR);
- }
+ private boolean isDraftVlm(Item vlm, Version version) {
+ return (version == null && isVlmWithoutCertifiedVersions(vlm)) ||
+ (version != null && VersionStatus.Draft.equals(version.getStatus()));
+ }
- if(VersionStatus.Draft.equals(version.getStatus())){
- return Optional.of(USED_VLM_IS_DRAFT_ERROR);
+ private boolean isVlmWithoutCertifiedVersions(Item vlm) {
+ Integer numOfCertifiedVersions = vlm.getVersionStatusCounters().get(VersionStatus.Certified);
+ return numOfCertifiedVersions == null || numOfCertifiedVersions < 1;
}
- return Optional.empty();
- }
-
- @Override
+ @Override
public LicenseAgreementEntity getLicenseAgreement(String vlmId, Version version,
String licenseAgreementId) {
LicenseAgreementEntity input = new LicenseAgreementEntity(vlmId, version, licenseAgreementId);