From d378c37fbd1ecec7b43394926f1ca32a695e07de Mon Sep 17 00:00:00 2001 From: vasraz Date: Mon, 22 Mar 2021 15:33:06 +0000 Subject: Reformat openecomp-be Signed-off-by: Vasyl Razinkov Issue-ID: SDC-3449 Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1 --- .../sdcrests/vsp/rest/ComponentDependencies.java | 108 +++--- .../vsp/rest/ComponentMonitoringUploads.java | 88 ++--- .../sdcrests/vsp/rest/ComponentProcesses.java | 201 +++++----- .../openecomp/sdcrests/vsp/rest/Components.java | 156 ++++---- .../org/openecomp/sdcrests/vsp/rest/Compute.java | 169 ++++----- .../sdcrests/vsp/rest/DeploymentFlavors.java | 122 +++--- .../org/openecomp/sdcrests/vsp/rest/Images.java | 214 +++++------ .../org/openecomp/sdcrests/vsp/rest/Networks.java | 100 +++-- .../java/org/openecomp/sdcrests/vsp/rest/Nics.java | 160 ++++---- .../vsp/rest/OrchestrationTemplateCandidate.java | 119 +++--- .../org/openecomp/sdcrests/vsp/rest/Processes.java | 178 +++++---- .../sdcrests/vsp/rest/VendorSoftwareProducts.java | 278 +++++++------- ...VendorSoftwareProductsForSwaggerFileUpload.java | 48 ++- .../openecomp/sdcrests/vsp/rest/VspEntities.java | 1 - .../mapping/MapComponentDataToComponentDto.java | 15 +- .../MapComponentDependencyEntityToCreationDto.java | 18 +- .../mapping/MapComponentDependencyEntityToDto.java | 23 +- .../MapComponentDependencyModelEntityToDto.java | 21 +- ...MapComponentDependencyModelRequestToEntity.java | 31 +- .../MapComponentEntityToComponentCreationDto.java | 17 +- .../mapping/MapComponentEntityToComponentDto.java | 20 +- .../MapComponentRequestDtoToComponentEntity.java | 21 +- .../mapping/MapCompositionEntityResponseToDto.java | 36 +- .../MapCompositionEntityValidationDataToDto.java | 33 +- .../mapping/MapComputeDataToComputeDetailsDto.java | 16 +- .../MapComputeDetailsDtoToComputeEntity.java | 14 +- .../MapComputeEntityToComputeCreationDto.java | 17 +- .../rest/mapping/MapComputeEntityToComputeDto.java | 25 +- .../mapping/MapComputeEntityToVspComputeDto.java | 23 +- ...FlavorEntityDeploymentFlavorToListResponse.java | 26 +- ...tFlavorEntityToDeploymentFlavorCreationDto.java | 18 +- ...eploymentFlavorEntityToDeploymentFlavorDto.java | 13 +- ...ntFlavorRequestDtoToDeploymentFlavorEntity.java | 26 +- .../MapDeploymentFlavorToDeploymentDto.java | 21 +- .../rest/mapping/MapFilesDataStructureToDto.java | 22 +- .../vsp/rest/mapping/MapImageDataToImageDto.java | 22 +- .../mapping/MapImageEntityToImageCreationDto.java | 16 +- .../vsp/rest/mapping/MapImageEntityToImageDto.java | 21 +- .../mapping/MapImageRequestDtoToImageEntity.java | 16 +- .../vsp/rest/mapping/MapItemToVspDetailsDto.java | 28 +- .../mapping/MapMonitoringUploadStatusToDto.java | 21 +- .../rest/mapping/MapNetworkEntityToNetworkDto.java | 20 +- .../MapNetworkRequestDtoToNetworkEntity.java | 23 +- .../vsp/rest/mapping/MapNetworkToNetworkDto.java | 16 +- .../MapNicEntityToNicCreationResponseDto.java | 18 +- .../vsp/rest/mapping/MapNicEntityToNicDto.java | 20 +- .../rest/mapping/MapNicRequestDtoToNicEntity.java | 26 +- .../sdcrests/vsp/rest/mapping/MapNicToNicDto.java | 26 +- .../mapping/MapPackageInfoToPackageInfoDto.java | 34 +- .../MapProcessEntityToProcessEntityDto.java | 25 +- .../MapProcessRequestDtoToProcessEntity.java | 21 +- ...ionnaireResponseToQuestionnaireResponseDto.java | 20 +- .../MapQuestionnaireToQuestionnaireDto.java | 21 +- ...pUploadFileResponseToUploadFileResponseDto.java | 24 +- .../rest/mapping/MapValidationResponseToDto.java | 92 +++-- .../rest/mapping/MapVspDescriptionDtoToItem.java | 20 +- .../mapping/MapVspDescriptionDtoToVspDetails.java | 47 ++- .../vsp/rest/mapping/MapVspDetailsToDto.java | 51 ++- .../rest/services/ComponentDependenciesImpl.java | 146 +++----- .../services/ComponentMonitoringUploadsImpl.java | 121 +++--- .../vsp/rest/services/ComponentProcessesImpl.java | 247 ++++++------ .../sdcrests/vsp/rest/services/ComponentsImpl.java | 180 ++++----- .../sdcrests/vsp/rest/services/ComputeImpl.java | 213 +++++------ .../vsp/rest/services/DeploymentFlavorsImpl.java | 163 ++++---- .../sdcrests/vsp/rest/services/ImagesImpl.java | 210 +++++------ .../sdcrests/vsp/rest/services/NetworksImpl.java | 131 +++---- .../sdcrests/vsp/rest/services/NicsImpl.java | 206 +++++------ .../OrchestrationTemplateCandidateException.java | 4 +- .../OrchestrationTemplateCandidateImpl.java | 255 ++++++------- .../sdcrests/vsp/rest/services/ProcessesImpl.java | 95 +++-- .../rest/services/VendorSoftwareProductsImpl.java | 412 ++++++++------------- .../vsp/rest/services/VspItemProperty.java | 11 +- .../vsp/rest/services/VspUniqueTypeProvider.java | 16 +- 73 files changed, 2424 insertions(+), 3012 deletions(-) (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp') 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/ComponentDependencies.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/ComponentDependencies.java index bfeb476836..732167937d 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/ComponentDependencies.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/ComponentDependencies.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,30 +17,35 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - 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.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyResponseDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +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.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; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyResponseDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/component-dependencies") @Produces(MediaType.APPLICATION_JSON) @@ -49,54 +54,41 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface ComponentDependencies extends VspEntities { - @POST - @Path("/") - @Operation( description= "Create a vendor software product component dependency") - Response create(@Valid ComponentDependencyModel request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product component dependency") + Response create(@Valid ComponentDependencyModel request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/") - @Operation(description = "Get component dependencies for vendor software product", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = ComponentDependencyResponseDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") - String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/") + @Operation(description = "Get component dependencies for vendor software product", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ComponentDependencyResponseDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{dependencyId}") - @Operation(description = "Delete component dependency for vendor software product") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") - @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product Component Dependency Id") @PathParam - ("dependencyId") String dependencyId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/{dependencyId}") + @Operation(description = "Delete component dependency for vendor software product") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product Component Dependency Id") @PathParam("dependencyId") String dependencyId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{dependencyId}") - @Operation(description = "Update component dependency for vendor software product") - Response update(@Valid ComponentDependencyModel request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") - String versionId, - @Parameter(description = "Vendor software product Component Dependency Id") @PathParam - ("dependencyId") String dependencyId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @PUT + @Path("/{dependencyId}") + @Operation(description = "Update component dependency for vendor software product") + Response update(@Valid ComponentDependencyModel request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product Component Dependency Id") @PathParam("dependencyId") String dependencyId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{dependencyId}") - @Operation(description = "Get component dependency for vendor software product", responses = @ApiResponse(content = @Content(schema = @Schema(implementation =ComponentDependencyResponseDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product Component Dependency Id") @PathParam - ("dependencyId") String dependencyId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{dependencyId}") + @Operation(description = "Get component dependency for vendor software product", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ComponentDependencyResponseDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product Component Dependency Id") @PathParam("dependencyId") String dependencyId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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/ComponentMonitoringUploads.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/ComponentMonitoringUploads.java index f575991456..1a34bfc47c 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/ComponentMonitoringUploads.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/ComponentMonitoringUploads.java @@ -17,73 +17,67 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - 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.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.constraints.NotNull; +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.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.openecomp.sdcrests.vendorsoftwareproducts.types.MonitoringUploadStatusDto; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; -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}/uploads/") +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/uploads/") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Component Uploads")}) @Validated public interface ComponentMonitoringUploads extends VspEntities { - @POST - @Path("types/{type}/") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Operation(description = "Upload file for component by type") - Response upload(@Multipart("upload") Attachment attachment, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") - String vspId, - @Parameter(description = "Vendor software product version Id") - @PathParam("versionId") String versionId, - @Parameter(description = "Component Id") @PathParam("componentId") String - componentId, - @Parameter(description = "Upload Type") @PathParam("type") String type, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; - @DELETE - @Path("types/{type}") - @Operation(description = "Delete file uploaded for component") - Response delete( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") - String versionId, - @Parameter(description = "Component Id") @PathParam("componentId") String componentId, - @Parameter(description = "Upload Type") @PathParam("type") String type, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws Exception; + @POST + @Path("types/{type}/") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Operation(description = "Upload file for component by type") + Response upload(@Multipart("upload") Attachment attachment, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Upload Type") @PathParam("type") String type, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; + + @DELETE + @Path("types/{type}") + @Operation(description = "Delete file uploaded for component") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Upload Type") @PathParam("type") String type, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; - @GET - @Path("") - @Operation(description = "Get the filenames of uploaded files by type", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation =MonitoringUploadStatusDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") - String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("") + @Operation(description = "Get the filenames of uploaded files by type", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = MonitoringUploadStatusDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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 b5907d5d30..3289238eb5 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 @@ -17,145 +17,124 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - 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.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +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.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Multipart; 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.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import java.util.List; - -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) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Component Processes")}) @Validated public interface ComponentProcesses extends VspEntities { - @GET - @Path("/") - @Operation(description = "List vendor software product component processes", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ProcessEntityDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - - @DELETE - @Path("/") - @Operation(description = "Delete vendor software product processes",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class)))) - Response deleteList( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/") - @Operation(description = "Create a vendor software product process") - Response create(@Valid ProcessRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @GET + @Path("/") + @Operation(description = "List vendor software product component processes", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ProcessEntityDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{processId}") - @Operation(description = "Get vendor software product process",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ProcessEntityDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/") + @Operation(description = "Delete vendor software product processes", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class)))) + Response deleteList(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{processId}") - @Operation(description = "Delete vendor software product process") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product process") + Response create(@Valid ProcessRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{processId}") - @Operation(description = "Update vendor software product process") - Response update(@Valid ProcessRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{processId}") + @Operation(description = "Get vendor software product process", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ProcessEntityDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @DELETE + @Path("/{processId}") + @Operation(description = "Delete vendor software product process") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{processId}") + @Operation(description = "Update vendor software product process") + Response update(@Valid ProcessRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{processId}/upload") - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Operation(description = "Get vendor software product process uploaded file") - Response getUploadedFile( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{processId}/upload") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Operation(description = "Get vendor software product process uploaded file") + Response getUploadedFile(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{processId}/upload") - @Operation(description = "Delete vendor software product process uploaded file") - Response deleteUploadedFile( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{processId}/upload") + @Operation(description = "Delete vendor software product process uploaded file") + Response deleteUploadedFile(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/{processId}/upload") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Operation(description = "Update vendor software product process upload") - Response uploadFile(@Multipart("upload") Attachment attachment, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product process Id") - @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/{processId}/upload") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Operation(description = "Update vendor software product process upload") + Response uploadFile(@Multipart("upload") Attachment attachment, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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/Components.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/Components.java index fa0ecbdcbe..ccad46bb3e 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/Components.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/Components.java @@ -17,18 +17,33 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - 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.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +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.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; @@ -36,99 +51,72 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponse import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import java.util.List; - -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") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Components")}) @Validated public interface Components extends VspEntities { - @GET - @Path("/") - @Operation(description = "List vendor software product components", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ComponentDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - - @DELETE - @Path("/") - @Operation(description = "Delete vendor software product components", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class)))) - Response deleteList( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/") - @Operation(description = "Create a vendor software product component") - Response create(@Valid ComponentRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @GET + @Path("/") + @Operation(description = "List vendor software product components", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ComponentDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{componentId}") - @Operation(description = "Get vendor software product component", responses = @ApiResponse(content = @Content(schema = @Schema(implementation =ComponentData.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/") + @Operation(description = "Delete vendor software product components", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class)))) + Response deleteList(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{componentId}") - @Operation(description = "Delete vendor software product component") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product component") + Response create(@Valid ComponentRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{componentId}") - @Operation(description = "Update vendor software product component") - Response update(@Valid ComponentRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{componentId}") + @Operation(description = "Get vendor software product component", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ComponentData.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @DELETE + @Path("/{componentId}") + @Operation(description = "Delete vendor software product component") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{componentId}") + @Operation(description = "Update vendor software product component") + Response update(@Valid ComponentRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{componentId}/questionnaire") - @Operation(description = "Get vendor software product component questionnaire",responses = @ApiResponse(content = @Content(schema = @Schema(implementation =QuestionnaireResponseDto.class)))) - Response getQuestionnaire( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{componentId}/questionnaire") + @Operation(description = "Get vendor software product component questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) + Response getQuestionnaire(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{componentId}/questionnaire") - @Operation(description = "Update vendor software product component questionnaire") - Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") - String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") - String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{componentId}/questionnaire") + @Operation(description = "Update vendor software product component questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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/Compute.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/Compute.java index ded4327dd2..666fad5ea3 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/Compute.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/Compute.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,125 +17,104 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - 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.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +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.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDetailsDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -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" + - "}/compute-flavors") +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId" + "}/compute-flavors") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Component Compute-flavors")}) @Validated public interface Compute extends VspEntities { - @GET - @Path("/") - @Operation(description = "Get list of vendor software product component compute-flavors", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation =ComputeDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/") + @Operation(description = "Get list of vendor software product component compute-flavors", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ComputeDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{computeFlavorId}") - @Operation(description = "Get vendor software product component compute-flavor", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation =ComputeDetailsDto.class))))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product compute-flavor Id") @PathParam - ("computeFlavorId") - String computeId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{computeFlavorId}") + @Operation(description = "Get vendor software product component compute-flavor", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ComputeDetailsDto.class))))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product compute-flavor Id") @PathParam("computeFlavorId") String computeId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/") - @Operation(description = "Create a vendor software product component compute-flavor") - Response create(@Valid ComputeDetailsDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product component compute-flavor") + Response create(@Valid ComputeDetailsDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{computeFlavorId}") - @Operation(description = "Update vendor software product component compute-flavor") - Response update(@Valid ComputeDetailsDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product compute-flavor Id") @PathParam - ("computeFlavorId") - String computeFlavorId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @PUT + @Path("/{computeFlavorId}") + @Operation(description = "Update vendor software product component compute-flavor") + Response update(@Valid ComputeDetailsDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product compute-flavor Id") @PathParam("computeFlavorId") String computeFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{computeFlavorId}/questionnaire") - @Operation(description = "Update vendor software product component compute-flavor questionnaire") - Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product compute-flavor Id") @PathParam - ("computeFlavorId") - String computeFlavorId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @PUT + @Path("/{computeFlavorId}/questionnaire") + @Operation(description = "Update vendor software product component compute-flavor questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product compute-flavor Id") @PathParam("computeFlavorId") String computeFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{computeFlavorId}") - @Operation(description = "Delete vendor software product component compute-flavor") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product compute-flavor Id") @PathParam - ("computeFlavorId") - String computeFlavorId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/{computeFlavorId}") + @Operation(description = "Delete vendor software product component compute-flavor") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product compute-flavor Id") @PathParam("computeFlavorId") String computeFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{computeFlavorId}/questionnaire") - @Operation(description = "Get vendor software product component compute-flavor questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation =QuestionnaireResponseDto.class)))) - Response getQuestionnaire( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product compute-flavor Id") @PathParam - ("computeFlavorId") String computeId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{computeFlavorId}/questionnaire") + @Operation(description = "Get vendor software product component compute-flavor questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) + Response getQuestionnaire(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product compute-flavor Id") @PathParam("computeFlavorId") String computeId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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/DeploymentFlavors.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/DeploymentFlavors.java index 7d74044645..4312b10ab3 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/DeploymentFlavors.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/DeploymentFlavors.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,32 +17,36 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - 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.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorListResponseDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +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.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; - +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorListResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorRequestDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/deployment-flavors") @Produces(MediaType.APPLICATION_JSON) @@ -51,59 +55,49 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface DeploymentFlavors extends VspEntities { - @POST - @Path("/") - @Operation(description = "Create a vendor software product Deployment Flavor") - Response create(@Valid DeploymentFlavorRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @POST + @Path("/") + @Operation(description = "Create a vendor software product Deployment Flavor") + Response create(@Valid DeploymentFlavorRequestDto request, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/") + @Operation(description = "List vendor software product Deployment Flavor", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = DeploymentFlavorListResponseDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/") - @Operation(description = "List vendor software product Deployment Flavor", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = DeploymentFlavorListResponseDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{deploymentFlavorId}") + @Operation(description = "Get vendor software product Deployment Flavor", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = DeploymentFlavorDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product Deployment Flavor Id") @PathParam("deploymentFlavorId") String deploymentFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{deploymentFlavorId}") - @Operation(description = "Get vendor software product Deployment Flavor",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = DeploymentFlavorDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product Deployment Flavor Id") @PathParam - ("deploymentFlavorId") String deploymentFlavorId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/schema") + Response getSchema(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/schema") - Response getSchema(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String - vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/{deploymentFlavorId}") + @Operation(description = "Delete vendor software product Deployment Flavor") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product Deployment Flavor Id") @PathParam("deploymentFlavorId") String deploymentFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{deploymentFlavorId}") - @Operation(description = "Delete vendor software product Deployment Flavor") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product Deployment Flavor Id") - @PathParam("deploymentFlavorId") String deploymentFlavorId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - - @PUT - @Path("/{deploymentFlavorId}") - @Operation(description = "Update vendor software product Deployment Flavor") - Response update(@Valid DeploymentFlavorRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product Deployment Flavor Id") - @PathParam("deploymentFlavorId") String deploymentFlavorId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @PUT + @Path("/{deploymentFlavorId}") + @Operation(description = "Update vendor software product Deployment Flavor") + Response update(@Valid DeploymentFlavorRequestDto request, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product Deployment Flavor Id") @PathParam("deploymentFlavorId") String deploymentFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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/Images.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/Images.java index 49a25ed273..f480405e45 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/Images.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/Images.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,33 +17,38 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - 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.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +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.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageRequestDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -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}/images") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -51,117 +56,90 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface Images extends VspEntities { - @GET - @Path("/") - @Operation(description = "List vendor software product component images",responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ImageDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - - @POST - @Path("/") - @Operation(description = "Create a vendor software product component image") - Response create(@Valid ImageRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @GET + @Path("/") + @Operation(description = "List vendor software product component images", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ImageDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/schema") - //@Operation(description = "Get schema for vendor software product component Image" , - // response = QuestionnaireResponseDto.class) - Response getImageSchema(@Parameter(description = "Vendor software product Id") @PathParam("vspId") - String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId,@NotNull - (message = USER_MISSING_ERROR_MSG) @HeaderParam - (USER_ID_HEADER_PARAM) String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product component image") + Response create(@Valid ImageRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - /*@GET - @Path("/{imageId}") - @Operation(description = "Get vendor software product component Image", - response = ImageDto.class, - responseContainer = "ImageEntityResponse") - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product image Id") @PathParam("imageId") - String imageId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user);*/ + @GET + @Path("/schema") + //@Operation(description = "Get schema for vendor software product component Image" , - @GET - @Path("/{imageId}") - @Operation(description = "Get vendor software product component Image",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ImageDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product Image Id") @PathParam - ("imageId") - String imageId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + // response = QuestionnaireResponseDto.class) + Response getImageSchema(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{imageId}") - @Operation(description = "Delete vendor software product Image") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product Image Id") @PathParam("imageId") - String imageId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + /*@GET + @Path("/{imageId}") + @Operation(description = "Get vendor software product component Image", + response = ImageDto.class, + responseContainer = "ImageEntityResponse") + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @Parameter(description = "Vendor software product image Id") @PathParam("imageId") + String imageId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user);*/ + @GET + @Path("/{imageId}") + @Operation(description = "Get vendor software product component Image", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ImageDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product Image Id") @PathParam("imageId") String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{imageId}") - @Operation(description = "Update vendor software product Image") - Response update(@Valid ImageRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product Image Id") @PathParam("imageId") - String imageId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/{imageId}") + @Operation(description = "Delete vendor software product Image") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product Image Id") @PathParam("imageId") String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{imageId}") + @Operation(description = "Update vendor software product Image") + Response update(@Valid ImageRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product Image Id") @PathParam("imageId") String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{imageId}/questionnaire") - @Operation(description = "Update vendor software product component image questionnaire") - Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, - @Parameter(description = "Vendor software product Id") - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") - @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product image Id") - @PathParam ("imageId") String imageId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{imageId}/questionnaire") + @Operation(description = "Update vendor software product component image questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product image Id") @PathParam("imageId") String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{imageId}/questionnaire") - @Operation(description = "Get vendor software product component image questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) - Response getQuestionnaire( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product image Id") @PathParam - ("imageId") String imageId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{imageId}/questionnaire") + @Operation(description = "Get vendor software product component image questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) + Response getQuestionnaire(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product image Id") @PathParam("imageId") String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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/Networks.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/Networks.java index f269832d6b..b2e356c23d 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/Networks.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/Networks.java @@ -17,30 +17,35 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - 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.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +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.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; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkRequestDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/networks") @Produces(MediaType.APPLICATION_JSON) @@ -48,51 +53,42 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Networks")}) @Validated public interface Networks extends VspEntities { - @GET - @Path("/") - @Operation(description = "List vendor software product networks",responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = NetworkDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - @POST - @Path("/") - @Operation(description = "Create a vendor software product network") - Response create(@Valid NetworkRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @GET + @Path("/") + @Operation(description = "List vendor software product networks", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = NetworkDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{networkId}") - @Operation(description = "Get vendor software product network",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = NetworkDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product network Id") - @PathParam("networkId") String networkId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product network") + Response create(@Valid NetworkRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{networkId}") - @Operation(description = "Delete vendor software product network") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product network Id") @PathParam("networkId") - String networkId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{networkId}") + @Operation(description = "Get vendor software product network", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = NetworkDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product network Id") @PathParam("networkId") String networkId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{networkId}") - @Operation(description = "Update vendor software product network") - Response update(@Valid NetworkRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product network Id") @PathParam("networkId") - String networkId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/{networkId}") + @Operation(description = "Delete vendor software product network") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product network Id") @PathParam("networkId") String networkId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{networkId}") + @Operation(description = "Update vendor software product network") + Response update(@Valid NetworkRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product network Id") @PathParam("networkId") String networkId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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/Nics.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/Nics.java index c50c593fce..8d0b8ca617 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/Nics.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/Nics.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,118 +17,104 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - 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.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +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.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicRequestDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -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}/nics") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Component NICs")}) @Validated public interface Nics extends VspEntities { - @GET - @Path("/") - @Operation(description = "List vendor software product component NICs",responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = NicDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - @POST - @Path("/") - @Operation(description = "Create a vendor software product NIC") - Response create(@Valid NicRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @GET + @Path("/") + @Operation(description = "List vendor software product component NICs", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = NicDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{nicId}") - @Operation(description = "Get vendor software product NIC", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = NicDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product NIC") + Response create(@Valid NicRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{nicId}") - @Operation(description = "Delete vendor software product NIC") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") - String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{nicId}") + @Operation(description = "Get vendor software product NIC", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = NicDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{nicId}") - @Operation(description = "Update vendor software product NIC") - Response update(@Valid NicRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") - String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/{nicId}") + @Operation(description = "Delete vendor software product NIC") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{nicId}") + @Operation(description = "Update vendor software product NIC") + Response update(@Valid NicRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{nicId}/questionnaire") - @Operation(description = "Get vendor software product component NIC questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) - Response getQuestionnaire( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{nicId}/questionnaire") + @Operation(description = "Get vendor software product component NIC questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) + Response getQuestionnaire(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{nicId}/questionnaire") - @Operation(description = "Update vendor software product component NIC questionnaire") - Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") - String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product NIC Id") - @PathParam("nicId") String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{nicId}/questionnaire") + @Operation(description = "Update vendor software product component NIC questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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 5d99e2dc84..23c8ef2481 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 @@ -13,35 +13,40 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - 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.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +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.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -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}/orchestration-template-candidate") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -49,60 +54,44 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface OrchestrationTemplateCandidate extends VspEntities { - @POST - @Path("/") - @Consumes(MediaType.MULTIPART_FORM_DATA) - Response upload( - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Multipart("upload") Attachment fileToUpload, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @POST + @Path("/") + @Consumes(MediaType.MULTIPART_FORM_DATA) + Response upload(@PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Multipart("upload") Attachment fileToUpload, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/") - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Operation(description = "Get uploaded Network Package file", - summary = "Downloads in uploaded Network Package file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation =File.class)))) - Response get( - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws IOException; + @GET + @Path("/") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Operation(description = "Get uploaded Network Package file", summary = "Downloads in uploaded Network Package file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class)))) + Response get(@PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws IOException; - @DELETE - @Path("/") - @Operation(description = "Delete orchestration template candidate file and its files data structure") - Response abort( - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId) - throws Exception; + @DELETE + @Path("/") + @Operation(description = "Delete orchestration template candidate file and its files data structure") + Response abort(@PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId) + throws Exception; - @PUT - @Path("/process") - @Operation(description = "process Orchestration Template Candidate",responses = @ApiResponse(content = @Content(schema = @Schema(implementation =UploadFileResponseDto.class)))) - Response process( - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws InvocationTargetException, IllegalAccessException; + @PUT + @Path("/process") + @Operation(description = "process Orchestration Template Candidate", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UploadFileResponseDto.class)))) + Response process(@PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws InvocationTargetException, IllegalAccessException; - @PUT - @Path("/manifest") - @Operation(description = "Update an existing vendor software product") - Response updateFilesDataStructure( - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Valid FileDataStructureDto fileDataStructureDto, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws Exception; + @PUT + @Path("/manifest") + @Operation(description = "Update an existing vendor software product") + Response updateFilesDataStructure(@PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Valid FileDataStructureDto fileDataStructureDto, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; - @GET - @Path("/manifest") - @Operation(description = "Get uploaded HEAT file files data structure", - summary = "Downloads the latest HEAT package",responses = @ApiResponse(content = @Content(schema = @Schema(implementation =FileDataStructureDto.class)))) - Response getFilesDataStructure( - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws Exception; + @GET + @Path("/manifest") + @Operation(description = "Get uploaded HEAT file files data structure", summary = "Downloads the latest HEAT package", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = FileDataStructureDto.class)))) + Response getFilesDataStructure(@PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; } 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/Processes.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/Processes.java index 27195e1cbb..5f4c6496ec 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/Processes.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/Processes.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,127 +17,115 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - 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.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +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.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Multipart; 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.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import java.util.List; - -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}/processes") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Processes")}) @Validated public interface Processes { - @GET - @Path("/") - @Operation(description = "List vendor software product processes", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ProcessEntityDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - - @DELETE - @Path("/") - @Operation(description = "Delete vendor software product processes", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class)))) - Response deleteList( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/") - @Operation(description = "Create a vendor software product process") - Response create(@Valid ProcessRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @GET + @Path("/") + @Operation(description = "List vendor software product processes", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ProcessEntityDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{processId}") - @Operation(description = "Get vendor software product process", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ProcessEntityDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/") + @Operation(description = "Delete vendor software product processes", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class)))) + Response deleteList(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{processId}") - @Operation(description = "Delete vendor software product process") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product process") + Response create(@Valid ProcessRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{processId}") - @Operation(description = "Update vendor software product process") - Response update(@Valid ProcessRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{processId}") + @Operation(description = "Get vendor software product process", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ProcessEntityDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @DELETE + @Path("/{processId}") + @Operation(description = "Delete vendor software product process") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{processId}") + @Operation(description = "Update vendor software product process") + Response update(@Valid ProcessRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{processId}/upload") - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Operation(description = "Get vendor software product process uploaded file") - Response getUploadedFile( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{processId}/upload") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Operation(description = "Get vendor software product process uploaded file") + Response getUploadedFile(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{processId}/upload") - @Operation(description = "Delete vendor software product process uploaded file") - Response deleteUploadedFile( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{processId}/upload") + @Operation(description = "Delete vendor software product process uploaded file") + Response deleteUploadedFile(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/{processId}/upload") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Operation(description = "Update vendor software product process upload") - Response uploadFile(@Multipart("upload") Attachment attachment, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product process Id") - @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/{processId}/upload") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Operation(description = "Update vendor software product process upload") + Response uploadFile(@Multipart("upload") Attachment attachment, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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/VendorSoftwareProducts.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/VendorSoftwareProducts.java index af9953ae69..328c96254f 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/VendorSoftwareProducts.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/VendorSoftwareProducts.java @@ -13,35 +13,45 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - 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.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.item.types.ItemCreationDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; -import org.springframework.validation.annotation.Validated; - +import java.io.File; +import java.io.IOException; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +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.core.MediaType; import javax.ws.rs.core.Response; -import java.io.File; -import java.io.IOException; -import java.util.List; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +import org.openecomp.sdcrests.item.types.ItemCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-software-products") @Produces(MediaType.APPLICATION_JSON) @@ -50,145 +60,105 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface VendorSoftwareProducts extends VspEntities { - @POST - @Path("/") - @Operation(description = "Create a new vendor software product",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ItemCreationDto.class)))) - Response createVsp(@Valid VspRequestDto vspRequestDto, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @GET - @Path("/") - @Operation(description = "Get list of vendor software products and their description",responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = VspDetailsDto.class))))) - Response listVsps(@Parameter(description = "Filter to return only Vendor Software Products with at" + - " least one version at this status. Currently supported values: 'Certified' , 'Draft'") - @QueryParam("versionFilter") String versionStatus, - @Parameter(description = "Filter to only return Vendor Software Products at this status." + - "Currently supported values: 'ACTIVE' , 'ARCHIVED'." + - "Default value = 'ACTIVE'.") - @QueryParam("Status") String itemStatus, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @GET - @Path("/{vspId}/versions/{versionId}") - @Parameter(description = "Get details of a vendor software product") - Response getVsp(@PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @PUT - @Path("/{vspId}/versions/{versionId}") - @Parameter(description = "Update an existing vendor software product") - Response updateVsp(@PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @Valid VspDescriptionDto vspDescriptionDto, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @DELETE - @Path("/{vspId}") - @Parameter(description = "Deletes vendor software product by given id") - Response deleteVsp(@PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @GET - @Path("/packages") - @Operation(description = "Get list of translated CSAR files details", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation=PackageInfoDto.class))))) - Response listPackages(@Parameter(description = "Vendor Software Product status filter. " + - "Currently supported values: 'ACTIVE', 'ARCHIVED'") - @QueryParam("Status") String status, - @Parameter(description = "Category") @QueryParam("category") String category, - @Parameter(description = "Sub-category") @QueryParam("subCategory") String subCategory, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @GET - @Path("/{vspId}/versions/{versionId}/orchestration-template") - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Operation(description = "Get Orchestration Template (HEAT) file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation=File.class)))) - Response getOrchestrationTemplate( - @PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - - @GET - @Path("/validation-vsp") - Response getValidationVsp( - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws Exception; - - @PUT - @Path("/{vspId}/versions/{versionId}/actions") - @Operation(description = "Actions on a vendor software product", - summary = "Performs one of the following actions on a vendor software product: |" - + "Checkout: Locks it for edits by other users. Only the locking user sees the edited " - + "version.|" - + "Undo_Checkout: Unlocks it and deletes the edits that were done.|" - + "Checkin: Unlocks it and activates the edited version to all users.| " - + "Submit: Finalize its active version.|" - + "Create_Package: Creates a CSAR zip file.|") - Response actOnVendorSoftwareProduct(VersionSoftwareProductActionRequestDto request, - @PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws IOException; - - @GET - @Path("/packages/{vspId}") - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Operation(description = "Get translated CSAR file", - summary = "Exports translated file to a zip file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation=File.class)))) - Response getTranslatedFile(@PathParam("vspId") String vspId, - @QueryParam("versionId") String versionId, - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @GET - @Path("/{vspId}/versions/{versionId}/questionnaire") - @Operation(description = "Get vendor software product questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation=QuestionnaireResponseDto.class)))) - Response getQuestionnaire(@PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @PUT - @Path("/{vspId}/versions/{versionId}/questionnaire") - @Operation(description = "Update vendor software product questionnaire") - Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, - @PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) + @POST + @Path("/") + @Operation(description = "Create a new vendor software product", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ItemCreationDto.class)))) + Response createVsp(@Valid VspRequestDto vspRequestDto, @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/") + @Operation(description = "Get list of vendor software products and their description", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = VspDetailsDto.class))))) + Response listVsps(@Parameter(description = "Filter to return only Vendor Software Products with at" + + " least one version at this status. Currently supported values: 'Certified' , 'Draft'") @QueryParam("versionFilter") String versionStatus, + @Parameter(description = "Filter to only return Vendor Software Products at this status." + + "Currently supported values: 'ACTIVE' , 'ARCHIVED'." + + "Default value = 'ACTIVE'.") @QueryParam("Status") String itemStatus, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{vspId}/versions/{versionId}") + @Parameter(description = "Get details of a vendor software product") + Response getVsp(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{vspId}/versions/{versionId}") + @Parameter(description = "Update an existing vendor software product") + Response updateVsp(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, @Valid VspDescriptionDto vspDescriptionDto, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @DELETE + @Path("/{vspId}") + @Parameter(description = "Deletes vendor software product by given id") + Response deleteVsp(@PathParam("vspId") String vspId, @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/packages") + @Operation(description = "Get list of translated CSAR files details", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = PackageInfoDto.class))))) + Response listPackages(@Parameter(description = "Vendor Software Product status filter. " + + "Currently supported values: 'ACTIVE', 'ARCHIVED'") @QueryParam("Status") String status, + @Parameter(description = "Category") @QueryParam("category") String category, + @Parameter(description = "Sub-category") @QueryParam("subCategory") String subCategory, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{vspId}/versions/{versionId}/orchestration-template") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Operation(description = "Get Orchestration Template (HEAT) file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class)))) + Response getOrchestrationTemplate(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/validation-vsp") + Response getValidationVsp(@NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; + + @PUT + @Path("/{vspId}/versions/{versionId}/actions") + @Operation(description = "Actions on a vendor software product", summary = "Performs one of the following actions on a vendor software product: |" + + "Checkout: Locks it for edits by other users. Only the locking user sees the edited " + "version.|" + + "Undo_Checkout: Unlocks it and deletes the edits that were done.|" + "Checkin: Unlocks it and activates the edited version to all users.| " + + "Submit: Finalize its active version.|" + "Create_Package: Creates a CSAR zip file.|") + Response actOnVendorSoftwareProduct(VersionSoftwareProductActionRequestDto request, @PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws IOException; + + @GET + @Path("/packages/{vspId}") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Operation(description = "Get translated CSAR file", summary = "Exports translated file to a zip file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class)))) + Response getTranslatedFile(@PathParam("vspId") String vspId, @QueryParam("versionId") String versionId, @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @PUT - @Path("/{vspId}/versions/{versionId}/heal") - @Operation(description = "Checkout and heal vendor software product questionnaire",responses = @ApiResponse(content = @Content(schema = @Schema(implementation=QuestionnaireResponseDto.class)))) - Response heal(@PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - - @GET - @Path("/{vspId}/versions/{versionId}/vspInformationArtifact") - @Produces(MediaType.TEXT_PLAIN) - @Operation(description = "Get vendor software product information artifact for specified version",responses = @ApiResponse(content = @Content(schema = @Schema(implementation=File.class)))) - Response getVspInformationArtifact(@PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @GET - @Path("/{vspId}/versions/{versionId}/compute-flavors") - @Operation(description = "Get list of vendor software product compute-flavors", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation=VspComputeDto.class))))) - Response listComputes(@Parameter(description = "Vendor software product Id") - @PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{vspId}/versions/{versionId}/questionnaire") + @Operation(description = "Get vendor software product questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) + Response getQuestionnaire(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{vspId}/versions/{versionId}/questionnaire") + @Operation(description = "Update vendor software product questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, @PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{vspId}/versions/{versionId}/heal") + @Operation(description = "Checkout and heal vendor software product questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) + Response heal(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{vspId}/versions/{versionId}/vspInformationArtifact") + @Produces(MediaType.TEXT_PLAIN) + @Operation(description = "Get vendor software product information artifact for specified version", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class)))) + Response getVspInformationArtifact(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{vspId}/versions/{versionId}/compute-flavors") + @Operation(description = "Get list of vendor software product compute-flavors", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = VspComputeDto.class))))) + Response listComputes(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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/VendorSoftwareProductsForSwaggerFileUpload.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/VendorSoftwareProductsForSwaggerFileUpload.java index cc94725501..70de99035b 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/VendorSoftwareProductsForSwaggerFileUpload.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/VendorSoftwareProductsForSwaggerFileUpload.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,28 +17,30 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - 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 com.sun.jersey.multipart.FormDataParam; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; -import org.springframework.validation.annotation.Validated; - +import java.io.InputStream; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.InputStream; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-software-products") @Produces(MediaType.APPLICATION_JSON) @@ -47,17 +49,11 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface VendorSoftwareProductsForSwaggerFileUpload { - - - @POST - @Path("/{vspId}/versions/{versionId}/orchestration-template-candidate") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Operation(description = "Uploads a HEAT package to translate",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UploadFileResponseDto.class)))) - Response uploadOrchestrationTemplateCandidate(@PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @FormDataParam("upload") - InputStream heatFileToUpload, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - } + @POST + @Path("/{vspId}/versions/{versionId}/orchestration-template-candidate") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Operation(description = "Uploads a HEAT package to translate", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UploadFileResponseDto.class)))) + Response uploadOrchestrationTemplateCandidate(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, + @FormDataParam("upload") InputStream heatFileToUpload, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); +} 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/VspEntities.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/VspEntities.java index 4514af649b..92b0dec6e3 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/VspEntities.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/VspEntities.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest; public interface VspEntities { 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/MapComponentDataToComponentDto.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/MapComponentDataToComponentDto.java index eae59cf103..ac6b3a887f 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/MapComponentDataToComponentDto.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/MapComponentDataToComponentDto.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; @@ -21,11 +20,11 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; public class MapComponentDataToComponentDto extends MappingBase { - @Override - public void doMapping(ComponentData source, ComponentDto target) { - target.setName(source.getName()); - target.setDisplayName( - source.getDisplayName() == null ? source.getName() : source.getDisplayName()); - target.setDescription(source.getDescription()); - } + + @Override + public void doMapping(ComponentData source, ComponentDto target) { + target.setName(source.getName()); + target.setDisplayName(source.getDisplayName() == null ? source.getName() : source.getDisplayName()); + target.setDescription(source.getDescription()); + } } 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/MapComponentDependencyEntityToCreationDto.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/MapComponentDependencyEntityToCreationDto.java index a82902bd84..e69d6a9380 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/MapComponentDependencyEntityToCreationDto.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/MapComponentDependencyEntityToCreationDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,20 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; - import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyCreationDto; -public class MapComponentDependencyEntityToCreationDto extends MappingBase - { +public class MapComponentDependencyEntityToCreationDto extends MappingBase { - @Override - public void doMapping(ComponentDependencyModelEntity source, - ComponentDependencyCreationDto target) { - target.setId(source.getId()); - } + @Override + public void doMapping(ComponentDependencyModelEntity source, ComponentDependencyCreationDto target) { + target.setId(source.getId()); + } } 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/MapComponentDependencyEntityToDto.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/MapComponentDependencyEntityToDto.java index 1fdadcbc88..aedd06be69 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/MapComponentDependencyEntityToDto.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/MapComponentDependencyEntityToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,22 +17,19 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyResponseDto; -public class MapComponentDependencyEntityToDto extends - MappingBase { +public class MapComponentDependencyEntityToDto extends MappingBase { - @Override - public void doMapping(ComponentDependencyModelEntity source, - ComponentDependencyResponseDto target) { - target.setSourceId(source.getSourceComponentId()); - target.setTargetId(source.getTargetComponentId()); - target.setRelationType(source.getRelation()); - target.setId(source.getId()); - } + @Override + public void doMapping(ComponentDependencyModelEntity source, ComponentDependencyResponseDto target) { + target.setSourceId(source.getSourceComponentId()); + target.setTargetId(source.getTargetComponentId()); + target.setRelationType(source.getRelation()); + target.setId(source.getId()); + } } 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/MapComponentDependencyModelEntityToDto.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/MapComponentDependencyModelEntityToDto.java index c4c54d4ed8..bcfe05da83 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/MapComponentDependencyModelEntityToDto.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/MapComponentDependencyModelEntityToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,21 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; -public class MapComponentDependencyModelEntityToDto extends - MappingBase { +public class MapComponentDependencyModelEntityToDto extends MappingBase { - @Override - public void doMapping(ComponentDependencyModelEntity source, - ComponentDependencyModel target) { - target.setSourceId(source.getSourceComponentId()); - target.setTargetId(source.getTargetComponentId()); - target.setRelationType(source.getRelation()); - } + @Override + public void doMapping(ComponentDependencyModelEntity source, ComponentDependencyModel target) { + target.setSourceId(source.getSourceComponentId()); + target.setTargetId(source.getTargetComponentId()); + target.setRelationType(source.getRelation()); + } } 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/MapComponentDependencyModelRequestToEntity.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/MapComponentDependencyModelRequestToEntity.java index 4988ab43ab..73ef053455 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/MapComponentDependencyModelRequestToEntity.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/MapComponentDependencyModelRequestToEntity.java @@ -12,11 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. -*/ - + */ package org.openecomp.sdcrests.vsp.rest.mapping; - import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; @@ -25,21 +23,18 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRelationType; -public class MapComponentDependencyModelRequestToEntity extends - MappingBase { +public class MapComponentDependencyModelRequestToEntity extends MappingBase { - @Override - public void doMapping(ComponentDependencyModel source, - ComponentDependencyModelEntity target) { - target.setSourceComponentId(source.getSourceId()); - target.setTargetComponentId(source.getTargetId()); - try { - ComponentRelationType.valueOf(source.getRelationType()); - target.setRelation(source.getRelationType()); - } catch (IllegalArgumentException exception) { - ErrorCode errorCode = - ComponentDependencyModelErrorBuilder.getInvalidRelationTypeErrorBuilder(); - throw new CoreException(errorCode, exception); + @Override + public void doMapping(ComponentDependencyModel source, ComponentDependencyModelEntity target) { + target.setSourceComponentId(source.getSourceId()); + target.setTargetComponentId(source.getTargetId()); + try { + ComponentRelationType.valueOf(source.getRelationType()); + target.setRelation(source.getRelationType()); + } catch (IllegalArgumentException exception) { + ErrorCode errorCode = ComponentDependencyModelErrorBuilder.getInvalidRelationTypeErrorBuilder(); + throw new CoreException(errorCode, exception); + } } - } } 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/MapComponentEntityToComponentCreationDto.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/MapComponentEntityToComponentCreationDto.java index f2f346891f..089a91694e 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/MapComponentEntityToComponentCreationDto.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/MapComponentEntityToComponentCreationDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,17 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentCreationDto; -public class MapComponentEntityToComponentCreationDto extends MappingBase { - @Override - public void doMapping(ComponentEntity source, ComponentCreationDto target) { - target.setVfcId(source.getId()); - } +public class MapComponentEntityToComponentCreationDto extends MappingBase { + + @Override + public void doMapping(ComponentEntity source, ComponentCreationDto target) { + target.setVfcId(source.getId()); + } } 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/MapComponentEntityToComponentDto.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/MapComponentEntityToComponentDto.java index 8878581d1c..e82363eae9 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/MapComponentEntityToComponentDto.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/MapComponentEntityToComponentDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; @@ -26,12 +25,13 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; public class MapComponentEntityToComponentDto extends MappingBase { - @Override - public void doMapping(ComponentEntity source, ComponentDto target) { - target.setId(source.getId()); - ComponentData component = source.getComponentCompositionData(); - if (component != null) { - new MapComponentDataToComponentDto().doMapping(component, target); + + @Override + public void doMapping(ComponentEntity source, ComponentDto target) { + target.setId(source.getId()); + ComponentData component = source.getComponentCompositionData(); + if (component != null) { + new MapComponentDataToComponentDto().doMapping(component, target); + } } - } } 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/MapComponentRequestDtoToComponentEntity.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/MapComponentRequestDtoToComponentEntity.java index 53a4482820..a890d0d737 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/MapComponentRequestDtoToComponentEntity.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/MapComponentRequestDtoToComponentEntity.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; @@ -21,14 +20,14 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; -public class MapComponentRequestDtoToComponentEntity - extends MappingBase { - @Override - public void doMapping(ComponentRequestDto source, ComponentEntity target) { - ComponentData component = new ComponentData(); - component.setName(source.getName()); - component.setDisplayName(source.getDisplayName()); - component.setDescription(source.getDescription()); - target.setComponentCompositionData(component); - } +public class MapComponentRequestDtoToComponentEntity extends MappingBase { + + @Override + public void doMapping(ComponentRequestDto source, ComponentEntity target) { + ComponentData component = new ComponentData(); + component.setName(source.getName()); + component.setDisplayName(source.getDisplayName()); + component.setDescription(source.getDescription()); + target.setComponentCompositionData(component); + } } 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/MapCompositionEntityResponseToDto.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/MapCompositionEntityResponseToDto.java index f7ecc243f1..743723771d 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/MapCompositionEntityResponseToDto.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/MapCompositionEntityResponseToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; @@ -26,22 +25,21 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionDataEntityDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; -public class MapCompositionEntityResponseToDto> - extends MappingBase, CompositionEntityResponseDto> { - private M dataMapper; - private Class targetDataClass; +public class MapCompositionEntityResponseToDto> extends + MappingBase, CompositionEntityResponseDto> { + + private M dataMapper; + private Class targetDataClass; - public MapCompositionEntityResponseToDto(M dataMapper, Class targetDataClass) { - this.dataMapper = dataMapper; - this.targetDataClass = targetDataClass; - } + public MapCompositionEntityResponseToDto(M dataMapper, Class targetDataClass) { + this.dataMapper = dataMapper; + this.targetDataClass = targetDataClass; + } - @Override - public void doMapping(CompositionEntityResponse source, - CompositionEntityResponseDto target) { - target.setId(source.getId()); - target.setSchema(source.getSchema()); - target.setData(dataMapper.applyMapping(source.getData(), targetDataClass)); - } + @Override + public void doMapping(CompositionEntityResponse source, CompositionEntityResponseDto target) { + target.setId(source.getId()); + target.setSchema(source.getSchema()); + target.setData(dataMapper.applyMapping(source.getData(), targetDataClass)); + } } 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/MapCompositionEntityValidationDataToDto.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/MapCompositionEntityValidationDataToDto.java index ee7a9f446e..00c5c2f266 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/MapCompositionEntityValidationDataToDto.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/MapCompositionEntityValidationDataToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,29 +17,26 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; +import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; -import java.util.stream.Collectors; +public class MapCompositionEntityValidationDataToDto extends MappingBase { -public class MapCompositionEntityValidationDataToDto - extends MappingBase { - @Override - public void doMapping(CompositionEntityValidationData source, - CompositionEntityValidationDataDto target) { - target.setEntityType(source.getEntityType()); - target.setEntityId(source.getEntityId()); - target.setEntityName(source.getEntityName()); - target.setErrors(source.getErrors()); - if (CollectionUtils.isNotEmpty(source.getSubEntitiesValidationData())) { - target.setSubEntitiesValidationData(source.getSubEntitiesValidationData().stream() - .map(sub -> applyMapping(sub, CompositionEntityValidationDataDto.class)) - .collect(Collectors.toList())); + @Override + public void doMapping(CompositionEntityValidationData source, CompositionEntityValidationDataDto target) { + target.setEntityType(source.getEntityType()); + target.setEntityId(source.getEntityId()); + target.setEntityName(source.getEntityName()); + target.setErrors(source.getErrors()); + if (CollectionUtils.isNotEmpty(source.getSubEntitiesValidationData())) { + target.setSubEntitiesValidationData( + source.getSubEntitiesValidationData().stream().map(sub -> applyMapping(sub, CompositionEntityValidationDataDto.class)) + .collect(Collectors.toList())); + } } - } } 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/MapComputeDataToComputeDetailsDto.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/MapComputeDataToComputeDetailsDto.java index 3bfecb93f5..a32f4fb076 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/MapComputeDataToComputeDetailsDto.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/MapComputeDataToComputeDetailsDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData; @@ -26,10 +25,9 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDetailsDto; public class MapComputeDataToComputeDetailsDto extends MappingBase { - @Override - public void doMapping(ComputeData source, ComputeDetailsDto target) { - - target.setName(source.getName()); - target.setDescription(source.getDescription()); - } + @Override + public void doMapping(ComputeData source, ComputeDetailsDto target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + } } 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/MapComputeDetailsDtoToComputeEntity.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/MapComputeDetailsDtoToComputeEntity.java index 93db7e3e76..835f5dd05d 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/MapComputeDetailsDtoToComputeEntity.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/MapComputeDetailsDtoToComputeEntity.java @@ -21,13 +21,11 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDescription; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDetailsDto; -public class MapComputeDetailsDtoToComputeEntity extends MappingBase { +public class MapComputeDetailsDtoToComputeEntity extends MappingBase { - @Override - public void doMapping(ComputeDetailsDto source, ComputeEntity target) { - ComputeDescription computeDesc = new ComputeDescription(source.getName(), source - .getDescription()); - target.setCompositionData(JsonUtil.object2Json(computeDesc)); - } + @Override + public void doMapping(ComputeDetailsDto source, ComputeEntity target) { + ComputeDescription computeDesc = new ComputeDescription(source.getName(), source.getDescription()); + target.setCompositionData(JsonUtil.object2Json(computeDesc)); + } } 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/MapComputeEntityToComputeCreationDto.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/MapComputeEntityToComputeCreationDto.java index 4e1599d058..531c28b48a 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/MapComputeEntityToComputeCreationDto.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/MapComputeEntityToComputeCreationDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,17 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeCreationDto; -public class MapComputeEntityToComputeCreationDto extends - MappingBase { - @Override - public void doMapping(ComputeEntity source, ComputeCreationDto target) { - target.setId(source.getId()); - } +public class MapComputeEntityToComputeCreationDto extends MappingBase { + + @Override + public void doMapping(ComputeEntity source, ComputeCreationDto target) { + target.setId(source.getId()); + } } 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/MapComputeEntityToComputeDto.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/MapComputeEntityToComputeDto.java index cd67d2444b..a2cdceb060 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/MapComputeEntityToComputeDto.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/MapComputeEntityToComputeDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.core.utilities.json.JsonUtil; @@ -27,15 +26,15 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDescription; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDto; public class MapComputeEntityToComputeDto extends MappingBase { - @Override - public void doMapping(ListComputeResponse source, ComputeDto target) { - target.setId(source.getComputeEntity().getId()); - if (source.getComputeEntity().getCompositionData() != null) { - ComputeDescription desc = JsonUtil.json2Object(source.getComputeEntity().getCompositionData - (), ComputeDescription.class); - target.setName(desc.getName()); - target.setDescription(desc.getDescription()); - target.setAssociatedToDeploymentFlavor(source.isAssociatedWithDeploymentFlavor()); + + @Override + public void doMapping(ListComputeResponse source, ComputeDto target) { + target.setId(source.getComputeEntity().getId()); + if (source.getComputeEntity().getCompositionData() != null) { + ComputeDescription desc = JsonUtil.json2Object(source.getComputeEntity().getCompositionData(), ComputeDescription.class); + target.setName(desc.getName()); + target.setDescription(desc.getDescription()); + target.setAssociatedToDeploymentFlavor(source.isAssociatedWithDeploymentFlavor()); + } } - } } 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/MapComputeEntityToVspComputeDto.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/MapComputeEntityToVspComputeDto.java index c75266f756..108d6438b5 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/MapComputeEntityToVspComputeDto.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/MapComputeEntityToVspComputeDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.core.utilities.json.JsonUtil; @@ -27,14 +26,14 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDescription; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto; public class MapComputeEntityToVspComputeDto extends MappingBase { - @Override - public void doMapping(ComputeEntity source, VspComputeDto target) { - target.setComputeFlavorId(source.getId()); - if (source.getCompositionData() != null) { - ComputeDescription desc = JsonUtil.json2Object(source.getCompositionData(), ComputeDescription - .class); - target.setName(desc.getName()); - target.setComponentId(source.getComponentId()); + + @Override + public void doMapping(ComputeEntity source, VspComputeDto target) { + target.setComputeFlavorId(source.getId()); + if (source.getCompositionData() != null) { + ComputeDescription desc = JsonUtil.json2Object(source.getCompositionData(), ComputeDescription.class); + target.setName(desc.getName()); + target.setComponentId(source.getComponentId()); + } } - } } 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/MapDeploymentFlavorEntityDeploymentFlavorToListResponse.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/MapDeploymentFlavorEntityDeploymentFlavorToListResponse.java index 42ff7c9058..292ee88ef9 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/MapDeploymentFlavorEntityDeploymentFlavorToListResponse.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/MapDeploymentFlavorEntityDeploymentFlavorToListResponse.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; @@ -25,18 +24,15 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavo import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorListResponseDto; -public class MapDeploymentFlavorEntityDeploymentFlavorToListResponse extends - MappingBase { - - @Override - public void doMapping(DeploymentFlavorEntity source, - DeploymentFlavorListResponseDto target) { - target.setId(source.getId()); - DeploymentFlavor deploymentFlavor = source.getDeploymentFlavorCompositionData(); +public class MapDeploymentFlavorEntityDeploymentFlavorToListResponse extends MappingBase { - if (deploymentFlavor != null) { - target.setModel(deploymentFlavor.getModel()); - target.setDescription(deploymentFlavor.getDescription()); + @Override + public void doMapping(DeploymentFlavorEntity source, DeploymentFlavorListResponseDto target) { + target.setId(source.getId()); + DeploymentFlavor deploymentFlavor = source.getDeploymentFlavorCompositionData(); + if (deploymentFlavor != null) { + target.setModel(deploymentFlavor.getModel()); + target.setDescription(deploymentFlavor.getDescription()); + } } - } } 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/MapDeploymentFlavorEntityToDeploymentFlavorCreationDto.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/MapDeploymentFlavorEntityToDeploymentFlavorCreationDto.java index 05fa35d0ba..80b6649005 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/MapDeploymentFlavorEntityToDeploymentFlavorCreationDto.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/MapDeploymentFlavorEntityToDeploymentFlavorCreationDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,20 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorCreationDto; +public class MapDeploymentFlavorEntityToDeploymentFlavorCreationDto extends MappingBase { -public class MapDeploymentFlavorEntityToDeploymentFlavorCreationDto extends MappingBase { - - @Override - public void doMapping(DeploymentFlavorEntity source, - DeploymentFlavorCreationDto target) { - target.setDeploymentFlavorId(source.getId()); - } + @Override + public void doMapping(DeploymentFlavorEntity source, DeploymentFlavorCreationDto target) { + target.setDeploymentFlavorId(source.getId()); + } } 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/MapDeploymentFlavorEntityToDeploymentFlavorDto.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/MapDeploymentFlavorEntityToDeploymentFlavorDto.java index 188ff82636..dbf9b2adf9 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/MapDeploymentFlavorEntityToDeploymentFlavorDto.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/MapDeploymentFlavorEntityToDeploymentFlavorDto.java @@ -13,19 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.mapping; - import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; -public class MapDeploymentFlavorEntityToDeploymentFlavorDto extends - MappingBase { - @Override - public void doMapping(DeploymentFlavorEntity source, DeploymentFlavorDto target) { - target.setId(source.getId()); +public class MapDeploymentFlavorEntityToDeploymentFlavorDto extends MappingBase { - } + @Override + public void doMapping(DeploymentFlavorEntity source, DeploymentFlavorDto target) { + target.setId(source.getId()); + } } 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/MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity.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/MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity.java index 97ccf28def..6bd60b81a2 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/MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity.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/MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; @@ -25,16 +24,15 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavo import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorRequestDto; -public class MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity - extends MappingBase { +public class MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity extends MappingBase { - @Override - public void doMapping(DeploymentFlavorRequestDto source, DeploymentFlavorEntity target) { - DeploymentFlavor deploymentFlavor = new DeploymentFlavor(); - deploymentFlavor.setModel(source.getModel()); - deploymentFlavor.setDescription(source.getDescription()); - deploymentFlavor.setFeatureGroupId(source.getFeatureGroupId()); - deploymentFlavor.setComponentComputeAssociations(source.getComponentComputeAssociations()); - target.setDeploymentFlavorCompositionData(deploymentFlavor); - } + @Override + public void doMapping(DeploymentFlavorRequestDto source, DeploymentFlavorEntity target) { + DeploymentFlavor deploymentFlavor = new DeploymentFlavor(); + deploymentFlavor.setModel(source.getModel()); + deploymentFlavor.setDescription(source.getDescription()); + deploymentFlavor.setFeatureGroupId(source.getFeatureGroupId()); + deploymentFlavor.setComponentComputeAssociations(source.getComponentComputeAssociations()); + target.setDeploymentFlavorCompositionData(deploymentFlavor); + } } 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/MapDeploymentFlavorToDeploymentDto.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/MapDeploymentFlavorToDeploymentDto.java index 06d299c805..b26669e511 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/MapDeploymentFlavorToDeploymentDto.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/MapDeploymentFlavorToDeploymentDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,20 +17,19 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; - public class MapDeploymentFlavorToDeploymentDto extends MappingBase { - @Override - public void doMapping(DeploymentFlavor source, DeploymentFlavorDto target) { - target.setModel(source.getModel()); - target.setDescription(source.getDescription()); - target.setFeatureGroupId(source.getFeatureGroupId()); - target.setComponentComputeAssociations(source.getComponentComputeAssociations()); - } + + @Override + public void doMapping(DeploymentFlavor source, DeploymentFlavorDto target) { + target.setModel(source.getModel()); + target.setDescription(source.getDescription()); + target.setFeatureGroupId(source.getFeatureGroupId()); + target.setComponentComputeAssociations(source.getComponentComputeAssociations()); + } } 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/MapFilesDataStructureToDto.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/MapFilesDataStructureToDto.java index c8734ff8ee..a769a4ed1b 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/MapFilesDataStructureToDto.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/MapFilesDataStructureToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,21 +17,19 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto; -public class MapFilesDataStructureToDto - extends MappingBase { +public class MapFilesDataStructureToDto extends MappingBase { - @Override - public void doMapping(FilesDataStructure source, FileDataStructureDto target) { - target.setModules(source.getModules()); - target.setArtifacts(source.getArtifacts()); - target.setNested(source.getNested()); - target.setUnassigned(source.getUnassigned()); - } + @Override + public void doMapping(FilesDataStructure source, FileDataStructureDto target) { + target.setModules(source.getModules()); + target.setArtifacts(source.getArtifacts()); + target.setNested(source.getNested()); + target.setUnassigned(source.getUnassigned()); + } } 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/MapImageDataToImageDto.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/MapImageDataToImageDto.java index 4df6eb3de9..005de5fe9c 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/MapImageDataToImageDto.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/MapImageDataToImageDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,25 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ImageData; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; - public class MapImageDataToImageDto extends MappingBase { - @Override - public void doMapping(ImageData source, ImageDto target) { - target.setFileName(source.getFileName()); - target.setDescription(source.getDescription()); - } + @Override + public void doMapping(ImageData source, ImageDto target) { + target.setFileName(source.getFileName()); + target.setDescription(source.getDescription()); + } } - - - - - - 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/MapImageEntityToImageCreationDto.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/MapImageEntityToImageCreationDto.java index cc15ef0898..5a811b2228 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/MapImageEntityToImageCreationDto.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/MapImageEntityToImageCreationDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,18 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageCreationDto; -public class MapImageEntityToImageCreationDto extends MappingBase { +public class MapImageEntityToImageCreationDto extends MappingBase { - @Override - public void doMapping(ImageEntity source, ImageCreationDto target) { - target.setId(source.getId()); - } + @Override + public void doMapping(ImageEntity source, ImageCreationDto target) { + target.setId(source.getId()); + } } 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/MapImageEntityToImageDto.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/MapImageEntityToImageDto.java index b35a0f2a38..d17735483f 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/MapImageEntityToImageDto.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/MapImageEntityToImageDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; @@ -27,14 +26,14 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; public class MapImageEntityToImageDto extends MappingBase { - @Override - public void doMapping(ImageEntity source, ImageDto target) { - target.setId(source.getId()); - Image image = source.getImageCompositionData(); - if (image != null) { - ImageData imageData = new ImageData(image.getFileName(), image.getDescription()); - new MapImageDataToImageDto().doMapping(imageData, target); + @Override + public void doMapping(ImageEntity source, ImageDto target) { + target.setId(source.getId()); + Image image = source.getImageCompositionData(); + if (image != null) { + ImageData imageData = new ImageData(image.getFileName(), image.getDescription()); + new MapImageDataToImageDto().doMapping(imageData, target); + } } - } } 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/MapImageRequestDtoToImageEntity.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/MapImageRequestDtoToImageEntity.java index 3e1c126226..fa2f432e89 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/MapImageRequestDtoToImageEntity.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/MapImageRequestDtoToImageEntity.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; @@ -23,12 +22,11 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageRequestDto; public class MapImageRequestDtoToImageEntity extends MappingBase { - @Override - public void doMapping(ImageRequestDto source, ImageEntity target) { - Image image = new Image(); - image.setFileName(source.getFileName()); - image.setDescription(source.getDescription()); - target.setImageCompositionData(image); - } - + @Override + public void doMapping(ImageRequestDto source, ImageEntity target) { + Image image = new Image(); + image.setFileName(source.getFileName()); + image.setDescription(source.getDescription()); + target.setImageCompositionData(image); + } } 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/MapItemToVspDetailsDto.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/MapItemToVspDetailsDto.java index 926f1f0b25..e0966e8350 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/MapItemToVspDetailsDto.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/MapItemToVspDetailsDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.versioning.types.Item; @@ -26,15 +25,16 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; import org.openecomp.sdcrests.vsp.rest.services.VspItemProperty; public class MapItemToVspDetailsDto extends MappingBase { - @Override - public void doMapping(Item source, VspDetailsDto target) { - target.setId(source.getId()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setVendorId((String) source.getProperties().get(VspItemProperty.VENDOR_ID)); - target.setVendorName((String) source.getProperties().get(VspItemProperty.VENDOR_NAME)); - target.setOnboardingMethod((String) source.getProperties().get(VspItemProperty.ONBOARDING_METHOD)); - target.setOwner(source.getOwner()); - target.setStatus(source.getStatus().name()); - } + + @Override + public void doMapping(Item source, VspDetailsDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setVendorId((String) source.getProperties().get(VspItemProperty.VENDOR_ID)); + target.setVendorName((String) source.getProperties().get(VspItemProperty.VENDOR_NAME)); + target.setOnboardingMethod((String) source.getProperties().get(VspItemProperty.ONBOARDING_METHOD)); + target.setOwner(source.getOwner()); + target.setStatus(source.getStatus().name()); + } } 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/MapMonitoringUploadStatusToDto.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/MapMonitoringUploadStatusToDto.java index 08d322dad0..08add59679 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/MapMonitoringUploadStatusToDto.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/MapMonitoringUploadStatusToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,19 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.MonitoringUploadStatusDto; -public class MapMonitoringUploadStatusToDto - extends MappingBase { - @Override - public void doMapping(MonitoringUploadStatus source, MonitoringUploadStatusDto target) { - target.setSnmpPoll(source.getSnmpPoll()); - target.setSnmpTrap(source.getSnmpTrap()); - target.setVesEvent(source.getVesEvent()); - } +public class MapMonitoringUploadStatusToDto extends MappingBase { + + @Override + public void doMapping(MonitoringUploadStatus source, MonitoringUploadStatusDto target) { + target.setSnmpPoll(source.getSnmpPoll()); + target.setSnmpTrap(source.getSnmpTrap()); + target.setVesEvent(source.getVesEvent()); + } } 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/MapNetworkEntityToNetworkDto.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/MapNetworkEntityToNetworkDto.java index 1d79f35769..cf2ced753e 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/MapNetworkEntityToNetworkDto.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/MapNetworkEntityToNetworkDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; @@ -26,12 +25,13 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; public class MapNetworkEntityToNetworkDto extends MappingBase { - @Override - public void doMapping(NetworkEntity source, NetworkDto target) { - target.setId(source.getId()); - Network network = source.getNetworkCompositionData(); - if (network != null) { - new MapNetworkToNetworkDto().doMapping(network, target); + + @Override + public void doMapping(NetworkEntity source, NetworkDto target) { + target.setId(source.getId()); + Network network = source.getNetworkCompositionData(); + if (network != null) { + new MapNetworkToNetworkDto().doMapping(network, target); + } } - } } 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/MapNetworkRequestDtoToNetworkEntity.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/MapNetworkRequestDtoToNetworkEntity.java index 00395c4b99..4db9209c53 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/MapNetworkRequestDtoToNetworkEntity.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/MapNetworkRequestDtoToNetworkEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; @@ -25,13 +24,13 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkRequestDto; -public class MapNetworkRequestDtoToNetworkEntity - extends MappingBase { - @Override - public void doMapping(NetworkRequestDto source, NetworkEntity target) { - Network network = new Network(); - network.setName(source.getName()); - network.setDhcp(source.isDhcp()); - target.setNetworkCompositionData(network); - } +public class MapNetworkRequestDtoToNetworkEntity extends MappingBase { + + @Override + public void doMapping(NetworkRequestDto source, NetworkEntity target) { + Network network = new Network(); + network.setName(source.getName()); + network.setDhcp(source.isDhcp()); + target.setNetworkCompositionData(network); + } } 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/MapNetworkToNetworkDto.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/MapNetworkToNetworkDto.java index dd819de1a6..6cede067f1 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/MapNetworkToNetworkDto.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/MapNetworkToNetworkDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; @@ -25,9 +24,10 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; public class MapNetworkToNetworkDto extends MappingBase { - @Override - public void doMapping(Network source, NetworkDto target) { - target.setName(source.getName()); - target.setDhcp(source.isDhcp()); - } + + @Override + public void doMapping(Network source, NetworkDto target) { + target.setName(source.getName()); + target.setDhcp(source.isDhcp()); + } } 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/MapNicEntityToNicCreationResponseDto.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/MapNicEntityToNicCreationResponseDto.java index 835ff0b7b9..a3be49e684 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/MapNicEntityToNicCreationResponseDto.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/MapNicEntityToNicCreationResponseDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,20 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; - import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicCreationResponseDto; -public class MapNicEntityToNicCreationResponseDto extends MappingBase { - +public class MapNicEntityToNicCreationResponseDto extends MappingBase { - @Override - public void doMapping(NicEntity source, NicCreationResponseDto target) { - target.setNicId(source.getId()); - } + @Override + public void doMapping(NicEntity source, NicCreationResponseDto target) { + target.setNicId(source.getId()); + } } 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/MapNicEntityToNicDto.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/MapNicEntityToNicDto.java index 2af7e2ff6b..ea56e73237 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/MapNicEntityToNicDto.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/MapNicEntityToNicDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; @@ -26,12 +25,13 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; public class MapNicEntityToNicDto extends MappingBase { - @Override - public void doMapping(NicEntity source, NicDto target) { - target.setId(source.getId()); - Nic nic = source.getNicCompositionData(); - if (nic != null) { - new MapNicToNicDto().doMapping(nic, target); + + @Override + public void doMapping(NicEntity source, NicDto target) { + target.setId(source.getId()); + Nic nic = source.getNicCompositionData(); + if (nic != null) { + new MapNicToNicDto().doMapping(nic, target); + } } - } } 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/MapNicRequestDtoToNicEntity.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/MapNicRequestDtoToNicEntity.java index 7fd0253556..da2d7c8814 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/MapNicRequestDtoToNicEntity.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/MapNicRequestDtoToNicEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; @@ -27,14 +26,15 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicRequestDto; public class MapNicRequestDtoToNicEntity extends MappingBase { - @Override - public void doMapping(NicRequestDto source, NicEntity target) { - Nic nic = new Nic(); - nic.setName(source.getName()); - nic.setDescription(source.getDescription()); - nic.setNetworkId(source.getNetworkId()); - nic.setNetworkType(NetworkType.valueOf(source.getNetworkType())); - nic.setNetworkDescription(source.getNetworkDescription()); - target.setNicCompositionData(nic); - } + + @Override + public void doMapping(NicRequestDto source, NicEntity target) { + Nic nic = new Nic(); + nic.setName(source.getName()); + nic.setDescription(source.getDescription()); + nic.setNetworkId(source.getNetworkId()); + nic.setNetworkType(NetworkType.valueOf(source.getNetworkType())); + nic.setNetworkDescription(source.getNetworkDescription()); + target.setNicCompositionData(nic); + } } 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/MapNicToNicDto.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/MapNicToNicDto.java index 8c48f18b3d..4a22fb5f19 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/MapNicToNicDto.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/MapNicToNicDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; @@ -25,15 +24,16 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; public class MapNicToNicDto extends MappingBase { - @Override - public void doMapping(Nic source, NicDto target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setNetworkId(source.getNetworkId()); - target.setNetworkName(source.getNetworkName()); - if (source.getNetworkType() != null) { - target.setNetworkType(source.getNetworkType().name()); + + @Override + public void doMapping(Nic source, NicDto target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setNetworkId(source.getNetworkId()); + target.setNetworkName(source.getNetworkName()); + if (source.getNetworkType() != null) { + target.setNetworkType(source.getNetworkType().name()); + } + target.setNetworkDescription(source.getNetworkDescription()); } - target.setNetworkDescription(source.getNetworkDescription()); - } } 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/MapPackageInfoToPackageInfoDto.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/MapPackageInfoToPackageInfoDto.java index 1bf13f8c3f..c6faa0361b 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/MapPackageInfoToPackageInfoDto.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/MapPackageInfoToPackageInfoDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; @@ -28,18 +27,19 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; * Created by TALIO on 4/25/2016. */ public class MapPackageInfoToPackageInfoDto extends MappingBase { - @Override - public void doMapping(PackageInfo source, PackageInfoDto target) { - target.setVspName(source.getVspName()); - target.setPackageId(source.getVspId()); - target.setDescription(source.getVspDescription()); - target.setVersion(source.getVersion()); - target.setPackageType(source.getPackageType()); - target.setCategory(source.getCategory()); - target.setSubCategory(source.getSubCategory()); - target.setPackageChecksum(source.getPackageChecksum()); - target.setVendorRelease(source.getVendorRelease()); - target.setVendorName(source.getVendorName()); - target.setResourceType(source.getResourceType()); - } + + @Override + public void doMapping(PackageInfo source, PackageInfoDto target) { + target.setVspName(source.getVspName()); + target.setPackageId(source.getVspId()); + target.setDescription(source.getVspDescription()); + target.setVersion(source.getVersion()); + target.setPackageType(source.getPackageType()); + target.setCategory(source.getCategory()); + target.setSubCategory(source.getSubCategory()); + target.setPackageChecksum(source.getPackageChecksum()); + target.setVendorRelease(source.getVendorRelease()); + target.setVendorName(source.getVendorName()); + target.setResourceType(source.getResourceType()); + } } 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/MapProcessEntityToProcessEntityDto.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/MapProcessEntityToProcessEntityDto.java index 96a67a9d87..6d6a6d29de 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/MapProcessEntityToProcessEntityDto.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/MapProcessEntityToProcessEntityDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,21 +17,20 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; -public class MapProcessEntityToProcessEntityDto - extends MappingBase { - @Override - public void doMapping(ProcessEntity source, ProcessEntityDto target) { - target.setId(source.getId()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setType(source.getType()); - target.setArtifactName(source.getArtifactName()); - } +public class MapProcessEntityToProcessEntityDto extends MappingBase { + + @Override + public void doMapping(ProcessEntity source, ProcessEntityDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + target.setArtifactName(source.getArtifactName()); + } } 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/MapProcessRequestDtoToProcessEntity.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/MapProcessRequestDtoToProcessEntity.java index d1a28d7145..2f53b24d25 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/MapProcessRequestDtoToProcessEntity.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/MapProcessRequestDtoToProcessEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,19 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; -public class MapProcessRequestDtoToProcessEntity - extends MappingBase { - @Override - public void doMapping(ProcessRequestDto source, ProcessEntity target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setType(source.getType()); - } +public class MapProcessRequestDtoToProcessEntity extends MappingBase { + + @Override + public void doMapping(ProcessRequestDto source, ProcessEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + } } 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/MapQuestionnaireResponseToQuestionnaireResponseDto.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/MapQuestionnaireResponseToQuestionnaireResponseDto.java index 52252c0425..598596b030 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/MapQuestionnaireResponseToQuestionnaireResponseDto.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/MapQuestionnaireResponseToQuestionnaireResponseDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,20 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; -public class MapQuestionnaireResponseToQuestionnaireResponseDto - extends MappingBase { +public class MapQuestionnaireResponseToQuestionnaireResponseDto extends MappingBase { - @Override - public void doMapping(QuestionnaireResponse source, QuestionnaireResponseDto target) { - target.setData(source.getData()); - target.setSchema(source.getSchema()); - target.setErrorMessage(source.getErrorMessage()); - } + @Override + public void doMapping(QuestionnaireResponse source, QuestionnaireResponseDto target) { + target.setData(source.getData()); + target.setSchema(source.getSchema()); + target.setErrorMessage(source.getErrorMessage()); + } } 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/MapQuestionnaireToQuestionnaireDto.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/MapQuestionnaireToQuestionnaireDto.java index fe8e3c5ea4..e846f0e047 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/MapQuestionnaireToQuestionnaireDto.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/MapQuestionnaireToQuestionnaireDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,25 +17,22 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; +import java.util.HashMap; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireDto; -import java.util.HashMap; - /** * Created by ayalaben on 9/26/2017 */ -public class MapQuestionnaireToQuestionnaireDto extends - MappingBase { +public class MapQuestionnaireToQuestionnaireDto extends MappingBase { - @Override - public void doMapping(CompositionEntity source, QuestionnaireDto target) { - target.setId(source.getId()); - target.setQuestionareData(JsonUtil.json2Object(source.getQuestionnaireData(), HashMap.class)); - } + @Override + public void doMapping(CompositionEntity source, QuestionnaireDto target) { + target.setId(source.getId()); + target.setQuestionareData(JsonUtil.json2Object(source.getQuestionnaireData(), HashMap.class)); + } } 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 48053d053d..f78e2e0dee 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 @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,10 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; - import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; @@ -28,13 +26,13 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto /** * Created by TALIO on 4/27/2016. */ -public class MapUploadFileResponseToUploadFileResponseDto - extends MappingBase { - @Override - public void doMapping(UploadFileResponse source, UploadFileResponseDto target) { - target.setStatus(source.getStatus()); - target.setErrors(source.getErrors()); - target.setOnboardingOrigin(source.getOnboardingType().toString()); - target.setNetworkPackageName(source.getNetworkPackageName()); - } +public class MapUploadFileResponseToUploadFileResponseDto extends MappingBase { + + @Override + 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 b3fbe1e7c9..8048786f69 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 @@ -13,9 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.mapping; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.openecomp.sdc.common.errors.ErrorCode; @@ -32,61 +38,47 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityVali import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireValidationResultDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto; -import java.util.*; -import java.util.stream.Collectors; +public class MapValidationResponseToDto extends MappingBase { -public class MapValidationResponseToDto - extends MappingBase { - private static Map> mapUploadDataErrors( - Map> uploadDataErrors) { - if (MapUtils.isEmpty(uploadDataErrors)) { - return null; + private static Map> mapUploadDataErrors(Map> uploadDataErrors) { + if (MapUtils.isEmpty(uploadDataErrors)) { + return null; + } + return uploadDataErrors.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> mapErrorMessages(entry.getValue()))); } - return uploadDataErrors.entrySet().stream().collect( - Collectors.toMap(Map.Entry::getKey, entry -> mapErrorMessages(entry.getValue()))); - } - private static QuestionnaireValidationResultDto mapQuestionnaireValidationResult( - QuestionnaireValidationResult questionnaireValidationResult) { - if (Objects.isNull(questionnaireValidationResult) - || Objects.isNull(questionnaireValidationResult.getValidationData())) { - return null; + private static QuestionnaireValidationResultDto mapQuestionnaireValidationResult(QuestionnaireValidationResult questionnaireValidationResult) { + if (Objects.isNull(questionnaireValidationResult) || Objects.isNull(questionnaireValidationResult.getValidationData())) { + return null; + } + QuestionnaireValidationResultDto questionnaireValidationResultDto = new QuestionnaireValidationResultDto(); + questionnaireValidationResultDto.setValid(questionnaireValidationResult.isValid()); + Set validationDataDto = new HashSet<>(); + for (CompositionEntityValidationData validationData : questionnaireValidationResult.getValidationData()) { + validationDataDto + .add(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)); + } + questionnaireValidationResultDto.setValidationData(validationDataDto); + return questionnaireValidationResultDto; } - QuestionnaireValidationResultDto questionnaireValidationResultDto = - new QuestionnaireValidationResultDto(); - questionnaireValidationResultDto.setValid(questionnaireValidationResult.isValid()); - Set validationDataDto = new HashSet<>(); - for (CompositionEntityValidationData validationData : questionnaireValidationResult - .getValidationData()) { - validationDataDto.add(new MapCompositionEntityValidationDataToDto().applyMapping( - validationData, CompositionEntityValidationDataDto.class)); + private static List mapErrorMessages(List errorMessages) { + return errorMessages == null ? null + : errorMessages.stream().map(errorMessage -> new MapErrorMessageToDto().applyMapping(errorMessage, ErrorMessageDto.class)) + .collect(Collectors.toList()); } - questionnaireValidationResultDto.setValidationData(validationDataDto); - return questionnaireValidationResultDto; - } - - - private static List mapErrorMessages(List errorMessages) { - return errorMessages == null ? null : errorMessages.stream().map( - errorMessage -> new MapErrorMessageToDto() - .applyMapping(errorMessage, ErrorMessageDto.class)).collect(Collectors.toList()); - } - - private static Collection mapErrorCodes(Collection errorCodes) { - return CollectionUtils.isEmpty(errorCodes) ? null : errorCodes.stream() - .map(errorCode -> new MapErrorCodeToDto().applyMapping(errorCode, ErrorCodeDto.class)) - .collect(Collectors.toList()); - } + private static Collection mapErrorCodes(Collection errorCodes) { + return CollectionUtils.isEmpty(errorCodes) ? null + : errorCodes.stream().map(errorCode -> new MapErrorCodeToDto().applyMapping(errorCode, ErrorCodeDto.class)).collect(Collectors.toList()); + } - @Override - public void doMapping(ValidationResponse source, ValidationResponseDto target) { - target.setValid(source.isValid()); - target.setVspErrors(mapErrorCodes(source.getVspErrors())); - target.setLicensingDataErrors(mapErrorCodes(source.getLicensingDataErrors())); - target.setUploadDataErrors(mapUploadDataErrors(source.getUploadDataErrors())); - target.setQuestionnaireValidationResult( - mapQuestionnaireValidationResult(source.getQuestionnaireValidationResult())); - } + @Override + public void doMapping(ValidationResponse source, ValidationResponseDto target) { + target.setValid(source.isValid()); + target.setVspErrors(mapErrorCodes(source.getVspErrors())); + target.setLicensingDataErrors(mapErrorCodes(source.getLicensingDataErrors())); + target.setUploadDataErrors(mapUploadDataErrors(source.getUploadDataErrors())); + target.setQuestionnaireValidationResult(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/MapVspDescriptionDtoToItem.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/MapVspDescriptionDtoToItem.java index 484b7c80bb..0543c20298 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/MapVspDescriptionDtoToItem.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/MapVspDescriptionDtoToItem.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.versioning.types.Item; @@ -26,11 +25,12 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; import org.openecomp.sdcrests.vsp.rest.services.VspItemProperty; public class MapVspDescriptionDtoToItem extends MappingBase { - @Override - public void doMapping(VspDescriptionDto source, Item target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.addProperty(VspItemProperty.VENDOR_ID, source.getVendorId()); - target.addProperty(VspItemProperty.VENDOR_NAME, source.getVendorName()); - } + + @Override + public void doMapping(VspDescriptionDto source, Item target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.addProperty(VspItemProperty.VENDOR_ID, source.getVendorId()); + target.addProperty(VspItemProperty.VENDOR_NAME, source.getVendorName()); + } } 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 3ab2667821..4c9c16df89 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 @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.LicenseType; @@ -29,27 +28,25 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; public class MapVspDescriptionDtoToVspDetails extends MappingBase { - @Override - public void doMapping(VspDescriptionDto source, VspDetails target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setCategory(source.getCategory()); - target.setSubCategory(source.getSubCategory()); - target.setIcon(source.getIcon()); - target.setVendorName(source.getVendorName()); - target.setVendorId(source.getVendorId()); - - if (source.getLicensingVersion() != null && source.getLicenseType() != LicenseType.EXTERNAL) { - target.setVlmVersion(new Version(source.getLicensingVersion())); - } - if (source.getLicenseType() != null) { - target.setLicenseType(source.getLicenseType().name()); - } - - LicensingData licensingData = source.getLicensingData(); - if (licensingData != null && source.getLicenseType() != LicenseType.EXTERNAL) { - target.setLicenseAgreement(licensingData.getLicenseAgreement()); - target.setFeatureGroups(licensingData.getFeatureGroups()); + @Override + public void doMapping(VspDescriptionDto source, VspDetails target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setCategory(source.getCategory()); + target.setSubCategory(source.getSubCategory()); + target.setIcon(source.getIcon()); + target.setVendorName(source.getVendorName()); + target.setVendorId(source.getVendorId()); + if (source.getLicensingVersion() != null && source.getLicenseType() != LicenseType.EXTERNAL) { + target.setVlmVersion(new Version(source.getLicensingVersion())); + } + if (source.getLicenseType() != null) { + target.setLicenseType(source.getLicenseType().name()); + } + LicensingData licensingData = source.getLicensingData(); + if (licensingData != null && source.getLicenseType() != LicenseType.EXTERNAL) { + target.setLicenseAgreement(licensingData.getLicenseAgreement()); + target.setFeatureGroups(licensingData.getFeatureGroups()); + } } - } } 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/MapVspDetailsToDto.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/MapVspDetailsToDto.java index 1ba5d1355c..1605ab7218 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/MapVspDetailsToDto.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/MapVspDetailsToDto.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.apache.commons.lang3.StringUtils; @@ -29,31 +28,29 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; public class MapVspDetailsToDto extends MappingBase { - @Override - public void doMapping(VspDetails source, VspDetailsDto target) { - target.setId(source.getId()); - target.setVersion(source.getVersion() == null ? null : source.getVersion().getId()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setIcon(source.getIcon()); - target.setCategory(source.getCategory()); - target.setSubCategory(source.getSubCategory()); - target.setVendorId(source.getVendorId()); - target.setVendorName(source.getVendorName()); - target.setLicensingVersion( - source.getVlmVersion() == null ? null : source.getVlmVersion().getId()); - if (StringUtils.isNotBlank(source.getLicenseType())) { - target.setLicenseType(LicenseType.valueOf(source.getLicenseType())); - } else if (StringUtils.isNotBlank(target.getLicensingVersion())){ - target.setLicenseType(LicenseType.INTERNAL); - } - if (source.getLicenseAgreement() != null || source.getFeatureGroups() != null) { - LicensingData licensingData = new LicensingData(); - licensingData.setLicenseAgreement(source.getLicenseAgreement()); - licensingData.setFeatureGroups(source.getFeatureGroups()); - target.setLicensingData(licensingData); + @Override + public void doMapping(VspDetails source, VspDetailsDto target) { + target.setId(source.getId()); + target.setVersion(source.getVersion() == null ? null : source.getVersion().getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setIcon(source.getIcon()); + target.setCategory(source.getCategory()); + target.setSubCategory(source.getSubCategory()); + target.setVendorId(source.getVendorId()); + target.setVendorName(source.getVendorName()); + target.setLicensingVersion(source.getVlmVersion() == null ? null : source.getVlmVersion().getId()); + if (StringUtils.isNotBlank(source.getLicenseType())) { + target.setLicenseType(LicenseType.valueOf(source.getLicenseType())); + } else if (StringUtils.isNotBlank(target.getLicensingVersion())) { + target.setLicenseType(LicenseType.INTERNAL); + } + if (source.getLicenseAgreement() != null || source.getFeatureGroups() != null) { + LicensingData licensingData = new LicensingData(); + licensingData.setLicenseAgreement(source.getLicenseAgreement()); + licensingData.setFeatureGroups(source.getFeatureGroups()); + target.setLicensingData(licensingData); + } + target.setOnboardingMethod(source.getOnboardingMethod()); } - - target.setOnboardingMethod(source.getOnboardingMethod()); - } } 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/ComponentDependenciesImpl.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/ComponentDependenciesImpl.java index becfac97b6..2357e94a95 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/ComponentDependenciesImpl.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/ComponentDependenciesImpl.java @@ -13,9 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager; import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; @@ -31,103 +33,73 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("componentDependencies") @Scope(value = "prototype") public class ComponentDependenciesImpl implements ComponentDependencies { - private final ComponentDependencyModelManager componentDependencyModelManager; - - public ComponentDependenciesImpl() { - this.componentDependencyModelManager = - ComponentDependencyModelManagerFactory.getInstance().createInterface(); - } - - public ComponentDependenciesImpl(ComponentDependencyModelManager componentDependencyModelManager) { - this.componentDependencyModelManager = componentDependencyModelManager; - } - - @Override - public Response create(ComponentDependencyModel request, String vspId, String versionId, - String user) { - final Version version = new Version(versionId); - - ComponentDependencyModelEntity modelEntity = - new MapComponentDependencyModelRequestToEntity().applyMapping(request, - ComponentDependencyModelEntity.class); - - modelEntity.setVspId(vspId); - modelEntity.setVersion(version); - - ComponentDependencyModelEntity componentDependency = - componentDependencyModelManager.createComponentDependency(modelEntity, vspId, version); - - MapComponentDependencyEntityToCreationDto mapping = - new MapComponentDependencyEntityToCreationDto(); - ComponentDependencyCreationDto createdComponentDependencyDto = mapping.applyMapping( - componentDependency, ComponentDependencyCreationDto.class); - return Response.ok(componentDependency != null ? createdComponentDependencyDto : null) - .build(); - } + private final ComponentDependencyModelManager componentDependencyModelManager; - @Override - public Response list(String vspId, String versionId, String user) { - - Version vspVersion = new Version(versionId); - - Collection componentDependencies = - componentDependencyModelManager.list(vspId, vspVersion); - - MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto(); - GenericCollectionWrapper results = new GenericCollectionWrapper - <>(); - for (ComponentDependencyModelEntity entity : componentDependencies) { - results.add(mapper.applyMapping(entity, ComponentDependencyResponseDto.class)); + public ComponentDependenciesImpl() { + this.componentDependencyModelManager = ComponentDependencyModelManagerFactory.getInstance().createInterface(); } - return Response.ok(results).build(); - } - - @Override - public Response delete(String vspId, String versionId, String dependencyId, String user) { - - Version vspVersion = new Version(versionId); - componentDependencyModelManager.delete(vspId, vspVersion, dependencyId); - return Response.ok().build(); - } - - @Override - public Response update(ComponentDependencyModel request, String vspId, String versionId, String - dependencyId, String user) { - - final Version version = new Version(versionId); - ComponentDependencyModelEntity modelEntity = - new MapComponentDependencyModelRequestToEntity().applyMapping(request, - ComponentDependencyModelEntity.class); - - modelEntity.setId(dependencyId); - modelEntity.setVspId(vspId); - modelEntity.setVersion(version); - componentDependencyModelManager.update(modelEntity); - return Response.ok().build(); - } + public ComponentDependenciesImpl(ComponentDependencyModelManager componentDependencyModelManager) { + this.componentDependencyModelManager = componentDependencyModelManager; + } - @Override - public Response get(String vspId, String version, String dependencyId, String user) { + @Override + public Response create(ComponentDependencyModel request, String vspId, String versionId, String user) { + final Version version = new Version(versionId); + ComponentDependencyModelEntity modelEntity = new MapComponentDependencyModelRequestToEntity() + .applyMapping(request, ComponentDependencyModelEntity.class); + modelEntity.setVspId(vspId); + modelEntity.setVersion(version); + ComponentDependencyModelEntity componentDependency = componentDependencyModelManager.createComponentDependency(modelEntity, vspId, version); + MapComponentDependencyEntityToCreationDto mapping = new MapComponentDependencyEntityToCreationDto(); + ComponentDependencyCreationDto createdComponentDependencyDto = mapping + .applyMapping(componentDependency, ComponentDependencyCreationDto.class); + return Response.ok(componentDependency != null ? createdComponentDependencyDto : null).build(); + } - ComponentDependencyModelEntity componentDependencyModelEntity = componentDependencyModelManager - .get(vspId, new Version(version), dependencyId); + @Override + public Response list(String vspId, String versionId, String user) { + Version vspVersion = new Version(versionId); + Collection componentDependencies = componentDependencyModelManager.list(vspId, vspVersion); + MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + for (ComponentDependencyModelEntity entity : componentDependencies) { + results.add(mapper.applyMapping(entity, ComponentDependencyResponseDto.class)); + } + return Response.ok(results).build(); + } - MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto(); - ComponentDependencyResponseDto componentDependencyResponseDto = - mapper.applyMapping(componentDependencyModelEntity, ComponentDependencyResponseDto.class); + @Override + public Response delete(String vspId, String versionId, String dependencyId, String user) { + Version vspVersion = new Version(versionId); + componentDependencyModelManager.delete(vspId, vspVersion, dependencyId); + return Response.ok().build(); + } - return Response.ok(componentDependencyModelEntity != null ? componentDependencyResponseDto : - null).build(); - } + @Override + public Response update(ComponentDependencyModel request, String vspId, String versionId, String dependencyId, String user) { + final Version version = new Version(versionId); + ComponentDependencyModelEntity modelEntity = new MapComponentDependencyModelRequestToEntity() + .applyMapping(request, ComponentDependencyModelEntity.class); + modelEntity.setId(dependencyId); + modelEntity.setVspId(vspId); + modelEntity.setVersion(version); + componentDependencyModelManager.update(modelEntity); + return Response.ok().build(); + } + @Override + public Response get(String vspId, String version, String dependencyId, String user) { + ComponentDependencyModelEntity componentDependencyModelEntity = componentDependencyModelManager + .get(vspId, new Version(version), dependencyId); + MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto(); + ComponentDependencyResponseDto componentDependencyResponseDto = mapper + .applyMapping(componentDependencyModelEntity, ComponentDependencyResponseDto.class); + return Response.ok(componentDependencyModelEntity != null ? componentDependencyResponseDto : null).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/ComponentMonitoringUploadsImpl.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/ComponentMonitoringUploadsImpl.java index 25c99b294b..64d36b95e0 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/ComponentMonitoringUploadsImpl.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/ComponentMonitoringUploadsImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.io.InputStream; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.openecomp.core.enrichment.types.MonitoringUploadType; import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; @@ -36,88 +38,67 @@ import org.openecomp.sdcrests.vsp.rest.mapping.MapMonitoringUploadStatusToDto; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.io.InputStream; - /** * @author katyr * @since June 26, 2017 */ - @Named @Service("componentMonitoringUploads") @Scope(value = "prototype") //@Validated public class ComponentMonitoringUploadsImpl implements ComponentMonitoringUploads { - private final MonitoringUploadsManager monitoringUploadsManager; - private final ComponentManager componentManager; - - public ComponentMonitoringUploadsImpl() { - this.monitoringUploadsManager = MonitoringUploadsManagerFactory.getInstance().createInterface(); - this.componentManager = ComponentManagerFactory.getInstance().createInterface(); - } - public ComponentMonitoringUploadsImpl(MonitoringUploadsManager monitoringUploadsManager, - ComponentManager componentManager) { - this.monitoringUploadsManager = monitoringUploadsManager; - this.componentManager = componentManager; - } + private final MonitoringUploadsManager monitoringUploadsManager; + private final ComponentManager componentManager; - @Override - public Response upload(Attachment attachment, - String vspId, String versionId, String componentId, String type, - String user) throws Exception { - - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - - MonitoringUploadType monitoringUploadType = getMonitoringUploadType(vspId, componentId, type); - monitoringUploadsManager.upload(attachment.getObject(InputStream.class), - attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, - monitoringUploadType); - return Response.ok().build(); - } - - private MonitoringUploadType getMonitoringUploadType(String vspId, String componentId, - String type) throws Exception { - MonitoringUploadType monitoringUploadType; - try { - monitoringUploadType = MonitoringUploadType.valueOf(type); - } catch (IllegalArgumentException exception) { - String errorWithParameters = ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.ILLEGAL_MONITORING_ARTIFACT_TYPE.getErrorMessage(), - componentId, vspId); - throw new Exception(errorWithParameters, exception); + public ComponentMonitoringUploadsImpl() { + this.monitoringUploadsManager = MonitoringUploadsManagerFactory.getInstance().createInterface(); + this.componentManager = ComponentManagerFactory.getInstance().createInterface(); } - return monitoringUploadType; - } - - @Override - public Response delete(String vspId, String versionId, String componentId, - String type, String user) throws Exception { - - MonitoringUploadType monitoringUploadType = getMonitoringUploadType(vspId, componentId, type); - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - monitoringUploadsManager.delete(vspId, version, componentId, monitoringUploadType); - return Response.ok().build(); - } + public ComponentMonitoringUploadsImpl(MonitoringUploadsManager monitoringUploadsManager, ComponentManager componentManager) { + this.monitoringUploadsManager = monitoringUploadsManager; + this.componentManager = componentManager; + } - @Override - public Response list(String vspId, String versionId, String componentId, - String user) { + @Override + public Response upload(Attachment attachment, String vspId, String versionId, String componentId, String type, String user) throws Exception { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + MonitoringUploadType monitoringUploadType = getMonitoringUploadType(vspId, componentId, type); + monitoringUploadsManager + .upload(attachment.getObject(InputStream.class), attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, + monitoringUploadType); + return Response.ok().build(); + } - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); + private MonitoringUploadType getMonitoringUploadType(String vspId, String componentId, String type) throws Exception { + MonitoringUploadType monitoringUploadType; + try { + monitoringUploadType = MonitoringUploadType.valueOf(type); + } catch (IllegalArgumentException exception) { + String errorWithParameters = ErrorMessagesFormatBuilder + .getErrorWithParameters(Messages.ILLEGAL_MONITORING_ARTIFACT_TYPE.getErrorMessage(), componentId, vspId); + throw new Exception(errorWithParameters, exception); + } + return monitoringUploadType; + } - MonitoringUploadStatus response = - monitoringUploadsManager.listFilenames(vspId, version, componentId); + @Override + public Response delete(String vspId, String versionId, String componentId, String type, String user) throws Exception { + MonitoringUploadType monitoringUploadType = getMonitoringUploadType(vspId, componentId, type); + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + monitoringUploadsManager.delete(vspId, version, componentId, monitoringUploadType); + return Response.ok().build(); + } - MonitoringUploadStatusDto returnEntity = - new MapMonitoringUploadStatusToDto() - .applyMapping(response, MonitoringUploadStatusDto.class); - return Response.status(Response.Status.OK).entity(returnEntity).build(); - } + @Override + public Response list(String vspId, String versionId, String componentId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + MonitoringUploadStatus response = monitoringUploadsManager.listFilenames(vspId, version, componentId); + MonitoringUploadStatusDto returnEntity = new MapMonitoringUploadStatusToDto().applyMapping(response, MonitoringUploadStatusDto.class); + return Response.status(Response.Status.OK).entity(returnEntity).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/ComponentProcessesImpl.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/ComponentProcessesImpl.java index 4e4d7d5d9e..ab0ad04075 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/ComponentProcessesImpl.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/ComponentProcessesImpl.java @@ -13,9 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.io.File; +import java.io.InputStream; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.openecomp.sdc.activitylog.ActivityLogManager; import org.openecomp.sdc.activitylog.ActivityLogManagerFactory; @@ -37,165 +41,124 @@ import org.openecomp.sdcrests.wrappers.StringWrapperResponse; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.io.File; -import java.io.InputStream; -import java.util.Collection; - @Named @Service("componentProcesses") @Scope(value = "prototype") public class ComponentProcessesImpl implements ComponentProcesses { - private final ProcessManager processManager; - private final ComponentManager componentManager; - private final ActivityLogManager activityLogManager; - - public ComponentProcessesImpl() { - this.processManager = ProcessManagerFactory.getInstance().createInterface(); - this.componentManager = ComponentManagerFactory.getInstance().createInterface(); - this.activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); - } - - public ComponentProcessesImpl(ProcessManager processManager, - ComponentManager componentManager, ActivityLogManager activityLogManager) { - this.processManager = processManager; - this.componentManager = componentManager; - this.activityLogManager = activityLogManager; - } - - @Override - public Response list(String vspId, String versionId, String componentId, String user) { + private final ProcessManager processManager; + private final ComponentManager componentManager; + private final ActivityLogManager activityLogManager; - Version version = new Version(versionId); - validateComponentExistence(vspId, version, componentId, user); - Collection processes = processManager.listProcesses(vspId, version, componentId); - - MapProcessEntityToProcessEntityDto mapper = new MapProcessEntityToProcessEntityDto(); - GenericCollectionWrapper results = new GenericCollectionWrapper<>(); - for (ProcessEntity process : processes) { - results.add(mapper.applyMapping(process, ProcessEntityDto.class)); + public ComponentProcessesImpl() { + this.processManager = ProcessManagerFactory.getInstance().createInterface(); + this.componentManager = ComponentManagerFactory.getInstance().createInterface(); + this.activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); } - return Response.ok(results).build(); - } - - @Override - public Response deleteList(String vspId, String versionId, String componentId, String user) { - - Version version = new Version(versionId); - validateComponentExistence(vspId, version, componentId, user); - processManager.deleteProcesses(vspId, version, componentId); - - return Response.ok().build(); - } - - @Override - public Response create(ProcessRequestDto request, String vspId, String versionId, - String componentId, String user) { - - ProcessEntity process = - new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); - process.setVspId(vspId); - process.setVersion(new Version(versionId)); - process.setComponentId(componentId); - - validateComponentExistence(vspId, process.getVersion(), componentId, user); - ProcessEntity createdProcess = processManager.createProcess(process); - - return Response - .ok(createdProcess != null ? new StringWrapperResponse(createdProcess.getId()) : null) - .build(); - } - - @Override - public Response get(String vspId, String versionId, String componentId, String processId, - String user) { - - Version version = new Version(versionId); - validateComponentExistence(vspId, version, componentId, user); - ProcessEntity process = processManager.getProcess(vspId, version, componentId, processId); - ProcessEntityDto result = - new MapProcessEntityToProcessEntityDto().applyMapping(process, ProcessEntityDto.class); - return Response.ok(result).build(); - } - - @Override - public Response delete(String vspId, String versionId, String componentId, String processId, - String user) { - - Version version = new Version(versionId); - validateComponentExistence(vspId, version, componentId, user); - processManager.deleteProcess(vspId, version, componentId, processId); - return Response.ok().build(); - } - - @Override - public Response update(ProcessRequestDto request, String vspId, String versionId, - String componentId, - String processId, String user) { - - ProcessEntity process = - new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); - process.setVspId(vspId); - process.setVersion(new Version(versionId)); - process.setComponentId(componentId); - process.setId(processId); - validateComponentExistence(vspId, process.getVersion(), componentId, user); - processManager.updateProcess(process); - return Response.ok().build(); - } + public ComponentProcessesImpl(ProcessManager processManager, ComponentManager componentManager, ActivityLogManager activityLogManager) { + this.processManager = processManager; + this.componentManager = componentManager; + this.activityLogManager = activityLogManager; + } - @Override - public Response getUploadedFile(String vspId, String versionId, String componentId, - String processId, String user) { + @Override + public Response list(String vspId, String versionId, String componentId, String user) { + Version version = new Version(versionId); + validateComponentExistence(vspId, version, componentId, user); + Collection processes = processManager.listProcesses(vspId, version, componentId); + MapProcessEntityToProcessEntityDto mapper = new MapProcessEntityToProcessEntityDto(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + for (ProcessEntity process : processes) { + results.add(mapper.applyMapping(process, ProcessEntityDto.class)); + } + return Response.ok(results).build(); + } - Version vspVersion = new Version(versionId); - validateComponentExistence(vspId, vspVersion, componentId, user); - File file = processManager.getProcessArtifact(vspId, vspVersion, componentId, processId); + @Override + public Response deleteList(String vspId, String versionId, String componentId, String user) { + Version version = new Version(versionId); + validateComponentExistence(vspId, version, componentId, user); + processManager.deleteProcesses(vspId, version, componentId); + return Response.ok().build(); + } - Response.ResponseBuilder response = Response.ok(file); - if (file == null) { - return Response.status(Response.Status.NOT_FOUND).build(); + @Override + public Response create(ProcessRequestDto request, String vspId, String versionId, String componentId, String user) { + ProcessEntity process = new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); + process.setVspId(vspId); + process.setVersion(new Version(versionId)); + process.setComponentId(componentId); + validateComponentExistence(vspId, process.getVersion(), componentId, user); + ProcessEntity createdProcess = processManager.createProcess(process); + return Response.ok(createdProcess != null ? new StringWrapperResponse(createdProcess.getId()) : null).build(); } - response.header("Content-Disposition", "attachment; filename=" + file.getName()); - return response.build(); - } - @Override - public Response deleteUploadedFile(String vspId, String versionId, String componentId, - String processId, - String user) { + @Override + public Response get(String vspId, String versionId, String componentId, String processId, String user) { + Version version = new Version(versionId); + validateComponentExistence(vspId, version, componentId, user); + ProcessEntity process = processManager.getProcess(vspId, version, componentId, processId); + ProcessEntityDto result = new MapProcessEntityToProcessEntityDto().applyMapping(process, ProcessEntityDto.class); + return Response.ok(result).build(); + } - Version version = new Version(versionId); - validateComponentExistence(vspId, version, componentId, user); - processManager.deleteProcessArtifact(vspId, version, componentId, processId); - return Response.ok().build(); - } + @Override + public Response delete(String vspId, String versionId, String componentId, String processId, String user) { + Version version = new Version(versionId); + validateComponentExistence(vspId, version, componentId, user); + processManager.deleteProcess(vspId, version, componentId, processId); + return Response.ok().build(); + } - @Override - public Response uploadFile(Attachment attachment, String vspId, String versionId, - String componentId, - String processId, String user) { + @Override + public Response update(ProcessRequestDto request, String vspId, String versionId, String componentId, String processId, String user) { + ProcessEntity process = new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); + process.setVspId(vspId); + process.setVersion(new Version(versionId)); + process.setComponentId(componentId); + process.setId(processId); + validateComponentExistence(vspId, process.getVersion(), componentId, user); + processManager.updateProcess(process); + return Response.ok().build(); + } - Version version = new Version(versionId); - validateComponentExistence(vspId, version, componentId, user); - processManager.uploadProcessArtifact(attachment.getObject(InputStream.class), - attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, - processId); - activityLogManager.logActivity(new ActivityLogEntity(vspId, version, - ActivityType.Upload_Artifact, user, true, "", "")); + @Override + public Response getUploadedFile(String vspId, String versionId, String componentId, String processId, String user) { + Version vspVersion = new Version(versionId); + validateComponentExistence(vspId, vspVersion, componentId, user); + File file = processManager.getProcessArtifact(vspId, vspVersion, componentId, processId); + Response.ResponseBuilder response = Response.ok(file); + if (file == null) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + response.header("Content-Disposition", "attachment; filename=" + file.getName()); + return response.build(); + } - return Response.ok().build(); - } + @Override + public Response deleteUploadedFile(String vspId, String versionId, String componentId, String processId, String user) { + Version version = new Version(versionId); + validateComponentExistence(vspId, version, componentId, user); + processManager.deleteProcessArtifact(vspId, version, componentId, processId); + return Response.ok().build(); + } + @Override + public Response uploadFile(Attachment attachment, String vspId, String versionId, String componentId, String processId, String user) { + Version version = new Version(versionId); + validateComponentExistence(vspId, version, componentId, user); + processManager + .uploadProcessArtifact(attachment.getObject(InputStream.class), attachment.getContentDisposition().getParameter("filename"), vspId, + version, componentId, processId); + activityLogManager.logActivity(new ActivityLogEntity(vspId, version, ActivityType.Upload_Artifact, user, true, "", "")); + return Response.ok().build(); + } - private void validateComponentExistence(String vspId, Version version, String componentId, - String user) { - if (componentId == null) { - return; + private void validateComponentExistence(String vspId, Version version, String componentId, String user) { + if (componentId == null) { + return; + } + componentManager.validateComponentExistence(vspId, version, componentId); } - componentManager.validateComponentExistence(vspId, version, componentId); - } } 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/ComponentsImpl.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/ComponentsImpl.java index fefa52842e..9f2cbd36b7 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/ComponentsImpl.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/ComponentsImpl.java @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; @@ -29,122 +31,104 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vsp.rest.Components; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDataToComponentDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentEntityToComponentCreationDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentEntityToComponentDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentRequestDtoToComponentEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("components") @Scope(value = "prototype") public class ComponentsImpl implements Components { - private final ComponentManager componentManager; - - public ComponentsImpl() { - this.componentManager = ComponentManagerFactory.getInstance().createInterface(); - } - - public ComponentsImpl(ComponentManager componentManager) { - this.componentManager = componentManager; - } - @Override - public Response list(String vspId, String versionId, String user) { + private final ComponentManager componentManager; - Collection components = - componentManager.listComponents(vspId, new Version(versionId)); - - MapComponentEntityToComponentDto mapper = new MapComponentEntityToComponentDto(); - GenericCollectionWrapper results = new GenericCollectionWrapper<>(); - for (ComponentEntity component : components) { - results.add(mapper.applyMapping(component, ComponentDto.class)); + public ComponentsImpl() { + this.componentManager = ComponentManagerFactory.getInstance().createInterface(); } - return Response.ok(results).build(); - } - - @Override - public Response deleteList(String vspId, String versionId, String user) { - componentManager.deleteComponents(vspId, new Version(versionId)); - return Response.ok().build(); - } - - @Override - public Response create(ComponentRequestDto request, String vspId, String versionId, String user) { - - ComponentEntity component = - new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); - component.setVspId(vspId); - component.setVersion(new Version(versionId)); - - ComponentEntity createdComponent = componentManager.createComponent(component); - MapComponentEntityToComponentCreationDto mapping = - new MapComponentEntityToComponentCreationDto(); - ComponentCreationDto createdComponentDto = mapping.applyMapping(createdComponent, - ComponentCreationDto.class); - return Response - .ok(createdComponent != null ? createdComponentDto : null) - .build(); - } - - @Override - public Response get(String vspId, String versionId, String componentId, String user) { + public ComponentsImpl(ComponentManager componentManager) { + this.componentManager = componentManager; + } - CompositionEntityResponse response = - componentManager.getComponent(vspId, new Version(versionId), componentId); + @Override + public Response list(String vspId, String versionId, String user) { + Collection components = componentManager.listComponents(vspId, new Version(versionId)); + MapComponentEntityToComponentDto mapper = new MapComponentEntityToComponentDto(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + for (ComponentEntity component : components) { + results.add(mapper.applyMapping(component, ComponentDto.class)); + } + return Response.ok(results).build(); + } - CompositionEntityResponseDto responseDto = new CompositionEntityResponseDto<>(); - new MapCompositionEntityResponseToDto<>(new MapComponentDataToComponentDto(), - ComponentDto.class).doMapping(response, responseDto); - return Response.ok(responseDto).build(); - } + @Override + public Response deleteList(String vspId, String versionId, String user) { + componentManager.deleteComponents(vspId, new Version(versionId)); + return Response.ok().build(); + } - @Override - public Response delete(String vspId, String versionId, String componentId, String user) { - componentManager.deleteComponent(vspId, new Version(versionId), componentId); - return Response.ok().build(); - } + @Override + public Response create(ComponentRequestDto request, String vspId, String versionId, String user) { + ComponentEntity component = new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); + component.setVspId(vspId); + component.setVersion(new Version(versionId)); + ComponentEntity createdComponent = componentManager.createComponent(component); + MapComponentEntityToComponentCreationDto mapping = new MapComponentEntityToComponentCreationDto(); + ComponentCreationDto createdComponentDto = mapping.applyMapping(createdComponent, ComponentCreationDto.class); + return Response.ok(createdComponent != null ? createdComponentDto : null).build(); + } - @Override - public Response update(ComponentRequestDto request, String vspId, String versionId, - String componentId, - String user) { - ComponentEntity componentEntity = - new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); - componentEntity.setVspId(vspId); - componentEntity.setVersion(new Version(versionId)); - componentEntity.setId(componentId); + @Override + public Response get(String vspId, String versionId, String componentId, String user) { + CompositionEntityResponse response = componentManager.getComponent(vspId, new Version(versionId), componentId); + CompositionEntityResponseDto responseDto = new CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapComponentDataToComponentDto(), ComponentDto.class).doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } - CompositionEntityValidationData validationData = - componentManager.updateComponent(componentEntity); - return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) - ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto().applyMapping(validationData, - CompositionEntityValidationDataDto.class)).build() : Response.ok().build(); - } + @Override + public Response delete(String vspId, String versionId, String componentId, String user) { + componentManager.deleteComponent(vspId, new Version(versionId), componentId); + return Response.ok().build(); + } - @Override - public Response getQuestionnaire(String vspId, String versionId, String componentId, - String user) { - QuestionnaireResponse questionnaireResponse = - componentManager.getQuestionnaire(vspId, new Version(versionId), componentId); + @Override + public Response update(ComponentRequestDto request, String vspId, String versionId, String componentId, String user) { + ComponentEntity componentEntity = new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); + componentEntity.setVspId(vspId); + componentEntity.setVersion(new Version(versionId)); + componentEntity.setId(componentId); + CompositionEntityValidationData validationData = componentManager.updateComponent(componentEntity); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() + : Response.ok().build(); + } - QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() - .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); - return Response.ok(result).build(); - } + @Override + public Response getQuestionnaire(String vspId, String versionId, String componentId, String user) { + QuestionnaireResponse questionnaireResponse = componentManager.getQuestionnaire(vspId, new Version(versionId), componentId); + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + } - @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, - String componentId, String user) { - componentManager - .updateQuestionnaire(vspId, new Version(versionId), componentId, questionnaireData); - return Response.ok().build(); - } + @Override + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId, String user) { + componentManager.updateQuestionnaire(vspId, new Version(versionId), componentId, questionnaireData); + return Response.ok().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/ComputeImpl.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/ComputeImpl.java index 1eea42803b..8c06629849 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/ComputeImpl.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/ComputeImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; @@ -32,137 +34,116 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData; import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDetailsDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vsp.rest.Compute; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeDataToComputeDetailsDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeDetailsDtoToComputeEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToComputeCreationDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToComputeDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("computes") @Scope(value = "prototype") public class ComputeImpl implements Compute { - private final ComputeManager computetManager; - private final ComponentManager componentManager; - public ComputeImpl() { - this.computetManager = ComputeManagerFactory.getInstance().createInterface(); - this.componentManager = ComponentManagerFactory.getInstance().createInterface(); - } + private final ComputeManager computetManager; + private final ComponentManager componentManager; - public ComputeImpl(ComputeManager computetManager, ComponentManager componentManager) { - this.computetManager = computetManager; - this.componentManager = componentManager; - } - - @Override - public Response list(String vspId, String versionId, String componentId, String user) { - - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - Collection computes = - computetManager.listComputes(vspId, version, componentId); - - MapComputeEntityToComputeDto mapper = new MapComputeEntityToComputeDto(); - GenericCollectionWrapper results = new GenericCollectionWrapper<>(); - for (ListComputeResponse compute : computes) { - results.add(mapper.applyMapping(compute, ComputeDto.class)); + public ComputeImpl() { + this.computetManager = ComputeManagerFactory.getInstance().createInterface(); + this.componentManager = ComponentManagerFactory.getInstance().createInterface(); } - return Response.ok(results).build(); - } - - @Override - public Response get(String vspId, String versionId, String componentId, String computeId, - String user) { - - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - CompositionEntityResponse response = - computetManager.getCompute(vspId, version, componentId, computeId); - - CompositionEntityResponseDto responseDto = new - CompositionEntityResponseDto<>(); - new MapCompositionEntityResponseToDto<>(new MapComputeDataToComputeDetailsDto(), - ComputeDetailsDto.class).doMapping(response, responseDto); - return Response.ok(responseDto).build(); - } - - @Override - public Response create(ComputeDetailsDto request, String vspId, String versionId, - String componentId, String user) { - - ComputeEntity compute = new MapComputeDetailsDtoToComputeEntity().applyMapping(request, - ComputeEntity.class); - compute.setVspId(vspId); - compute.setVersion(new Version(versionId)); - compute.setComponentId(componentId); - componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId); - - ComputeEntity createdCompute = computetManager.createCompute(compute); - - MapComputeEntityToComputeCreationDto mapper = new MapComputeEntityToComputeCreationDto(); - ComputeCreationDto createdComputeDto = - mapper.applyMapping(createdCompute, ComputeCreationDto.class); - return Response.ok(createdComputeDto != null ? createdComputeDto : null).build(); - } - - @Override - public Response update(ComputeDetailsDto request, String vspId, String versionId, - String componentId, String computeFlavorId, String user) { - - ComputeEntity compute = - new MapComputeDetailsDtoToComputeEntity().applyMapping(request, ComputeEntity.class); - compute.setVspId(vspId); - compute.setVersion(new Version(versionId)); - compute.setComponentId(componentId); - compute.setId(computeFlavorId); - - componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId); - CompositionEntityValidationData validationData = computetManager.updateCompute(compute); - return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) - ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto().applyMapping(validationData, - CompositionEntityValidationDataDto.class)).build() : Response.ok().build(); - } + public ComputeImpl(ComputeManager computetManager, ComponentManager componentManager) { + this.computetManager = computetManager; + this.componentManager = componentManager; + } - @Override - public Response delete(String vspId, String versionId, String componentId, String computeFlavorId, - String user) { + @Override + public Response list(String vspId, String versionId, String componentId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + Collection computes = computetManager.listComputes(vspId, version, componentId); + MapComputeEntityToComputeDto mapper = new MapComputeEntityToComputeDto(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + for (ListComputeResponse compute : computes) { + results.add(mapper.applyMapping(compute, ComputeDto.class)); + } + return Response.ok(results).build(); + } - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - computetManager.deleteCompute(vspId, version, componentId, computeFlavorId); - return Response.ok().build(); - } + @Override + public Response get(String vspId, String versionId, String componentId, String computeId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + CompositionEntityResponse response = computetManager.getCompute(vspId, version, componentId, computeId); + CompositionEntityResponseDto responseDto = new CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapComputeDataToComputeDetailsDto(), ComputeDetailsDto.class).doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } - @Override - public Response getQuestionnaire(String vspId, String versionId, String componentId, - String computeFlavorId, String user) { + @Override + public Response create(ComputeDetailsDto request, String vspId, String versionId, String componentId, String user) { + ComputeEntity compute = new MapComputeDetailsDtoToComputeEntity().applyMapping(request, ComputeEntity.class); + compute.setVspId(vspId); + compute.setVersion(new Version(versionId)); + compute.setComponentId(componentId); + componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId); + ComputeEntity createdCompute = computetManager.createCompute(compute); + MapComputeEntityToComputeCreationDto mapper = new MapComputeEntityToComputeCreationDto(); + ComputeCreationDto createdComputeDto = mapper.applyMapping(createdCompute, ComputeCreationDto.class); + return Response.ok(createdComputeDto != null ? createdComputeDto : null).build(); + } - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - QuestionnaireResponse questionnaireResponse = - computetManager.getComputeQuestionnaire(vspId, version, componentId, computeFlavorId); + @Override + public Response update(ComputeDetailsDto request, String vspId, String versionId, String componentId, String computeFlavorId, String user) { + ComputeEntity compute = new MapComputeDetailsDtoToComputeEntity().applyMapping(request, ComputeEntity.class); + compute.setVspId(vspId); + compute.setVersion(new Version(versionId)); + compute.setComponentId(componentId); + compute.setId(computeFlavorId); + componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId); + CompositionEntityValidationData validationData = computetManager.updateCompute(compute); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() + : Response.ok().build(); + } - QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() - .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); - return Response.ok(result).build(); - } + @Override + public Response delete(String vspId, String versionId, String componentId, String computeFlavorId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + computetManager.deleteCompute(vspId, version, componentId, computeFlavorId); + return Response.ok().build(); + } - @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, - String componentId, String computeFlavorId, String user) { + @Override + public Response getQuestionnaire(String vspId, String versionId, String componentId, String computeFlavorId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + QuestionnaireResponse questionnaireResponse = computetManager.getComputeQuestionnaire(vspId, version, componentId, computeFlavorId); + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + } - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - computetManager.updateComputeQuestionnaire(vspId, version, componentId, computeFlavorId, - questionnaireData); - return Response.ok().build(); - } + @Override + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId, String computeFlavorId, + String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + computetManager.updateComputeQuestionnaire(vspId, version, componentId, computeFlavorId, questionnaireData); + return Response.ok().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/DeploymentFlavorsImpl.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/DeploymentFlavorsImpl.java index 13851e72e1..1f022aee18 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/DeploymentFlavorsImpl.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/DeploymentFlavorsImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManager; import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManagerFactory; @@ -28,108 +30,93 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor; import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorListResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorRequestDto; import org.openecomp.sdcrests.vsp.rest.DeploymentFlavors; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorEntityDeploymentFlavorToListResponse; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorEntityToDeploymentFlavorCreationDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorToDeploymentDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("deploymentFlavors") @Scope(value = "prototype") public class DeploymentFlavorsImpl implements DeploymentFlavors { - private final DeploymentFlavorManager deploymentFlavorManager; - - public DeploymentFlavorsImpl() { - this.deploymentFlavorManager = - DeploymentFlavorManagerFactory.getInstance().createInterface(); - } - - public DeploymentFlavorsImpl(DeploymentFlavorManager deploymentFlavorManager) { - this.deploymentFlavorManager = deploymentFlavorManager; - } - @Override - public Response create(DeploymentFlavorRequestDto request, String vspId, String versionId, - String user) { - DeploymentFlavorEntity deploymentFlavorEntity = - new MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity() - .applyMapping(request, DeploymentFlavorEntity.class); - deploymentFlavorEntity.setVspId(vspId); - deploymentFlavorEntity.setVersion(new Version(versionId)); - DeploymentFlavorEntity createdDeploymentFlavor = - deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity); - MapDeploymentFlavorEntityToDeploymentFlavorCreationDto mapping = - new MapDeploymentFlavorEntityToDeploymentFlavorCreationDto(); - DeploymentFlavorCreationDto deploymentFlavorCreatedDto = mapping.applyMapping - (createdDeploymentFlavor, DeploymentFlavorCreationDto.class); - return Response - .ok(createdDeploymentFlavor != null ? deploymentFlavorCreatedDto : null) - .build(); - } + private final DeploymentFlavorManager deploymentFlavorManager; - @Override - public Response list(String vspId, String versionId, String user) { - Collection deploymentFlavors = - deploymentFlavorManager.listDeploymentFlavors(vspId, new Version(versionId)); + public DeploymentFlavorsImpl() { + this.deploymentFlavorManager = DeploymentFlavorManagerFactory.getInstance().createInterface(); + } - MapDeploymentFlavorEntityDeploymentFlavorToListResponse mapper = new - MapDeploymentFlavorEntityDeploymentFlavorToListResponse(); - GenericCollectionWrapper results = - new GenericCollectionWrapper<>(); - for (DeploymentFlavorEntity deploymentFlavor : deploymentFlavors) { - results.add(mapper.applyMapping(deploymentFlavor, DeploymentFlavorListResponseDto.class)); + public DeploymentFlavorsImpl(DeploymentFlavorManager deploymentFlavorManager) { + this.deploymentFlavorManager = deploymentFlavorManager; } - return Response.ok(results).build(); - } - @Override - public Response get(String vspId, String versionId, String deploymentFlavorId, String user) { - CompositionEntityResponse response = deploymentFlavorManager - .getDeploymentFlavor(vspId, new Version(versionId), deploymentFlavorId); + @Override + public Response create(DeploymentFlavorRequestDto request, String vspId, String versionId, String user) { + DeploymentFlavorEntity deploymentFlavorEntity = new MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity() + .applyMapping(request, DeploymentFlavorEntity.class); + deploymentFlavorEntity.setVspId(vspId); + deploymentFlavorEntity.setVersion(new Version(versionId)); + DeploymentFlavorEntity createdDeploymentFlavor = deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity); + MapDeploymentFlavorEntityToDeploymentFlavorCreationDto mapping = new MapDeploymentFlavorEntityToDeploymentFlavorCreationDto(); + DeploymentFlavorCreationDto deploymentFlavorCreatedDto = mapping.applyMapping(createdDeploymentFlavor, DeploymentFlavorCreationDto.class); + return Response.ok(createdDeploymentFlavor != null ? deploymentFlavorCreatedDto : null).build(); + } - CompositionEntityResponseDto responseDto = new - CompositionEntityResponseDto<>(); - new MapCompositionEntityResponseToDto<>(new MapDeploymentFlavorToDeploymentDto(), - DeploymentFlavorDto.class) - .doMapping(response, responseDto); - return Response.ok(responseDto).build(); - } + @Override + public Response list(String vspId, String versionId, String user) { + Collection deploymentFlavors = deploymentFlavorManager.listDeploymentFlavors(vspId, new Version(versionId)); + MapDeploymentFlavorEntityDeploymentFlavorToListResponse mapper = new MapDeploymentFlavorEntityDeploymentFlavorToListResponse(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + for (DeploymentFlavorEntity deploymentFlavor : deploymentFlavors) { + results.add(mapper.applyMapping(deploymentFlavor, DeploymentFlavorListResponseDto.class)); + } + return Response.ok(results).build(); + } - @Override - public Response getSchema(String vspId, String versionId, String user) { - CompositionEntityResponse response = deploymentFlavorManager - .getDeploymentFlavorSchema(vspId, new Version(versionId)); - return Response.ok(response).build(); - } + @Override + public Response get(String vspId, String versionId, String deploymentFlavorId, String user) { + CompositionEntityResponse response = deploymentFlavorManager + .getDeploymentFlavor(vspId, new Version(versionId), deploymentFlavorId); + CompositionEntityResponseDto responseDto = new CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapDeploymentFlavorToDeploymentDto(), DeploymentFlavorDto.class).doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } - @Override - public Response delete(String vspId, String versionId, String deploymentFlavorId, String user) { - Version version = new Version(versionId); - deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId); - return Response.ok().build(); - } + @Override + public Response getSchema(String vspId, String versionId, String user) { + CompositionEntityResponse response = deploymentFlavorManager.getDeploymentFlavorSchema(vspId, new Version(versionId)); + return Response.ok(response).build(); + } - @Override - public Response update(DeploymentFlavorRequestDto request, String vspId, String versionId, - String deploymentFlavorId, String user) { - DeploymentFlavorEntity deploymentFlavorEntity = - new MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity().applyMapping(request, - DeploymentFlavorEntity.class); - deploymentFlavorEntity.setVspId(vspId); - deploymentFlavorEntity.setVersion(new Version(versionId)); - deploymentFlavorEntity.setId(deploymentFlavorId); + @Override + public Response delete(String vspId, String versionId, String deploymentFlavorId, String user) { + Version version = new Version(versionId); + deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId); + return Response.ok().build(); + } - CompositionEntityValidationData validationData = - deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity); - return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) - ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto().applyMapping(validationData, - CompositionEntityValidationDataDto.class)).build() : Response.ok().build(); - } + @Override + public Response update(DeploymentFlavorRequestDto request, String vspId, String versionId, String deploymentFlavorId, String user) { + DeploymentFlavorEntity deploymentFlavorEntity = new MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity() + .applyMapping(request, DeploymentFlavorEntity.class); + deploymentFlavorEntity.setVspId(vspId); + deploymentFlavorEntity.setVersion(new Version(versionId)); + deploymentFlavorEntity.setId(deploymentFlavorId); + CompositionEntityValidationData validationData = deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() + : Response.ok().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/ImagesImpl.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/ImagesImpl.java index 7971b48427..350630c0aa 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/ImagesImpl.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/ImagesImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,10 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; - +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; @@ -32,135 +33,116 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image; import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vsp.rest.Images; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapImageEntityToImageCreationDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapImageEntityToImageDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapImageRequestDtoToImageEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - - @Named @Service("images") @Scope(value = "prototype") public class ImagesImpl implements Images { - private final ImageManager imageManager; - private final ComponentManager componentManager; - - public ImagesImpl() { - this.imageManager = ImageManagerFactory.getInstance().createInterface(); - this.componentManager = - ComponentManagerFactory.getInstance().createInterface(); - } - - public ImagesImpl(ImageManager imageManager, ComponentManager componentManager) { - this.imageManager = imageManager; - this.componentManager = componentManager; - } - - @Override - public Response create(ImageRequestDto request, String vspId, String versionId, - String componentId, String user) { - ImageEntity image = - new MapImageRequestDtoToImageEntity().applyMapping(request, ImageEntity.class); - image.setVspId(vspId); - image.setComponentId(componentId); - image.setVersion(new Version(versionId)); - componentManager.validateComponentExistence(vspId, image.getVersion(), componentId); - ImageEntity createdImage = imageManager.createImage(image); - MapImageEntityToImageCreationDto mapping = new MapImageEntityToImageCreationDto(); - ImageCreationDto createdImageDto = mapping.applyMapping(createdImage, ImageCreationDto.class); - return Response - .ok(createdImage != null ? createdImageDto : null) - .build(); - } + private final ImageManager imageManager; + private final ComponentManager componentManager; - @Override - public Response getImageSchema(String vspId, String versionId, String componentId, String user) { - CompositionEntityResponse response = imageManager.getImageSchema(vspId); - return Response.ok(response).build(); - } - - @Override - public Response get(String vspId, String versionId, String componentId, String imageId, - String user) { - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - CompositionEntityResponse response = - imageManager.getImage(vspId, version, componentId, imageId); - - return Response.ok(response).build(); - } - - @Override - public Response list(String vspId, String versionId, String componentId, String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - Collection images = imageManager.listImages(vspId, vspVersion, componentId); - - MapImageEntityToImageDto mapper = new MapImageEntityToImageDto(); - GenericCollectionWrapper results = new GenericCollectionWrapper<>(); - for (ImageEntity image : images) { - results.add(mapper.applyMapping(image, ImageDto.class)); + public ImagesImpl() { + this.imageManager = ImageManagerFactory.getInstance().createInterface(); + this.componentManager = ComponentManagerFactory.getInstance().createInterface(); } - return Response.ok(results).build(); - } + public ImagesImpl(ImageManager imageManager, ComponentManager componentManager) { + this.imageManager = imageManager; + this.componentManager = componentManager; + } - @Override - public Response delete(String vspId, String versionId, String componentId, String imageId, - String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - imageManager.deleteImage(vspId, vspVersion, componentId, imageId); - return Response.ok().build(); - } + @Override + public Response create(ImageRequestDto request, String vspId, String versionId, String componentId, String user) { + ImageEntity image = new MapImageRequestDtoToImageEntity().applyMapping(request, ImageEntity.class); + image.setVspId(vspId); + image.setComponentId(componentId); + image.setVersion(new Version(versionId)); + componentManager.validateComponentExistence(vspId, image.getVersion(), componentId); + ImageEntity createdImage = imageManager.createImage(image); + MapImageEntityToImageCreationDto mapping = new MapImageEntityToImageCreationDto(); + ImageCreationDto createdImageDto = mapping.applyMapping(createdImage, ImageCreationDto.class); + return Response.ok(createdImage != null ? createdImageDto : null).build(); + } - @Override - public Response update(ImageRequestDto request, String vspId, String versionId, - String componentId, String imageId, String user) { - ImageEntity imageEntity = new MapImageRequestDtoToImageEntity().applyMapping(request, - ImageEntity.class); - imageEntity.setVspId(vspId); - imageEntity.setVersion(new Version(versionId)); - imageEntity.setComponentId(componentId); - imageEntity.setId(imageId); - componentManager.validateComponentExistence(vspId, imageEntity.getVersion(), componentId); + @Override + public Response getImageSchema(String vspId, String versionId, String componentId, String user) { + CompositionEntityResponse response = imageManager.getImageSchema(vspId); + return Response.ok(response).build(); + } - CompositionEntityValidationData validationData = imageManager.updateImage(imageEntity); - return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) - ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto() - .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : - Response.ok().build(); - } + @Override + public Response get(String vspId, String versionId, String componentId, String imageId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + CompositionEntityResponse response = imageManager.getImage(vspId, version, componentId, imageId); + return Response.ok(response).build(); + } - @Override - public Response getQuestionnaire(String vspId, String versionId, String componentId, - String imageId, String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - QuestionnaireResponse questionnaireResponse = - imageManager.getImageQuestionnaire(vspId, vspVersion, componentId, imageId); + @Override + public Response list(String vspId, String versionId, String componentId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + Collection images = imageManager.listImages(vspId, vspVersion, componentId); + MapImageEntityToImageDto mapper = new MapImageEntityToImageDto(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + for (ImageEntity image : images) { + results.add(mapper.applyMapping(image, ImageDto.class)); + } + return Response.ok(results).build(); + } - QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() - .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); - return Response.ok(result).build(); + @Override + public Response delete(String vspId, String versionId, String componentId, String imageId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + imageManager.deleteImage(vspId, vspVersion, componentId, imageId); + return Response.ok().build(); + } - } + @Override + public Response update(ImageRequestDto request, String vspId, String versionId, String componentId, String imageId, String user) { + ImageEntity imageEntity = new MapImageRequestDtoToImageEntity().applyMapping(request, ImageEntity.class); + imageEntity.setVspId(vspId); + imageEntity.setVersion(new Version(versionId)); + imageEntity.setComponentId(componentId); + imageEntity.setId(imageId); + componentManager.validateComponentExistence(vspId, imageEntity.getVersion(), componentId); + CompositionEntityValidationData validationData = imageManager.updateImage(imageEntity); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() + : Response.ok().build(); + } - @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, - String componentId, String imageId, String user) { - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - imageManager.updateImageQuestionnaire(vspId, version, componentId, imageId, questionnaireData); - return Response.ok().build(); - } + @Override + public Response getQuestionnaire(String vspId, String versionId, String componentId, String imageId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + QuestionnaireResponse questionnaireResponse = imageManager.getImageQuestionnaire(vspId, vspVersion, componentId, imageId); + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + } + @Override + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId, String imageId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + imageManager.updateImageQuestionnaire(vspId, version, componentId, imageId, questionnaireData); + return Response.ok().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/NetworksImpl.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/NetworksImpl.java index 6a6cbd0e60..e25ef8e324 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/NetworksImpl.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/NetworksImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.NetworkManager; import org.openecomp.sdc.vendorsoftwareproduct.NetworkManagerFactory; @@ -33,93 +35,74 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityVali import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkRequestDto; import org.openecomp.sdcrests.vsp.rest.Networks; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkEntityToNetworkDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkRequestDtoToNetworkEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkToNetworkDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("networks") @Scope(value = "prototype") public class NetworksImpl implements Networks { - private final NetworkManager networkManager; - - public NetworksImpl(NetworkManager networkManager) { - this.networkManager = networkManager; - } + private final NetworkManager networkManager; - public NetworksImpl() { - this(NetworkManagerFactory.getInstance().createInterface()); - } - - @Override - public Response list(String vspId, String versionId, String user) { - Collection networks = - networkManager.listNetworks(vspId, new Version(versionId)); - - MapNetworkEntityToNetworkDto mapper = new MapNetworkEntityToNetworkDto(); - GenericCollectionWrapper results = new GenericCollectionWrapper<>(); - for (NetworkEntity network : networks) { - results.add(mapper.applyMapping(network, NetworkDto.class)); + public NetworksImpl(NetworkManager networkManager) { + this.networkManager = networkManager; } - return Response.ok(results).build(); - } - - @Override - public Response create(NetworkRequestDto request, String vspId, String versionId, String user) { - NetworkEntity network = - new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); - network.setVspId(vspId); - network.setVersion(new Version(versionId)); - NetworkEntity createdNetwork = networkManager.createNetwork(network); - return Response - .ok(createdNetwork != null ? new StringWrapperResponse(createdNetwork.getId()) : null) - .build(); - } + public NetworksImpl() { + this(NetworkManagerFactory.getInstance().createInterface()); + } - @Override - public Response get(String vspId, String versionId, String networkId, String user) { - CompositionEntityResponse response = - networkManager.getNetwork(vspId, - new Version(versionId), networkId - ); + @Override + public Response list(String vspId, String versionId, String user) { + Collection networks = networkManager.listNetworks(vspId, new Version(versionId)); + MapNetworkEntityToNetworkDto mapper = new MapNetworkEntityToNetworkDto(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + for (NetworkEntity network : networks) { + results.add(mapper.applyMapping(network, NetworkDto.class)); + } + return Response.ok(results).build(); + } - CompositionEntityResponseDto responseDto = new CompositionEntityResponseDto<>(); - new MapCompositionEntityResponseToDto<>(new MapNetworkToNetworkDto(), NetworkDto.class) - .doMapping(response, responseDto); - return Response.ok(responseDto).build(); - } + @Override + public Response create(NetworkRequestDto request, String vspId, String versionId, String user) { + NetworkEntity network = new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); + network.setVspId(vspId); + network.setVersion(new Version(versionId)); + NetworkEntity createdNetwork = networkManager.createNetwork(network); + return Response.ok(createdNetwork != null ? new StringWrapperResponse(createdNetwork.getId()) : null).build(); + } - @Override - public Response delete(String vspId, String versionId, String networkId, String user) { - networkManager - .deleteNetwork(vspId, new Version(versionId), - networkId); - return Response.ok().build(); - } + @Override + public Response get(String vspId, String versionId, String networkId, String user) { + CompositionEntityResponse response = networkManager.getNetwork(vspId, new Version(versionId), networkId); + CompositionEntityResponseDto responseDto = new CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapNetworkToNetworkDto(), NetworkDto.class).doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } - @Override - public Response update(NetworkRequestDto request, String vspId, String versionId, - String networkId, String user) { - NetworkEntity networkEntity = - new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); - networkEntity.setVspId(vspId); - networkEntity.setVersion(new Version(versionId)); - networkEntity.setId(networkId); + @Override + public Response delete(String vspId, String versionId, String networkId, String user) { + networkManager.deleteNetwork(vspId, new Version(versionId), networkId); + return Response.ok().build(); + } - CompositionEntityValidationData validationData = - networkManager.updateNetwork(networkEntity); - return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) - ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto() - .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : - Response.ok().build(); - } + @Override + public Response update(NetworkRequestDto request, String vspId, String versionId, String networkId, String user) { + NetworkEntity networkEntity = new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); + networkEntity.setVspId(vspId); + networkEntity.setVersion(new Version(versionId)); + networkEntity.setId(networkId); + CompositionEntityValidationData validationData = networkManager.updateNetwork(networkEntity); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() + : Response.ok().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/NicsImpl.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/NicsImpl.java index 11ed508286..9784015089 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/NicsImpl.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/NicsImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; @@ -31,131 +33,115 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicCreationResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vsp.rest.Nics; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicEntityToNicCreationResponseDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicEntityToNicDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicRequestDtoToNicEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicToNicDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("nics") @Scope(value = "prototype") public class NicsImpl implements Nics { - private final NicManager nicManager; - private final ComponentManager componentManager; - - public NicsImpl() { - this.nicManager = NicManagerFactory.getInstance().createInterface(); - this.componentManager = ComponentManagerFactory.getInstance().createInterface(); - } - public NicsImpl(NicManager nicManager, ComponentManager componentManager) { - this.nicManager = nicManager; - this.componentManager = componentManager; - } + private final NicManager nicManager; + private final ComponentManager componentManager; - @Override - public Response list(String vspId, String versionId, String componentId, String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - Collection nics = nicManager.listNics(vspId, vspVersion, componentId); - - MapNicEntityToNicDto mapper = new MapNicEntityToNicDto(); - GenericCollectionWrapper results = new GenericCollectionWrapper<>(); - for (NicEntity nic : nics) { - results.add(mapper.applyMapping(nic, NicDto.class)); + public NicsImpl() { + this.nicManager = NicManagerFactory.getInstance().createInterface(); + this.componentManager = ComponentManagerFactory.getInstance().createInterface(); } - return Response.ok(results).build(); - } - - @Override - public Response create(NicRequestDto request, String vspId, String versionId, String componentId, - String user) { - NicEntity nic = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); - nic.setVspId(vspId); - nic.setVersion(new Version(versionId)); - nic.setComponentId(componentId); - componentManager.validateComponentExistence(vspId, nic.getVersion(), componentId); - - NicEntity createdNic = nicManager.createNic(nic); - MapNicEntityToNicCreationResponseDto mapping = - new MapNicEntityToNicCreationResponseDto(); - NicCreationResponseDto createdNicDto = mapping.applyMapping(createdNic, - NicCreationResponseDto.class); - return Response.ok(createdNic != null ? createdNicDto : null) - .build(); - } - - @Override - public Response get(String vspId, String versionId, String componentId, String nicId, - String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - CompositionEntityResponse response = - nicManager.getNic(vspId, vspVersion, componentId, nicId); + public NicsImpl(NicManager nicManager, ComponentManager componentManager) { + this.nicManager = nicManager; + this.componentManager = componentManager; + } - CompositionEntityResponseDto responseDto = new CompositionEntityResponseDto<>(); - new MapCompositionEntityResponseToDto<>(new MapNicToNicDto(), NicDto.class) - .doMapping(response, responseDto); - return Response.ok(responseDto).build(); - } + @Override + public Response list(String vspId, String versionId, String componentId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + Collection nics = nicManager.listNics(vspId, vspVersion, componentId); + MapNicEntityToNicDto mapper = new MapNicEntityToNicDto(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + for (NicEntity nic : nics) { + results.add(mapper.applyMapping(nic, NicDto.class)); + } + return Response.ok(results).build(); + } - @Override - public Response delete(String vspId, String versionId, String componentId, String nicId, - String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - nicManager.deleteNic(vspId, vspVersion, componentId, nicId); - return Response.ok().build(); - } + @Override + public Response create(NicRequestDto request, String vspId, String versionId, String componentId, String user) { + NicEntity nic = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); + nic.setVspId(vspId); + nic.setVersion(new Version(versionId)); + nic.setComponentId(componentId); + componentManager.validateComponentExistence(vspId, nic.getVersion(), componentId); + NicEntity createdNic = nicManager.createNic(nic); + MapNicEntityToNicCreationResponseDto mapping = new MapNicEntityToNicCreationResponseDto(); + NicCreationResponseDto createdNicDto = mapping.applyMapping(createdNic, NicCreationResponseDto.class); + return Response.ok(createdNic != null ? createdNicDto : null).build(); + } - @Override - public Response update(NicRequestDto request, String vspId, String versionId, String componentId, - String nicId, - String user) { - NicEntity nicEntity = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); - nicEntity.setVspId(vspId); - nicEntity.setVersion(new Version(versionId)); - nicEntity.setComponentId(componentId); - nicEntity.setId(nicId); + @Override + public Response get(String vspId, String versionId, String componentId, String nicId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + CompositionEntityResponse response = nicManager.getNic(vspId, vspVersion, componentId, nicId); + CompositionEntityResponseDto responseDto = new CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapNicToNicDto(), NicDto.class).doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } - componentManager.validateComponentExistence(vspId, nicEntity.getVersion(), componentId); - CompositionEntityValidationData validationData = - nicManager.updateNic(nicEntity); - return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) - ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto() - .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : - Response.ok().build(); - } + @Override + public Response delete(String vspId, String versionId, String componentId, String nicId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + nicManager.deleteNic(vspId, vspVersion, componentId, nicId); + return Response.ok().build(); + } - @Override - public Response getQuestionnaire(String vspId, String versionId, String componentId, String nicId, - String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - QuestionnaireResponse questionnaireResponse = - nicManager.getNicQuestionnaire(vspId, vspVersion, componentId, nicId); + @Override + public Response update(NicRequestDto request, String vspId, String versionId, String componentId, String nicId, String user) { + NicEntity nicEntity = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); + nicEntity.setVspId(vspId); + nicEntity.setVersion(new Version(versionId)); + nicEntity.setComponentId(componentId); + nicEntity.setId(nicId); + componentManager.validateComponentExistence(vspId, nicEntity.getVersion(), componentId); + CompositionEntityValidationData validationData = nicManager.updateNic(nicEntity); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() + : Response.ok().build(); + } - QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() - .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); - return Response.ok(result).build(); - } + @Override + public Response getQuestionnaire(String vspId, String versionId, String componentId, String nicId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + QuestionnaireResponse questionnaireResponse = nicManager.getNicQuestionnaire(vspId, vspVersion, componentId, nicId); + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + } - @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, - String componentId, - String nicId, String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - nicManager - .updateNicQuestionnaire(vspId, vspVersion, componentId, nicId, questionnaireData); - return Response.ok().build(); - } + @Override + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId, String nicId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + nicManager.updateNicQuestionnaire(vspId, vspVersion, componentId, nicId, questionnaireData); + return Response.ok().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/OrchestrationTemplateCandidateException.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/OrchestrationTemplateCandidateException.java index a7e65a7e6f..1e20d1ced7 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/OrchestrationTemplateCandidateException.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/OrchestrationTemplateCandidateException.java @@ -19,9 +19,9 @@ */ package org.openecomp.sdcrests.vsp.rest.services; -public class OrchestrationTemplateCandidateException extends Exception{ +public class OrchestrationTemplateCandidateException extends Exception { - public OrchestrationTemplateCandidateException(String message, Throwable t){ + public OrchestrationTemplateCandidateException(String message, Throwable t) { super(message, t); } } 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 b393153ece..48ad75d09c 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 @@ -18,7 +18,6 @@ * Modifications copyright (c) 2019 Nokia * ================================================================================ */ - package org.openecomp.sdcrests.vsp.rest.services; import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters; @@ -74,56 +73,47 @@ import org.springframework.stereotype.Service; @Service("orchestrationTemplateCandidate") @Scope(value = "prototype") public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplateCandidate { - private static final Logger LOGGER = - LoggerFactory.getLogger(OrchestrationTemplateCandidateImpl.class); - private final OrchestrationTemplateCandidateManager candidateManager; - - private final VendorSoftwareProductManager vendorSoftwareProductManager; - private final ActivityLogManager activityLogManager; - - - public OrchestrationTemplateCandidateImpl() { - this.candidateManager = OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface(); - this.vendorSoftwareProductManager = VspManagerFactory.getInstance().createInterface(); - this.activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); - } - - // Constructor used in test to avoid mock static - public OrchestrationTemplateCandidateImpl( - OrchestrationTemplateCandidateManager candidateManager, - VendorSoftwareProductManager vendorSoftwareProductManager, - ActivityLogManager activityLogManager) { - this.candidateManager = candidateManager; - this.vendorSoftwareProductManager = vendorSoftwareProductManager; - this.activityLogManager = activityLogManager; - } - - @Override - public Response upload(final String vspId, final String versionId, - final Attachment fileToUpload, final String user) { - final byte[] fileToUploadBytes = fileToUpload.getObject(byte[].class); - final DataHandler dataHandler = fileToUpload.getDataHandler(); - final String filename = ValidationUtils.sanitizeInputString(dataHandler.getName()); - - final OnboardingPackageProcessor onboardingPackageProcessor = new OnboardingPackageProcessor(filename, fileToUploadBytes); - if (onboardingPackageProcessor.hasErrors()) { - final UploadFileResponseDto uploadFileResponseDto = - buildUploadResponseWithError(onboardingPackageProcessor.getErrorMessages().toArray(new ErrorMessage[0])); - return Response.status(Status.NOT_ACCEPTABLE).entity(uploadFileResponseDto).build(); - } - final OnboardPackageInfo onboardPackageInfo = onboardingPackageProcessor.getOnboardPackageInfo().orElse(null); + private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateCandidateImpl.class); + private final OrchestrationTemplateCandidateManager candidateManager; + private final VendorSoftwareProductManager vendorSoftwareProductManager; + private final ActivityLogManager activityLogManager; - if (onboardPackageInfo == null) { - final UploadFileResponseDto uploadFileResponseDto = buildUploadResponseWithError( - new ErrorMessage(ErrorLevel.ERROR, Messages.PACKAGE_PROCESS_ERROR.formatMessage(filename))); - return Response.ok(uploadFileResponseDto).build(); + public OrchestrationTemplateCandidateImpl() { + this.candidateManager = OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface(); + this.vendorSoftwareProductManager = VspManagerFactory.getInstance().createInterface(); + this.activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); } - final VspDetails vspDetails = new VspDetails(ValidationUtils.sanitizeInputString(vspId), - new Version(ValidationUtils.sanitizeInputString(versionId))); - return processOnboardPackage(onboardPackageInfo, vspDetails); - } + // Constructor used in test to avoid mock static + public OrchestrationTemplateCandidateImpl(OrchestrationTemplateCandidateManager candidateManager, + VendorSoftwareProductManager vendorSoftwareProductManager, ActivityLogManager activityLogManager) { + this.candidateManager = candidateManager; + this.vendorSoftwareProductManager = vendorSoftwareProductManager; + this.activityLogManager = activityLogManager; + } + + @Override + public Response upload(final String vspId, final String versionId, final Attachment fileToUpload, final String user) { + final byte[] fileToUploadBytes = fileToUpload.getObject(byte[].class); + final DataHandler dataHandler = fileToUpload.getDataHandler(); + final String filename = ValidationUtils.sanitizeInputString(dataHandler.getName()); + final OnboardingPackageProcessor onboardingPackageProcessor = new OnboardingPackageProcessor(filename, fileToUploadBytes); + if (onboardingPackageProcessor.hasErrors()) { + final UploadFileResponseDto uploadFileResponseDto = buildUploadResponseWithError( + onboardingPackageProcessor.getErrorMessages().toArray(new ErrorMessage[0])); + return Response.status(Status.NOT_ACCEPTABLE).entity(uploadFileResponseDto).build(); + } + final OnboardPackageInfo onboardPackageInfo = onboardingPackageProcessor.getOnboardPackageInfo().orElse(null); + if (onboardPackageInfo == null) { + final UploadFileResponseDto uploadFileResponseDto = buildUploadResponseWithError( + new ErrorMessage(ErrorLevel.ERROR, Messages.PACKAGE_PROCESS_ERROR.formatMessage(filename))); + return Response.ok(uploadFileResponseDto).build(); + } + final VspDetails vspDetails = new VspDetails(ValidationUtils.sanitizeInputString(vspId), + new Version(ValidationUtils.sanitizeInputString(versionId))); + return processOnboardPackage(onboardPackageInfo, vspDetails); + } private Response processOnboardPackage(final OnboardPackageInfo onboardPackageInfo, final VspDetails vspDetails) { final UploadFileResponse uploadFileResponse = candidateManager.upload(vspDetails, onboardPackageInfo); @@ -132,108 +122,89 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate return Response.ok(uploadFileResponseDto).build(); } - private UploadFileResponseDto buildUploadResponseWithError(final ErrorMessage... errorMessages) { - final UploadFileResponseDto uploadFileResponseDto = new UploadFileResponseDto(); - final Map> errorMap = new HashMap<>(); - final List errorMessageList = new ArrayList<>(); - Collections.addAll(errorMessageList, errorMessages); - errorMap.put(SdcCommon.UPLOAD_FILE, errorMessageList); - uploadFileResponseDto.setErrors(errorMap); - return uploadFileResponseDto; - } - - @Override - public Response get(String vspId, String versionId, String user) throws IOException { - Optional> zipFile = candidateManager.get(vspId, new Version(versionId)); - String fileName; - if (zipFile.isPresent()) { - fileName = "Candidate." + zipFile.get().getLeft(); - } else { - zipFile = vendorSoftwareProductManager.get(vspId, new Version((versionId))); - - if (!zipFile.isPresent()) { - ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR, - getErrorWithParameters( - Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(), - "")); - LOGGER.error(errorMessage.getMessage()); - return Response.status(Response.Status.NOT_FOUND).build(); - } - fileName = "Processed." + zipFile.get().getLeft(); + private UploadFileResponseDto buildUploadResponseWithError(final ErrorMessage... errorMessages) { + final UploadFileResponseDto uploadFileResponseDto = new UploadFileResponseDto(); + final Map> errorMap = new HashMap<>(); + final List errorMessageList = new ArrayList<>(); + Collections.addAll(errorMessageList, errorMessages); + errorMap.put(SdcCommon.UPLOAD_FILE, errorMessageList); + uploadFileResponseDto.setErrors(errorMap); + return uploadFileResponseDto; } - Response.ResponseBuilder response = Response.ok(zipFile.get().getRight()); - response.header("Content-Disposition", "attachment; filename=" + fileName); - return response.build(); - } - - @Override - public Response abort(String vspId, String versionId) { - candidateManager.abort(vspId, new Version(versionId)); - return Response.ok().build(); - } - - @Override - public Response process(String vspId, String versionId, String user) { - - Version version = new Version(versionId); - OrchestrationTemplateActionResponse response = candidateManager.process(vspId, version); - - activityLogManager.logActivity(new ActivityLogEntity(vspId, version, - ActivityType.Upload_Network_Package, user, true, "", "")); - - OrchestrationTemplateActionResponseDto responseDto = copyOrchestrationTemplateActionResponseToDto(response); - return Response.ok(responseDto).build(); - } - - @Override - public Response updateFilesDataStructure( - String vspId, String versionId, FileDataStructureDto fileDataStructureDto, String user) { - - FilesDataStructure fileDataStructure = copyFilesDataStructureDtoToFilesDataStructure(fileDataStructureDto); + @Override + public Response get(String vspId, String versionId, String user) throws IOException { + Optional> zipFile = candidateManager.get(vspId, new Version(versionId)); + String fileName; + if (zipFile.isPresent()) { + fileName = "Candidate." + zipFile.get().getLeft(); + } else { + zipFile = vendorSoftwareProductManager.get(vspId, new Version((versionId))); + if (!zipFile.isPresent()) { + ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR, + getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(), "")); + LOGGER.error(errorMessage.getMessage()); + return Response.status(Response.Status.NOT_FOUND).build(); + } + fileName = "Processed." + zipFile.get().getLeft(); + } + Response.ResponseBuilder response = Response.ok(zipFile.get().getRight()); + response.header("Content-Disposition", "attachment; filename=" + fileName); + return response.build(); + } - ValidationResponse response = candidateManager - .updateFilesDataStructure(vspId, new Version(versionId), fileDataStructure); + @Override + public Response abort(String vspId, String versionId) { + candidateManager.abort(vspId, new Version(versionId)); + return Response.ok().build(); + } - if (!response.isValid()) { - return Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapValidationResponseToDto() - .applyMapping(response, ValidationResponseDto.class)).build(); + @Override + public Response process(String vspId, String versionId, String user) { + Version version = new Version(versionId); + OrchestrationTemplateActionResponse response = candidateManager.process(vspId, version); + activityLogManager.logActivity(new ActivityLogEntity(vspId, version, ActivityType.Upload_Network_Package, user, true, "", "")); + OrchestrationTemplateActionResponseDto responseDto = copyOrchestrationTemplateActionResponseToDto(response); + return Response.ok(responseDto).build(); } - return Response.ok(fileDataStructureDto).build(); - } - - @Override - public Response getFilesDataStructure(String vspId, String versionId, String user) { - Optional filesDataStructure = - candidateManager.getFilesDataStructure(vspId, new Version(versionId)); - if (!filesDataStructure.isPresent()) { - filesDataStructure = vendorSoftwareProductManager.getOrchestrationTemplateStructure(vspId, - new Version(versionId)); + + @Override + public Response updateFilesDataStructure(String vspId, String versionId, FileDataStructureDto fileDataStructureDto, String user) { + FilesDataStructure fileDataStructure = copyFilesDataStructureDtoToFilesDataStructure(fileDataStructureDto); + ValidationResponse response = candidateManager.updateFilesDataStructure(vspId, new Version(versionId), fileDataStructure); + if (!response.isValid()) { + return Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapValidationResponseToDto().applyMapping(response, ValidationResponseDto.class)).build(); + } + return Response.ok(fileDataStructureDto).build(); } - FileDataStructureDto fileDataStructureDto = - filesDataStructure.map(dataStructure -> new MapFilesDataStructureToDto() - .applyMapping(dataStructure, FileDataStructureDto.class)) + @Override + public Response getFilesDataStructure(String vspId, String versionId, String user) { + Optional filesDataStructure = candidateManager.getFilesDataStructure(vspId, new Version(versionId)); + if (!filesDataStructure.isPresent()) { + filesDataStructure = vendorSoftwareProductManager.getOrchestrationTemplateStructure(vspId, new Version(versionId)); + } + FileDataStructureDto fileDataStructureDto = filesDataStructure + .map(dataStructure -> new MapFilesDataStructureToDto().applyMapping(dataStructure, FileDataStructureDto.class)) .orElse(new FileDataStructureDto()); - return Response.ok(fileDataStructureDto).build(); - } - - private OrchestrationTemplateActionResponseDto copyOrchestrationTemplateActionResponseToDto(OrchestrationTemplateActionResponse response){ - OrchestrationTemplateActionResponseDto result = new OrchestrationTemplateActionResponseDto(); - result.setErrors(response.getErrors()); - result.setFileNames(response.getFileNames()); - result.setStatus(response.getStatus()); - return result; - } - - private FilesDataStructure copyFilesDataStructureDtoToFilesDataStructure(FileDataStructureDto fileDataStructureDto){ - FilesDataStructure filesDataStructure = new FilesDataStructure(); - filesDataStructure.setArtifacts(fileDataStructureDto.getArtifacts()); - filesDataStructure.setModules(fileDataStructureDto.getModules()); - filesDataStructure.setNested(fileDataStructureDto.getNested()); - filesDataStructure.setUnassigned(fileDataStructureDto.getUnassigned()); - return filesDataStructure; - } + return Response.ok(fileDataStructureDto).build(); + } + + private OrchestrationTemplateActionResponseDto copyOrchestrationTemplateActionResponseToDto(OrchestrationTemplateActionResponse response) { + OrchestrationTemplateActionResponseDto result = new OrchestrationTemplateActionResponseDto(); + result.setErrors(response.getErrors()); + result.setFileNames(response.getFileNames()); + result.setStatus(response.getStatus()); + return result; + } + private FilesDataStructure copyFilesDataStructureDtoToFilesDataStructure(FileDataStructureDto fileDataStructureDto) { + FilesDataStructure filesDataStructure = new FilesDataStructure(); + filesDataStructure.setArtifacts(fileDataStructureDto.getArtifacts()); + filesDataStructure.setModules(fileDataStructureDto.getModules()); + filesDataStructure.setNested(fileDataStructureDto.getNested()); + filesDataStructure.setUnassigned(fileDataStructureDto.getUnassigned()); + return filesDataStructure; + } } 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/ProcessesImpl.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/ProcessesImpl.java index 3a03b1f73b..2d6efcda88 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/ProcessesImpl.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/ProcessesImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,9 +19,10 @@ * Modifications copyright (c) 2019 Nokia * ================================================================================ */ - package org.openecomp.sdcrests.vsp.rest.services; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; import org.openecomp.sdcrests.vsp.rest.ComponentProcesses; @@ -30,66 +31,60 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; - @Named @Service("processes") @Scope(value = "prototype") public class ProcessesImpl implements Processes { - private final ComponentProcesses componentProcesses; + private final ComponentProcesses componentProcesses; - @Autowired - public ProcessesImpl(ComponentProcesses componentProcesses) { - this.componentProcesses = componentProcesses; - } + @Autowired + public ProcessesImpl(ComponentProcesses componentProcesses) { + this.componentProcesses = componentProcesses; + } - @Override - public Response list(String vspId, String versionId, String user) { - return componentProcesses.list(vspId, versionId, null, user); - } + @Override + public Response list(String vspId, String versionId, String user) { + return componentProcesses.list(vspId, versionId, null, user); + } - @Override - public Response deleteList(String vspId, String versionId, String user) { - return componentProcesses.deleteList(vspId, versionId, null, user); - } + @Override + public Response deleteList(String vspId, String versionId, String user) { + return componentProcesses.deleteList(vspId, versionId, null, user); + } - @Override - public Response create(ProcessRequestDto request, String vspId, String versionId, String user) { - return componentProcesses.create(request, vspId, versionId, null, user); - } + @Override + public Response create(ProcessRequestDto request, String vspId, String versionId, String user) { + return componentProcesses.create(request, vspId, versionId, null, user); + } - @Override - public Response get(String vspId, String versionId, String processId, String user) { - return componentProcesses.get(vspId, versionId, null, processId, user); - } + @Override + public Response get(String vspId, String versionId, String processId, String user) { + return componentProcesses.get(vspId, versionId, null, processId, user); + } - @Override - public Response delete(String vspId, String versionId, String processId, String user) { - return componentProcesses.delete(vspId, versionId, null, processId, user); - } + @Override + public Response delete(String vspId, String versionId, String processId, String user) { + return componentProcesses.delete(vspId, versionId, null, processId, user); + } - @Override - public Response update(ProcessRequestDto request, String vspId, String versionId, - String processId, String user) { - return componentProcesses.update(request, vspId, versionId, null, processId, user); - } + @Override + public Response update(ProcessRequestDto request, String vspId, String versionId, String processId, String user) { + return componentProcesses.update(request, vspId, versionId, null, processId, user); + } - @Override - public Response getUploadedFile(String vspId, String versionId, String processId, String user) { - return componentProcesses.getUploadedFile(vspId, versionId, null, processId, user); - } + @Override + public Response getUploadedFile(String vspId, String versionId, String processId, String user) { + return componentProcesses.getUploadedFile(vspId, versionId, null, processId, user); + } - @Override - public Response deleteUploadedFile(String vspId, String versionId, String processId, - String user) { - return componentProcesses.deleteUploadedFile(vspId, versionId, null, processId, user); - } + @Override + public Response deleteUploadedFile(String vspId, String versionId, String processId, String user) { + return componentProcesses.deleteUploadedFile(vspId, versionId, null, processId, user); + } - @Override - public Response uploadFile(Attachment attachment, String vspId, String versionId, - String processId, String user) { - return componentProcesses.uploadFile(attachment, vspId, versionId, null, processId, user); - } + @Override + public Response uploadFile(Attachment attachment, String vspId, String versionId, String processId, String user) { + return componentProcesses.uploadFile(attachment, vspId, versionId, null, processId, user); + } } 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 91c1959c86..74d2fde097 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 @@ -13,9 +13,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.services; +import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION; +import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; +import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME; +import static org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod.NetworkPackage; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections4.MapUtils; import org.openecomp.core.dao.UniqueValueDaoFactory; import org.openecomp.core.util.UniqueValueUtil; @@ -40,7 +63,12 @@ import org.openecomp.sdc.notification.services.NotificationPropagationManager; import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.*; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.errors.CreatePackageForNonFinalVendorSoftwareProductErrorBuilder; import org.openecomp.sdc.vendorsoftwareproduct.errors.OnboardingMethodErrorBuilder; import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilder; @@ -59,27 +87,28 @@ import org.openecomp.sdc.versioning.types.NotificationEventTypes; import org.openecomp.sdcrests.item.rest.mapping.MapVersionToDto; import org.openecomp.sdcrests.item.types.ItemCreationDto; import org.openecomp.sdcrests.item.types.VersionDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; +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.VendorSoftwareProductAction; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspRequestDto; import org.openecomp.sdcrests.vsp.rest.VendorSoftwareProducts; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToVspComputeDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapItemToVspDetailsDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapPackageInfoToPackageInfoDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapValidationResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDescriptionDtoToItem; +import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDescriptionDtoToVspDetails; +import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDetailsToDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.io.File; -import java.io.IOException; -import java.util.*; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION; -import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; -import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME; -import static org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod.NetworkPackage; -import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.*; - @Named @Service("vendorSoftwareProducts") @Scope(value = "prototype") @@ -89,28 +118,17 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { private static final String VALIDATION_VSP_USER = "validationOnlyVspUser"; private static final String SUBMIT_ITEM_ACTION = "Submit_Item"; private static final String ATTACHMENT_FILENAME = "attachment; filename="; - private static final String SUBMIT_HEALED_VERSION_ERROR = - "VSP Id %s: Error while submitting version %s created based on Certified version %s for healing purpose."; + private static final String SUBMIT_HEALED_VERSION_ERROR = "VSP Id %s: Error while submitting version %s created based on Certified version %s for healing purpose."; private static final Logger LOGGER = LoggerFactory.getLogger(VendorSoftwareProductsImpl.class); private static final Object VALIDATION_VSP_CACHE_LOCK = new Object(); - private static ItemCreationDto cachedValidationVsp; - - private final AsdcItemManager itemManager = AsdcItemManagerFactory.getInstance() - .createInterface(); - private final PermissionsManager permissionsManager = - PermissionsManagerFactory.getInstance().createInterface(); - private final VersioningManager versioningManager = - VersioningManagerFactory.getInstance().createInterface(); - private final VendorSoftwareProductManager vendorSoftwareProductManager = - VspManagerFactory.getInstance().createInterface(); - private final ActivityLogManager activityLogManager = - ActivityLogManagerFactory.getInstance().createInterface(); - private final NotificationPropagationManager notifier = - NotificationPropagationManagerFactory.getInstance().createInterface(); - private final UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory - .getInstance().createInterface()); - + private final AsdcItemManager itemManager = AsdcItemManagerFactory.getInstance().createInterface(); + private final PermissionsManager permissionsManager = PermissionsManagerFactory.getInstance().createInterface(); + private final VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface(); + private final VendorSoftwareProductManager vendorSoftwareProductManager = VspManagerFactory.getInstance().createInterface(); + private final ActivityLogManager activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); + private final NotificationPropagationManager notifier = NotificationPropagationManagerFactory.getInstance().createInterface(); + private final UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface()); @Override public Response createVsp(VspRequestDto vspRequestDto, String user) { @@ -119,74 +137,55 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { } private ItemCreationDto createVspItem(VspRequestDto vspRequestDto, String user) { - OnboardingMethod onboardingMethod = null; - try { onboardingMethod = OnboardingMethod.valueOf(vspRequestDto.getOnboardingMethod()); } catch (IllegalArgumentException e) { LOGGER.error("Error while creating VSP. Message: " + e.getMessage()); throwUnknownOnboardingMethodException(e); } - ItemCreationDto itemCreationDto = null; - if (onboardingMethod == NetworkPackage - || onboardingMethod == OnboardingMethod.Manual) { + if (onboardingMethod == NetworkPackage || onboardingMethod == OnboardingMethod.Manual) { itemCreationDto = createItem(vspRequestDto, user, onboardingMethod); - } else { - throwUnknownOnboardingMethodException( - new IllegalArgumentException("Wrong parameter Onboarding Method")); + throwUnknownOnboardingMethodException(new IllegalArgumentException("Wrong parameter Onboarding Method")); } - return itemCreationDto; } private ItemCreationDto createItem(VspRequestDto vspRequestDto, String user, OnboardingMethod onboardingMethod) { - Item item = new MapVspDescriptionDtoToItem().applyMapping(vspRequestDto, Item.class); item.setType(ItemType.vsp.name()); item.setOwner(user); item.setStatus(ItemStatus.ACTIVE); item.addProperty(VspItemProperty.ONBOARDING_METHOD, onboardingMethod.name()); - uniqueValueUtil.validateUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, item.getName()); item = itemManager.create(item); uniqueValueUtil.createUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, item.getName()); - Version version = versioningManager.create(item.getId(), new Version(), null); - - VspDetails vspDetails = - new MapVspDescriptionDtoToVspDetails().applyMapping(vspRequestDto, VspDetails.class); + VspDetails vspDetails = new MapVspDescriptionDtoToVspDetails().applyMapping(vspRequestDto, VspDetails.class); vspDetails.setId(item.getId()); vspDetails.setVersion(version); vspDetails.setOnboardingMethod(vspRequestDto.getOnboardingMethod()); - vendorSoftwareProductManager.createVsp(vspDetails); versioningManager.publish(item.getId(), version, "Initial vsp:" + vspDetails.getName()); ItemCreationDto itemCreationDto = new ItemCreationDto(); itemCreationDto.setItemId(item.getId()); itemCreationDto.setVersion(new MapVersionToDto().applyMapping(version, VersionDto.class)); - activityLogManager.logActivity(new ActivityLogEntity(vspDetails.getId(), version, - ActivityType.Create, user, true, "", "")); + activityLogManager.logActivity(new ActivityLogEntity(vspDetails.getId(), version, ActivityType.Create, user, true, "", "")); return itemCreationDto; } private void throwUnknownOnboardingMethodException(IllegalArgumentException e) { - ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder - .getInvalidOnboardingMethodErrorBuilder(); + ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder.getInvalidOnboardingMethodErrorBuilder(); throw new CoreException(onboardingMethodUpdateErrorCode, e); } @Override public Response listVsps(String versionStatus, String itemStatus, String user) { - GenericCollectionWrapper results = new GenericCollectionWrapper<>(); MapItemToVspDetailsDto mapper = new MapItemToVspDetailsDto(); - - getVspList(versionStatus, itemStatus, user) - .forEach(vspItem -> results.add(mapper.applyMapping(vspItem, VspDetailsDto.class))); - + getVspList(versionStatus, itemStatus, user).forEach(vspItem -> results.add(mapper.applyMapping(vspItem, VspDetailsDto.class))); return Response.ok(results).build(); } @@ -194,23 +193,18 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { public Response getVsp(String vspId, String versionId, String user) { Version version = versioningManager.get(vspId, new Version(versionId)); VspDetails vspDetails = vendorSoftwareProductManager.getVsp(vspId, version); - try { - HealingManagerFactory.getInstance().createInterface() - .healItemVersion(vspId, version, ItemType.vsp, false) - .ifPresent(healedVersion -> { - vspDetails.setVersion(healedVersion); - if (version.getStatus() == VersionStatus.Certified) { - submitHealedVersion(vspDetails, versionId, user); - } - }); + HealingManagerFactory.getInstance().createInterface().healItemVersion(vspId, version, ItemType.vsp, false).ifPresent(healedVersion -> { + vspDetails.setVersion(healedVersion); + if (version.getStatus() == VersionStatus.Certified) { + submitHealedVersion(vspDetails, versionId, user); + } + }); } catch (Exception e) { LOGGER.error(String.format("Error while auto healing VSP with Id %s and version %s", vspId, versionId), e); } - VspDetailsDto vspDetailsDto = new MapVspDetailsToDto().applyMapping(vspDetails, VspDetailsDto.class); addNetworkPackageInfo(vspId, vspDetails.getVersion(), vspDetailsDto); - return Response.ok(vspDetailsDto).build(); } @@ -220,88 +214,63 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { // sync vlm if not exists on user space versioningManager.get(vspDetails.getVendorId(), vspDetails.getVlmVersion()); } - - submit(vspDetails.getId(), vspDetails.getVersion(), "Submit healed Vsp", user) - .ifPresent(validationResponse -> { - throw new IllegalStateException("Certified vsp after healing failed on validation"); - }); + submit(vspDetails.getId(), vspDetails.getVersion(), "Submit healed Vsp", user).ifPresent(validationResponse -> { + throw new IllegalStateException("Certified vsp after healing failed on validation"); + }); vendorSoftwareProductManager.createPackage(vspDetails.getId(), vspDetails.getVersion()); } catch (Exception ex) { - LOGGER.error(String.format(SUBMIT_HEALED_VERSION_ERROR, vspDetails.getId(), vspDetails.getVersion().getId(), - baseVersionId), ex); + LOGGER.error(String.format(SUBMIT_HEALED_VERSION_ERROR, vspDetails.getId(), vspDetails.getVersion().getId(), baseVersionId), ex); } } @Override - public Response updateVsp(String vspId, String versionId, VspDescriptionDto vspDescriptionDto, - String user) { - VspDetails vspDetails = - new MapVspDescriptionDtoToVspDetails().applyMapping(vspDescriptionDto, VspDetails.class); + public Response updateVsp(String vspId, String versionId, VspDescriptionDto vspDescriptionDto, String user) { + VspDetails vspDetails = new MapVspDescriptionDtoToVspDetails().applyMapping(vspDescriptionDto, VspDetails.class); vspDetails.setId(vspId); vspDetails.setVersion(new Version(versionId)); - vendorSoftwareProductManager.updateVsp(vspDetails); - - updateVspItem(vspId,vspDescriptionDto); - + updateVspItem(vspId, vspDescriptionDto); return Response.ok().build(); } @Override public Response deleteVsp(String vspId, String user) { Item vsp = itemManager.get(vspId); - if (!vsp.getType().equals(ItemType.vsp.name())) { - throw new CoreException((new ErrorCode.ErrorCodeBuilder() - .withMessage(String.format("Vsp with id %s does not exist.", - vspId)).build())); + throw new CoreException((new ErrorCode.ErrorCodeBuilder().withMessage(String.format("Vsp with id %s does not exist.", vspId)).build())); } - Integer certifiedVersionsCounter = vsp.getVersionStatusCounters().get(VersionStatus.Certified); if (Objects.isNull(certifiedVersionsCounter) || certifiedVersionsCounter == 0) { - versioningManager.list(vspId) - .forEach(version -> vendorSoftwareProductManager.deleteVsp(vspId, version)); + versioningManager.list(vspId).forEach(version -> vendorSoftwareProductManager.deleteVsp(vspId, version)); itemManager.delete(vsp); permissionsManager.deleteItemPermissions(vspId); uniqueValueUtil.deleteUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, vsp.getName()); - notifyUsers(vspId, vsp.getName(), null, null, user, - NotificationEventTypes.DELETE); - + notifyUsers(vspId, vsp.getName(), null, null, user, NotificationEventTypes.DELETE); return Response.ok().build(); } else { - return Response.status(Response.Status.FORBIDDEN) - .entity(new Exception(Messages.DELETE_VSP_ERROR.getErrorMessage())).build(); + return Response.status(Response.Status.FORBIDDEN).entity(new Exception(Messages.DELETE_VSP_ERROR.getErrorMessage())).build(); } } @Override - public Response actOnVendorSoftwareProduct(VersionSoftwareProductActionRequestDto request, - String vspId, String versionId, - String user) throws IOException { + public Response actOnVendorSoftwareProduct(VersionSoftwareProductActionRequestDto request, String vspId, String versionId, String user) + throws IOException { Version version = new Version(versionId); - if (request.getAction() == VendorSoftwareProductAction.Submit) { if (!permissionsManager.isAllowed(vspId, user, SUBMIT_ITEM_ACTION)) { - return Response.status(Response.Status.FORBIDDEN) - .entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build(); + return Response.status(Response.Status.FORBIDDEN).entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build(); } - String message = request.getSubmitRequest() == null ? "Submit" - : request.getSubmitRequest().getMessage(); + String message = request.getSubmitRequest() == null ? "Submit" : request.getSubmitRequest().getMessage(); Optional validationResponse = submit(vspId, version, message, user); - if (validationResponse.isPresent()) { ValidationResponseDto validationResponseDto = new MapValidationResponseToDto() - .applyMapping(validationResponse.get(), ValidationResponseDto.class); - return Response.status(Response.Status.EXPECTATION_FAILED).entity(validationResponseDto) - .build(); + .applyMapping(validationResponse.get(), ValidationResponseDto.class); + return Response.status(Response.Status.EXPECTATION_FAILED).entity(validationResponseDto).build(); } - notifyUsers(vspId, null, version, message, user, NotificationEventTypes.SUBMIT); - } else if (request.getAction() == VendorSoftwareProductAction.Create_Package) { return createPackage(vspId, version); } - return Response.ok().build(); } @@ -312,35 +281,24 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { } private ItemCreationDto retrieveValidationVsp() { - synchronized (VALIDATION_VSP_CACHE_LOCK) { - if (cachedValidationVsp != null) { return cachedValidationVsp; } - VspRequestDto validationVspRequest = new VspRequestDto(); validationVspRequest.setOnboardingMethod(NetworkPackage.toString()); validationVspRequest.setName(VALIDATION_VSP_NAME); - try { - cachedValidationVsp = createVspItem(validationVspRequest, VALIDATION_VSP_USER); return cachedValidationVsp; - } catch (CoreException vspCreateException) { LOGGER.debug("Failed to create validation VSP", vspCreateException); - Predicate validationVspFilter = item -> ItemType.vsp.name().equals(item.getType()) - && VALIDATION_VSP_NAME.equals(item.getName()); - String validationVspId = itemManager.list(validationVspFilter).stream().findFirst() - .orElseThrow(() -> new IllegalStateException( - "Vsp with name " + VALIDATION_VSP_NAME + - " does not exist even though the name exists according to " + - "unique value util")) - .getId(); - + Predicate validationVspFilter = item -> ItemType.vsp.name().equals(item.getType()) && VALIDATION_VSP_NAME + .equals(item.getName()); + String validationVspId = itemManager.list(validationVspFilter).stream().findFirst().orElseThrow(() -> new IllegalStateException( + "Vsp with name " + VALIDATION_VSP_NAME + " does not exist even though the name exists according to " + "unique value util")) + .getId(); Version validationVspVersion = versioningManager.list(validationVspId).iterator().next(); - cachedValidationVsp = new ItemCreationDto(); cachedValidationVsp.setItemId(validationVspId); cachedValidationVsp.setVersion(new MapVersionToDto().applyMapping(validationVspVersion, VersionDto.class)); @@ -351,9 +309,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { @Override public Response getOrchestrationTemplate(String vspId, String versionId, String user) { - byte[] orchestrationTemplateFile = - vendorSoftwareProductManager.getOrchestrationTemplateFile(vspId, new Version(versionId)); - + byte[] orchestrationTemplateFile = vendorSoftwareProductManager.getOrchestrationTemplateFile(vspId, new Version(versionId)); if (orchestrationTemplateFile == null || orchestrationTemplateFile.length == 0) { return Response.status(Response.Status.NOT_FOUND).build(); } @@ -364,21 +320,12 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { @Override public Response listPackages(String status, String category, String subCategory, String user) { - - List vspsIds = - getVspList(null, status != null ? ItemStatus.valueOf(status).name() : null, user) - .stream().map(Item::getId).collect(Collectors.toList()); - - List packageInfoList = - vendorSoftwareProductManager.listPackages(category, subCategory); - - packageInfoList = packageInfoList.stream(). - filter(packageInfo -> vspsIds.contains(packageInfo.getVspId())) - .collect(Collectors.toList()); - + List vspsIds = getVspList(null, status != null ? ItemStatus.valueOf(status).name() : null, user).stream().map(Item::getId) + .collect(Collectors.toList()); + List packageInfoList = vendorSoftwareProductManager.listPackages(category, subCategory); + packageInfoList = packageInfoList.stream().filter(packageInfo -> vspsIds.contains(packageInfo.getVspId())).collect(Collectors.toList()); GenericCollectionWrapper results = new GenericCollectionWrapper<>(); MapPackageInfoToPackageInfoDto mapper = new MapPackageInfoToPackageInfoDto(); - if (packageInfoList != null) { for (PackageInfo packageInfo : packageInfoList) { results.add(mapper.applyMapping(packageInfo, PackageInfoDto.class)); @@ -393,90 +340,71 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { Version version; if (versionName == null) { version = versions.stream().filter(ver -> VersionStatus.Certified == ver.getStatus()) - .max(Comparator.comparingDouble(o -> Double.parseDouble(o.getName()))) - .orElseThrow(() -> new CoreException(new PackageNotFoundErrorBuilder(vspId).build())); + .max(Comparator.comparingDouble(o -> Double.parseDouble(o.getName()))) + .orElseThrow(() -> new CoreException(new PackageNotFoundErrorBuilder(vspId).build())); } else { - version = versions.stream().filter(ver -> versionName.equals(ver.getName())) - .findFirst() - .orElseThrow(() -> new CoreException(new PackageNotFoundErrorBuilder(vspId).build())); - + version = versions.stream().filter(ver -> versionName.equals(ver.getName())).findFirst() + .orElseThrow(() -> new CoreException(new PackageNotFoundErrorBuilder(vspId).build())); if (version.getStatus() != VersionStatus.Certified) { throw new CoreException(new RequestedVersionInvalidErrorBuilder().build()); } } - File zipFile = vendorSoftwareProductManager.getTranslatedFile(vspId, version); - Response.ResponseBuilder response = Response.ok(zipFile); if (zipFile == null) { return Response.status(Response.Status.NOT_FOUND).build(); } response.header(CONTENT_DISPOSITION, ATTACHMENT_FILENAME + zipFile.getName()); - return response.build(); } @Override public Response getQuestionnaire(String vspId, String versionId, String user) { - QuestionnaireResponse questionnaireResponse = - vendorSoftwareProductManager.getVspQuestionnaire(vspId, new Version(versionId)); - + QuestionnaireResponse questionnaireResponse = vendorSoftwareProductManager.getVspQuestionnaire(vspId, new Version(versionId)); if (questionnaireResponse.getErrorMessage() != null) { - return Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapQuestionnaireResponseToQuestionnaireResponseDto() - .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class)).build(); + return Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapQuestionnaireResponseToQuestionnaireResponseDto().applyMapping(questionnaireResponse, QuestionnaireResponseDto.class)) + .build(); } - QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() - .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); return Response.ok(result).build(); } @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String - versionId, String user) { - vendorSoftwareProductManager - .updateVspQuestionnaire(vspId, new Version(versionId), questionnaireData); + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String user) { + vendorSoftwareProductManager.updateVspQuestionnaire(vspId, new Version(versionId), questionnaireData); return Response.ok().build(); } @Override public Response heal(String vspId, String versionId, String user) { - HealingManagerFactory.getInstance().createInterface() - .healItemVersion(vspId, new Version(versionId), ItemType.vsp, true); + HealingManagerFactory.getInstance().createInterface().healItemVersion(vspId, new Version(versionId), ItemType.vsp, true); return Response.ok().build(); } @Override public Response getVspInformationArtifact(String vspId, String versionId, String user) { - File textInformationArtifact = - vendorSoftwareProductManager.getInformationArtifact(vspId, new Version(versionId)); - + File textInformationArtifact = vendorSoftwareProductManager.getInformationArtifact(vspId, new Version(versionId)); Response.ResponseBuilder response = Response.ok(textInformationArtifact); if (textInformationArtifact == null) { return Response.status(Response.Status.NOT_FOUND).build(); } - response - .header(CONTENT_DISPOSITION, ATTACHMENT_FILENAME + textInformationArtifact.getName()); + response.header(CONTENT_DISPOSITION, ATTACHMENT_FILENAME + textInformationArtifact.getName()); return response.build(); } @Override public Response listComputes(String vspId, String version, String user) { - - Collection computes = - vendorSoftwareProductManager.getComputeByVsp(vspId, new Version(version)); - + Collection computes = vendorSoftwareProductManager.getComputeByVsp(vspId, new Version(version)); MapComputeEntityToVspComputeDto mapper = new MapComputeEntityToVspComputeDto(); GenericCollectionWrapper results = new GenericCollectionWrapper<>(); for (ComputeEntity compute : computes) { results.add(mapper.applyMapping(compute, VspComputeDto.class)); } - return Response.ok(results).build(); } - private void updateVspItem(String vspId, VspDescriptionDto vspDescriptionDto) { Item retrievedItem = itemManager.get(vspId); Item item = new MapVspDescriptionDtoToItem().applyMapping(vspDescriptionDto, Item.class); @@ -487,52 +415,37 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { item.setVersionStatusCounters(retrievedItem.getVersionStatusCounters()); item.setCreationTime(retrievedItem.getCreationTime()); item.setModificationTime(new Date()); - item.addProperty(VspItemProperty.ONBOARDING_METHOD, - retrievedItem.getProperties().get(VspItemProperty.ONBOARDING_METHOD)); - + item.addProperty(VspItemProperty.ONBOARDING_METHOD, retrievedItem.getProperties().get(VspItemProperty.ONBOARDING_METHOD)); itemManager.update(item); } - private Optional submit(String vspId, Version version, String message, - String user) throws IOException { - + private Optional submit(String vspId, Version version, String message, String user) throws IOException { VspDetails vspDetails = vendorSoftwareProductManager.getVsp(vspId, version); if (vspDetails.getVlmVersion() != null) { vspDetails.setVlmVersion(versioningManager.get(vspDetails.getVendorId(), vspDetails.getVlmVersion())); } ValidationResponse validationResponse = vendorSoftwareProductManager.validate(vspDetails); - Map> compilationErrors = - vendorSoftwareProductManager.compile(vspId, version); + Map> compilationErrors = vendorSoftwareProductManager.compile(vspId, version); if (!validationResponse.isValid() || MapUtils.isNotEmpty(compilationErrors)) { - activityLogManager.logActivity( - new ActivityLogEntity(vspId, version, ActivityType.Submit, user, false, - "Failed on validation before submit", "")); + activityLogManager + .logActivity(new ActivityLogEntity(vspId, version, ActivityType.Submit, user, false, "Failed on validation before submit", "")); return Optional.of(validationResponse); } - versioningManager.submit(vspId, version, message); - activityLogManager.logActivity( - new ActivityLogEntity(vspId, version, ActivityType.Submit, user, true, "", message)); + activityLogManager.logActivity(new ActivityLogEntity(vspId, version, ActivityType.Submit, user, true, "", message)); return Optional.empty(); } - private void notifyUsers(String itemId, String itemName, Version version, String message, - String userName, NotificationEventTypes eventType) { + private void notifyUsers(String itemId, String itemName, Version version, String message, String userName, NotificationEventTypes eventType) { Map eventProperties = new HashMap<>(); - eventProperties - .put(ITEM_NAME, itemName == null ? itemManager.get(itemId).getName() : itemName); + eventProperties.put(ITEM_NAME, itemName == null ? itemManager.get(itemId).getName() : itemName); eventProperties.put(ITEM_ID, itemId); - if (version != null) { - eventProperties.put(VERSION_NAME, version.getName() == null - ? versioningManager.get(itemId, version).getName() - : version.getName()); + eventProperties.put(VERSION_NAME, version.getName() == null ? versioningManager.get(itemId, version).getName() : version.getName()); eventProperties.put(VERSION_ID, version.getId()); } - eventProperties.put(SUBMIT_DESCRIPTION, message); eventProperties.put(PERMISSION_USER, userName); - Event syncEvent = new SyncEvent(eventType.getEventName(), itemId, eventProperties, itemId); try { notifier.notifySubscribers(syncEvent, userName); @@ -544,91 +457,68 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { private Response createPackage(String vspId, Version version) throws IOException { Version retrievedVersion = versioningManager.get(vspId, version); if (retrievedVersion.getStatus() != VersionStatus.Certified) { - throw new CoreException( - new CreatePackageForNonFinalVendorSoftwareProductErrorBuilder(vspId, version) - .build()); + throw new CoreException(new CreatePackageForNonFinalVendorSoftwareProductErrorBuilder(vspId, version).build()); } - PackageInfo packageInfo = - vendorSoftwareProductManager.createPackage(vspId, retrievedVersion); - return Response.ok(packageInfo == null - ? null - : new MapPackageInfoToPackageInfoDto().applyMapping(packageInfo, PackageInfoDto.class)) - .build(); + PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(vspId, retrievedVersion); + return Response.ok(packageInfo == null ? null : new MapPackageInfoToPackageInfoDto().applyMapping(packageInfo, PackageInfoDto.class)).build(); } - private void addNetworkPackageInfo(String vspId, Version version, VspDetailsDto vspDetailsDto) { - Optional candidateInfo = - OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface() + private void addNetworkPackageInfo(String vspId, Version version, VspDetailsDto vspDetailsDto) { + Optional candidateInfo = OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface() .getInfo(vspId, version); - if (candidateInfo.isPresent()) { - if (candidateInfo.get().getValidationDataStructure() != null) { - vspDetailsDto.setValidationData(candidateInfo.get().getValidationDataStructure()); - } - vspDetailsDto.setNetworkPackageName(candidateInfo.get().getFileName()); - vspDetailsDto.setCandidateOnboardingOrigin(candidateInfo.get().getFileSuffix()); - } else { - OrchestrationTemplateEntity orchestrationTemplateInfo = - vendorSoftwareProductManager.getOrchestrationTemplateInfo(vspId, version); - if (Objects.nonNull(orchestrationTemplateInfo) && Objects.nonNull(orchestrationTemplateInfo - .getFileSuffix())) { - if (orchestrationTemplateInfo.getValidationDataStructure() != null) { - vspDetailsDto.setValidationData(orchestrationTemplateInfo.getValidationDataStructure()); + if (candidateInfo.isPresent()) { + if (candidateInfo.get().getValidationDataStructure() != null) { + vspDetailsDto.setValidationData(candidateInfo.get().getValidationDataStructure()); + } + vspDetailsDto.setNetworkPackageName(candidateInfo.get().getFileName()); + vspDetailsDto.setCandidateOnboardingOrigin(candidateInfo.get().getFileSuffix()); + } else { + OrchestrationTemplateEntity orchestrationTemplateInfo = vendorSoftwareProductManager.getOrchestrationTemplateInfo(vspId, version); + if (Objects.nonNull(orchestrationTemplateInfo) && Objects.nonNull(orchestrationTemplateInfo.getFileSuffix())) { + if (orchestrationTemplateInfo.getValidationDataStructure() != null) { + vspDetailsDto.setValidationData(orchestrationTemplateInfo.getValidationDataStructure()); + } + vspDetailsDto.setNetworkPackageName(orchestrationTemplateInfo.getFileName()); + vspDetailsDto.setOnboardingOrigin(orchestrationTemplateInfo.getFileSuffix()); + } } - vspDetailsDto.setNetworkPackageName(orchestrationTemplateInfo.getFileName()); - vspDetailsDto.setOnboardingOrigin(orchestrationTemplateInfo.getFileSuffix()); - } } - } - - private boolean userHasPermission(String itemId, String userId) { - return permissionsManager.getUserItemPermission(itemId, userId) - .map(permission -> permission - .matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name())) - .orElse(false); - } - - private Predicate createItemPredicate(String versionStatus, - String itemStatus, - String user) { - Predicate itemPredicate = item -> ItemType.vsp.name().equals(item.getType()); + private boolean userHasPermission(String itemId, String userId) { + return permissionsManager.getUserItemPermission(itemId, userId) + .map(permission -> permission.matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name())).orElse(false); + } + + private Predicate createItemPredicate(String versionStatus, String itemStatus, String user) { + Predicate itemPredicate = item -> ItemType.vsp.name().equals(item.getType()); if (ItemStatus.ARCHIVED.name().equals(itemStatus)) { itemPredicate = itemPredicate.and(item -> ItemStatus.ARCHIVED.equals(item.getStatus())); } else { itemPredicate = itemPredicate.and(item -> ItemStatus.ACTIVE.equals(item.getStatus())); - if (VersionStatus.Certified.name().equals(versionStatus)) { - itemPredicate = itemPredicate - .and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Certified)); - + itemPredicate = itemPredicate.and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Certified)); } else if (VersionStatus.Draft.name().equals(versionStatus)) { - itemPredicate = itemPredicate.and( - item -> item.getVersionStatusCounters().containsKey(VersionStatus.Draft) - && userHasPermission(item.getId(), user)); + itemPredicate = itemPredicate + .and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Draft) && userHasPermission(item.getId(), user)); } } return itemPredicate; } private List getVspList(String versionStatus, String itemStatus, String user) { - Predicate itemPredicate = createItemPredicate(versionStatus, itemStatus, user); - - return itemManager.list(itemPredicate).stream() - .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())). - collect(Collectors.toList()); + return itemManager.list(itemPredicate).stream().sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())) + .collect(Collectors.toList()); } private class SyncEvent implements Event { private final String eventType; - private final String originatorId; private final Map attributes; private final String entityId; - SyncEvent(String eventType, String originatorId, - Map attributes, String entityId) { + SyncEvent(String eventType, String originatorId, Map attributes, String entityId) { this.eventType = eventType; this.originatorId = originatorId; this.attributes = attributes; 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/VspItemProperty.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/VspItemProperty.java index c958ea7c79..87ac7d8fd2 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/VspItemProperty.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/VspItemProperty.java @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.services; public final class VspItemProperty { - public static final String VENDOR_ID = "vendorId"; - public static final String VENDOR_NAME = "vendorName"; - public static final String ONBOARDING_METHOD = "onboardingMethod"; - private VspItemProperty() { + public static final String VENDOR_ID = "vendorId"; + public static final String VENDOR_NAME = "vendorName"; + public static final String ONBOARDING_METHOD = "onboardingMethod"; - } + private VspItemProperty() { + } } 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/VspUniqueTypeProvider.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/VspUniqueTypeProvider.java index cb7c136969..b06f4cc383 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/VspUniqueTypeProvider.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/VspUniqueTypeProvider.java @@ -15,20 +15,18 @@ */ package org.openecomp.sdcrests.vsp.rest.services; -import org.openecomp.sdcrests.uniquevalue.types.UniqueTypesProvider; +import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME; import java.util.Collections; import java.util.Map; - -import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME; +import org.openecomp.sdcrests.uniquevalue.types.UniqueTypesProvider; public class VspUniqueTypeProvider implements UniqueTypesProvider { - private static final Map uniqueTypes = - Collections.singletonMap("VspName", VENDOR_SOFTWARE_PRODUCT_NAME); + private static final Map uniqueTypes = Collections.singletonMap("VspName", VENDOR_SOFTWARE_PRODUCT_NAME); - @Override - public Map listUniqueTypes() { - return uniqueTypes; - } + @Override + public Map listUniqueTypes() { + return uniqueTypes; + } } -- cgit 1.2.3-korg