diff options
Diffstat (limited to 'openecomp-be/api')
16 files changed, 183 insertions, 129 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java index d399469745..2f6d298f01 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java @@ -35,29 +35,25 @@ import org.openecomp.sdc.common.errors.ValidationErrorBuilder; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import javax.validation.Path; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; public class DefaultExceptionMapper implements ExceptionMapper<Exception> { private static final String ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE = "errorCodesToResponseStatusMapping.json"; @SuppressWarnings("unchecked") private static Map<String, String> errorCodeToResponseStatus = - JsonUtil.json2Object(FileUtils - .getFileInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE), Map.class); + FileUtils.readViaInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE, + stream -> JsonUtil.json2Object(stream, Map.class)); + private static Logger logger = (Logger) LoggerFactory.getLogger(DefaultExceptionMapper.class); @Override diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java index 36e25e0f2e..4365ace85d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java @@ -32,7 +32,9 @@ import javax.ws.rs.core.Response; public class EntitlementPoolLimitsImpl implements EntitlementPoolLimits { private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); + VendorLicenseManagerFactory.getInstance().createInterface(); + + public static final String parent = "EntitlementPool"; @Override public Response createLimit(LimitRequestDto request, @@ -44,18 +46,19 @@ public class EntitlementPoolLimitsImpl implements EntitlementPoolLimits { MdcUtil.initMdc(LoggerServiceName.Create_LIMIT.toString()); vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf - (versionId), entitlementPoolId), user); + (versionId), entitlementPoolId), user); LimitEntity limitEntity = - new MapLimitRequestDtoToLimitEntity() - .applyMapping(request, LimitEntity.class); + new MapLimitRequestDtoToLimitEntity() + .applyMapping(request, LimitEntity.class); limitEntity.setEpLkgId(entitlementPoolId); limitEntity.setVendorLicenseModelId(vlmId); + limitEntity.setParent(parent); LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity, user); MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto(); LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto - .class); + .class); /*StringWrapperResponse result = createdLimit != null ? new StringWrapperResponse(createdLimit.getId()) @@ -65,24 +68,24 @@ public class EntitlementPoolLimitsImpl implements EntitlementPoolLimits { //return Response.ok(result).build(); return Response.ok(createdLimitDto != null ? createdLimitDto : null) - .build(); + .build(); } @Override public Response listLimits(String vlmId, String versionId, String entitlementPoolId, String - user) { + user) { mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP id", entitlementPoolId); MdcUtil.initMdc(LoggerServiceName.List_EP.toString()); vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf - (versionId), entitlementPoolId), user); + (versionId), entitlementPoolId), user); Collection<LimitEntity> limits = - vendorLicenseManager.listLimits(vlmId, Version.valueOf(versionId), entitlementPoolId, user); + vendorLicenseManager.listLimits(vlmId, Version.valueOf(versionId), entitlementPoolId, user); GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>(); MapLimitEntityToLimitDto outputMapper = - new MapLimitEntityToLimitDto(); + new MapLimitEntityToLimitDto(); for (LimitEntity limit : limits) { result.add(outputMapper.applyMapping(limit, LimitEntityDto.class)); } @@ -96,12 +99,12 @@ public class EntitlementPoolLimitsImpl implements EntitlementPoolLimits { public Response getLimit( String vlmId, String versionId, String entitlementPoolId, String limitId, String user) { mdcDataDebugMessage.debugEntryMessage("VLM id, EP id, Limit Id", vlmId, entitlementPoolId, - limitId); + limitId); MdcUtil.initMdc(LoggerServiceName.Get_LIMIT.toString()); vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf - (versionId), entitlementPoolId), user); + (versionId), entitlementPoolId), user); LimitEntity epInput = new LimitEntity(); epInput.setVendorLicenseModelId(vlmId); epInput.setVersion(Version.valueOf(versionId)); @@ -110,11 +113,11 @@ public class EntitlementPoolLimitsImpl implements EntitlementPoolLimits { LimitEntity limit = vendorLicenseManager.getLimit(epInput, user); LimitEntityDto entitlementPoolEntityDto = limit == null ? null : - new MapLimitEntityToLimitDto() - .applyMapping(limit, LimitEntityDto.class); + new MapLimitEntityToLimitDto() + .applyMapping(limit, LimitEntityDto.class); mdcDataDebugMessage.debugExitMessage("VLM id, EP id, Limit Id", vlmId, entitlementPoolId, - limitId); + limitId); return Response.ok(entitlementPoolEntityDto).build(); } @@ -127,39 +130,40 @@ public class EntitlementPoolLimitsImpl implements EntitlementPoolLimits { String limitId, String user) { mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP id", entitlementPoolId, "limit Id", - limitId); + limitId); MdcUtil.initMdc(LoggerServiceName.Update_LIMIT.toString()); vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf - (versionId), entitlementPoolId), user); + (versionId), entitlementPoolId), user); LimitEntity limitEntity = - new MapLimitRequestDtoToLimitEntity() - .applyMapping(request, LimitEntity.class); + new MapLimitRequestDtoToLimitEntity() + .applyMapping(request, LimitEntity.class); limitEntity.setEpLkgId(entitlementPoolId); limitEntity.setVendorLicenseModelId(vlmId); limitEntity.setId(limitId); + limitEntity.setParent(parent); vendorLicenseManager.updateLimit(limitEntity, user); mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "EP id", entitlementPoolId, "limit Id", - limitId); + limitId); return Response.ok().build(); } /** - * Delete entitlement pool. - * - * @param vlmId the vlm id - * @param entitlementPoolId the entitlement pool id - * @param limitId the limitId - * @param user the user - * @return the response + * Delete entitlement pool. + * + * @param vlmId the vlm id + * @param entitlementPoolId the entitlement pool id + * @param limitId the limitId + * @param user the user + * @return the response */ public Response deleteLimit(String vlmId, String versionId, String entitlementPoolId, - String limitId, String user) { + String limitId, String user) { mdcDataDebugMessage.debugEntryMessage("VLM id, Verison Id, EP id, Limit Id", vlmId, versionId, entitlementPoolId, limitId); MdcUtil.initMdc(LoggerServiceName.Delete_LIMIT.toString()); @@ -170,6 +174,8 @@ public class EntitlementPoolLimitsImpl implements EntitlementPoolLimits { limitInput.setVendorLicenseModelId(vlmId); limitInput.setEpLkgId(entitlementPoolId); limitInput.setId(limitId); + limitInput.setParent(parent); + vendorLicenseManager.deleteLimit(limitInput, user); mdcDataDebugMessage.debugExitMessage("VLM id, Verison Id, EP id, Limit Id", vlmId, versionId, entitlementPoolId, limitId); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java index 4c85cfa45f..bedbc928ed 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java @@ -32,7 +32,9 @@ public class LicenseKeyGroupLimitsImpl implements LicenseKeyGroupLimits { private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); + VendorLicenseManagerFactory.getInstance().createInterface(); + + public static final String parent = "LicenseKeyGroup"; @Override public Response createLimit(LimitRequestDto request, @@ -48,15 +50,16 @@ public class LicenseKeyGroupLimitsImpl implements LicenseKeyGroupLimits { (versionId), licenseKeyGroupId), user); LimitEntity limitEntity = - new MapLimitRequestDtoToLimitEntity() - .applyMapping(request, LimitEntity.class); + new MapLimitRequestDtoToLimitEntity() + .applyMapping(request, LimitEntity.class); limitEntity.setEpLkgId(licenseKeyGroupId); limitEntity.setVendorLicenseModelId(vlmId); + limitEntity.setParent(parent); LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity, user); MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto(); LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto - .class); + .class); /*StringWrapperResponse result = createdLimit != null ? new StringWrapperResponse(createdLimit.getId()) : null;*/ @@ -65,24 +68,24 @@ public class LicenseKeyGroupLimitsImpl implements LicenseKeyGroupLimits { //return Response.ok(result).build(); return Response.ok(createdLimitDto != null ? createdLimitDto : null) - .build(); + .build(); } @Override public Response listLimits(String vlmId, String versionId, String licenseKeyGroupId, String - user) { + user) { mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId); MdcUtil.initMdc(LoggerServiceName.List_EP.toString()); vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf - (versionId), licenseKeyGroupId), user); + (versionId), licenseKeyGroupId), user); Collection<LimitEntity> limits = - vendorLicenseManager.listLimits(vlmId, Version.valueOf(versionId), licenseKeyGroupId, user); + vendorLicenseManager.listLimits(vlmId, Version.valueOf(versionId), licenseKeyGroupId, user); GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>(); MapLimitEntityToLimitDto outputMapper = - new MapLimitEntityToLimitDto(); + new MapLimitEntityToLimitDto(); for (LimitEntity limit : limits) { result.add(outputMapper.applyMapping(limit, LimitEntityDto.class)); } @@ -100,24 +103,25 @@ public class LicenseKeyGroupLimitsImpl implements LicenseKeyGroupLimits { String limitId, String user) { mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId, "limit Id", - limitId); + limitId); MdcUtil.initMdc(LoggerServiceName.Update_LIMIT.toString()); vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf - (versionId), licenseKeyGroupId), user); + (versionId), licenseKeyGroupId), user); LimitEntity limitEntity = - new MapLimitRequestDtoToLimitEntity() - .applyMapping(request, LimitEntity.class); + new MapLimitRequestDtoToLimitEntity() + .applyMapping(request, LimitEntity.class); limitEntity.setEpLkgId(licenseKeyGroupId); limitEntity.setVendorLicenseModelId(vlmId); limitEntity.setId(limitId); + limitEntity.setParent(parent); vendorLicenseManager.updateLimit(limitEntity, user); mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId, "limit Id", - limitId); + limitId); return Response.ok().build(); } @@ -134,20 +138,22 @@ public class LicenseKeyGroupLimitsImpl implements LicenseKeyGroupLimits { public Response deleteLimit(String vlmId, String versionId, String licenseKeyGroupId, String limitId, String user) { mdcDataDebugMessage.debugEntryMessage("VLM id, Verison Id, LKG id, Limit Id", vlmId, versionId, - licenseKeyGroupId, limitId); + licenseKeyGroupId, limitId); MdcUtil.initMdc(LoggerServiceName.Delete_LIMIT.toString()); vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf - (versionId), licenseKeyGroupId), user); + (versionId), licenseKeyGroupId), user); LimitEntity limitInput = new LimitEntity(); limitInput.setVendorLicenseModelId(vlmId); limitInput.setEpLkgId(licenseKeyGroupId); limitInput.setId(limitId); + limitInput.setParent(parent); + vendorLicenseManager.deleteLimit(limitInput, user); mdcDataDebugMessage.debugExitMessage("VLM id, Verison Id, LKG id, Limit Id", vlmId, versionId, - licenseKeyGroupId, limitId); + licenseKeyGroupId, limitId); return Response.ok().build(); } @@ -156,11 +162,11 @@ public class LicenseKeyGroupLimitsImpl implements LicenseKeyGroupLimits { public Response getLimit( String vlmId, String versionId, String licenseKeyGroupId, String limitId, String user) { mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id, Limit Id", vlmId, licenseKeyGroupId, - limitId); + limitId); MdcUtil.initMdc(LoggerServiceName.Get_LIMIT.toString()); vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf - (versionId), licenseKeyGroupId), user); + (versionId), licenseKeyGroupId), user); LimitEntity epInput = new LimitEntity(); epInput.setVendorLicenseModelId(vlmId); epInput.setVersion(Version.valueOf(versionId)); @@ -169,11 +175,11 @@ public class LicenseKeyGroupLimitsImpl implements LicenseKeyGroupLimits { LimitEntity limit = vendorLicenseManager.getLimit(epInput, user); LimitEntityDto entitlementPoolEntityDto = limit == null ? null : - new MapLimitEntityToLimitDto() - .applyMapping(limit, LimitEntityDto.class); + new MapLimitEntityToLimitDto() + .applyMapping(limit, LimitEntityDto.class); mdcDataDebugMessage.debugExitMessage("VLM id, LKG id, Limit Id", vlmId, licenseKeyGroupId, - limitId); + limitId); return Response.ok(entitlementPoolEntityDto).build(); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml index f146881751..d65e9e6b27 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml @@ -102,11 +102,11 @@ <artifactId>woodstox-core-asl</artifactId> <version>${woodstox.version}</version> </dependency> - <dependency> + <!--dependency> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> <version>${project.version}</version> - </dependency> + </dependency--> <dependency> <groupId>com.sun.jersey.contribs</groupId> <artifactId>jersey-multipart</artifactId> 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()); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OnboardingMethod.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OnboardingMethod.java index 3059efb171..0db4b0476d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OnboardingMethod.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OnboardingMethod.java @@ -1,6 +1,6 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; public enum OnboardingMethod { - HEAT, + NetworkPackage, Manual; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/UploadFileResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/UploadFileResponseDto.java index a79c70a4d2..3bf2e8ced1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/UploadFileResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/UploadFileResponseDto.java @@ -32,6 +32,8 @@ import java.util.Map; public class UploadFileResponseDto { private Map<String, List<ErrorMessage>> errors; private UploadFileStatus status; + private String onboardingOrigin; + private String networkPackageName; public Map<String, List<ErrorMessage>> getErrors() { return errors; @@ -49,4 +51,19 @@ public class UploadFileResponseDto { this.status = status; } + public String getOnboardingOrigin() { + return onboardingOrigin; + } + + public void setOnboardingOrigin(String onboardingOrigin) { + this.onboardingOrigin = onboardingOrigin; + } + + public String getNetworkPackageName() { + return networkPackageName; + } + + public void setNetworkPackageName(String networkPackageName) { + this.networkPackageName = networkPackageName; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java index 80b68deeeb..9062f89d22 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java @@ -44,6 +44,8 @@ public class VspDescriptionDto { @NotNull private String onboardingMethod; + private String onboardingOrigin; + private String networkPackageName; public String getName() { return name; @@ -124,4 +126,20 @@ public class VspDescriptionDto { public void setOnboardingMethod(String onboardingMethod) { this.onboardingMethod = onboardingMethod; } + + public String getOnboardingOrigin() { + return onboardingOrigin; + } + + public void setOnboardingOrigin(String onboardingOrigin) { + this.onboardingOrigin = onboardingOrigin; + } + + public String getNetworkPackageName() { + return networkPackageName; + } + + public void setNetworkPackageName(String networkPackageName) { + this.networkPackageName = networkPackageName; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java index d105acb406..28a77f2e66 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java @@ -41,7 +41,8 @@ public class VspDetailsDto extends VspDescriptionDto { private String lockingUser; private ValidationStructureList validationData; private String isOldVersion; - + private String onboardingOrigin; + private String networkPackageName; public String getId() { return id; } @@ -104,8 +105,21 @@ public class VspDetailsDto extends VspDescriptionDto { public void setValidationData(ValidationStructureList validationData) { this.validationData = validationData; + } + + public String getOnboardingOrigin() { + return onboardingOrigin; + } + public void setOnboardingOrigin(String onboardingOrigin) { + this.onboardingOrigin = onboardingOrigin; + } + public String getNetworkPackageName() { + return networkPackageName; } + public void setNetworkPackageName(String networkPackageName) { + this.networkPackageName = networkPackageName; + } } |