diff options
author | ayalaben <ayala.benzvi@amdocs.com> | 2018-10-16 18:13:22 +0300 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2018-10-17 10:24:05 +0000 |
commit | 5e5d239283077beefc07e0891ebb76bbb5a3e906 (patch) | |
tree | f67b78b44dce3307a6aa24206438c02a37d627b5 /openecomp-be/lib | |
parent | ce0558f2df8e85f3f10df1676bb06bf3b68e683f (diff) |
VSP submit doesn't validate vlm version
Change-Id: If98f41c186b330e7f17e51ef88c6b5e91121f2c9
Issue-ID: SDC-1843
Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'openecomp-be/lib')
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 |