summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp')
-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/ComponentProcesses.java19
-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/OrchestrationTemplateCandidate.java3
-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/mapping/MapUploadFileResponseToUploadFileResponseDto.java2
-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/mapping/MapValidationResponseToDto.java32
-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/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java2
-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/mapping/MapVspDescriptionDtoToVspDetails.java2
-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/OrchestrationTemplateCandidateImpl.java30
-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.java35
8 files changed, 61 insertions, 64 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/ComponentProcesses.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/ComponentProcesses.java
index ca50ef1426..edb3b5bfc2 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/ComponentProcesses.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/ComponentProcesses.java
@@ -20,35 +20,24 @@
package org.openecomp.sdcrests.vsp.rest;
-import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
-import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
-
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
-import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Pattern;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
+import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/processes")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
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/OrchestrationTemplateCandidate.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/OrchestrationTemplateCandidate.java
index fbf29185e3..fa7f421fc8 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/OrchestrationTemplateCandidate.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/OrchestrationTemplateCandidate.java
@@ -23,6 +23,7 @@ package org.openecomp.sdcrests.vsp.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
+import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import org.openecomp.sdc.vendorsoftwareproduct.types.FileDataStructureDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto;
@@ -61,7 +62,7 @@ public interface OrchestrationTemplateCandidate extends VspEntities {
Response upload(
@PathParam("vspId") String vspId,
@ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
- @Multipart("upload") InputStream heatFileToUpload,
+ @Multipart("upload") Attachment fileToUpload,
@NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
@GET
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/mapping/MapUploadFileResponseToUploadFileResponseDto.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/mapping/MapUploadFileResponseToUploadFileResponseDto.java
index cccfd02371..48053d053d 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/mapping/MapUploadFileResponseToUploadFileResponseDto.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/mapping/MapUploadFileResponseToUploadFileResponseDto.java
@@ -34,5 +34,7 @@ public class MapUploadFileResponseToUploadFileResponseDto
public void doMapping(UploadFileResponse source, UploadFileResponseDto target) {
target.setStatus(source.getStatus());
target.setErrors(source.getErrors());
+ target.setOnboardingOrigin(source.getOnboardingType().toString());
+ target.setNetworkPackageName(source.getNetworkPackageName());
}
}
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/mapping/MapValidationResponseToDto.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/mapping/MapValidationResponseToDto.java
index 89d210f372..3cabebbb69 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/mapping/MapValidationResponseToDto.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/mapping/MapValidationResponseToDto.java
@@ -24,8 +24,6 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.vendorsoftwareproduct.types.ComponentValidationResult;
-import org.openecomp.sdc.vendorsoftwareproduct.types.DeploymentFlavorValidationResult;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
@@ -49,37 +47,37 @@ import java.util.Set;
import java.util.stream.Collectors;
public class MapValidationResponseToDto
- extends MappingBase<ValidationResponse, ValidationResponseDto> {
+ extends MappingBase<ValidationResponse, ValidationResponseDto> {
private static Map<String, List<ErrorMessageDto>> mapUploadDataErrors(
- Map<String, List<ErrorMessage>> uploadDataErrors) {
+ Map<String, List<ErrorMessage>> uploadDataErrors) {
if (MapUtils.isEmpty(uploadDataErrors)) {
return null;
}
return uploadDataErrors.entrySet().stream().collect(
- Collectors.toMap(entry -> entry.getKey(), entry -> mapErrorMessages(entry.getValue())));
+ Collectors.toMap(entry -> entry.getKey(), entry -> mapErrorMessages(entry.getValue())));
}
private static QuestionnaireValidationResultDto mapQuestionnaireValidationResult(
- QuestionnaireValidationResult questionnaireValidationResult) {
+ QuestionnaireValidationResult questionnaireValidationResult) {
if (Objects.isNull(questionnaireValidationResult)
- || Objects.isNull(questionnaireValidationResult.getValidationData())) {
+ || Objects.isNull(questionnaireValidationResult.getValidationData())) {
return null;
}
QuestionnaireValidationResultDto questionnaireValidationResultDto =
- new QuestionnaireValidationResultDto();
+ new QuestionnaireValidationResultDto();
questionnaireValidationResultDto.setValid(questionnaireValidationResult.isValid());
Set<CompositionEntityValidationDataDto> validationDataDto = new HashSet<>();
for(CompositionEntityValidationData validationData : questionnaireValidationResult.getValidationData()){
validationDataDto.add(new MapCompositionEntityValidationDataToDto().applyMapping
- (validationData, CompositionEntityValidationDataDto.class));
+ (validationData, CompositionEntityValidationDataDto.class));
}
questionnaireValidationResultDto.setValidationData(validationDataDto);
return questionnaireValidationResultDto;
}
- private static ComponentValidationResultDto mapcomponentValidationResult(
+ /*private static ComponentValidationResultDto mapcomponentValidationResult(
ComponentValidationResult componentValidationResult) {
if (componentValidationResult == null) {
return null;
@@ -115,18 +113,18 @@ public class MapValidationResponseToDto
deploymentFlavorValidationResultDto.setValidationData(validationDataDto);
return deploymentFlavorValidationResultDto;
- }
+ }*/
private static List<ErrorMessageDto> mapErrorMessages(List<ErrorMessage> errorMessages) {
return errorMessages == null ? null : errorMessages.stream().map(
- errorMessage -> new MapErrorMessageToDto()
- .applyMapping(errorMessage, ErrorMessageDto.class)).collect(Collectors.toList());
+ errorMessage -> new MapErrorMessageToDto()
+ .applyMapping(errorMessage, ErrorMessageDto.class)).collect(Collectors.toList());
}
private static Collection<ErrorCodeDto> mapErrorCodes(Collection<ErrorCode> errorCodes) {
return CollectionUtils.isEmpty(errorCodes) ? null : errorCodes.stream()
- .map(errorCode -> new MapErrorCodeToDto().applyMapping(errorCode, ErrorCodeDto.class))
- .collect(Collectors.toList());
+ .map(errorCode -> new MapErrorCodeToDto().applyMapping(errorCode, ErrorCodeDto.class))
+ .collect(Collectors.toList());
}
@Override
@@ -136,8 +134,6 @@ public class MapValidationResponseToDto
target.setLicensingDataErrors(mapErrorCodes(source.getLicensingDataErrors()));
target.setUploadDataErrors(mapUploadDataErrors(source.getUploadDataErrors()));
target.setQuestionnaireValidationResult(
- mapQuestionnaireValidationResult(source.getQuestionnaireValidationResult()));
- target.setComponentValidationResult(mapcomponentValidationResult(source.getComponentValidationResult()));
- target.setDeploymentFlavorValidationResult(mapdeploymentFlavorValidationResult(source.getDeploymentFlavorValidationResult()));
+ mapQuestionnaireValidationResult(source.getQuestionnaireValidationResult()));
}
}
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/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.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/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java
index 9093da599f..815135f834 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/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.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/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java
@@ -45,8 +45,10 @@ public class MapVersionedVendorSoftwareProductInfoToVspDetailsDto
target.setSubCategory(vsp.getSubCategory());
target.setVendorId(vsp.getVendorId());
target.setVendorName(vsp.getVendorName());
+ target.setOnboardingOrigin(vsp.getOnboardingOrigin());
target.setLicensingVersion(vsp.getVlmVersion() == null ? null : new VersionDto(vsp.getVlmVersion().toString(), vsp.getVlmVersion().toString()));
target.setIsOldVersion("False");
+ target.setNetworkPackageName(vsp.getNetworkPackageName());
if (vsp.getLicenseAgreement() != null || vsp.getFeatureGroups() != null) {
LicensingData licensingData = new LicensingData();
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/mapping/MapVspDescriptionDtoToVspDetails.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/mapping/MapVspDescriptionDtoToVspDetails.java
index 9808bbb2b6..ba3d92e5d2 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/mapping/MapVspDescriptionDtoToVspDetails.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/mapping/MapVspDescriptionDtoToVspDetails.java
@@ -39,6 +39,8 @@ public class MapVspDescriptionDtoToVspDetails extends MappingBase<VspDescription
target.setVendorName(source.getVendorName());
target.setVendorId(source.getVendorId());
target.setOnboardingMethod(source.getOnboardingMethod());
+ target.setOnboardingOrigin(source.getOnboardingOrigin());
+ target.setNetworkPackageName(source.getNetworkPackageName());
VersionDto vlmVersion = source.getLicensingVersion();
if (vlmVersion != null) {
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/OrchestrationTemplateCandidateImpl.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/OrchestrationTemplateCandidateImpl.java
index 0793e9473e..07cef57251 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/OrchestrationTemplateCandidateImpl.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/OrchestrationTemplateCandidateImpl.java
@@ -1,10 +1,10 @@
package org.openecomp.sdcrests.vsp.rest.services;
import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.sdc.common.errors.Messages;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.MdcUtil;
@@ -32,11 +32,11 @@ import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
import java.util.Optional;
+import static org.openecomp.core.utilities.file.FileUtils.getFileExtension;
+import static org.openecomp.core.utilities.file.FileUtils.getNetworkPackageName;
+
@Named
@Service("orchestrationTemplateCandidate")
@Scope(value = "prototype")
@@ -48,31 +48,35 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
LoggerFactory.getLogger(OrchestrationTemplateCandidateImpl.class);
@Override
- public Response upload(String vspId, String versionId, InputStream heatFileToUpload,
+ public Response upload(String vspId, String versionId, Attachment fileToUpload,
String user) {
MdcUtil.initMdc(LoggerServiceName.Upload_File.toString());
logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_HEAT + vspId);
-
+ String filename = fileToUpload.getContentDisposition().getParameter("filename");
UploadFileResponse uploadFileResponse = candidateManager
.upload(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction
- .Write), heatFileToUpload, user);
+ .Write), fileToUpload.getObject(InputStream.class), user, getFileExtension(filename),
+ getNetworkPackageName(filename));
UploadFileResponseDto uploadFileResponseDto = new MapUploadFileResponseToUploadFileResponseDto()
.applyMapping(uploadFileResponse, UploadFileResponseDto.class);
return Response.ok(uploadFileResponseDto).build();
}
+
+
@Override
public Response get(String vspId, String versionId, String user) throws IOException {
- Optional<byte[]> zipFile =
- candidateManager
- .get(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction.Read), user);
+
+ Optional<Pair<String, byte[]>> zipFile = candidateManager
+ .get(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction.Read), user);
if (!zipFile.isPresent()) {
return Response.status(Response.Status.NOT_FOUND).build();
}
- Response.ResponseBuilder response = Response.ok(zipFile.get());
- response.header("Content-Disposition", "attachment; filename=HeatCandidate.zip");
+ Response.ResponseBuilder response = Response.ok(zipFile.get().getRight());
+ String filename = "Candidate." + zipFile.get().getLeft();
+ response.header("Content-Disposition", "attachment; filename=" + filename);
return response.build();
}
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 8f2e73bff6..0b73cbcee6 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
@@ -47,14 +47,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProd
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.types.VersionInfo;
import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.*;
import org.openecomp.sdcrests.vsp.rest.VendorSoftwareProducts;
import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToVspComputeDto;
import org.openecomp.sdcrests.vsp.rest.mapping.MapPackageInfoToPackageInfoDto;
@@ -100,9 +93,13 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
+ vspDescriptionDto.getName());
VspCreationDto vspCreationDto = null;
- switch (vspDescriptionDto.getOnboardingMethod()) {
- case "HEAT":
- case "Manual":
+ OnboardingMethod onboardingMethod = OnboardingMethod.valueOf(vspDescriptionDto.getOnboardingMethod());
+ if (onboardingMethod == null){
+ return handleUnkownOnboardingMethod();
+ }
+ switch (onboardingMethod) {
+ case NetworkPackage:
+ case Manual:
VspDetails vspDetails = new MapVspDescriptionDtoToVspDetails().
applyMapping(vspDescriptionDto, VspDetails.class);
@@ -112,17 +109,21 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
vspCreationDto = mapping.applyMapping(vspDetails, VspCreationDto.class);
break;
default:
- ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder
- .getInvalidOnboardingMethodErrorBuilder();
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
- LoggerTragetServiceName.ADD_VSP, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), onboardingMethodUpdateErrorCode.message());
- throw new CoreException(onboardingMethodUpdateErrorCode);
+ return handleUnkownOnboardingMethod();
}
return Response.ok(vspCreationDto).build();
}
+ private Response handleUnkownOnboardingMethod() {
+ ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder
+ .getInvalidOnboardingMethodErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.ADD_VSP, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), onboardingMethodUpdateErrorCode.message());
+ throw new CoreException(onboardingMethodUpdateErrorCode);
+ }
+
@Override
public Response listVsps(String versionFilter, String user) {
MdcUtil.initMdc(LoggerServiceName.List_VSP.toString());