diff options
author | 2017-09-12 11:00:02 +0000 | |
---|---|---|
committer | 2017-09-12 11:00:02 +0000 | |
commit | e6fc26ab18d1409c490c859398fc5fca71d0518b (patch) | |
tree | 30441a6b43e2507e8cdef3589a5defc74083263f /openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org | |
parent | a0858efdab2f9bdc5d46be5655cdbb76708f4763 (diff) | |
parent | c8a540b3c234449163f6fb1899807bba951113b4 (diff) |
Merge "Create new VSP, onboard from TOSCA file - UI"
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org')
7 files changed, 46 insertions, 46 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/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..4c6cdaa54d 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,11 @@ 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.utilities.file.FileUtils; 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,10 +33,8 @@ 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.*; @Named @Service("orchestrationTemplateCandidate") @@ -48,31 +47,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), + FileUtils.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()); |