diff options
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp')
36 files changed, 1344 insertions, 463 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencyModels.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/ComponentDependencyModels.java new file mode 100644 index 0000000000..5df05d1cf1 --- /dev/null +++ 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/ComponentDependencyModels.java @@ -0,0 +1,55 @@ +package org.openecomp.sdcrests.vsp.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModelRequestDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +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 static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; + +import java.util.List; + +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/component-dependency-model") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Product Component Dependency Model") +@Validated +public interface ComponentDependencyModels extends VspEntities { + + @POST + @Path("/") + @ApiOperation(value = "Create a vendor software product component dependency model") + Response create(@Valid ComponentDependencyModelRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @GET + @Path("/") + @ApiOperation(value = "Get component dependency Model for vendor software product", + response = ComponentDependencyModelRequestDto.class, + responseContainer = "List") + Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @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/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 3fae16cf7f..ca50ef1426 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 @@ -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. @@ -20,7 +20,7 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; import io.swagger.annotations.Api; @@ -49,24 +49,22 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@Path("/v1.0/vendor-software-products/{vspId}/components/{componentId}/processes") +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/processes") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor Software Product Component Processes") @Validated -public interface ComponentProcesses { +public interface ComponentProcesses extends VspEntities { @GET @Path("/") @ApiOperation(value = "List vendor software product component processes", response = ProcessEntityDto.class, responseContainer = "List") Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @@ -75,18 +73,20 @@ public interface ComponentProcesses { responseContainer = "List") Response deleteList( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/") @ApiOperation(value = "Create a vendor software product process") Response create(@Valid ProcessRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -94,25 +94,24 @@ public interface ComponentProcesses { @ApiOperation(value = "Get vendor software product process", response = ProcessEntityDto.class) Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{processId}") @ApiOperation(value = "Delete vendor software product process") Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @@ -120,11 +119,12 @@ public interface ComponentProcesses { @ApiOperation(value = "Update vendor software product process") Response update(@Valid ProcessRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -133,36 +133,36 @@ public interface ComponentProcesses { @ApiOperation(value = "Get vendor software product process uploaded file") Response getUploadedFile( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{processId}/upload") @ApiOperation(value = "Delete vendor software product process uploaded file") Response deleteUploadedFile( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/{processId}/upload") @Consumes(MediaType.MULTIPART_FORM_DATA) @ApiOperation(value = "Update vendor software product process upload") Response uploadFile(@Multipart("upload") Attachment attachment, - @ApiParam(value = "Vendor software product Id") @PathParam("vspId") - String vspId, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @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/ComponentUploads.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/ComponentUploads.java index c7ad2f7fe5..313ae24e95 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/ComponentUploads.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/ComponentUploads.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. @@ -20,7 +20,7 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; import io.swagger.annotations.Api; @@ -43,62 +43,66 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -@Path("/v1.0/vendor-software-products/{vspId}/components/{componentId}/monitors") +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/monitors") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor Software Product Component MIB Uploads") @Validated -public interface ComponentUploads { +public interface ComponentUploads extends VspEntities { @POST @Path("/snmp-trap/upload") @Consumes(MediaType.MULTIPART_FORM_DATA) - @ApiOperation(value = "Upload vendor software product MIB Trap Definitions file") + @ApiOperation(value = "Upload vendor software product MIB SNMP_TRAP Definitions file") Response uploadTrapMibFile(@Multipart("upload") Attachment attachment, - @ApiParam(value = "Vendor software product Id") @PathParam("vspId") - String vspId, - @ApiParam(value = "Vendor software product component Id") - @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Component Id") @PathParam("componentId") String + componentId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/snmp-trap") - @ApiOperation(value = "Delete vendor software product MIB Trap Definitions file") + @ApiOperation(value = "Delete vendor software product MIB SNMP_TRAP Definitions file") Response deleteTrapMibFile( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/snmp/upload") @Consumes(MediaType.MULTIPART_FORM_DATA) - @ApiOperation(value = "Upload vendor software product MIB Poll Definitions file") + @ApiOperation(value = "Upload vendor software product MIB SNMP_POLL Definitions file") Response uploadPollMibFile(@Multipart("upload") Attachment attachment, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/snmp") - @ApiOperation(value = "Delete vendor software product MIB Poll Definitions file") + @ApiOperation(value = "Delete vendor software product MIB SNMP_POLL Definitions file") Response deletePollMibFile( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + // TODO: 2/27/2017 add version @GET @Path("/snmp/") @ApiOperation(value = "Get the filenames of uploaded MIB definitions", response = MibUploadStatusDto.class) Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @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 949a40cfbb..cff69d2c01 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 @@ -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. @@ -20,14 +20,10 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; -import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; @@ -36,7 +32,6 @@ import org.springframework.validation.annotation.Validated; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -46,26 +41,26 @@ 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; -@Path("/v1.0/vendor-software-products/{vspId}/components") +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) @Api(value = "Vendor Software Product Components") @Validated -public interface Components { +public interface Components extends VspEntities { @GET @Path("/") @ApiOperation(value = "List vendor software product components", response = ComponentDto.class, responseContainer = "List") Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @@ -74,14 +69,16 @@ public interface Components { responseContainer = "List") Response deleteList( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/") @ApiOperation(value = "Create a vendor software product component") Response create(@Valid ComponentRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -90,21 +87,20 @@ public interface Components { response = ComponentData.class, responseContainer = "CompositionEntityResponse") Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "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}") @ApiOperation(value = "Delete vendor software product component") Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @@ -112,9 +108,10 @@ public interface Components { @ApiOperation(value = "Update vendor software product component") Response update(@Valid ComponentRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -123,11 +120,10 @@ public interface Components { response = QuestionnaireResponseDto.class) Response getQuestionnaire( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "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") @@ -135,8 +131,10 @@ public interface Components { Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") + String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @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 5c7c9d7bd8..fae6510bc2 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 @@ -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. @@ -20,20 +20,15 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.openecomp.sdc.versioning.dao.types.Version; 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.validation.constraints.Pattern; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -43,26 +38,26 @@ 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; -@Path("/v1.0/vendor-software-products/{vspId}/networks") +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}/networks") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor Software Product Networks") @Validated -public interface Networks { +public interface Networks extends VspEntities { @GET @Path("/") @ApiOperation(value = "List vendor software product networks", response = NetworkDto.class, responseContainer = "List") Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @@ -70,7 +65,8 @@ public interface Networks { @ApiOperation(value = "Create a vendor software product network") Response create(@Valid NetworkRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -78,21 +74,20 @@ public interface Networks { @ApiOperation(value = "Get vendor software product network", response = NetworkDto.class) Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @ApiParam(value = "Vendor software product network Id") @PathParam("networkId") - String networkId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "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}") @ApiOperation(value = "Delete vendor software product network") Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product network Id") @PathParam("networkId") String networkId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @@ -100,8 +95,9 @@ public interface Networks { @ApiOperation(value = "Update vendor software product network") Response update(@Valid NetworkRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product network Id") @PathParam("networkId") String networkId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @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 8cf26a405b..c29966b54b 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 @@ -20,7 +20,7 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; import io.swagger.annotations.Api; @@ -49,24 +49,22 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@Path("/v1.0/vendor-software-products/{vspId}/components/{componentId}/nics") +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/nics") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor Software Product Component NICs") @Validated -public interface Nics { +public interface Nics extends VspEntities { @GET @Path("/") @ApiOperation(value = "List vendor software product component NICs", response = NicDto.class, responseContainer = "List") Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @@ -74,9 +72,10 @@ public interface Nics { @ApiOperation(value = "Create a vendor software product NIC") Response create(@Valid NicRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -84,24 +83,23 @@ public interface Nics { @ApiOperation(value = "Get vendor software product NIC", response = NicDto.class) Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") String nicId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{nicId}") @ApiOperation(value = "Delete vendor software product NIC") Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @@ -109,11 +107,12 @@ public interface Nics { @ApiOperation(value = "Update vendor software product NIC") Response update(@Valid NicRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -122,12 +121,11 @@ public interface Nics { response = QuestionnaireResponseDto.class) Response getQuestionnaire( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") String nicId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @Path("/{nicId}/questionnaire") @@ -135,10 +133,11 @@ public interface Nics { Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") String nicId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @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 new file mode 100644 index 0000000000..fbf29185e3 --- /dev/null +++ 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 @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.openecomp.sdc.vendorsoftwareproduct.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.Consumes; +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 java.io.File; +import java.io.IOException; +import java.io.InputStream; +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) +@Api(value = "Orchestration Template Candidate") +@Validated +public interface OrchestrationTemplateCandidate extends VspEntities { + + @POST + @Path("/") + @Consumes(MediaType.MULTIPART_FORM_DATA) + Response upload( + @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @Multipart("upload") InputStream heatFileToUpload, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @ApiOperation(value = "Get uploaded candidate HEAT file", + notes = "Downloads in process candidate HEAT file", + response = File.class) + Response get( + @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws IOException; + + @PUT + @Path("/process") + @ApiOperation(value = "process Orchestration Template Candidate", + response = UploadFileResponseDto.class) + Response process( + @PathParam("vspId") String vspId, + @ApiParam(value = "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") + @ApiOperation(value = "Update an existing vendor software product") + Response updateFilesDataStructure( + @PathParam("vspId") String vspId, + @ApiParam(value = "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") + @ApiOperation(value = "Get uploaded HEAT file files data structure", + notes = "Downloads the latest HEAT package", + response = FileDataStructureDto.class) + Response getFilesDataStructure( + @PathParam("vspId") String vspId, + @ApiParam(value = "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 b5c74587e4..93dcbc4e32 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 @@ -20,9 +20,6 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -31,26 +28,19 @@ import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; - import org.springframework.validation.annotation.Validated; import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@Path("/v1.0/vendor-software-products/{vspId}/processes") +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) @Api(value = "Vendor Software Product Processes") @@ -62,10 +52,8 @@ public interface Processes { response = ProcessEntityDto.class, responseContainer = "List") Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @@ -74,14 +62,16 @@ public interface Processes { responseContainer = "List") Response deleteList( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/") @ApiOperation(value = "Create a vendor software product process") Response create(@Valid ProcessRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -89,21 +79,20 @@ public interface Processes { @ApiOperation(value = "Get vendor software product process", response = ProcessEntityDto.class) Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{processId}") @ApiOperation(value = "Delete vendor software product process") Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @@ -111,9 +100,10 @@ public interface Processes { @ApiOperation(value = "Update vendor software product process") Response update(@Valid ProcessRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -122,30 +112,30 @@ public interface Processes { @ApiOperation(value = "Get vendor software product process uploaded file") Response getUploadedFile( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{processId}/upload") @ApiOperation(value = "Delete vendor software product process uploaded file") Response deleteUploadedFile( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/{processId}/upload") @Consumes(MediaType.MULTIPART_FORM_DATA) @ApiOperation(value = "Update vendor software product process upload") Response uploadFile(@Multipart("upload") Attachment attachment, - @ApiParam(value = "Vendor software product Id") @PathParam("vspId") - String vspId, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @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 259ef723c6..53fe2af31d 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 @@ -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. @@ -20,127 +20,105 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; - -import org.apache.cxf.jaxrs.ext.multipart.Multipart; -import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; +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 java.io.InputStream; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.io.File; +import java.io.IOException; +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") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor Software Products") @Validated -public interface VendorSoftwareProducts { +public interface VendorSoftwareProducts extends VspEntities { @POST @Path("/") @ApiOperation(value = "Create a new vendor software product", response = VspCreationDto.class) - Response createNewVsp(@Valid VspDescriptionDto vspDescriptionDto, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) - String user); + Response createVsp(@Valid VspDescriptionDto vspDescriptionDto, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @Path("/") @ApiOperation(value = "Get list of vendor software products and their description", responseContainer = "List") - Response getVspList(@ApiParam( + Response listVsps(@ApiParam( value = "Currently supported values: 'Final' - only vendor software products with final " - + "version will be return - with their latest final version") - @QueryParam("versionFilter") String versionFilter, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) - String user); + + " version will be return - with their latest final version") + @QueryParam("versionFilter") String versionFilter, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/packages") - @ApiOperation(value = "Get list of translated CSAR files details", - response = PackageInfoDto.class, - responseContainer = "List") - Response listPackages(@ApiParam("Category") @QueryParam("category") String category, - @ApiParam("Sub-category") @QueryParam("subCategory") String subCategory, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) - String user); @GET - @Path("/{vspId}") + @Path("/{vspId}/versions/{versionId}") @ApiOperation(value = "Get details of a vendor software product") - Response getVspDetails(@PathParam("vspId") String vspId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + 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}") + @Path("/{vspId}/versions/{versionId}") @ApiOperation(value = "Update an existing vendor software product") - Response updateVsp(@PathParam("vspId") String vspId, @Valid VspDescriptionDto vspDescriptionDto, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) - String user); + 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}") @ApiOperation(value = "Deletes vendor software product by given id") Response deleteVsp(@PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) - String user); + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("{vspId}/upload") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @ApiOperation(value = "Uploads a HEAT package to translate", - response = UploadFileResponseDto.class) - Response uploadFile(@PathParam("vspId") String vspId, - @Multipart("upload") InputStream heatFileToUpload, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) - String user); + @GET + @Path("/packages") + @ApiOperation(value = "Get list of translated CSAR files details", + response = PackageInfoDto.class, + responseContainer = "List") + Response listPackages(@ApiParam("Category") @QueryParam("category") String category, + @ApiParam("Sub-category") @QueryParam("subCategory") String subCategory, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET - @Path("/{vspId}/downloadHeat") + @Path("/{vspId}/versions/{versionId}/orchestration-template") @Produces(MediaType.APPLICATION_OCTET_STREAM) - @ApiOperation(value = "Get uploaded HEAT file", + @ApiOperation(value = "Get Orchestration Template (HEAT) file", notes = "Downloads the latest HEAT package", response = File.class) - Response getLatestHeatPackage(@PathParam("vspId") String vspId, - /*@NotNull(message = USER_MISSING_ERROR_MSG)*/ - @HeaderParam(USER_HEADER_PARAM) String user); + 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}/actions") + @Path("/{vspId}/versions/{versionId}/actions") @ApiOperation(value = "Actions on a vendor software product", notes = "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 " @@ -149,14 +127,11 @@ public interface VendorSoftwareProducts { + "Checkin: Unlocks it and activates the edited version to all users.| " + "Submit: Finalize its active version.|" + "Create_Package: Creates a CSAR zip file.|") - /*@ApiResponses(value = { - @ApiResponse(code = 200, message = "Action succeeded"), - @ApiResponse(code = 417, message = "Validation before submit has failed", - response = ValidationResponseDto.class)})*/ Response actOnVendorSoftwareProduct(@PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, VersionSoftwareProductActionRequestDto request, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user) + @HeaderParam(USER_ID_HEADER_PARAM) String user) throws IOException; @GET @@ -166,28 +141,46 @@ public interface VendorSoftwareProducts { notes = "Exports translated file to a zip file", response = File.class) Response getTranslatedFile(@PathParam("vspId") String vspId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - /*@NotNull(message = USER_MISSING_ERROR_MSG)*/ - @HeaderParam(USER_HEADER_PARAM) String user); + @QueryParam("versionId") String versionId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET - @Path("/{vspId}/questionnaire") + @Path("/{vspId}/versions/{versionId}/questionnaire") @ApiOperation(value = "Get vendor software product questionnaire", response = QuestionnaireResponseDto.class) Response getQuestionnaire(@PathParam("vspId") String vspId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, + @PathParam("versionId") String versionId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT - @Path("/{vspId}/questionnaire") + @Path("/{vspId}/versions/{versionId}/questionnaire") @ApiOperation(value = "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_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + + @PUT + @Path("/{vspId}/versions/{versionId}/heal") + @ApiOperation(value = "Checkout and heal vendor software product questionnaire", + response = 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) + @ApiOperation(value = "Get vendor software product information artifact for specified version", + response = 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); + } 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 new file mode 100644 index 0000000000..eb70394b28 --- /dev/null +++ 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 @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import com.sun.jersey.multipart.FormDataParam; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; +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 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; + +@Path("/v1.0/vendor-software-products") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Products") +@Validated +public interface VendorSoftwareProductsForSwaggerFileUpload { + + + + @POST + @Path("/{vspId}/versions/{versionId}/orchestration-template-candidate") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @ApiOperation(value = "Uploads a HEAT package to translate", + response = 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 new file mode 100644 index 0000000000..bd53305e33 --- /dev/null +++ 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 @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; +import org.openecomp.sdc.versioning.VersioningManager; +import org.openecomp.sdc.versioning.VersioningManagerFactory; +import org.openecomp.sdc.versioning.VersioningUtil; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionInfo; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; + +public interface VspEntities { + VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface(); + + default Version resolveVspVersion(String vspId, String version, String user, + VersionableEntityAction action) { + return VersioningUtil + .resolveVersion(Version.valueOf(version), getVersionInfo(vspId, action, user), user); + } + + default VersionInfo getVersionInfo(String vendorSoftwareProductId, VersionableEntityAction action, + String user) { + return versioningManager.getEntityVersionInfo( + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, + vendorSoftwareProductId, user, action); + } +} 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 e448ed6ca7..b669830bc7 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 @@ -30,6 +30,8 @@ public class MapComponentDataToComponentDto extends MappingBase<ComponentData, C target.setName(source.getName()); target.setDisplayName( source.getDisplayName() == null ? source.getName() : source.getDisplayName()); + target.setVfcCode( + source.getVfcCode() == null ? target.getDisplayName() : source.getVfcCode()); 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/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 new file mode 100644 index 0000000000..0c923fe82b --- /dev/null +++ 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 @@ -0,0 +1,25 @@ +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.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; +import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRelationType; + +public class MapComponentDependencyModelEntityToDto extends + MappingBase<ComponentDependencyModelEntity, ComponentDependencyModel> { + + @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 new file mode 100644 index 0000000000..e51ccbd937 --- /dev/null +++ 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 @@ -0,0 +1,36 @@ +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.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; +import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder; +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<ComponentDependencyModel, ComponentDependencyModelEntity> { + + @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(); + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.CREATE_COMPONENT_DEPENDENCY_MODEL, ErrorLevel.ERROR.name(), + errorCode.id(), errorCode.message() ); + throw new CoreException(errorCode); + } + } +} 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 ce9e32770c..f61ee0d4ab 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 @@ -32,6 +32,7 @@ public class MapComponentRequestDtoToComponentEntity ComponentData component = new ComponentData(); component.setName(source.getName()); component.setDisplayName(source.getDisplayName()); + component.setVfcCode(source.getVfcCode()); 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 b5b7ccdfee..f7ecc243f1 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 @@ -26,8 +26,8 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionDataEntityDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; -public class MapCompositionEntityResponseToDto<S extends CompositionDataEntity, - T extends CompositionDataEntityDto, M extends MappingBase<S, T>> +public class MapCompositionEntityResponseToDto<S extends CompositionDataEntity, T extends + CompositionDataEntityDto, M extends MappingBase<S, T>> extends MappingBase<CompositionEntityResponse<S>, CompositionEntityResponseDto<T>> { private M dataMapper; private Class<T> 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 cb726dfc79..ee7a9f446e 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 @@ -21,7 +21,7 @@ package org.openecomp.sdcrests.vsp.rest.mapping; import org.apache.commons.collections4.CollectionUtils; -import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; @@ -34,6 +34,7 @@ public class MapCompositionEntityValidationDataToDto 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() 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/MapFilesDataStructureToGetFileDataStructureResponseDto.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/MapFilesDataStructureToGetFileDataStructureResponseDto.java new file mode 100644 index 0000000000..b7d4670203 --- /dev/null +++ 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/MapFilesDataStructureToGetFileDataStructureResponseDto.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + + +import org.openecomp.sdc.vendorsoftwareproduct.types.GetFileDataStructureResponseDTO; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; +import org.openecomp.sdcrests.mapping.MappingBase; + +/** + * Created by TALIO on 4/27/2016. + */ +public class MapFilesDataStructureToGetFileDataStructureResponseDto + extends MappingBase<FilesDataStructure, GetFileDataStructureResponseDTO> { + @Override + public void doMapping(FilesDataStructure source, GetFileDataStructureResponseDTO target) { + target.setModules(source.getModules()); + target.setArtifacts(source.getArtifacts()); + target.setUnassigned(source.getUnassigned()); + target.setNested(source.getNested()); + } +} 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 9cd365480e..34616b4306 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 @@ -24,10 +24,12 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; +/** + * Created by TALIO on 4/25/2016. + */ public class MapPackageInfoToPackageInfoDto extends MappingBase<PackageInfo, PackageInfoDto> { @Override public void doMapping(PackageInfo source, PackageInfoDto target) { - target.setDisplayName(source.getDisplayName()); target.setVspName(source.getVspName()); target.setPackageId(source.getVspId()); target.setDescription(source.getVspDescription()); 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 5842a30b70..96a67a9d87 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 @@ -31,6 +31,7 @@ public class MapProcessEntityToProcessEntityDto 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 1fd35d1960..d1a28d7145 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 @@ -30,5 +30,6 @@ public class MapProcessRequestDtoToProcessEntity 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 23fdf385e4..52252c0425 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 @@ -31,5 +31,6 @@ public class MapQuestionnaireResponseToQuestionnaireResponseDto 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/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 29b6701413..cccfd02371 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 @@ -25,12 +25,14 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; +/** + * Created by TALIO on 4/27/2016. + */ public class MapUploadFileResponseToUploadFileResponseDto extends MappingBase<UploadFileResponse, UploadFileResponseDto> { @Override public void doMapping(UploadFileResponse source, UploadFileResponseDto target) { target.setStatus(source.getStatus()); target.setErrors(source.getErrors()); - target.setFileNames(source.getFileNames()); } } 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 68bc97d1a6..e6346c452d 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 @@ -26,6 +26,7 @@ import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult; import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdcrests.common.mapping.MapErrorCodeToDto; import org.openecomp.sdcrests.common.mapping.MapErrorMessageToDto; import org.openecomp.sdcrests.common.types.ErrorCodeDto; @@ -35,10 +36,12 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityVali import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireValidationResultDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto; - +import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; public class MapValidationResponseToDto @@ -60,9 +63,14 @@ public class MapValidationResponseToDto QuestionnaireValidationResultDto questionnaireValidationResultDto = new QuestionnaireValidationResultDto(); questionnaireValidationResultDto.setValid(questionnaireValidationResult.isValid()); - questionnaireValidationResultDto.setValidationData(new MapCompositionEntityValidationDataToDto() - .applyMapping(questionnaireValidationResult.getValidationData(), - CompositionEntityValidationDataDto.class)); + + Set<CompositionEntityValidationDataDto> validationDataDto = new HashSet<>(); + for(CompositionEntityValidationData validationData : questionnaireValidationResult.getValidationData()){ + validationDataDto.add(new MapCompositionEntityValidationDataToDto().applyMapping + (validationData, CompositionEntityValidationDataDto.class)); + } + + questionnaireValidationResultDto.setValidationData(validationDataDto); return questionnaireValidationResultDto; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java index 9f03f7ff0d..6eca00e8aa 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java @@ -24,7 +24,7 @@ import org.openecomp.core.utilities.CommonMethods; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData; import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo; -import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.common.types.VersionDto; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; @@ -38,14 +38,15 @@ public class MapVersionedVendorSoftwareProductInfoToVspDetailsDto VspDetails vsp = source.getVspDetails(); target.setId(vsp.getId()); - target.setVersion(vsp.getVersion().toString()); + target.setVersion(new VersionDto(vsp.getVersion().toString(), vsp.getVersion().toString())); target.setName(vsp.getName()); target.setDescription(vsp.getDescription()); target.setCategory(vsp.getCategory()); target.setSubCategory(vsp.getSubCategory()); target.setVendorId(vsp.getVendorId()); target.setVendorName(vsp.getVendorName()); - target.setLicensingVersion(vsp.getVlmVersion() == null ? null : vsp.getVlmVersion().toString()); + target.setLicensingVersion(vsp.getVlmVersion() == null ? null : new VersionDto(vsp.getVlmVersion().toString(), vsp.getVlmVersion().toString())); + target.setIsOldVersion("False"); if (vsp.getLicenseAgreement() != null || vsp.getFeatureGroups() != null) { LicensingData licensingData = new LicensingData(); @@ -61,13 +62,15 @@ public class MapVersionedVendorSoftwareProductInfoToVspDetailsDto if (!CommonMethods.isEmpty(source.getVersionInfo().getViewableVersions())) { target.setViewableVersions( - source.getVersionInfo().getViewableVersions().stream().map(Version::toString) + source.getVersionInfo().getViewableVersions().stream() + .map(version -> new VersionDto(version.toString(), version.toString())) .collect(Collectors.toList())); } if (!CommonMethods.isEmpty(source.getVersionInfo().getFinalVersions())) { target.setFinalVersions( - source.getVersionInfo().getFinalVersions().stream().map(Version::toString) + source.getVersionInfo().getFinalVersions().stream() + .map(version -> new VersionDto(version.toString(), version.toString())) .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/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 77093fe682..ec0843263a 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 @@ -23,11 +23,10 @@ package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData; import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.common.types.VersionDto; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; -import java.util.regex.Pattern; - public class MapVspDescriptionDtoToVspDetails extends MappingBase<VspDescriptionDto, VspDetails> { @Override @@ -40,11 +39,13 @@ public class MapVspDescriptionDtoToVspDetails extends MappingBase<VspDescription target.setVendorName(source.getVendorName()); target.setVendorId(source.getVendorId()); - String vlmVersion = source.getLicensingVersion(); + VersionDto vlmVersion = source.getLicensingVersion(); if (vlmVersion != null) { - target.setVlmVersion( - Pattern.compile(Version.VERSION_REGEX).matcher(vlmVersion).find() ? Version - .valueOf(vlmVersion) : null); + Version version = Version.valueOf(vlmVersion.getId()); + target.setVlmVersion(version); +// target.setVlmVersion( +// Pattern.compile(Version.VERSION_REGEX).matcher(vlmVersion.getId()).find() ? Version +// .valueOf(vlmVersion.getId()) : null); } LicensingData licensingData = source.getLicensingData(); 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/MspVspDetailsToVspCreationDto.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/MspVspDetailsToVspCreationDto.java index a2de1741a3..5480dc13d5 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/MspVspDetailsToVspCreationDto.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/MspVspDetailsToVspCreationDto.java @@ -24,6 +24,9 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto; +/** + * Created by TALIO on 5/15/2016. + */ public class MspVspDetailsToVspCreationDto extends MappingBase<VspDetails, VspCreationDto> { @Override public void doMapping(VspDetails source, VspCreationDto 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/services/ComponentDependencyModelsImpl.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/ComponentDependencyModelsImpl.java new file mode 100644 index 0000000000..4a23140c88 --- /dev/null +++ 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/ComponentDependencyModelsImpl.java @@ -0,0 +1,78 @@ +package org.openecomp.sdcrests.vsp.rest.services; + +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModelRequestDto; +import org.openecomp.sdcrests.vsp.rest.ComponentDependencyModels; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDependencyModelEntityToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDependencyModelRequestToEntity; + +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +@Service("componentDependencyModel") +@Scope(value = "prototype") +public class ComponentDependencyModelsImpl implements ComponentDependencyModels { + + private ComponentDependencyModelManager componentDependencyModelManager = + ComponentDependencyModelManagerFactory.getInstance().createInterface(); + + @Override + public Response create(ComponentDependencyModelRequestDto request, String vspId, + String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.CREATE_COMPONENT_DEPENDENCY_MODEL.toString()); + List<ComponentDependencyModelEntity> modelEntities = new + ArrayList<ComponentDependencyModelEntity>(); + + final Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + + if (request.getComponentDependencyModels() != null) { + for(ComponentDependencyModel model : request.getComponentDependencyModels()) { + ComponentDependencyModelEntity modelEntity = + new MapComponentDependencyModelRequestToEntity().applyMapping(model, + ComponentDependencyModelEntity.class); + + modelEntity.setVspId(vspId); + modelEntity.setVersion(version); + modelEntities.add(modelEntity); + } + } + + componentDependencyModelManager + .createComponentDependencyModel(modelEntities, vspId, version, user); + + return Response.ok().build(); + } + + @Override + public Response list(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.GET_COMPONENT_DEPENDENCY_MODEL.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + + Collection<ComponentDependencyModelEntity> componentDependencies = + componentDependencyModelManager.list(vspId, vspVersion, user); + + MapComponentDependencyModelEntityToDto mapper = new MapComponentDependencyModelEntityToDto(); + GenericCollectionWrapper<ComponentDependencyModel> results = new GenericCollectionWrapper + <ComponentDependencyModel>(); + for (ComponentDependencyModelEntity entity : componentDependencies) { + results.add(mapper.applyMapping(entity, ComponentDependencyModel.class)); + } + + return Response.ok(results).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 2b16fea6c0..abcb3c5322 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 @@ -21,9 +21,19 @@ package org.openecomp.sdcrests.vsp.rest.services; import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.messages.AuditMessages; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.ProcessManager; +import org.openecomp.sdc.vendorsoftwareproduct.ProcessManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; import org.openecomp.sdcrests.vsp.rest.ComponentProcesses; @@ -31,29 +41,40 @@ import org.openecomp.sdcrests.vsp.rest.mapping.MapProcessEntityToProcessEntityDt import org.openecomp.sdcrests.vsp.rest.mapping.MapProcessRequestDtoToProcessEntity; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; - -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; import java.io.File; import java.io.InputStream; import java.util.Collection; -import javax.inject.Named; -import javax.ws.rs.core.Response; +import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID; @Named @Service("componentProcesses") @Scope(value = "prototype") public class ComponentProcessesImpl implements ComponentProcesses { - @Autowired - private VendorSoftwareProductManager vendorSoftwareProductManager; + + private ProcessManager processManager = ProcessManagerFactory.getInstance().createInterface(); + private ComponentManager componentManager = + ComponentManagerFactory.getInstance().createInterface(); + private static final Logger logger = + LoggerFactory.getLogger(ComponentProcessesImpl.class); @Override - public Response list(String vspId, String componentId, String version, String user) { - Collection<ProcessEntity> processes = vendorSoftwareProductManager - .listProcesses(vspId, Version.valueOf(version), componentId, user); + public Response list(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_Component_Processes.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + validateComponentExistence(vspId, vspVersion, componentId, user); + Collection<ProcessEntity> processes; + if (componentId.equals(VendorSoftwareProductConstants.GENERAL_COMPONENT_ID)) { + processes = processManager.listProcesses(vspId, vspVersion, null, user); + } else { + processes = processManager.listProcesses(vspId, vspVersion, componentId, user); + } + MapProcessEntityToProcessEntityDto mapper = new MapProcessEntityToProcessEntityDto(); GenericCollectionWrapper<ProcessEntityDto> results = new GenericCollectionWrapper<>(); @@ -65,58 +86,81 @@ public class ComponentProcessesImpl implements ComponentProcesses { } @Override - public Response deleteList(String vspId, String componentId, String user) { - vendorSoftwareProductManager.deleteProcesses(vspId, componentId, user); + public Response deleteList(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_List_Component_Processes.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + validateComponentExistence(vspId, version, componentId, user); + processManager.deleteProcesses(vspId, version, componentId, user); + return Response.ok().build(); } @Override - public Response create(ProcessRequestDto request, String vspId, String componentId, String user) { + public Response create(ProcessRequestDto request, String vspId, String versionId, + String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_Component_Processes.toString()); ProcessEntity process = new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); process.setVspId(vspId); - process.setComponentId(componentId); + process.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); + if (!componentId.equals(VendorSoftwareProductConstants.GENERAL_COMPONENT_ID)) { + process.setComponentId(componentId); + } + + validateComponentExistence(vspId, process.getVersion(), componentId, user); + ProcessEntity createdProcess = processManager.createProcess(process, user); - ProcessEntity createdProcess = vendorSoftwareProductManager.createProcess(process, user); return Response .ok(createdProcess != null ? new StringWrapperResponse(createdProcess.getId()) : null) .build(); } @Override - public Response get(String vspId, String componentId, String processId, String version, + public Response get(String vspId, String versionId, String componentId, String processId, String user) { - ProcessEntity process = vendorSoftwareProductManager - .getProcess(vspId, Version.valueOf(version), componentId, processId, user); + MdcUtil.initMdc(LoggerServiceName.Get_Component_Processes.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + validateComponentExistence(vspId, vspVersion, componentId, user); + ProcessEntity process = + processManager.getProcess(vspId, vspVersion, componentId, processId, user); ProcessEntityDto result = new MapProcessEntityToProcessEntityDto().applyMapping(process, ProcessEntityDto.class); return Response.ok(result).build(); } @Override - public Response delete(String vspId, String componentId, String processId, String user) { - vendorSoftwareProductManager.deleteProcess(vspId, componentId, processId, user); + public Response delete(String vspId, String versionId, String componentId, String processId, + String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_Component_Processes.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + validateComponentExistence(vspId, version, componentId, user); + processManager.deleteProcess(vspId, version, componentId, processId, user); return Response.ok().build(); } @Override - public Response update(ProcessRequestDto request, String vspId, String componentId, + public Response update(ProcessRequestDto request, String vspId, String versionId, + String componentId, String processId, String user) { - ProcessEntity processEntity = + MdcUtil.initMdc(LoggerServiceName.Update_Component_Processes.toString()); + ProcessEntity process = new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); - processEntity.setVspId(vspId); - processEntity.setComponentId(componentId); - processEntity.setId(processId); - - vendorSoftwareProductManager.updateProcess(processEntity, user); + process.setVspId(vspId); + process.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); + process.setComponentId(componentId); + process.setId(processId); + validateComponentExistence(vspId, process.getVersion(), componentId, user); + processManager.updateProcess(process, user); return Response.ok().build(); } @Override - public Response getUploadedFile(String vspId, String componentId, String processId, - String version, String user) { - File file = vendorSoftwareProductManager - .getProcessArtifact(vspId, Version.valueOf(version), componentId, processId, user); + public Response getUploadedFile(String vspId, String versionId, String componentId, + String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Uploaded_File_Component_Processes.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + validateComponentExistence(vspId, vspVersion, componentId, user); + File file = processManager.getProcessArtifact(vspId, vspVersion, componentId, processId, user); Response.ResponseBuilder response = Response.ok(file); if (file == null) { @@ -127,18 +171,36 @@ public class ComponentProcessesImpl implements ComponentProcesses { } @Override - public Response deleteUploadedFile(String vspId, String componentId, String processId, + public Response deleteUploadedFile(String vspId, String versionId, String componentId, + String processId, String user) { - vendorSoftwareProductManager.deleteProcessArtifact(vspId, componentId, processId, user); + MdcUtil.initMdc(LoggerServiceName.Delete_Uploaded_File_Component_Processes.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + validateComponentExistence(vspId, version, componentId, user); + processManager.deleteProcessArtifact(vspId, version, componentId, processId, user); return Response.ok().build(); } @Override - public Response uploadFile(Attachment attachment, String vspId, String componentId, + public Response uploadFile(Attachment attachment, String vspId, String versionId, + String componentId, String processId, String user) { - vendorSoftwareProductManager.uploadProcessArtifact(attachment.getObject(InputStream.class), - attachment.getContentDisposition().getParameter("filename"), vspId, componentId, processId, - user); + MdcUtil.initMdc(LoggerServiceName.Upload_File_Component_Processes.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_PROCESS_ARTIFACT + vspId); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + validateComponentExistence(vspId, version, componentId, user); + processManager.uploadProcessArtifact(attachment.getObject(InputStream.class), + attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, + processId, user); return Response.ok().build(); } + + + private void validateComponentExistence(String vspId, Version version, String componentId, + String user) { + if (GENERAL_COMPONENT_ID.equals(componentId)) { + return; + } + componentManager.validateComponentExistence(vspId, version, componentId, 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/ComponentUploadsImpl.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/ComponentUploadsImpl.java index 3cd384d7e7..7a2a1578b6 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/ComponentUploadsImpl.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/ComponentUploadsImpl.java @@ -21,63 +21,113 @@ package org.openecomp.sdcrests.vsp.rest.services; import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.core.enrichment.types.ArtifactType; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.messages.AuditMessages; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.MibManager; +import org.openecomp.sdc.vendorsoftwareproduct.MibManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; import org.openecomp.sdcrests.vendorsoftwareproducts.types.MibUploadStatusDto; import org.openecomp.sdcrests.vsp.rest.ComponentUploads; import org.openecomp.sdcrests.vsp.rest.mapping.MapMibUploadStatusToDto; - -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import java.io.InputStream; import javax.inject.Named; import javax.ws.rs.core.Response; +import java.io.InputStream; @Named @Service("componentUploads") @Scope(value = "prototype") @Validated public class ComponentUploadsImpl implements ComponentUploads { - @Autowired - private VendorSoftwareProductManager vendorSoftwareProductManager; + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + private MibManager mibManager = MibManagerFactory.getInstance().createInterface(); + private ComponentManager componentManager = + ComponentManagerFactory.getInstance().createInterface(); + private static final Logger logger = + LoggerFactory.getLogger(ComponentUploadsImpl.class); @Override - public Response uploadTrapMibFile(Attachment attachment, String vspId, String componentId, + public Response uploadTrapMibFile(Attachment attachment, String vspId, String versionId, String componentId, String user) { - vendorSoftwareProductManager.uploadComponentMib(attachment.getObject(InputStream.class), - attachment.getContentDisposition().getParameter("filename"), vspId, componentId, true, - user); + mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); + MdcUtil.initMdc(LoggerServiceName.Upload_MIB_File.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_ARTIFACT_MIB_TRAP + vspId); + + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, version, componentId, user); + mibManager.upload(attachment.getObject(InputStream.class), + attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, + ArtifactType.SNMP_TRAP, user); + + mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); return Response.ok().build(); } @Override - public Response deleteTrapMibFile(String vspId, String componentId, String user) { - vendorSoftwareProductManager.deleteComponentMib(vspId, componentId, true, user); + public Response deleteTrapMibFile(String vspId, String versionId, String componentId, String user) { + mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); + MdcUtil.initMdc(LoggerServiceName.Delete_MIB_File.toString()); + + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, version, componentId, user); + mibManager.delete(vspId, version, componentId, ArtifactType.SNMP_TRAP, user); + + mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); return Response.ok().build(); } @Override - public Response uploadPollMibFile(Attachment attachment, String vspId, String componentId, + public Response uploadPollMibFile(Attachment attachment, String vspId, String versionId, String componentId, String user) { - vendorSoftwareProductManager.uploadComponentMib(attachment.getObject(InputStream.class), - attachment.getContentDisposition().getParameter("filename"), vspId, componentId, false, - user); + + mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_ARTIFACT_MIB_POLL + vspId); + MdcUtil.initMdc(LoggerServiceName.Upload_MIB_File.toString()); + + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, version, componentId, user); + mibManager.upload(attachment.getObject(InputStream.class), + attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, + ArtifactType.SNMP_POLL, user); + + mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); return Response.ok().build(); } @Override - public Response deletePollMibFile(String vspId, String componentId, String user) { - vendorSoftwareProductManager.deleteComponentMib(vspId, componentId, false, user); + public Response deletePollMibFile(String vspId, String versionId, String componentId, String + user) { + mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); + MdcUtil.initMdc(LoggerServiceName.Delete_MIB_File.toString()); + + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, version, componentId, user); + mibManager.delete(vspId, version, componentId, ArtifactType.SNMP_POLL, user); + + mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); return Response.ok().build(); } @Override - public Response list(String vspId, String componentId, String user) { - MibUploadStatus response = - vendorSoftwareProductManager.listMibFilenames(vspId, componentId, user); + public Response list(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_MIB_Files.toString()); + + Version version = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, version, componentId, user); + + MibUploadStatus response = mibManager.listFilenames(vspId, version, componentId, user); MibUploadStatusDto returnEntity = new MapMibUploadStatusToDto().applyMapping(response, MibUploadStatusDto.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/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 cba9abbdbc..a36534ae4f 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 @@ -21,13 +21,17 @@ package org.openecomp.sdcrests.vsp.rest.services; import org.apache.commons.collections4.CollectionUtils; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; -import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData; 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.sdc.versioning.types.VersionableEntityAction; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; @@ -42,27 +46,26 @@ import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDat import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; - -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import java.util.Collection; 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 { - @Autowired - private VendorSoftwareProductManager vendorSoftwareProductManager; + private ComponentManager componentManager = + ComponentManagerFactory.getInstance().createInterface(); @Override - public Response list(String vspId, String version, String user) { + public Response list(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_Components.toString()); Collection<ComponentEntity> components = - vendorSoftwareProductManager.listComponents(vspId, Version.valueOf(version), user); + componentManager.listComponents(vspId, resolveVspVersion(vspId, versionId, user, + VersionableEntityAction.Read), user); MapComponentEntityToComponentDto mapper = new MapComponentEntityToComponentDto(); GenericCollectionWrapper<ComponentDto> results = new GenericCollectionWrapper<>(); @@ -74,27 +77,33 @@ public class ComponentsImpl implements Components { } @Override - public Response deleteList(String vspId, String user) { - vendorSoftwareProductManager.deleteComponents(vspId, user); + public Response deleteList(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_List_Components.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.deleteComponents(vspId, version, user); return Response.ok().build(); } @Override - public Response create(ComponentRequestDto request, String vspId, String user) { + public Response create(ComponentRequestDto request, String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_Component.toString()); ComponentEntity component = new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); component.setVspId(vspId); - ComponentEntity createdComponent = - vendorSoftwareProductManager.createComponent(component, user); + component.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); + + ComponentEntity createdComponent = componentManager.createComponent(component, user); return Response .ok(createdComponent != null ? new StringWrapperResponse(createdComponent.getId()) : null) .build(); } @Override - public Response get(String vspId, String componentId, String version, String user) { - CompositionEntityResponse<ComponentData> response = vendorSoftwareProductManager - .getComponent(vspId, Version.valueOf(version), componentId, user); + public Response get(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Component.toString()); + CompositionEntityResponse<ComponentData> response = componentManager + .getComponent(vspId, resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), + componentId, user); CompositionEntityResponseDto<ComponentDto> responseDto = new CompositionEntityResponseDto<>(); new MapCompositionEntityResponseToDto<>(new MapComponentDataToComponentDto(), @@ -103,32 +112,38 @@ public class ComponentsImpl implements Components { } @Override - public Response delete(String vspId, String componentId, String user) { - vendorSoftwareProductManager.deleteComponent(vspId, componentId, user); + public Response delete(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_Component.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.deleteComponent(vspId, version, componentId, user); return Response.ok().build(); } @Override - public Response update(ComponentRequestDto request, String vspId, String componentId, + public Response update(ComponentRequestDto request, String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Update_Component.toString()); ComponentEntity componentEntity = new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); componentEntity.setVspId(vspId); + componentEntity.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); componentEntity.setId(componentId); CompositionEntityValidationData validationData = - vendorSoftwareProductManager.updateComponent(componentEntity, user); + componentManager.updateComponent(componentEntity, user); return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto() - .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : - Response.ok().build(); + new MapCompositionEntityValidationDataToDto().applyMapping(validationData, + CompositionEntityValidationDataDto.class)).build() : Response.ok().build(); } @Override - public Response getQuestionnaire(String vspId, String componentId, String version, String user) { - QuestionnaireResponse questionnaireResponse = vendorSoftwareProductManager - .getComponentQuestionnaire(vspId, Version.valueOf(version), componentId, user); + public Response getQuestionnaire(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Questionnaire_Component.toString()); + QuestionnaireResponse questionnaireResponse = componentManager + .getQuestionnaire(vspId, + resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), componentId, + user); QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); @@ -136,10 +151,11 @@ public class ComponentsImpl implements Components { } @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String componentId, + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId, String user) { - vendorSoftwareProductManager - .updateComponentQuestionnaire(vspId, componentId, questionnaireData, user); + MdcUtil.initMdc(LoggerServiceName.Update_Questionnaire_Component.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.updateQuestionnaire(vspId, version, componentId, questionnaireData, user); 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 afc25ab4b0..471138f23c 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 @@ -21,12 +21,15 @@ package org.openecomp.sdcrests.vsp.rest.services; import org.apache.commons.collections4.CollectionUtils; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.NetworkManager; +import org.openecomp.sdc.vendorsoftwareproduct.NetworkManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; -import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; -import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; @@ -39,26 +42,27 @@ import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkRequestDtoToNetworkEnti import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkToNetworkDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import java.util.Collection; 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 { - @Autowired - private VendorSoftwareProductManager vendorSoftwareProductManager; + + private NetworkManager networkManager = + NetworkManagerFactory.getInstance().createInterface(); @Override - public Response list(String vspId, String version, String user) { + public Response list(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_Network.toString()); Collection<NetworkEntity> networks = - vendorSoftwareProductManager.listNetworks(vspId, Version.valueOf(version), user); + networkManager.listNetworks(vspId, + resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user); MapNetworkEntityToNetworkDto mapper = new MapNetworkEntityToNetworkDto(); GenericCollectionWrapper<NetworkDto> results = new GenericCollectionWrapper<>(); @@ -70,20 +74,25 @@ public class NetworksImpl implements Networks { } @Override - public Response create(NetworkRequestDto request, String vspId, String user) { + public Response create(NetworkRequestDto request, String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_Network.toString()); NetworkEntity network = new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); network.setVspId(vspId); - NetworkEntity createdNetwork = vendorSoftwareProductManager.createNetwork(network, user); + network.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); + NetworkEntity createdNetwork = networkManager.createNetwork(network, user); return Response .ok(createdNetwork != null ? new StringWrapperResponse(createdNetwork.getId()) : null) .build(); } @Override - public Response get(String vspId, String networkId, String version, String user) { + public Response get(String vspId, String versionId, String networkId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Network.toString()); CompositionEntityResponse<Network> response = - vendorSoftwareProductManager.getNetwork(vspId, Version.valueOf(version), networkId, user); + networkManager.getNetwork(vspId, + resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), networkId, + user); CompositionEntityResponseDto<NetworkDto> responseDto = new CompositionEntityResponseDto<>(); new MapCompositionEntityResponseToDto<>(new MapNetworkToNetworkDto(), NetworkDto.class) @@ -92,24 +101,29 @@ public class NetworksImpl implements Networks { } @Override - public Response delete(String vspId, String networkId, String user) { - vendorSoftwareProductManager.deleteNetwork(vspId, networkId, user); + public Response delete(String vspId, String versionId, String networkId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_Network.toString()); + networkManager + .deleteNetwork(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction.Write), + networkId, user); return Response.ok().build(); } @Override - public Response update(NetworkRequestDto request, String vspId, String networkId, String user) { + public Response update(NetworkRequestDto request, String vspId, String versionId, String networkId, String user) { + MdcUtil.initMdc(LoggerServiceName.Update_Network.toString()); NetworkEntity networkEntity = new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); networkEntity.setVspId(vspId); + networkEntity.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); networkEntity.setId(networkId); CompositionEntityValidationData validationData = - vendorSoftwareProductManager.updateNetwork(networkEntity, user); + networkManager.updateNetwork(networkEntity, user); return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto() - .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : + 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 ce601ec999..922700671c 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 @@ -21,14 +21,19 @@ package org.openecomp.sdcrests.vsp.rest.services; import org.apache.commons.collections4.CollectionUtils; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.NicManager; +import org.openecomp.sdc.vendorsoftwareproduct.NicManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; -import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData; 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.sdc.versioning.types.VersionableEntityAction; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; @@ -43,27 +48,27 @@ import org.openecomp.sdcrests.vsp.rest.mapping.MapNicToNicDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; - -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import java.util.Collection; 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 { - @Autowired - private VendorSoftwareProductManager vendorSoftwareProductManager; + private NicManager nicManager = NicManagerFactory.getInstance().createInterface(); + private ComponentManager componentManager = + ComponentManagerFactory.getInstance().createInterface(); @Override - public Response list(String vspId, String componentId, String version, String user) { - Collection<NicEntity> nics = - vendorSoftwareProductManager.listNics(vspId, Version.valueOf(version), componentId, user); + public Response list(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_nics.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + Collection<NicEntity> nics = nicManager.listNics(vspId, vspVersion, componentId, user); MapNicEntityToNicDto mapper = new MapNicEntityToNicDto(); GenericCollectionWrapper<NicDto> results = new GenericCollectionWrapper<>(); @@ -75,20 +80,26 @@ public class NicsImpl implements Nics { } @Override - public Response create(NicRequestDto request, String vspId, String componentId, String user) { + public Response create(NicRequestDto request, String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_nic.toString()); NicEntity nic = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); nic.setVspId(vspId); + nic.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); nic.setComponentId(componentId); + componentManager.validateComponentExistence(vspId, nic.getVersion(), componentId, user); - NicEntity createdNic = vendorSoftwareProductManager.createNic(nic, user); + NicEntity createdNic = nicManager.createNic(nic, user); return Response.ok(createdNic != null ? new StringWrapperResponse(createdNic.getId()) : null) .build(); } @Override - public Response get(String vspId, String componentId, String nicId, String version, String user) { - CompositionEntityResponse<Nic> response = vendorSoftwareProductManager - .getNic(vspId, Version.valueOf(version), componentId, nicId, user); + public Response get(String vspId, String versionId, String componentId, String nicId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_nic.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + CompositionEntityResponse<Nic> response = + nicManager.getNic(vspId, vspVersion, componentId, nicId, user); CompositionEntityResponseDto<NicDto> responseDto = new CompositionEntityResponseDto<>(); new MapCompositionEntityResponseToDto<>(new MapNicToNicDto(), NicDto.class) @@ -97,33 +108,42 @@ public class NicsImpl implements Nics { } @Override - public Response delete(String vspId, String componentId, String nicId, String user) { - vendorSoftwareProductManager.deleteNic(vspId, componentId, nicId, user); + public Response delete(String vspId, String versionId, String componentId, String nicId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_nic.toString()); + Version vspVersion = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + nicManager.deleteNic(vspId, vspVersion, componentId, nicId, user); return Response.ok().build(); } @Override - public Response update(NicRequestDto request, String vspId, String componentId, String nicId, + public Response update(NicRequestDto request, String vspId, String versionId, String componentId, String nicId, String user) { + MdcUtil.initMdc(LoggerServiceName.Update_nic.toString()); NicEntity nicEntity = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); nicEntity.setVspId(vspId); + nicEntity.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); nicEntity.setComponentId(componentId); nicEntity.setId(nicId); + componentManager.validateComponentExistence(vspId, nicEntity.getVersion(), componentId, user); CompositionEntityValidationData validationData = - vendorSoftwareProductManager.updateNic(nicEntity, user); + nicManager.updateNic(nicEntity, user); return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto() - .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : + new MapCompositionEntityValidationDataToDto() + .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : Response.ok().build(); } @Override - public Response getQuestionnaire(String vspId, String componentId, String nicId, String version, + public Response getQuestionnaire(String vspId, String versionId, String componentId, String nicId, String user) { - QuestionnaireResponse questionnaireResponse = vendorSoftwareProductManager - .getNicQuestionnaire(vspId, Version.valueOf(version), componentId, nicId, user); + MdcUtil.initMdc(LoggerServiceName.Get_Questionnaire_nic.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + QuestionnaireResponse questionnaireResponse = + nicManager.getNicQuestionnaire(vspId, vspVersion, componentId, nicId, user); QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); @@ -131,10 +151,13 @@ public class NicsImpl implements Nics { } @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String componentId, + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId, String nicId, String user) { - vendorSoftwareProductManager - .updateNicQuestionnaire(vspId, componentId, nicId, questionnaireData, user); + MdcUtil.initMdc(LoggerServiceName.Update_Questionnaire_nic.toString()); + Version vspVersion = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + nicManager + .updateNicQuestionnaire(vspId, vspVersion, componentId, nicId, questionnaireData, user); 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/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 new file mode 100644 index 0000000000..d5eb961285 --- /dev/null +++ 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 @@ -0,0 +1,134 @@ +package org.openecomp.sdcrests.vsp.rest.services; + +import org.apache.commons.beanutils.BeanUtils; +import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; +import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.messages.AuditMessages; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager; +import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.types.FileDataStructureDto; +import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.OrchestrationTemplateActionResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto; +import org.openecomp.sdcrests.vsp.rest.OrchestrationTemplateCandidate; +import org.openecomp.sdcrests.vsp.rest.mapping.MapUploadFileResponseToUploadFileResponseDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapValidationResponseToDto; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import javax.inject.Named; +import javax.ws.rs.core.Response; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import java.util.Optional; + +@Named +@Service("orchestrationTemplateCandidate") +@Scope(value = "prototype") +public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplateCandidate { + + private OrchestrationTemplateCandidateManager candidateManager = + OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface(); + private static final Logger logger = + LoggerFactory.getLogger(OrchestrationTemplateCandidateImpl.class); + + @Override + public Response upload(String vspId, String versionId, InputStream heatFileToUpload, + String user) { + MdcUtil.initMdc(LoggerServiceName.Upload_File.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_HEAT + vspId); + + UploadFileResponse uploadFileResponse = candidateManager + .upload(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction + .Write), heatFileToUpload, user); + UploadFileResponseDto uploadFileResponseDto = new MapUploadFileResponseToUploadFileResponseDto() + .applyMapping(uploadFileResponse, UploadFileResponseDto.class); + + return Response.ok(uploadFileResponseDto).build(); + } + + @Override + public Response get(String vspId, String versionId, String user) throws IOException { + Optional<byte[]> zipFile = + candidateManager + .get(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction.Read), user); + + if (!zipFile.isPresent()) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + Response.ResponseBuilder response = Response.ok(zipFile.get()); + response.header("Content-Disposition", "attachment; filename=HeatCandidate.zip"); + return response.build(); + } + + @Override + public Response process(String vspId, String versionId, String user) + throws InvocationTargetException, IllegalAccessException { + + OrchestrationTemplateActionResponse response = + candidateManager + .process(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction.Write), + user); + OrchestrationTemplateActionResponseDto responseDto = + new OrchestrationTemplateActionResponseDto(); + BeanUtils.copyProperties(responseDto, response); + return Response.ok(responseDto).build(); + } + + @Override + public Response updateFilesDataStructure( + String vspId, String versionId, FileDataStructureDto fileDataStructureDto, String user) + throws Exception { + + FilesDataStructure fileDataStructure = new FilesDataStructure(); + try { + BeanUtils.copyProperties(fileDataStructure, fileDataStructureDto); + } catch (IllegalAccessException | InvocationTargetException exception) { + String errorWithParameters = ErrorMessagesFormatBuilder + .getErrorWithParameters(Messages.MAPPING_OBJECTS_FAILURE.getErrorMessage(), + fileDataStructureDto.toString(), fileDataStructure.toString()); + throw new Exception(errorWithParameters, exception); + } + ValidationResponse response = candidateManager + .updateFilesDataStructure(vspId, + resolveVspVersion(vspId, null, user, VersionableEntityAction + .Write), user, fileDataStructure); + + if (!response.isValid()) { + return Response.status(Response.Status.EXPECTATION_FAILED).entity( + new MapValidationResponseToDto() + .applyMapping(response, ValidationResponseDto.class)).build(); + } + return Response.ok(fileDataStructureDto).build(); + } + + @Override + public Response getFilesDataStructure(String vspId, String versionId, String user) + throws Exception { + Optional<FilesDataStructure> filesDataStructure = candidateManager + .getFilesDataStructure(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction + .Read), user); + FileDataStructureDto fileDataStructureDto = new FileDataStructureDto(); + if (filesDataStructure.isPresent()) { + try { + BeanUtils.copyProperties(fileDataStructureDto, filesDataStructure.get()); + } catch (IllegalAccessException | InvocationTargetException exception) { + String errorWithParameters = ErrorMessagesFormatBuilder + .getErrorWithParameters(Messages.MAPPING_OBJECTS_FAILURE.getErrorMessage(), + filesDataStructure.toString(), fileDataStructureDto.toString()); + throw new Exception(errorWithParameters, exception); + } + } + return Response.ok(fileDataStructureDto).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/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 004d84591a..a175908cd1 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 @@ -20,9 +20,12 @@ package org.openecomp.sdcrests.vsp.rest.services; -import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID; - import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.messages.AuditMessages; +import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; import org.openecomp.sdcrests.vsp.rest.ComponentProcesses; import org.openecomp.sdcrests.vsp.rest.Processes; @@ -33,6 +36,8 @@ import org.springframework.stereotype.Service; import javax.inject.Named; import javax.ws.rs.core.Response; +import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID; + @Named @Service("processes") @Scope(value = "prototype") @@ -40,50 +45,65 @@ public class ProcessesImpl implements Processes { @Autowired private ComponentProcesses componentProcesses; + private static final Logger logger = + LoggerFactory.getLogger(ProcessesImpl.class); @Override - public Response list(String vspId, String version, String user) { - return componentProcesses.list(vspId, GENERAL_COMPONENT_ID, version, user); + public Response list(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_Processes.toString()); + return componentProcesses.list(vspId, versionId, GENERAL_COMPONENT_ID, user); } @Override - public Response deleteList(String vspId, String user) { - return componentProcesses.deleteList(vspId, GENERAL_COMPONENT_ID, user); + public Response deleteList(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_List_Processes.toString()); + return componentProcesses.deleteList(vspId,versionId, GENERAL_COMPONENT_ID, user); } @Override - public Response create(ProcessRequestDto request, String vspId, String user) { - return componentProcesses.create(request, vspId, GENERAL_COMPONENT_ID, user); + public Response create(ProcessRequestDto request, String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_Process.toString()); + return componentProcesses.create(request, vspId, versionId, GENERAL_COMPONENT_ID, user); } @Override - public Response get(String vspId, String processId, String version, String user) { - return componentProcesses.get(vspId, GENERAL_COMPONENT_ID, processId, version, user); + public Response get(String vspId, String versionId, String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Processes.toString()); + return componentProcesses.get(vspId, versionId, GENERAL_COMPONENT_ID, processId, user); } @Override - public Response delete(String vspId, String processId, String user) { - return componentProcesses.delete(vspId, GENERAL_COMPONENT_ID, processId, user); + public Response delete(String vspId, String versionId, String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_Processes.toString()); + return componentProcesses.delete(vspId, versionId, GENERAL_COMPONENT_ID, processId, user); } @Override - public Response update(ProcessRequestDto request, String vspId, String processId, String user) { - return componentProcesses.update(request, vspId, GENERAL_COMPONENT_ID, processId, user); + public Response update(ProcessRequestDto request, String vspId, String versionId, String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Update_Process.toString()); + return componentProcesses.update(request, vspId, versionId, GENERAL_COMPONENT_ID, processId, user); } @Override - public Response getUploadedFile(String vspId, String processId, String version, String user) { + public Response getUploadedFile(String vspId, String versionId, String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Uploaded_File_Processes.toString()); return componentProcesses - .getUploadedFile(vspId, GENERAL_COMPONENT_ID, processId, version, user); + .getUploadedFile(vspId, versionId, GENERAL_COMPONENT_ID, processId, user); } @Override - public Response deleteUploadedFile(String vspId, String processId, String user) { - return componentProcesses.deleteUploadedFile(vspId, GENERAL_COMPONENT_ID, processId, user); + public Response deleteUploadedFile(String vspId, String versionId, String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_Uploaded_File_Processes.toString()); + return componentProcesses.deleteUploadedFile(vspId, versionId, GENERAL_COMPONENT_ID, + processId, user); } @Override - public Response uploadFile(Attachment attachment, String vspId, String processId, String user) { - return componentProcesses.uploadFile(attachment, vspId, GENERAL_COMPONENT_ID, processId, user); + public Response uploadFile(Attachment attachment, String vspId, String versionId, String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Upload_File_Processes.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_PROCESS_ARTIFACT + vspId); + return componentProcesses.uploadFile(attachment, vspId, versionId, GENERAL_COMPONENT_ID, + 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 1c13f172f1..c730066770 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 @@ -20,17 +20,26 @@ package org.openecomp.sdcrests.vsp.rest.services; +import org.openecomp.sdc.activityLog.ActivityLogManager; +import org.openecomp.sdc.activityLog.ActivityLogManagerFactory; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.messages.AuditMessages; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; -import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo; import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionInfo; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto; @@ -39,38 +48,46 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; import org.openecomp.sdcrests.vsp.rest.VendorSoftwareProducts; import org.openecomp.sdcrests.vsp.rest.mapping.MapPackageInfoToPackageInfoDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; -import org.openecomp.sdcrests.vsp.rest.mapping.MapUploadFileResponseToUploadFileResponseDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapValidationResponseToDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapVersionedVendorSoftwareProductInfoToVspDetailsDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDescriptionDtoToVspDetails; import org.openecomp.sdcrests.vsp.rest.mapping.MspVspDetailsToVspCreationDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; - -import org.springframework.beans.factory.annotation.Autowired; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; +import org.slf4j.MDC; 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.io.InputStream; import java.util.List; -import javax.inject.Named; -import javax.ws.rs.core.Response; + @Named @Service("vendorSoftwareProducts") @Scope(value = "prototype") public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { - @Autowired - private VendorSoftwareProductManager vendorSoftwareProductManager; + private VendorSoftwareProductManager vendorSoftwareProductManager = + VspManagerFactory.getInstance().createInterface(); + + private static final Logger logger = + LoggerFactory.getLogger(VendorSoftwareProductsImpl.class); + + private ActivityLogManager activityLogManager = + ActivityLogManagerFactory.getInstance().createInterface(); @Override - public Response createNewVsp(VspDescriptionDto vspDescriptionDto, String user) { + public Response createVsp(VspDescriptionDto vspDescriptionDto, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_VSP.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_VSP + vspDescriptionDto.getName()); + VspDetails vspDetails = new MapVspDescriptionDtoToVspDetails().applyMapping(vspDescriptionDto, VspDetails.class); - vspDetails = vendorSoftwareProductManager.createNewVsp(vspDetails, user); + vspDetails = vendorSoftwareProductManager.createVsp(vspDetails, user); MspVspDetailsToVspCreationDto mapping = new MspVspDetailsToVspCreationDto(); VspCreationDto vspCreationDto = mapping.applyMapping(vspDetails, VspCreationDto.class); @@ -79,9 +96,10 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { } @Override - public Response getVspList(String versionFilter, String user) { + public Response listVsps(String versionFilter, String user) { + MdcUtil.initMdc(LoggerServiceName.List_VSP.toString()); List<VersionedVendorSoftwareProductInfo> vspList = - vendorSoftwareProductManager.getVspList(versionFilter, user); + vendorSoftwareProductManager.listVsps(versionFilter, user); GenericCollectionWrapper<VspDetailsDto> results = new GenericCollectionWrapper<>(); if (!vspList.isEmpty()) { @@ -96,22 +114,51 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { } @Override - public Response getVspDetails(String vspId, String version, String user) { - VersionedVendorSoftwareProductInfo vspDetails = - vendorSoftwareProductManager.getVspDetails(vspId, Version.valueOf(version), user); + public Response getVsp(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_VSP.toString()); + - VspDetailsDto vspDetailsDto = vspDetails == null ? null + VspDetails vspDetails = + vendorSoftwareProductManager + .getVsp(vspId, resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), + user); + + VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user); + + // + if (vspDetails.getOldVersion() != null && !"".equals(vspDetails.getOldVersion())) { + if (Version.valueOf(versionId).equals(versionInfo.getActiveVersion())) { + try { + Version healedVersion = vendorSoftwareProductManager.callAutoHeal(vspId, versionInfo, + vspDetails, user); + vspDetails = + vendorSoftwareProductManager + .getVsp(vspId, resolveVspVersion(vspId, healedVersion.toString(), user, + VersionableEntityAction.Read), user); + versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user); + } catch (Exception e) { + //to do + } + } + } + + VspDetailsDto vspDetailsDto = vspDetails == null + ? null : new MapVersionedVendorSoftwareProductInfoToVspDetailsDto() - .applyMapping(vspDetails, VspDetailsDto.class); + .applyMapping(new VersionedVendorSoftwareProductInfo(vspDetails, versionInfo), + VspDetailsDto.class); return Response.ok(vspDetailsDto).build(); } @Override - public Response updateVsp(String vspId, VspDescriptionDto vspDescriptionDto, String user) { + public Response updateVsp(String vspId, String versionId, VspDescriptionDto vspDescriptionDto, + String user) { + MdcUtil.initMdc(LoggerServiceName.Update_VSP.toString()); VspDetails vspDetails = new MapVspDescriptionDtoToVspDetails().applyMapping(vspDescriptionDto, VspDetails.class); vspDetails.setId(vspId); + vspDetails.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); vendorSoftwareProductManager.updateVsp(vspDetails, user); @@ -120,26 +167,35 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { @Override public Response deleteVsp(String vspId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_VSP.toString()); vendorSoftwareProductManager.deleteVsp(vspId, user); return Response.ok().build(); } @Override - public Response actOnVendorSoftwareProduct(String vspId, + public Response actOnVendorSoftwareProduct(String vspId, String versionId, VersionSoftwareProductActionRequestDto request, String user) throws IOException { + switch (request.getAction()) { case Checkout: + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Checkout_VSP.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CHECK_OUT_VSP + vspId); vendorSoftwareProductManager.checkout(vspId, user); break; case Undo_Checkout: + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Undo_Checkout_VSP.toString()); vendorSoftwareProductManager.undoCheckout(vspId, user); break; case Checkin: + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Checkin_VSP.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CHECK_IN_VSP + vspId); vendorSoftwareProductManager.checkin(vspId, user); break; case Submit: + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Submit_VSP.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VSP + vspId); ValidationResponse validationResponse = vendorSoftwareProductManager.submit(vspId, user); if (!validationResponse.isValid()) { return Response.status(Response.Status.EXPECTATION_FAILED).entity( @@ -148,8 +204,12 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { } break; case Create_Package: - PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(vspId, user); - return Response.ok(packageInfo == null ? null + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Create_Package.toString()); + + PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(vspId, + resolveVspVersion(vspId, null, user, VersionableEntityAction.Read), user); + return Response.ok(packageInfo == null + ? null : new MapPackageInfoToPackageInfoDto().applyMapping(packageInfo, PackageInfoDto.class)) .build(); default: @@ -159,30 +219,33 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { } @Override - public Response uploadFile(String uploadVspId, InputStream heatFileToUpload, String user) { - UploadFileResponse uploadFileResponse = - vendorSoftwareProductManager.uploadFile(uploadVspId, heatFileToUpload, user); - - UploadFileResponseDto uploadFileResponseDto = new MapUploadFileResponseToUploadFileResponseDto() - .applyMapping(uploadFileResponse, UploadFileResponseDto.class); - - return Response.ok(uploadFileResponseDto).build(); + public Response getValidationVsp(String user) + throws Exception { + String validationVspId = vendorSoftwareProductManager.fetchValidationVsp(user); + StringWrapperResponse response = new StringWrapperResponse(validationVspId); + return Response.ok(response).build(); } - @Override - public Response getLatestHeatPackage(String vspId, String user) { - File zipFile = vendorSoftwareProductManager.getLatestHeatPackage(vspId, user); - if (zipFile == null) { + @Override + public Response getOrchestrationTemplate(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Uploaded_File.toString()); + byte[] orchestrationTemplateFile = + vendorSoftwareProductManager + .getOrchestrationTemplateFile(vspId, + resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user); + + if (orchestrationTemplateFile == null) { return Response.status(Response.Status.NOT_FOUND).build(); } - Response.ResponseBuilder response = Response.ok(zipFile); - response.header("Content-Disposition", "attachment; filename=" + zipFile.getName()); + Response.ResponseBuilder response = Response.ok(orchestrationTemplateFile); + response.header("Content-Disposition", "attachment; filename=LatestHeatPackage.zip"); return response.build(); } @Override public Response listPackages(String category, String subCategory, String user) { + MdcUtil.initMdc(LoggerServiceName.List_Packages.toString()); List<PackageInfo> packageInfoList = vendorSoftwareProductManager.listPackages(category, subCategory); @@ -198,22 +261,39 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { } @Override - public Response getTranslatedFile(String vspId, String version, String user) { - File zipFile = - vendorSoftwareProductManager.getTranslatedFile(vspId, Version.valueOf(version), user); + public Response getTranslatedFile(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Translated_File.toString()); + + Version version = Version.valueOf(versionId); + Version resolvedVersion = version == null + ? getVersionInfo(vspId, VersionableEntityAction.Read, user).getLatestFinalVersion() + : version; + + File zipFile = vendorSoftwareProductManager.getTranslatedFile(vspId, resolvedVersion, user); Response.ResponseBuilder response = Response.ok(zipFile); if (zipFile == null) { + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.IMPORT_FAIL + vspId); return Response.status(Response.Status.NOT_FOUND).build(); } response.header("Content-Disposition", "attachment; filename=" + zipFile.getName()); + + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.IMPORT_SUCCESS + vspId); return response.build(); } @Override - public Response getQuestionnaire(String vspId, String version, String user) { + public Response getQuestionnaire(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Questionnaire_VSP.toString()); QuestionnaireResponse questionnaireResponse = - vendorSoftwareProductManager.getVspQuestionnaire(vspId, Version.valueOf(version), user); + vendorSoftwareProductManager.getVspQuestionnaire(vspId, + resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user); + + if (questionnaireResponse.getErrorMessage() != null) { + return Response.status(Response.Status.EXPECTATION_FAILED).entity( + new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class)).build(); + } QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); @@ -221,8 +301,35 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { } @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String user) { - vendorSoftwareProductManager.updateVspQuestionnaire(vspId, questionnaireData, user); + public Response updateQuestionnaire(String questionnaireData, String vspId, String + versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Update_Questionnaire_VSP.toString()); + vendorSoftwareProductManager.updateVspQuestionnaire(vspId, + resolveVspVersion(vspId, null, user, VersionableEntityAction.Write), + questionnaireData, user); + return Response.ok().build(); + } + + @Override + public Response heal(String vspId, String versionId, String user) { + vendorSoftwareProductManager.heal(vspId, Version.valueOf(versionId), user); + return Response.ok().build(); } + + @Override + public Response getVspInformationArtifact(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Information_Artifact.toString()); + File textInformationArtifact = + vendorSoftwareProductManager.getInformationArtifact(vspId, + resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user); + + 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()); + return response.build(); + } } |