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());
}
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;
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.
}
@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